In my models I have the created_at/updated_at columns defined as TimestampWithTimeZone.
When I retrieve the models, the TimestampWithTimeZone columns are returned as arrays with a strange format, like \"created_at\":[2024,75,16,24,39,144518000,0,0,0]} but I was expecting an ISO8601, something more like \"created_at\":\"+002024-03-15T16:26:38.178125000Z\" that my frontend can consume directly.
Reproduces How Often
Always reproducible.
Workarounds
My work around currently is to generate my entities with sea-orm-cli generate entity -o "entity/src/entities" --with-serde both --date-time-crate time, then to manually edit the models everywhere I use a TimestampWithTimeZone and add this serde attribute: #[serde(with = "time::serde::iso8601")]. However this approach does not scale.
Is there a way to have seaorm automatically add the serde attribute for the TimestampWithTimeZone fields?
Description & Expected Behavior
In my models I have the created_at/updated_at columns defined as
TimestampWithTimeZone
.When I retrieve the models, the
TimestampWithTimeZone
columns are returned as arrays with a strange format, like\"created_at\":[2024,75,16,24,39,144518000,0,0,0]}
but I was expecting an ISO8601, something more like\"created_at\":\"+002024-03-15T16:26:38.178125000Z\"
that my frontend can consume directly.Reproduces How Often
Always reproducible.
Workarounds
My work around currently is to generate my entities with
sea-orm-cli generate entity -o "entity/src/entities" --with-serde both --date-time-crate time
, then to manually edit the models everywhere I use aTimestampWithTimeZone
and add this serde attribute:#[serde(with = "time::serde::iso8601")]
. However this approach does not scale.Is there a way to have seaorm automatically add the serde attribute for the TimestampWithTimeZone fields?
Reproducible Example
entity/src/entities/submission.rs
:The JSON output is:
Versions
I am using seaorm 0.12.14 with the time library.