Skip to content

[codex] Fix Postgres text array cell edits#1527

Merged
sorenbs merged 2 commits into
mainfrom
codex/fix-postgres-text-array-cell-edits
Jun 16, 2026
Merged

[codex] Fix Postgres text array cell edits#1527
sorenbs merged 2 commits into
mainfrom
codex/fix-postgres-text-array-cell-edits

Conversation

@sorenbs

@sorenbs sorenbs commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix inline-value PostgreSQL writes for native array cell edits by serializing JS arrays as cast array[...] expressions when noParameters compilation is enabled.
  • Add a PGlite-backed regression test for updating a text[] column to ["tag1", "tag2", "tag3"] with inline parameters.
  • Document native PostgreSQL array cell editing and add a patch changeset.

Root Cause

ImmediateValuePlugin marks Kysely values as inline literals when noParameters is enabled. Kysely's Postgres compiler cannot inline a JavaScript array as a single immediate value, so a text[] edit compiled from ["tag1", "tag2", "tag3"] threw invalid immediate value tag1,tag2,tag3 before the update query could run.

Validation

  • Reproduced the failure first with pnpm vitest --project data data/postgres-core/dml.test.ts; the new regression failed with invalid immediate value tag1,tag2,tag3 before the fix.
  • pnpm vitest --project data data/postgres-core/dml.test.ts
  • pnpm typecheck
  • pnpm test:data
  • pnpm lint (passes with existing warning-only lint output)
  • pnpm demo:ppg, then Playwright at http://localhost:4310: edited organizations.regions text[] for org_acme to [ "tag1", "tag2", "tag3" ], confirmed Save 1 row, saw no save error, and verified the database row persisted as ["tag1","tag2","tag3"].

@sorenbs sorenbs requested a deployment to production June 16, 2026 15:03 Abandoned
@sorenbs sorenbs requested a deployment to production June 16, 2026 15:03 Abandoned
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Compute preview deployed.

Branch: codex/fix-postgres-text-array-cell-edits
Service: codex-fix-postgres-text-array-cell-edits
Preview: https://cmqgrvstp01v11ef53kx2mqw2.cdg.prisma.build
Version: https://cv-2fbdbe3b5474.cdg.prisma.build

@sorenbs sorenbs marked this pull request as ready for review June 16, 2026 15:04
@coderabbitai

coderabbitai Bot commented Jun 16, 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: 21783cc6-47fc-4442-9fa3-f8f77b233347

📥 Commits

Reviewing files that changed from the base of the PR and between 8c73515 and cd10a44.

📒 Files selected for processing (1)
  • data/postgres-core/dml.test.ts

Summary by CodeRabbit

Bug Fixes

  • Fixed PostgreSQL text array editing in Prisma Studio when inline SQL literals are used, ensuring array values are written back with explicit array[...] casts and zero query parameters.

Documentation

  • Updated documentation to describe native PostgreSQL array editing using JSON-style array input, including correct cast behavior for inline literals.

Tests

  • Added coverage for PostgreSQL text[] inserts and updates verifying the generated SQL shape (no parameters) and persisted values.

Walkthrough

The PR fixes PostgreSQL text array cell edits when queries are compiled with inline values (noParameters: true). ApplyWriteTransformationsProps and TransformValuesProps in data/query.ts gain an optional noParameters field. transformValues maps this to an inlineArrayValues option passed to transformValue, which now accepts an options object and adds a new code path that builds a cast(array[...] as text[]) SQL expression for array-typed columns. getInsertQuery and getUpdateQuery in data/postgres-core/dml.ts are updated to forward requirements?.noParameters into applyTransformations. New integration tests for both insert and update operations, a FEATURES.md entry, and a changeset file are also added.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly references the main fix: PostgreSQL text array cell edits, which is the primary focus of this pull request.
Description check ✅ Passed The description provides a clear summary of the fix, root cause analysis, and validation steps that directly relate to the changeset modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-postgres-text-array-cell-edits
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/fix-postgres-text-array-cell-edits

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@data/postgres-core/dml.test.ts`:
- Around line 1235-1265: Add a new test below the existing "supports PostgreSQL
text array updates when parameters are inlined" test that mirrors the same
coverage for the insert flow. Create a test that calls getInsertQuery with a
text array column (arr_col) containing sample data like ["tag1", "tag2",
"tag3"], using the same noParameters: true option, and verify both the generated
SQL snapshot matches the expected inline array casting format and that the data
persists correctly when executed. This ensures getInsertQuery maintains the same
noParameters contract as the existing update test to prevent one-sided
regressions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 48b0dae5-1b43-4a9d-aa44-a5a09f2cfc64

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad7169 and 8c73515.

📒 Files selected for processing (5)
  • .changeset/fix-postgres-text-array-edits.md
  • FEATURES.md
  • data/postgres-core/dml.test.ts
  • data/postgres-core/dml.ts
  • data/query.ts

Comment thread data/postgres-core/dml.test.ts
@sorenbs sorenbs merged commit ff11835 into main Jun 16, 2026
3 checks passed
@sorenbs sorenbs deleted the codex/fix-postgres-text-array-cell-edits branch June 16, 2026 15:36
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.

1 participant