fix(cleanup): bind array params as arrays, not expanded value lists - #6010
fix(cleanup): bind array params as arrays, not expanded value lists#6010TheodoreSpeaks wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Large-value metadata cleanup: All three prune DELETE paths now use Webhook polling config: Key removal in Tests / mocks: Adds Reviewed by Cursor Bugbot for commit cf599d0. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryFixes Drizzle SQL array binding so Postgres receives a single
Confidence Score: 5/5Safe to merge; the change correctly binds arrays as single Postgres parameters and is covered by targeted SQL rendering tests. The four production call sites and mocks implement the standard drizzle escape hatch for array parameters, matching the failure mode described in production (22P02 / record-to-text[] cast), with no remaining incorrect expansion on the changed paths.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/execution/payloads/large-value-metadata.ts | Binds workspace ID arrays via sql.param in three prune DELETE statements so Postgres accepts text[] casts at any array size. |
| apps/sim/lib/webhooks/polling/utils.ts | Binds removedKeys as a single array param for jsonb - key removal, avoiding the same cast failure on config updates. |
| apps/sim/lib/execution/payloads/prune-metadata-sql.test.ts | Unmocks drizzle/schema and asserts rendered prune SQL uses ANY($n::text[]) for single and multi workspace ids. |
| packages/testing/src/mocks/database.mock.ts | Adds sql.param to the shared createMockSql helper so tests that use param binding do not break. |
| apps/sim/lib/webhooks/polling/utils.test.ts | Local drizzle mock exposes sql.param as identity so removedKeys still appear in captured values. |
Reviews (1): Last reviewed commit: "fix(cleanup): bind array params as array..." | Re-trigger Greptile
Summary
Failed to prune metadata:ref.workspace_id = ANY(($1)::text[])→22P02 Array value must start with "{"ANY(${arr}::text[])casts a row constructor (or, with one element, a bare scalar) totext[]— Postgres rejects bothworkspaceIdssites in the prune queries withsql.param(...), which binds the whole array as a single parameter (ANY($1::text[])) and is correct at every size, including emptylib/webhooks/polling/utils.tsbuilt- ${removedKeys}::text[]for the jsonb key-removal operator, so any polling config update that drops a key would fail the same way. Fixed identicallyscript-migrationshits use postgres-js's ownsqltag, which binds arrays natively — not affected. Themcp/discoverIN ${workspaceIds}is guarded against empty upstream — left aloneType of Change
Testing
prune-metadata-sql.test.tsrenders the real prune statements (unmocking drizzle + schema, capturing via a fake client) and assertsANY($1::text[])— verified it fails on the old form and passes on the fix, for both single and multi idsql.paramto the shared testing mock and the polling test's local drizzle mock; 126 tests across payloads, webhooks/polling, cleanup passtsc --noEmitclean;bun run lintand the full audit suite passChecklist