{"record":{"id":"a09a7cb01185d672","repo":"SeaQL/sea-orm","slug":"failed-to-get-mac-address-array","errorCode":null,"errorMessage":"Failed to get mac address array","messagePattern":"Failed to get mac address array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":691,"sourceCode":"                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::IpNetwork(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-mac_address\")]\n                        \"MACADDR\" | \"MACADDR8\" => Value::MacAddress(\n                            row.try_get::<Option<mac_address::MacAddress>, _>(c.ordinal())\n                                .expect(\"Failed to get mac address\"),\n                        ),\n                        #[cfg(all(feature = \"with-mac_address\", feature = \"postgres-array\"))]\n                        \"MACADDR[]\" | \"MACADDR8[]\" => Value::Array(\n                            sea_query::ArrayType::MacAddress,\n                            row.try_get::<Option<Vec<mac_address::MacAddress>>, _>(c.ordinal())\n                                .expect(\"Failed to get mac address array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::MacAddress(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMESTAMP\" => Value::ChronoDateTime(\n                            row.try_get::<Option<chrono::NaiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIMESTAMP\" => Value::TimeDateTime(\n                            row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\"),","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L673-L709","documentation":"This panic is raised when sea-orm cannot decode a MACADDR[]/MACADDR8[] array column into Option<Vec<mac_address::MacAddress>> (requires `with-mac_address` and `postgres-array`). try_get fails when the value is not a recognized macaddr array (e.g. text[]), the element type OID is unsupported by the linked sqlx, or feature flags are inconsistent between sea-orm and sqlx. The `.expect` escalates the decode error into a panic during row conversion.","triggerScenarios":"Selecting a macaddr[] column whose actual type is text[] or which was cast in SQL, or compiling sea-orm's mac-address array branch against an sqlx build missing the MacAddress array FromSql impl.","commonSituations":"Device tables storing multiple interface MACs in text[] later modeled as typed arrays; array_agg over macaddr in old Postgres versions returning text[]; feature-flag drift between workspace crates.","solutions":["Check the type with `SELECT pg_typeof(col)` and cast explicitly: `SELECT col::macaddr[] FROM t`.","Migrate text[] columns to macaddr[]: `ALTER TABLE t ALTER col TYPE macaddr[] USING col::macaddr[]`.","Enable `with-mac_address` and `postgres-array` together on sea-orm in all crates and align the sqlx version.","Update sqlx/sea-orm if your pinned version lacks macaddr array element support."],"exampleFix":"// before\nSELECT macs FROM nics; -- macs is text[]\n\n// after\nSELECT macs::macaddr[] AS macs FROM nics;","handlingStrategy":"validation","validationCode":"// Confirm the column is a true macaddr[] array:\nlet t = db.query_one(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a WHERE a.attrelid = 'nics'::regclass AND a.attname = 'macs'\",\n)).await?;\n// expect \"macaddr[]\"","typeGuard":null,"tryCatchPattern":"// Fall back to text[] plus parse when the schema is text-based:\nlet rows = db.query_all(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT macs::text[] FROM nics\",\n)).await?;\nlet macs: Vec<mac_address::MacAddress> = rows[0].try_get::<Vec<String>, _>(0)?\n    .into_iter()\n    .map(|s| s.parse())\n    .collect::<Result<_, _>>()?;","preventionTips":["Store MAC lists in macaddr[] columns, not text[].","Enable with-mac_address and postgres-array together on sea-orm.","Cast explicit ::macaddr[] around array_agg or CASE expressions.","Keep a single sqlx version and re-check types after schema migrations."],"tags":["postgres","mac-address","type-decoding","panic","array","sea-orm"],"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"}