Skip to content

180#181

Merged
RAprogramm merged 1 commit into
mainfrom
180
Jul 4, 2026
Merged

180#181
RAprogramm merged 1 commit into
mainfrom
180

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #180.

#[auto] fields were included in generated INSERTs with Default::default() values — created_at: DateTime<Utc> wrote an explicit 1970-01-01, silently clobbering the table's DEFAULT now(). Found while validating the crate against a real backend.

Fix

  • Context now carries separate columns_str (SELECT, all columns) and insert_columns_str/placeholders (INSERT, minus #[auto])
  • Insertable struct, insert bindings and Entity→Insertable mappers skip auto fields; DB defaults apply and persisted values come back via RETURNING * (the default)
  • All insert paths updated: create (all returning modes), create_many, upsert, aggregate-root save, transaction adapter
  • Upsert DO UPDATE SET also stops overwriting auto columns (previously reset created_at on the update path)
  • With returning = "id"/"none"/custom the returned pre-built entity still carries placeholder auto values — unchanged semantics, now documented by the column split

Testing

  • 2 new unit tests pinning the insert column shape — 677 total green
  • clippy --all-targets -D warnings clean, all-features suite green, deny ok

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm merged commit 3a24083 into main Jul 4, 2026
15 checks passed
@RAprogramm RAprogramm deleted the 180 branch July 4, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sql): #[auto] fields are inserted with Default::default(), clobbering DB defaults

1 participant