SeaQL/sea-orm · error

Failed to get unsigned integer

Error message

Failed to get unsigned integer

What it means

In `from_sqlx_mysql_row_to_proxy_row`, a column typed "INT UNSIGNED" is decoded with `row.try_get::<u32>` and `.expect("Failed to get unsigned integer")`. The panic fires when sqlx cannot decode the cell as u32 — typically a NULL requested as non-Option u32, or a reported/actual type mismatch in the row.

Source

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

            .iter()
            .map(|c| {
                (
                    c.name().to_string(),
                    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"),

View on GitHub (pinned to e29bcd1b41)

Solutions

  1. Make the column non-nullable or use COALESCE(col, 0).
  2. Decode as `Option<u32>` and map NULL to Value::Unsigned(None).
  3. Surface try_get errors as DbErr with column context instead of .expect.
  4. Check sqlx version compatibility with the sea-orm build.

Example fix

// before
"INT UNSIGNED" => Value::Unsigned(
    row.try_get(c.ordinal()).expect("Failed to get unsigned integer"),
)
// after: tolerate NULL
"INT UNSIGNED" => Value::Unsigned(
    row.try_get::<Option<u32>, _>(c.ordinal())
        .expect("Failed to get unsigned integer"),
)
Defensive patterns

Strategy: validation

Validate before calling

// check NULL before decoding INT UNSIGNED as u32
if row.try_get_raw(c.ordinal())?.is_null() && c.type_info().name() == "INT UNSIGNED" {
    // handle NULL path
}

Try / catch

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

Prevention

When it happens

Trigger: Proxy backend query against MySQL returning an INT UNSIGNED column that is NULL, or a value that fails u32 decoding due to expression/CAST type changes.

Common situations: Nullable INT UNSIGNED columns (e.g. counters) read through the proxy backend; aggregate or aliased expressions whose type_info differs from the raw value; sqlx runtime/compile-time version mismatch.

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/4ec1ba791d434817. Report an issue: GitHub.