You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE TABLE IF NOT EXISTS "users" (
"id" uuid PRIMARY KEY DEFAULT uuid7(),
"created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
#[derive(Clone, Default, sqlx::FromRow)]
pub struct User {
pub id: Uuid,
pub created_at: DateTime<Utc>,
}
fn foo(conn: PgPool, user_id: Uuid) {
let user = query_as!(
User,
r#"SELECT id, created_at FROM users WHERE users.id = $1"#,
&user_id
)
.fetch_one(&conn)
.await?;
}
153 | let recover = query_as!(User,
| ___________________________^
154 | | r#"SELECT id, created_at FROM users WHERE users.id = $1"#,
158 | | &user_id
159 | | )
| |_____________^ the trait `From<OffsetDateTime>` is not implemented for `chrono::DateTime<Utc>`, which is required by `OffsetDateTime: Into<_>`
Info
SQLx version: 0.8.0
SQLx features enabled: "postgres", "runtime-tokio-rustls", "macros", "migrate", "json", "chrono", "uuid"
Database server and version: Postgres 16.3
Operating system: Linux
rustc --version: 1.80.0
Reacted by ling, Toby Dimmick, Brian May, martinhath and Morb
Here is my MRE, assuming that the typo in the sqlx veryion above is a typo (otherwise upgrate do 0.8 and be happy that your issue is fixed ^^) bin.tar.gz
It's not just another crate depending on time. It's another crate that depends on sqlx and enables the time feature, due to Cargo's feature unification.
In your case, that appears to be tower-sessions-sqlx-store:
This is pretty annoying. We need to update to 0.8.x due to the advisory in 0.7.x but we have to change hundreds of queries due to that change. I sthere any easier approach?
I included mitigation advice in the advisory for a reason. If you take reasonable precautions it's unlikely to be exploitable.
For that same reason, I'm not inclined to spend my limited bandwidth backporting the fix. We have no LTS policy for releases and I don't want people to get the impression that we do.
If the danger was more immediate, it'd be a different story, but no other database lib has even bothered to publish an advisory yet, and I know at least Diesel is likely affected as well because they've done their own extensive audit and they're considering backporting the changes.
Otherwise, you could instead find and deal with the dependency that's enabling the time feature unconditionally. There's unlikely to be many candidates.
Activity
CommanderStorm commentedon Aug 7, 2024
Hi.


I tried to reproduce this, but cannot:
Could you try producing a minimal reproducible example?
Without this, helping you is basically impossible.
Here is my MRE, assuming that the typo in the sqlx veryion above is a typo (otherwise upgrate do 0.8 and be happy that your issue is fixed ^^)
bin.tar.gz
CommanderStorm commentedon Aug 7, 2024
Note that I also cannot reproduce this in
0.7...Idk what you did..
karuna commentedon Aug 7, 2024
I guess something else activating
timekaruna commentedon Aug 7, 2024
Here's my
cargo treeoutput.I see some depends on
timetree.txt
karuna commentedon Aug 7, 2024
Yup, can confirm something is activating
time. Here's my mre:ajep.tar.gz
abonander commentedon Aug 7, 2024
This was a breaking change in 0.8.0. It's the first entry in the CHANGELOG: https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md#breaking
The plan is to make it possible to specify an override in
sqlx.toml(#3383, still WIP): https://github.com/launchbadge/sqlx/blob/e14c737310783def83fa39a74fc349f5b4b8872b/sqlx-core/src/config/reference.toml#L21karuna commentedon Aug 8, 2024
@abonander I thought explicitly disabling
timeon features is enough.I'll wait for #3383 then.
abonander commentedon Aug 9, 2024
It's not just another crate depending on
time. It's another crate that depends onsqlxand enables thetimefeature, due to Cargo's feature unification.In your case, that appears to be
tower-sessions-sqlx-store:We can confirm this by looking at their
Cargo.toml: https://github.com/maxcountryman/tower-sessions-stores/blob/cecfba06e7ebc031d59d51a5926e19b3bc2c2d0d/sqlx-store/Cargo.toml#L23I would consider this their bug due to them hardcoding the
timefeature instead of allowing you to choose.abonander commentedon Aug 9, 2024
In the meantime, you can use type overrides to work around this: https://docs.rs/sqlx/latest/sqlx/macro.query.html#force-a-differentcustom-type
cemoktra commentedon Aug 20, 2024
This is pretty annoying. We need to update to 0.8.x due to the advisory in 0.7.x but we have to change hundreds of queries due to that change. I sthere any easier approach?
Or can the advisory be fixed in a 0.7.5?
abonander commentedon Aug 20, 2024
I included mitigation advice in the advisory for a reason. If you take reasonable precautions it's unlikely to be exploitable.
For that same reason, I'm not inclined to spend my limited bandwidth backporting the fix. We have no LTS policy for releases and I don't want people to get the impression that we do.
If the danger was more immediate, it'd be a different story, but no other database lib has even bothered to publish an advisory yet, and I know at least Diesel is likely affected as well because they've done their own extensive audit and they're considering backporting the changes.
Otherwise, you could instead find and deal with the dependency that's enabling the
timefeature unconditionally. There's unlikely to be many candidates.jdu commentedon Aug 29, 2024
Is there a way to do this on an INSERT/UPDATE, I can't seem to see what the syntax would look like in that case.
cemoktra commentedon Aug 29, 2024
Usually you just bind your value:
value as _karuna commentedon Sep 3, 2024
let's wait for this maxcountryman/tower-sessions-stores#46 to be released
karuna commentedon Oct 24, 2024
Maybe use my fork for temporary solution: https://crates.io/crates/tower-sessions-sqlx-store-chrono