{"record":{"id":"e53d9abe54b95798","repo":"SeaQL/sea-orm","slug":"failed-to-get-small-integer-e53d9a","errorCode":null,"errorMessage":"Failed to get small integer","messagePattern":"Failed to get small integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":421,"sourceCode":"                        \"SMALLINT UNSIGNED\" => Value::SmallUnsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned small integer\"),\n                        ),\n                        \"INT UNSIGNED\" => Value::Unsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned integer\"),\n                        ),\n                        \"MEDIUMINT UNSIGNED\" | \"BIGINT UNSIGNED\" => Value::BigUnsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned big integer\"),\n                        ),\n                        \"TINYINT\" => Value::TinyInt(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get tiny integer\"),\n                        ),\n                        \"SMALLINT\" => Value::SmallInt(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get small integer\"),\n                        ),\n                        \"INT\" => {\n                            Value::Int(row.try_get(c.ordinal()).expect(\"Failed to get integer\"))\n                        }\n                        \"MEDIUMINT\" | \"BIGINT\" => Value::BigInt(\n                            row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),\n                        ),\n                        \"FLOAT\" => {\n                            Value::Float(row.try_get(c.ordinal()).expect(\"Failed to get float\"))\n                        }\n                        \"DOUBLE\" => {\n                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }\n\n                        \"BIT\" | \"BINARY\" | \"VARBINARY\" | \"TINYBLOB\" | \"BLOB\" | \"MEDIUMBLOB\"\n                        | \"LONGBLOB\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes\")","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L403-L439","documentation":"In `ProxyRow`, `SMALLINT` MySQL columns are read via `row.try_get::<i16>` and unwrapped with `.expect(\"Failed to get small integer\")`. If the value cannot be decoded as i16 — most commonly because it is NULL, or the underlying value has a different type than the described metadata — the expect panics with this message.","triggerScenarios":"A SMALLINT column containing NULL in a result set decoded through the proxy driver, or metadata/actual-type mismatch (e.g. column altered to SMALLINT UNSIGNED or INT after description).","commonSituations":"Nullable smallint columns joined via LEFT JOIN yielding NULL; schema drift after migrations; proxy-driver mock rows returning i32/u16 for a column described as SMALLINT.","solutions":["Declare the field as `Option<i16>` if the column is nullable, or add a NOT NULL constraint","Regenerate the entity from the live schema to match the real column type","Fix mock/proxy test data to return `i16` values for SMALLINT columns","Remove SELECT-list expressions (COALESCE/CAST) that alter the column's reported type"],"exampleFix":"// before\npub rank: i16,\n// after\npub rank: Option<i16>,","handlingStrategy":"validation","validationCode":"// Verify SMALLINT columns before decoding\nSELECT COLUMN_TYPE, IS_NULLABLE FROM information_schema.COLUMNS\nWHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?;\n// expect COLUMN_TYPE = 'smallint', IS_NULLABLE = 'NO'","typeGuard":"fn is_i16_compatible(col_type: &str, nullable: bool, value_is_null: bool) -> bool {\n    col_type.eq_ignore_ascii_case(\"smallint\") && !nullable && !value_is_null\n}","tryCatchPattern":null,"preventionTips":["Use Option<i16> for nullable smallint fields","Check LEFT JOINs that introduce NULLs into otherwise NOT NULL columns","Keep proxy mock data as i16 for SMALLINT columns","Regenerate entities after migrations"],"tags":["mysql","sqlx","decoding","proxy-driver"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}