Skip to content

fix(pg): serialize nullish custom array values as SQL NULL - #3845

Draft
liuyinchu wants to merge 1 commit into
brianc:masterfrom
liuyinchu:fix/nullish-custom-array-values
Draft

liuyinchu wants to merge 1 commit into
brianc:masterfrom
liuyinchu:fix/nullish-custom-array-values

Conversation

@liuyinchu

Copy link
Copy Markdown

A custom value whose toPostgres() returns null or undefined works as a scalar parameter, but throws TypeError: Cannot read properties of null (reading 'replace') when used inside an array.

The parameter-conversion documentation says array items are recursively converted using the same rules. Prepare each element once and emit unquoted SQL NULL when the prepared value is nullish; other values keep their existing escaping.

Regressions cover null/undefined returns, nested arrays, chained custom conversion, exactly-once conversion, and literal NULL, empty-string, zero and false controls.

Validation on Node 24.22.1 / Linux:

  • New regression fails against unchanged production code with the expected TypeError.
  • Utility suite: 55 passing.
  • Complete pg unit suite (make test-unit): 289 passing.
  • Affected-file ESLint and git diff --check: pass.

No live PostgreSQL, native libpq, Cloudflare worker, or full-monorepo integration run is claimed. The published patch is byte-for-byte identical to the tested patch on the unchanged upstream base.

Disclosure: Codex implemented and tested this change under the submitting account's authorization.

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