fix: Postgres enum array cell updates - #1546
Conversation
Array cell values were passed to the driver as raw JS array parameters, which fails for enum arrays because drivers (pglite, adapter-pg bridges) cannot serialize arrays of user-defined element types, producing "malformed array literal" errors. Always compile array writes as explicit array[...] constructor expressions with an array-type cast so writes never depend on driver-specific array parameter serialization. Also fix deserializeError assigning the restored error name to the serialized payload instead of the reconstructed Error. Fixes #1487 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
Summary by CodeRabbit
WalkthroughPostgreSQL array write transformations now always use explicit 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
|
Compute preview deployed. Branch: |
Fixes #1487
Root cause
The array cell editor submits a JS array (e.g.
["ADMIN","MANAGE"]). In parameters mode,transformValuecompiled it tocast($1 as "public"."my_enum"[])with the raw JS array as the parameter — drivers have no serializer for arrays of user-defined element types, so the value degraded to a bare string and Postgres rejected it withmalformed array literal(22P02). Nativetext[]happened to work because drivers register serializers for built-in array OIDs, which is why the earlier text-array fix (ff11835, gated onnoParameters) didn't cover enums.Fix
Array-typed columns with JS array values are now always compiled as
cast(array[$1, $2, …] as "schema"."type"[])(individual scalar parameters, or inlined literals innoParametersmode), removing any dependence on driver-specific array serialization — and the now-unusednoParametersgating indml.ts.Also fixes a small adjacent bug found while tracing why the console showed no error details:
deserializeErrorassigned the restored error name to the serialized payload instead of the reconstructedError.Verification
pnpm test:data203 tests passing; typecheck/lint clean; changeset included.🤖 Generated with Claude Code