Skip to content

docs: the date extremes stand for the infinities, on every read path - #173

Merged
CaffeinatedCoder merged 3 commits into
mainfrom
fix/discrete-infinity-bound
Oct 18, 2026
Merged

CaffeinatedCoder merged 3 commits into
mainfrom
fix/discrete-infinity-bound

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #117

Stacked on #171 (base fix/inverted-range-literal); retarget to main once #171 merges.

Problem

A date range with an exclusive infinite bound, the form daterange('2026-01-01', 'infinity') prints, reads as [2026-01-01,9999-12-30] through a column and through every literal entry point, while PostgreSQL's range also holds its real 9999-12-31, and upper(x) gives infinity. The issue proposed reading the exclusive bound as the inclusive extreme ([2026-01-01,9999-12-31]), and offered documenting it as the alternative.

The proposed reading can't be made consistent. Measured against PostgreSQL 17:

  • Column, upper side. Npgsql reads [x,infinity) and [x,9999-12-31) as the same NpgsqlRange<DateOnly> (both 9999-12-31, upper exclusive). [x,9999-12-31) is how PostgreSQL stores the plugin's own [x,9999-12-30]. Reading it inclusive in FromProvider made DifferentialFuzzParityTests load every stored [x,9999-12-30] as [x,9999-12-31].
  • Column, lower side. An exclusive lower bound can only be -infinity, but PostgreSQL's own algebra produces it: (,) - (,-infinity] is (-infinity,), which excludes the minimum it subtracted. Reading it inclusive failed DifferentialFuzzParityTests for Except, Complement and operator - on DateRange and LocalDateRange.
  • Literal only. Changing just RangeFormat would make one server value read as [x,9999-12-30] from its column and [x,9999-12-31] from its own text.

So in this library the date extreme is the infinity, as Npgsql's mapping and the StoreTemporal rule already say, and an exclusive infinity excludes it on every path. The reading stays, and this PR documents and pins it. No behaviour changes, so there's no changelog Breaking line and no migration entry; there is a Docs: line under Fixed.

Change

  • docs/architecture.md#domain-width-and-the-boundary: a paragraph and table, "The date extremes stand for the infinities", with why the inclusive reading can't be used.
  • docs/serialization.md#dates-and-times-are-strict-iso-8601: the literal rule (claim J36 quotes it).
  • docs/efcore.md#rows-written-by-other-tools: other writers' [x,infinity) rows load one day short. Have them write an absent bound (daterange(x, NULL) → [x,)) or an inclusive one ('[x,infinity]' → [x,9999-12-31]).
  • DomainBoundaryDivergenceTests (integration): for eight forms (daterange(x,'infinity'), '(-infinity,x]', both infinities in both bound styles, (,infinity), (-infinity,), inclusive infinity, the plugin's own [x,9999-12-30]), the column read equals Parse of the server's text, a multirange literal of it, and the LocalDateRange reads. A second test pins the divergence itself: the server's range contains its 9999-12-31.
  • LiteralCorpusProbeTests: the infinity bound family's write-back on the date kinds counts as this documented boundary. That includes LocalDateRange's -9998-01-02, which PostgreSQL refuses on write (loud). The four #117 candidates are removed.
  • test/oracles/seeds/column-minus-infinity-read-as-minimum.patch: the column-side reading, caught by DifferentialFuzzParityTests.
  • Changelog: a Docs: line under 10.0.0 Fixed (root and core).

Tests

  • Proven by planting each proposed reading:
    • The literal one (RangeFormat reads an exclusive infinity/-infinity bound inclusive) fails 6 DomainBoundaryDivergenceTests cases, e.g. daterange('2026-01-01', 'infinity') through its text [2026-01-01,infinity).
    • The column one (FromProvider) fails 3 cases and DifferentialFuzzParityTests.
  • dotnet test: every project passes, both integration suites included (Docker, postgres:17).

🤖 Generated with Claude Code

#117 proposed reading an exclusive infinite date bound as the inclusive
extreme, so [x,infinity) would keep 9999-12-31. Measured against
PostgreSQL 17 it can't be done consistently:

- Column, upper side: Npgsql reads infinity) and 9999-12-31) as the same
  DateOnly, and [x,9999-12-31) is how PostgreSQL stores the plugin's own
  [x,9999-12-30]. Reading it inclusive made DifferentialFuzzParityTests
  load every such row a day long.
- Column, lower side: PostgreSQL's own algebra produces the exclusive
  form, (,) - (,-infinity] = (-infinity,), which excludes the minimum it
  subtracted. Reading it inclusive failed DifferentialFuzzParityTests
  for Except, Complement and operator -.
- Literal: changing only the text would make one server value read as
  [x,9999-12-30] from its column and [x,9999-12-31] from its text.

So the extreme is the infinity, as Npgsql's mapping and StoreTemporal
already say, and the reading stays. Documented in architecture.md's
boundary section (with a table), serialization.md (claim J36) and
efcore.md#rows-written-by-other-tools, which tells other writers to use
an absent or inclusive open end. DomainBoundaryDivergenceTests now holds
the column and the text (Parse, a multirange literal, LocalDateRange)
to the same value for eight forms; planting either proposed reading
fails it. LiteralCorpusProbeTests counts the infinity-bound write-back
of the date kinds as that documented boundary, so the four #117
candidates go. The column plant is kept as a seed for
DifferentialFuzzParityTests.

Closes #117

Found-By: OT
Defect-Class: STORE

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) area/ranges Range unions, variants and the shape engines package/nodatime Affects CodoMetis.ValueRanges.NodaTime package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime severity/low Cosmetic, message or documentation-level difference stacked Base is another open PR; merge in order, CI does not run until it targets main labels Oct 18, 2026
…bound

# Conflicts:
#	CHANGELOG.md
#	docs/architecture.md
#	test/CodoMetis.ValueRanges.EFCore.PostgreSQL.IntegrationTests/DomainBoundaryDivergenceTests.cs
#	test/oracles/candidates.json
Base automatically changed from fix/inverted-range-literal to main October 18, 2026 14:35
@CaffeinatedCoder CaffeinatedCoder removed the stacked Base is another open PR; merge in order, CI does not run until it targets main label Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit b1d5a74 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/discrete-infinity-bound branch October 18, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/literals Parse, TryParse and formatting area/ranges Range unions, variants and the shape engines bug Something isn't working found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime package/nodatime Affects CodoMetis.ValueRanges.NodaTime severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A discrete range read as [x,infinity) loses 9999-12-31; UpperBound disagrees between memory and server

1 participant