Skip to content

Keep Unicode whitespace at the edges of array elements - #53

Merged
quinnj-bot[bot] merged 4 commits into
mainfrom
claude/array-unicode-whitespace
Nov 19, 2026
Merged

quinnj-bot[bot] merged 4 commits into
mainfrom
claude/array-unicode-whitespace

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

Text array elements lost a leading or trailing no-break space (U+00A0), ideographic space (U+3000), or other Unicode space when read. The array parser trimmed elements with Base.strip, which removes Unicode space separators. PostgreSQL quotes an array element only when it contains ASCII whitespace, so these characters arrive unquoted and belong to the element.

For example, SELECT ARRAY[E'\u00a0lead', E'trail\u00a0'] returned ["lead", "trail"].

What changed

  • The parser no longer strips unquoted array elements. The server quotes every element that contains ASCII whitespace, so an unquoted element has no whitespace to trim except the Unicode spaces that belong to it.

Scope

  • Covers untyped results and typed Vector{String} fields over text[], varchar[], and char(n)[] columns.
  • Quoted elements, ranges, and composites did not trim and are unchanged.

Blast Radius

Only array elements that start or end with non-ASCII whitespace decode differently. They now match what the server stores. Hand-written literals with a space after an unquoted element ({1 ,2}) would now keep it, but the parser only reads server output.

Verification

  • New test in Type Parsing: fails on main (the decoded array is ["lead", "trail", ...]), passes with the fix.
  • A differential harness compared 26,000 decoded values with each server's binary output (*send functions) on PostgreSQL 13, 17, and 18. On main it found 14 text, varchar, and char arrays with this defect. With the fix it found none. No other result changed.
  • Self-review: parse_unquoted is the only array, range, or composite parser that trimmed. Whitespace before an element is still skipped. Server output never has whitespace after an unquoted element, and no unit test feeds one.

🤖 Generated with Claude Code

quinnj and others added 4 commits November 19, 2026 01:08
PostgreSQL quotes an array element only when it contains ASCII
whitespace, so an element that starts or ends with a no-break space
or another Unicode space separator arrives unquoted. This test reads
such elements untyped and through a typed Vector{String} field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PostgreSQL's array output quotes an element only when it contains ASCII
whitespace, so an element that starts or ends with U+00A0 (no-break
space), U+3000, or another Unicode space separator arrives unquoted.
parse_unquoted trimmed elements with Base.strip, which also removes
those characters, so they were silently dropped from decoded text,
varchar, and char arrays, untyped and typed alike.

Trim only the ASCII whitespace the array grammar itself ignores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server quotes every element that contains ASCII whitespace, so the
trailing-whitespace trim could only run on text the server never sends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quinnj-bot
quinnj-bot Bot merged commit c137bfa into main Nov 19, 2026
16 checks passed
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