sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Inserting large unsigned bigint in MySQL returns "Out of range value" error

Open aguspdana opened this issue 1 year ago • 1 comments

Bug Description

Inserting unsigned integer larger than i64::MAX into a BIGINT UNSIGNED column returns "Out of range value" error.

Err(Database(MySqlDatabaseError { code: Some("22003"), number: 1264, message: "target: sigmo.-.primary: vttablet: rpc error: code = FailedPrecondition desc = Out of range value for column 'id' at row 1...

I'm using PlanetScale DB. Typing the query directly in the console worked.

Minimal Reproduction

CREATE TABLE hash_map (
    id BIGINT UNSIGNED,
    value TEXT
);

INSERT INTO hash_map (id, value)
VALUES (14959631574144683550, "Dog");

Info

  • SQLx version: 0.7.3
  • SQLx features enabled: "chrono", "json", "macros", "mysql", "tls-native-tls", "runtime-tokio"
  • Database server and version: PlanetScale (MySQL)
  • Operating system: M2 Mac
  • rustc --version: 1.74.0

aguspdana avatar Mar 10 '24 05:03 aguspdana

I'm not sure how this is a SQLx bug, honestly. You're using an integer literal, not a bind parameter, correct? SQLx sends the query string verbatim and doesn't set any sql_mode flags that would change the evaluation here. It sounds like maybe you've got strict mode enabled in your application.

abonander avatar Mar 31 '24 20:03 abonander