Closed saintazunya closed 2 years ago
Hey @saintazunya, this is just a display issue. In reality the OffsetDateTime
is binded (insert) with subseconds.
let transaction_log = transaction_log::Model {
id: 1,
date: date!(2022 - 03 - 13),
time: time!(16:24:00),
date_time: date!(2022 - 03 - 13).with_time(time!(16:24:00)),
date_time_tz: date!(2022 - 03 - 13)
.with_time(time!(16:24:00.123456789))
.assume_utc(),
};
let res = TransactionLog::insert(transaction_log.clone().into_active_model())
.exec(db)
.await?;
The to_string
method is defined in SeaQuery at here whereas the to_string
format is defined as "[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour sign:mandatory][offset_minute]"
at here
Hi @billy1624 thanks for replying.
I understand this is a display issue but I think to_string
should also return a valid, as expected query instead of truncating the details in datatime. Or at lease we should add a documentation on the method to indicate its behaviors.
Right, a PR on sea-query would be appreciated to fix the formatting.
Right, a PR on sea-query would be appreciated to fix the formatting.
@tyt2y3 hello! This is breaching change, is it ok?
Yes
@saintazunya thank you, I create PR: https://github.com/SeaQL/sea-query/pull/468
When a field is type
OffsetDatetime
,to_string
method generates a truncated time instead of full precision.quick example:
prints out
INSERT INTO "testtable" ("id", "created_at") VALUES (1, '2022-10-07 03:50:22 +0000')
while expecting:
INSERT INTO "testtable" ("id", "created_at") VALUES (1, '2022-10-07 03:50:22.767233 +00:00')