Repository navigation
docs: sub-microsecond temporal text is three values, at most 1 µs apart - #175
Merged
Merged
Conversation
#126 found that a temporal literal with more than six fraction digits is one value in memory (100 ns BCL, 1 ns NodaTime), another on the server reading the same text (rounded half-to-even to the microsecond), and a third in the store (truncated toward 2000-01-01, as Npgsql binds). Rounding on parse, the issue's first option, would break the library's own round trip: a value with sub-microsecond ticks, anything built from DateTime.Now, prints seven digits and would read back as a different value (claim S08; 12 round-trip unit tests fail with it planted). It would also disagree with every parameter, which Npgsql truncates. So the divergence is documented, the issue's second option: architecture.md#domain-width-and-the-boundary (Precision), serialization.md (claim J37) and the NodaTime README. DomainBoundaryDivergenceTests pins the three values against PostgreSQL for DateTimeRange (seven digits) and LocalDateTimeRange (nine), and that the library's literal round-trips them; LiteralCorpusProbeTests counts the sub-microsecond family as that documented divergence, so the 22 #126 candidates go. Planting six-digit parsing fails the new test. Closes #126 Found-By: OT Defect-Class: LIT Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 18, 2026
…iteral # Conflicts: # docs/architecture.md # test/CodoMetis.ValueRanges.EFCore.PostgreSQL.IntegrationTests/DomainBoundaryDivergenceTests.cs
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 #126
Stacked on #173 (base
fix/discrete-infinity-bound), which is stacked on #171.Problem
A temporal literal with more than six fraction digits holds three values. The library keeps every digit its type can hold (100 ns BCL, 1 ns NodaTime). PostgreSQL reads the same text rounded half-to-even to the microsecond. The EF Core store writes it truncated toward 2000-01-01, as Npgsql binds a parameter. So
[2026-01-01 10:00:00.1234567,)is .1234567 in memory, .123457 on the server read from that text, and .123456 stored.The issue offered two options: round on parse, or document the divergence. Rounding on parse breaks a held promise. A value with sub-microsecond ticks (anything built from
DateTime.Now) prints seven digits, and claim S08 says sub-second ticks survive the literal and JSON. With rounding, such a value would read back as a different value. Planting six-digit parsing fails 12 round-trip unit tests. It would also disagree with every parameter, which Npgsql truncates rather than rounds. The store rule (StoreTemporal/NodaStoreTemporal) already follows Npgsql. So this PR documents the divergence and pins it, and no behaviour changes.Change
docs/architecture.md#domain-width-and-the-boundary: a Precision paragraph, with why parse doesn't round.docs/serialization.md#dates-and-times-are-strict-iso-8601: the three values and the advice to round yourself when a value must equal the server's reading of its text (claim J37 quotes it). The NodaTime README says the same for nanoseconds.DomainBoundaryDivergenceTests(integration) pins the three values against PostgreSQL 17, forDateTimeRangewith seven digits (.1234567,.0000015) andLocalDateTimeRangewith nine, and that the library's literal round-trips its digits.LiteralCorpusProbeTestscounts thesub-microsecondfamily on temporal kinds as this documented divergence. The 22#126candidates are removed.Docs:line under 10.0.0 Fixed (root and core). No migration entry, since nothing changes.Tests
IsoTemporalcutting the fraction to six digits, both newDomainBoundaryDivergenceTestsrows fail ("the library keeps every 100 ns digit"), and 12 unit tests fail.dotnet test: every project passes, both integration suites included (Docker, postgres:17).🤖 Generated with Claude Code