-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLite: Format of DateTimeUtc is wrong #2290
Comments
Any information regarding this — or about a good workaround?
|
I'm not sure how to force SeaORM to save model fields in a different format. You can apply a workaround at the level of your query. Something like this (not tested): Expr::cust_with_expr("unixepoch(?)", Expr::col(Column::ExpiresAt)).gte(Expr::cust("unixepoch('now')")) According to the documentation you linked, |
Where? I cannot find a format with milliseconds and timezones.
And the problem is, there are other applications which also depend on the same data structure. When now seaORM saves all timestamps in a different format this causes problems or at least confusion. Where is the format defined? Is it on your side or in sqlx? |
Sure, I agree, it would be better if SeaORM used the standard format.
I'm not a maintainer and I'm not familiar with the lower-level part that interacts with SQLx, so I don't know. I just suggested a quick workaround that doesn't require digging into that. If you need to store the right format, then don't use that workaround. I guess, your options are:
It's this format with
The timezone is OK, as the doc says two paragraphs ahead:
It gives this example:
|
This is not an option, as it only creates preventable load.
Ok, thanks anyway and then I hope for an answer from a maintainer or similar. |
Is there any maintainer who wants to say something about this? 🤔 |
They seem barely active for the last month or two. I don't know why. You can also try reaching out on their Discord server. |
Thanks, but I do not have Discord... Sad that they are only barely active - any reason known for this? Unfortunately, there is no other asynchronous ORM for SQlite and I depend on the bug fix 😄 |
Well, it's FOSS. It's probably easier to fork and fix the issue than to switch your entire project to a different ORM. I'm in a similar position right now, I use my own fork with some functionality that I really needed quickly (#2265). It's been over a month with no response about merging it. |
If you have the time and power, yeah... Switching wouldn't be a big problem, the project is currently still in it's creation state but their is no alternative. |
In this test:
|
Nevermind, found it in sea-query https://github.com/SeaQL/sea-query/blob/master/src/value.rs#L1067 Probably the default format of to_string is the problem 🤔 |
Mmh nope: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=42fa924b3e35d4570250912324505b45 results in a different format... |
Ok, I think I found the error source. Instead of this function: https://github.com/launchbadge/sqlx/blob/a892ebc6e283f443145f92bbc7fce4ae44547331/sqlx-sqlite/src/types/chrono.rs#L73 , this function: https://github.com/launchbadge/sqlx/blob/a892ebc6e283f443145f92bbc7fce4ae44547331/sqlx-sqlite/src/types/chrono.rs#L64C1-L71C2 is called, which leads to an incorrect format. |
Created a PR against SQLx |
Description
When saving a value of type
DateTimeUtc
in the database, an incorrect format is used.This prevents, e.g., the comparison between
CURRENT_TIMESTAMP
and the value.Additionally, it causes compatibility issues with other applications using the same database.
Steps to Reproduce
DateTimeUtc
Expected Behavior
The timestamp is saved like this:
2024-07-17 17:02:14
, to remain compatible and follow the defaults. (https://www.sqlite.org/lang_datefunc.html)Actual Behavior
The timestamp is saved like this:
2024-07-17T17:02:14.727131+00:00
Workarounds
I don't know if there is a workaround — can the format be specified? But it should be by default the format specified by sqlite.
Reproducible Example
Just create a Model with a field of type
DateTimeUtc
:Versions
Sea-Orm version: 1.0.0-rc.7
Rust: 1.79.0
Platform e.g.: stable-x86_64-apple-darwin
The text was updated successfully, but these errors were encountered: