Generated create/create_many/upsert include #[auto] fields in the INSERT column list, and From<CreateRequest> fills them with Default::default(). For created_at: DateTime<Utc> that means an explicit 1970-01-01 is written, silently overriding the table's DEFAULT now().
Expected
#[auto] means "the database generates this value": auto fields must be excluded from the INSERT column list entirely so column defaults apply, and the persisted values must come back via RETURNING (the default returning = "full" already refetches the row).
Scope
- Insert column list / placeholders /
Insertable struct / bindings skip #[auto] fields (create, create_many, upsert)
returning = "id"/"none"/custom keep returning the pre-built entity — document that auto fields are placeholders there
- Unit tests for column-list shape; trybuild pass case asserting the generated INSERT omits auto columns
Generated
create/create_many/upsertinclude#[auto]fields in the INSERT column list, andFrom<CreateRequest>fills them withDefault::default(). Forcreated_at: DateTime<Utc>that means an explicit1970-01-01is written, silently overriding the table'sDEFAULT now().Expected
#[auto]means "the database generates this value": auto fields must be excluded from the INSERT column list entirely so column defaults apply, and the persisted values must come back viaRETURNING(the defaultreturning = "full"already refetches the row).Scope
Insertablestruct / bindings skip#[auto]fields (create, create_many, upsert)returning = "id"/"none"/customkeep returning the pre-built entity — document that auto fields are placeholders there