-
-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Sqlite uses stringly-typed datetimes, and that causes a world of hurt if you are not careful.
In this particular occasion: jiff-diesel serializes DateTime as YYYY-MM-DDTHH:MM:SS
.
But built-in Sqlite functions, including current_timestamp
(which is emitted by diesel::dsl::now
), produce YYYY-MM-DD HH:MM:SS
format (space instead of T
).
Thus, if you use naive comparisons, you can get stuff like 2025-06-01T00:00:00
> 2025-06-01 10:00:00
. Ouch.
Another pain point that current_timestamp
does not include timezone information, so you cannot parse the values it produces at jiff_diesel::Timestamp
What jiff_diesel (and maybe jiff_sqlx) crate can do to mitigate the problem:
- add a notice in the documentation (e.g. "Database support" section) that Sqlite is a special beast, you need to be extra careful about your time representation, and that
current_timestamp
/dsl::now
would produce DateTime, not Timestamp values. - make the format for DateTime
YYYY-MM-DD HH:MM:SS
because that matches the format Sqlite functions output - maybe make
jiff_diesel
's Timestamp also serialize asYYYY-MM-DD HH:MM:SS
in UTC?
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested