-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: datetime and timestamp can't query as chrono::DateTime<chrono::Utc>
?
#598
Comments
chrono::DateTime<chrono::Utc>
?chrono::DateTime<chrono::Utc>
?
Does anyone have any insight into what's causing this? I don't know much about how the BTW @biluohc there's a markdown error in your issue description, I think you need a |
Just works™ for me. I'm using the postgres EDIT: Sorry, I see this seems to be MySQL. |
@jplatte this is sqlite actually, unless i totally misread the issue |
It looks like this issue is related: #1004 My guess is that |
And the workaround is to opt out of type checking of that column with |
Oh, it says SQLite in the title 🤦🏼 I saw |
Sounds correct. |
Yeah, this is working as intended. Unfortunately, SQLite doesn't have a timezone-aware datetime type so our only option is |
@mehcode interesting, I thought that this was just a limitation, but it sounds like it's actually a design decision to only let you get a Should |
It's true that SQLite in SQLx does have support for UTC date times though. A point of confusion here could be that - in general - SQLx needs to map a SQL type to one Rust type. This is observable in many areas, if you use For datetimes, we need to pick a canonical type for SQLite. It's true that We could actually quite easily support inferring a utc datetimes from something like |
This allows us to explicitly opt into using `DateTime<Utc>` instead of `NaiveDateTime` without doing conversions at query time (either via `col as "col: DateTime<Utc>" or mapping the results manually). Ref: launchbadge#598 (comment)
This allows us to explicitly opt into using `DateTime<Utc>` instead of `NaiveDateTime` without doing conversions at query time (either via `col as "col: DateTime<Utc>" or mapping the results manually). Ref: launchbadge#598 (comment)
Version: v0.4.0-beta.1 and master
Problem: Whether it is
datetime
ortimestamp
in sql, the rust code can chooseNaiveDatetime
only.Error:
The text was updated successfully, but these errors were encountered: