fix(cleanup): pass array values as scalar binds, incompatible with fetch_types false - #6035
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The three prune DELETE helpers now filter with
Reviewed by Cursor Bugbot for commit 47e9621. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryFixes prune/webhook SQL that still failed under
Confidence Score: 5/5Safe to merge; the binding fix matches the deployed client constraint and is covered by render-level tests for the prune path. Scalar IN lists and ARRAY[scalar…] construction avoid the 22P02 array-parameter path under fetch_types: false; empty IN is guarded; webhook pattern aligns with production sql.join ARRAY usage.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/execution/payloads/large-value-metadata.ts | Empty guards plus IN-list scalar binds avoid postgres.js array serialization when fetch_types is false. |
| apps/sim/lib/execution/payloads/prune-metadata-sql.test.ts | Dialect render tests require workspace_id IN ($n…) and forbid array params and bad ANY/IN forms. |
| apps/sim/lib/webhooks/polling/utils.ts | jsonb key removal uses ARRAY of scalar binds via sql.join, matching existing table dispatcher pattern. |
| apps/sim/lib/webhooks/polling/utils.test.ts | Mock updated for sql.join; asserts scalar removed key value rather than a whole array param. |
Reviews (1): Last reviewed commit: "fix(cleanup): pass array values as scala..." | Re-trigger Greptile
Summary
22P02 Array value must start with "{". My fix there usedsql.param(arr), which binds the array as a single parameter — and that is incompatible with the shared client configpackages/db/db.tssetsfetch_types: false, which skips thepg_catalog.pg_typeroundtrip. That roundtrip is what builds postgres.js's array serializers, so an array parameter can no longer be encoded and Postgres rejects it. Scalar params are unaffectedfetch_types: trueboth forms work; withfetch_types: false,sql.param(arr)fails and anINlist of scalars succeedsworkspaceIdssites toworkspace_id IN ${workspaceIds}(scalar binds only) and added an explicit empty guard to each prune helper, sinceIN ()is a syntax errorARRAY[$1, $2]::text[]built from scalar binds — the jsonb-operator needs a real array operand, so it can't useINThe
db.tsdocstring says "writes never reach the array serializer because Drizzle serializes arrays before binding". That holds for drizzle-typed columns, but not for a rawsqltemplate binding an array — which is exactly this path.Type of Change
Testing
prune-metadata-sql.test.tsnow renders the real prune statements and asserts anINlist plus no array parameter at all; covers single and multiple ids, and still rejects the= INandANY((...))formsworkspace_id IN ($1)with 0 array paramsEXPLAINed all 3 real statements against staging through the cleanup bouncer withfetch_types: false— the exact deployed combination that fails today: 3 planned OK, 0 failedtsc --noEmitclean; lint and the full audit suite passChecklist