Skip to content

fix: Postgres enum array cell updates - #1546

Merged
sorenbs merged 1 commit into
mainfrom
fix/1487-enum-array-update
Jul 18, 2026
Merged

fix: Postgres enum array cell updates#1546
sorenbs merged 1 commit into
mainfrom
fix/1487-enum-array-update

Conversation

@sorenbs

@sorenbs sorenbs commented Jul 18, 2026

Copy link
Copy Markdown
Member

Fixes #1487

Root cause

The array cell editor submits a JS array (e.g. ["ADMIN","MANAGE"]). In parameters mode, transformValue compiled it to cast($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 with malformed array literal (22P02). Native text[] happened to work because drivers register serializers for built-in array OIDs, which is why the earlier text-array fix (ff11835, gated on noParameters) 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 in noParameters mode), removing any dependence on driver-specific array serialization — and the now-unused noParameters gating in dml.ts.

Also fixes a small adjacent bug found while tracing why the console showed no error details: deserializeError assigned the restored error name to the serialized payload instead of the reconstructed Error.

Verification

  • Two new regression tests (enum[] update in param mode and inline mode) with SQL snapshots and persistence checks against pglite; the param-mode test fails with 22P02 before the fix.
  • pnpm test:data 203 tests passing; typecheck/lint clean; changeset included.

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ebd63a8e-03e5-4e78-b8d8-47bcfa25789d

📥 Commits

Reviewing files that changed from the base of the PR and between 81354ff and 71f4d61.

📒 Files selected for processing (6)
  • .changeset/fix-postgres-enum-array-updates.md
  • FEATURES.md
  • data/bff/bff-client.ts
  • data/postgres-core/dml.test.ts
  • data/postgres-core/dml.ts
  • data/query.ts
💤 Files with no reviewable changes (1)
  • data/postgres-core/dml.ts

Summary by CodeRabbit

  • Bug Fixes

    • Fixed PostgreSQL enum array updates that could fail with an “Update Operation failed” error.
    • Improved reliability when saving PostgreSQL array values, including updates using inline SQL.
    • Preserved original error names when displaying errors received through the Studio backend.
  • Documentation

    • Updated typed cell editing guidance to reflect reliable PostgreSQL array updates.

Walkthrough

PostgreSQL array write transformations now always use explicit array[...] expressions with array-type casts, independent of the noParameters setting. PostgreSQL insert and update query builders pass default keyword support directly. Enum array update tests cover parameterized and inlined SQL modes, generated queries, parameters, and persisted values. Error deserialization preserves serialized error names, and documentation plus a changeset describe the fix.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing PostgreSQL enum array cell updates.
Description check ✅ Passed The description is directly related to the code changes and explains the enum-array fix and error-detail fix.
Linked Issues check ✅ Passed The PR addresses #1487 by fixing enum array updates and restoring error details in the console path.
Out of Scope Changes check ✅ Passed The changes are scoped to the reported bug, related tests, docs, and the adjacent error-deserialization fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1487-enum-array-update
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/1487-enum-array-update

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Compute preview deployed.

Branch: fix/1487-enum-array-update
Service: fix-1487-enum-array-update
Preview: https://vypdx1v4f3e2hbw0gu43icst.cdg.prisma.build

@sorenbs
sorenbs merged commit 6415faf into main Jul 18, 2026
3 checks passed
@sorenbs
sorenbs deleted the fix/1487-enum-array-update branch July 18, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update an enum array still doesnt work

1 participant