SeaQL/sea-orm · error

Failed to get unsigned big integer

Error message

Failed to get unsigned big integer

What it means

In `from_sqlx_mysql_row_to_proxy_row`, columns typed "MEDIUMINT UNSIGNED" or "BIGINT UNSIGNED" are decoded with `row.try_get::<u64>` and `.expect("Failed to get unsigned big integer")`. The panic fires when sqlx cannot decode the cell as u64 — most commonly a NULL value requested as a non-Option type, or a decode/type mismatch between the reported column type and the actual value.

Source

Thrown at sea-orm-sync/src/driver/sqlx_mysql.rs:405

                    match c.type_info().name() {
                        "TINYINT(1)" | "BOOLEAN" => {
                            Value::Bool(row.try_get(c.ordinal()).expect("Failed to get boolean"))
                        }
                        "TINYINT UNSIGNED" => Value::TinyUnsigned(
                            row.try_get(c.ordinal())
                                .expect("Failed to get unsigned tiny integer"),
                        ),
                        "SMALLINT UNSIGNED" => Value::SmallUnsigned(
                            row.try_get(c.ordinal())
                                .expect("Failed to get unsigned small integer"),
                        ),
                        "INT UNSIGNED" => Value::Unsigned(
                            row.try_get(c.ordinal())
                                .expect("Failed to get unsigned integer"),
                        ),
                        "MEDIUMINT UNSIGNED" | "BIGINT UNSIGNED" => Value::BigUnsigned(
                            row.try_get(c.ordinal())
                                .expect("Failed to get unsigned big integer"),
                        ),
                        "TINYINT" => Value::TinyInt(
                            row.try_get(c.ordinal())
                                .expect("Failed to get tiny integer"),
                        ),
                        "SMALLINT" => Value::SmallInt(
                            row.try_get(c.ordinal())
                                .expect("Failed to get small integer"),
                        ),
                        "INT" => {
                            Value::Int(row.try_get(c.ordinal()).expect("Failed to get integer"))
                        }
                        "MEDIUMINT" | "BIGINT" => Value::BigInt(
                            row.try_get(c.ordinal()).expect("Failed to get big integer"),
                        ),
                        "FLOAT" => {
                            Value::Float(row.try_get(c.ordinal()).expect("Failed to get float"))
                        }

View on GitHub (pinned to e29bcd1b41)

Solutions

  1. Make the column non-nullable or wrap with COALESCE in the query.
  2. Decode as `Option<u64>` and map NULL to Value::BigUnsigned(None).
  3. Replace .expect with error propagation naming the failing column.
  4. Verify the sqlx runtime matches sea-orm's compiled dependency version.

Example fix

// before
"MEDIUMINT UNSIGNED" | "BIGINT UNSIGNED" => Value::BigUnsigned(
    row.try_get(c.ordinal()).expect("Failed to get unsigned big integer"),
)
// after: tolerate NULL
"MEDIUMINT UNSIGNED" | "BIGINT UNSIGNED" => Value::BigUnsigned(
    row.try_get::<Option<u64>, _>(c.ordinal())
        .expect("Failed to get unsigned big integer"),
)
Defensive patterns

Strategy: validation

Validate before calling

// check NULL before decoding MEDIUMINT/BIGINT UNSIGNED as u64
if row.try_get_raw(c.ordinal())?.is_null()
    && matches!(c.type_info().name(), "MEDIUMINT UNSIGNED" | "BIGINT UNSIGNED") {
    // handle NULL path
}

Try / catch

let v: Option<u64> = row.try_get(c.ordinal())?;

Prevention

When it happens

Trigger: Proxy backend query against MySQL returning a MEDIUMINT UNSIGNED / BIGINT UNSIGNED column that is NULL, or whose value cannot decode into u64 (expressions, casts, or mismatched type_info).

Common situations: Nullable BIGINT UNSIGNED columns (e.g. auto-increment ids in UNION results) via the proxy backend; COUNT/MAX expressions over unsigned columns returning unexpected types; sqlx version drift.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10). Data as JSON: /api/errors/008da2d3c2542996. Report an issue: GitHub.