{"record":{"id":"99f9787a56e78f98","repo":"SeaQL/sea-orm","slug":"failed-to-get-serialized-string-99f978","errorCode":null,"errorMessage":"Failed to get serialized string","messagePattern":"Failed to get serialized string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":518,"sourceCode":"                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"YEAR\" => Value::ChronoDate(\n                            row.try_get::<Option<chrono::NaiveDate>, _>(c.ordinal())\n                                .expect(\"Failed to get year\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"YEAR\" => Value::TimeDate(\n                            row.try_get::<Option<time::Date>, _>(c.ordinal())\n                                .expect(\"Failed to get year\")\n                                .map(Box::new),\n                        ),\n\n                        \"ENUM\" | \"SET\" | \"GEOMETRY\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get serialized string\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-bigdecimal\")]\n                        \"DECIMAL\" => Value::BigDecimal(\n                            row.try_get::<Option<bigdecimal::BigDecimal>, _>(c.ordinal())\n                                .expect(\"Failed to get decimal\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-rust_decimal\",\n                            not(feature = \"with-bigdecimal\")\n                        ))]\n                        \"DECIMAL\" => Value::Decimal(\n                            row.try_get::<Option<rust_decimal::Decimal>, _>(c.ordinal())\n                                .expect(\"Failed to get decimal\")\n                                .map(Box::new),\n                        ),","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L500-L536","documentation":"This panic comes from an `.expect(\"Failed to get serialized string\")` inside sea-orm's sqlx MySQL driver while converting a sqlx row into a ProxyRow. For columns whose MySQL type is ENUM, SET, or GEOMETRY, the driver decodes the raw value as an Option<String>; if sqlx returns a decode error (type mismatch, NULL handling, or a value that cannot be represented as a string), the expect panics. SeaORM uses expect() here because the column type was already inspected via type_info, so a failure indicates an unexpected driver/type state rather than a normal error path.","triggerScenarios":"Fetching a row from MySQL whose column type_info().name() is \"ENUM\", \"SET\", or \"GEOMETRY\" and where `row.try_get::<Option<String>, _>(c.ordinal())` fails -- e.g. the driver returns a non-string representation for GEOMETRY binary data, or the sqlx type decoding for that column fails.","commonSituations":"Selecting GEOMETRY/POINT/POLYGON columns directly (they are decoded as strings here but binary representations can fail), custom ENUM definitions on MySQL with unusual collations, sqlx version upgrades that changed how ENUM/SET values are decoded, and raw SQL queries through sea-orm's proxy/driver layer that return such columns.","solutions":["Avoid selecting ENUM/SET/GEOMETRY columns directly; cast them to plain VARCHAR in SQL, e.g. `CAST(geom AS CHAR)` or `COLUMN::as_text()`.","Ensure the sqlx `mysql` feature with the needed `runtime`/`tls` flags matches the crate versions sea-orm was built against; pin compatible versions.","For GEOMETRY, retrieve ST_AsText(geom) / ST_AsBinary(geom) in the query instead of the raw column.","If upgrading sqlx or sea-orm, check the changelog for MySQL ENUM/SET decode changes and adjust column types or entity definitions.","As a workaround, wrap the query so the offending column is returned as a JSON or TEXT alias."],"exampleFix":"// before\nlet rows = MyEntity::find().from_raw_sql(Statement::from_string(\n    DatabaseBackend::MySql, \"SELECT geom FROM places\",\n)).into_model::<MyModel>().all(db).await?;\n\n// after\nlet rows = MyEntity::find().from_raw_sql(Statement::from_string(\n    DatabaseBackend::MySql, \"SELECT ST_AsText(geom) AS geom FROM places\",\n)).into_model::<MyModel>().all(db).await?;","handlingStrategy":"validation","validationCode":"// Before querying, verify column types are decode-safe:\nlet check = db.query_all(Statement::from_string(\n    DatabaseBackend::MySql,\n    \"SELECT COLUMN_NAME, DATA_TYPE FROM information_schema.COLUMNS\n     WHERE TABLE_NAME = 'places' AND DATA_TYPE IN ('enum','set','geometry')\",\n)).await?;\nif !check.is_empty() {\n    // cast these columns in your SELECT (ST_AsText / CAST(... AS CHAR))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never select raw GEOMETRY/ENUM/SET columns in raw SQL; always cast (ST_AsText, CAST AS CHAR).","Keep sea-orm and sqlx versions aligned in Cargo.lock.","Prefer entity models generated by sea-orm-cli over ad-hoc raw queries.","Add integration tests that fetch every column of a table to catch decode panics early."],"tags":["mysql","sqlx","column-decode","panic"],"backgroundTag":"database-query-failed","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"}