{"record":{"id":"00983a71b5ab58be","repo":"SeaQL/sea-orm","slug":"failed-to-get-string-array-00983a","errorCode":null,"errorMessage":"Failed to get string array","messagePattern":"Failed to get string array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":564,"sourceCode":"                                .expect(\"Failed to get double array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Double(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"VARCHAR\" | \"CHAR\" | \"TEXT\" | \"NAME\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get string\"),\n                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"VARCHAR[]\" | \"CHAR[]\" | \"TEXT[]\" | \"NAME[]\" => Value::Array(\n                            sea_query::ArrayType::String,\n                            row.try_get::<Option<Vec<String>>, _>(c.ordinal())\n                                .expect(\"Failed to get string array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::String(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"BYTEA\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes\"),\n                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"BYTEA[]\" => Value::Array(\n                            sea_query::ArrayType::Bytes,\n                            row.try_get::<Option<Vec<Vec<u8>>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes array\")","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L546-L582","documentation":"This panic comes from `.expect(\"Failed to get string array\")` in ProxyRow (src/driver/sqlx_postgres.rs:564). For VARCHAR[]/CHAR[]/TEXT[]/NAME[] columns (with the `postgres-array` feature), the driver decodes `Option<Vec<String>>` and panics when sqlx cannot produce that type. The most common cause is the array's element type not actually being text, or array support not being compiled in.","triggerScenarios":"Reading a text[] column that was created from a non-text array (e.g. int[] or bytea[] under a text[] alias), expressions like array_agg over non-text columns, or a value that is NULL-typed array in a driver version that rejects it for Vec<String>.","commonSituations":"Forgot `postgres-array` feature flag, ORM/sqlx version skew after an upgrade, schema drift where a column changed to text[] but rows were written with a different element type, or extensions (hstore-like) reporting array type names.","solutions":["Enable the `postgres-array` feature on sea-orm and sqlx and rebuild.","Check the element type (`SELECT array_typeof(col)`) and cast in SQL: `col::text[]`.","Pin matching sea-orm/sqlx versions; array decoding differs across sqlx releases.","Log with RUST_LOG=sqlx=debug to expose the underlying decode error before the panic.","Swap expect for an error mapped to DbErr::Custom that includes the column ordinal."],"exampleFix":"// before\nrow.try_get::<Option<Vec<String>>, _>(c.ordinal()).expect(\"Failed to get string array\")\n// after\nrow.try_get::<Option<Vec<String>>, _>(c.ordinal())\n    .map_err(|e| DbErr::Custom(format!(\"text[] decode failed col {}: {e}\", c.ordinal())))?","handlingStrategy":"validation","validationCode":"// Verify the array holds text elements:\n// SELECT array_typeof(col) FROM t LIMIT 1;  -- expect 'text'\n// Or cast: SELECT col::text[] FROM ...","typeGuard":"fn is_text_array_col(c: &ProxyColumn) -> bool {\n    matches!(c.ty.as_str(), \"VARCHAR[]\" | \"CHAR[]\" | \"TEXT[]\" | \"NAME[]\")\n}","tryCatchPattern":"std::panic::catch_unwind(|| read_row(row))\n    .map_err(|p| DbErr::Custom(format!(\"text[] decode panic: {p:?}\")))?;","preventionTips":["Enable the `postgres-array` feature on both sea-orm and sqlx.","Cast to ::text[] when element type is uncertain.","Check array_typeof in validation queries.","Align sea-orm and sqlx versions.","Avoid array_agg over non-text columns feeding text[]-typed reads."],"tags":["postgres","sqlx","array","type-mismatch","panic"],"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"}