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
I'm currently using SQLx in Rust to query Postgres, and I'm trying to implement optimistic locking. Typically, in Postgres, I would use xmin for this purpose. However, when attempting to execute the following query:
let row:(Uuid,i32) = sqlx::query_as("INSERT INTO example (name) VALUES ($1) RETURNING id, xmin").bind("test").fetch_one(&mut conn).await.expect("Failed to insert row.");
I encounter a runtime error:
Failed to insert row.: ColumnDecode { index: "1", source: "mismatched types; Rust type `i32` (as SQL type `INT4`) is not compatible with SQL type `xid`" }
It seems that SQLx does not support this type directly. Does anyone have any ideas or suggestions on how to work around this issue?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently using SQLx in Rust to query Postgres, and I'm trying to implement optimistic locking. Typically, in Postgres, I would use xmin for this purpose. However, when attempting to execute the following query:
I encounter a runtime error:
It seems that SQLx does not support this type directly. Does anyone have any ideas or suggestions on how to work around this issue?
Beta Was this translation helpful? Give feedback.
All reactions