Repository navigation
fix: strip whitespace at either end of a quoted or escaped temporal set element - #81
Merged
Merged
Conversation
…et element array_in hands quoted and escaped whitespace to the element's input function. date_in, timestamp_in, timestamptz_in and time_in strip space, tab, LF, CR, VT and FF from both ends; textin keeps them; uuid_in rejects them (measured on PostgreSQL 17, recorded in #70). The temporal families handed the whitespace to the strict ISO grammar, so {" 2026-01-01"} threw. Each temporal family's ParseValue, closed and wrapper arity, core and NodaTime, now trims through LiteralWhiteSpace.TrimAsInputFunction. The trim stays out of the shared array parser, which would strip a text[] element's own spaces. Parse, TryParse, the TypeConverter and the JSON element path all go through ParseValue. The numeric families already trimmed exactly these characters through the BCL number parsers. SetElementWhiteSpaceContractTests sweeps every discovered set type against the measured behaviour of its input function, and a live parity test asks PostgreSQL for the same literals, reading text[] element by element so a dropped space cannot hide on both sides. GuidSet accepting whitespace uuid_in rejects is registered as a candidate against #78 (10.0.0). Two seeds: the revert of this fix, and a trim in the shared parser for every family. Closes #70 Found-By: RV Defect-Class: LIT Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #70
Problem
A date or time value set threw on a quoted or escaped element with whitespace at either end, but PostgreSQL reads it:
I measured this on PostgreSQL 17 for every element type a set family maps to. The full table is in the issue.
array_indrops whitespace around a bare element itself, and hands quoted or escaped whitespace to the element's input function:int2in,int4in,int8in,numeric_inint.Parse,decimal.Parse)date_in,timestamp_in,timestamptz_in,time_intextinuuid_inU+00A0, U+2003 and an element of only whitespace are rejected everywhere except
textin.This fails loudly and the fix only accepts more, so it fits 9.1.0.
Change
LiteralWhiteSpace.TrimAsInputFunction: one helper, documented with the measurements, that trims the same six ASCII characters (space, tab, LF, CR, VT, FF).ParseValueof each temporal family calls that helper before the strict ISO grammar. That's 18 call sites:DateSet,DateTimeSet,DateTimeOffsetSetandTimeSetwith their wrapper arities, andLocalDateSet,LocalDateTimeSet,InstantSet,LocalTimeSetandYearMonthSetwith theirs.Parse,TryParse, theTypeConverterand the JSON element path all go throughParseValue. The element grammar itself is unchanged.SetFormatparser, because that would strip atext[]element's own spaces. A seed shows the tests catch that.docs/value-sets.md#parse-and-print-literalsgets two new "Good to know" bullets, after the ones claimS12quotes. New claimS16quotes them.### Fixedline each in the root, core and NodaTime changelogs.Tests
SetElementWhiteSpaceContractTests(conventions, new oracle inoracles.json) sweeps all 30 discovered set types throughParse,TryParse, theTypeConverterand, for temporal sets, JSON. It checks each one against its input function's measured behaviour: strips, keeps or rejects. A new element type with no measured behaviour fails by name. The GuidSet rows are registered incandidates.jsonagainst GuidSet accepts whitespace inside an element that PostgreSQL's uuid_in rejects #78.LiteralGrammarParityTests.ElementWhitespace_ReadsAsPostgresReadsIt(integration) covers 15 array type and family pairs against a live PostgreSQL, with 8 whitespace characters × 9 forms each. It readstext[]withunnest: reparsing the server's array output with the parser under test hid a dropped space on both sides, and the second seed showed that before I changed it. Theuuid[]rows are a candidate against GuidSet accepts whitespace inside an element that PostgreSQL's uuid_in rejects #78.StringSetkeeps its spaces (SetParseFormatTests), and a NodaTime repro (NodaTimeSetTests).temporal-set-element-whitespace-kept.patchis this fix reverted. The core and NodaTime repro tests fail, the sweep fails withDateSet: Parse rejected …, and the parity test fails withdate[] DateSet {" 2026-01-01"}: library refused, PostgreSQL {2026-01-01}.set-element-whitespace-trimmed-for-text.patchmoves the trim into the shared parser for every family. TheStringSetunit test fails, the sweep fails withStringSet: Parse read {" beta "} as {beta}, and the parity test fails withtext[] StringSet {" ab"}: library {ab}, PostgreSQL {" ab"}.dotnet run tools/oracles.cs seeds element-whitespacereports every (seed, oracle) pair caught.dotnet test, including both integration projects, passes locally.🤖 Generated with Claude Code