launchbadge / sqlx

🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
Apache License 2.0
12.38k stars 1.18k forks source link

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

Open aguspdana opened 3 months ago

aguspdana commented 3 months ago

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

abonander commented 3 months ago

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.