SeaQL/sea-orm · error

Failed to get big integer

Error message

Failed to get big integer

What it means

Proxy-row conversion maps "BIGINT"/"INT8" columns with row.try_get::<i64>(ordinal) and unwraps with expect("Failed to get big integer"). It panics when the value is NULL or otherwise not decodable as i64. This arm is chosen purely from the declared column type, not the actual stored value.

Source

Thrown at src/driver/sqlx_sqlite.rs:432

    use sqlx::{Column, Row, TypeInfo};
    crate::ProxyRow {
        values: row
            .columns()
            .iter()
            .map(|c| {
                (
                    c.name().to_string(),
                    match c.type_info().name() {
                        "BOOLEAN" => {
                            Value::Bool(row.try_get(c.ordinal()).expect("Failed to get boolean"))
                        }

                        "INTEGER" => {
                            Value::Int(row.try_get(c.ordinal()).expect("Failed to get integer"))
                        }

                        "BIGINT" | "INT8" => Value::BigInt(
                            row.try_get(c.ordinal()).expect("Failed to get big integer"),
                        ),

                        "REAL" => {
                            Value::Double(row.try_get(c.ordinal()).expect("Failed to get double"))
                        }

                        "TEXT" => Value::String(
                            row.try_get::<Option<String>, _>(c.ordinal())
                                .expect("Failed to get string")
                                .map(Box::new),
                        ),

                        "BLOB" => Value::Bytes(
                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())
                                .expect("Failed to get bytes")
                                .map(Box::new),
                        ),

View on GitHub (pinned to e29bcd1b41)

Solutions

  1. Coalesce NULLs in the query: IFNULL(col, 0)
  2. Add NOT NULL/default constraints to BIGINT columns
  3. Sanitize data written by external tools so types match declarations
  4. Avoid the proxy feature so decode failures surface as DbErr

Example fix

// before
SELECT created_at_epoch FROM events; -- NULL panics
// after
SELECT IFNULL(created_at_epoch, 0) AS created_at_epoch FROM events;
Defensive patterns

Strategy: try-catch

Validate before calling

// Reject NULL bigint cells before querying:
// SELECT IFNULL(big_col, 0) AS big_col FROM t;

Type guard

fn as_bigint(v: &sea_query::Value) -> Option<i64> {
    match v { sea_query::Value::BigInt(i) => Some(*i), _ => None }
}

Try / catch

let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| from_sqlx_sqlite_row_to_proxy_row(&row)));
match result { Ok(r) => r, Err(_) => return Err(DbErr::Custom("bigint decode failed".into())) }

Prevention

When it happens

Trigger: Reading a BIGINT/INT8 column through the proxy driver whose cell is NULL, or whose stored value is text/real that sqlx refuses to decode into i64.

Common situations: NULL timestamps-as-epoch columns; values inserted as strings by external scripts; joins producing NULL bigint columns.

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/9a9ee31990208acc. Report an issue: GitHub.