Skip to content

#237 fix: give auto temporal columns a database default in migrations - #238

Merged
RAprogramm merged 1 commit into
mainfrom
237
Jul 26, 2026
Merged

#237 fix: give auto temporal columns a database default in migrations#238
RAprogramm merged 1 commit into
mainfrom
237

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #237

A column marked #[auto] is excluded from the generated INSERT, but the DDL emitted DEFAULT only when one was written by hand. A table created from MIGRATION_UP therefore rejected the first create() with 23502 not-null violation — including for the entity shape used in the README quick start.

Non-nullable #[auto] columns with a temporal type now receive the matching clock default:

SQL type Default
TIMESTAMPTZ, TIMESTAMP NOW()
DATE CURRENT_DATE
TIME, TIMETZ CURRENT_TIME

An explicit #[column(default = "...")] still wins. Nullable auto columns, arrays and non-temporal types are untouched — the macro has no meaningful value to invent there, and a nullable column already accepts the absent value.

Verification

The live-Postgres entity from #234 drops its #[column(default = "NOW()")] workaround, so crud_roundtrip now fails without this fix and passes with it. Three unit tests cover the clock defaults, the explicit-default precedence, and the untouched cases.

Docs

#[auto] documentation updated in the README attribute reference and in the attribute page of all five wiki languages.

@RAprogramm
RAprogramm merged commit 302e028 into main Jul 26, 2026
18 checks passed
@RAprogramm
RAprogramm deleted the 237 branch July 26, 2026 05:48
@codecov

codecov Bot commented Jul 26, 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 mentioned this pull request Jul 26, 2026
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(migrations): auto timestamp columns are NOT NULL without a DEFAULT

1 participant