fix(export): write infinite timestamps and dates as infinity, not year 9999 - #339
Merged
Merged
Conversation
…r 9999 Npgsql reads a Postgres 'infinity' or '-infinity' timestamp, timestamptz or date as the largest or smallest DateTime (DateOnly, DateTimeOffset). Export and copy wrote those with "O", so every CSV/TSV/Markdown/JSON/INSERT carried 9999-12-31T23:59:59.9999999 and 0001-01-01T00:00:00.0000000, which Postgres reads back as finite values. Range bounds went through the same formatter. PgValueSyntax.TemporalInfinity is now the one place that knows the mapping; ResultExporter's scalar text and CellText.Temporal both ask it first, so a cell, an array element and a range bound ([2026-01-01,infinity)) all write the word. The FK hop's seed goes through FormatSqlLiteral and gets it too. ResultExporterInfinityTests covers every format; with PGNIMBUS_TEST_CONN it reads 12 infinite values from the server and casts each written form back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What and why
Npgsql reads a Postgres
infinity/-infinitytimestamp, timestamptz or date as the largest or smallestDateTime(alsoDateOnly,DateTimeOffset). Export and copy wrote those with"O", so CSV, TSV, Markdown, JSON and INSERT output had9999-12-31T23:59:59.9999999and0001-01-01T00:00:00.0000000. Postgres reads both back as finite values. Since #330, range bounds use the same formatter, so[2026-01-01,infinity)had the same problem. The grid already showedinfinity.Fix:
PgValueSyntax.TemporalInfinitymaps those max/min values to the words. It is the only code that knows Npgsql's mapping.ResultExporter's scalar text calls the helper first. This covers cells, array elements and range bounds in every format. JSON now writes dates and times through the same text and no longer has its own"O"cases.CellText.Temporalcalls the same helper instead of keeping its own copy.FormatSqlLiteral, so it gets the fix too.Known edge: Npgsql also reads
0001-01-01 00:00:00asDateTime.MinValue. So the grid and export both show that one finite value as-infinity. This is documented in.claude/CLAUDE.md.Not in this PR: filter-by-cell (
RowFilterSql.ValueText),SqlLiteral.FormatandPgValueSyntax.InvariantTexthave the same bug. A separate session is fixing them.Visible to users (release notes)
Export and copy (CSV, TSV, JSON, Markdown, INSERT) now write infinite timestamps and dates as
infinity/-infinity. Before, they wrote9999-12-31T23:59:59.9999999/0001-01-01T00:00:00.0000000. Range bounds change the same way ([2026-01-01,infinity)).Verified
dotnet build PgNimbus.slnx: 0 warnings, 0 errorsdotnet test --project tests/PgNimbus.Core.Tests:ResultExporter*tests pass. That includes the 12 new live cases: scalar, array, range and multirange infinities, each written as TSV, INSERT and JSON and cast back on the server.Every new test failed before the fix: 7/7 unit tests, and 12/12 live cases on the server.
dotnet test --project tests/PgNimbus.App.Tests: 760 total, 0 failed.NativeAOT publish: not run. No new reflection or JSON serialization.
Screenshots: no scenario shows an infinite date, so no baseline or published image changes.
CI (
build-test, postgres:17 withPGNIMBUS_TEST_CONNset): Core 2081 total, 0 failed, 13 skipped. The skips are SSH, the native keychain and preloaded pg_stat_statements; none of the new live cases skipped.Anything left unverified: the full Core suite against a local server. Docker's engine crashed during the local run, so all of its database tests timed out.
Checklist
PgNimbus.Corestill has zero UI dependencies🤖 Generated with Claude Code