Skip to content

Fix BCE NodaTime SQL literal formatting - #4023

Merged
roji merged 1 commit into
mainfrom
roji-triage-issue-3532
Oct 18, 2026
Merged

roji merged 1 commit into
mainfrom
roji-triage-issue-3532

Conversation

@roji

@roji roji commented Oct 18, 2026

Copy link
Copy Markdown
Member

BCE NodaTime values currently generate ISO SQL literals with negative years or year zero, which PostgreSQL rejects. Format SQL literals using year-of-era notation and a BC suffix, including timestamps, legacy Instant mappings, ranges, and multiranges.

Keep JSON serialization in its existing ISO format and preserve infinity handling. Add paired SQL/JSON coverage for NodaTime and BCL date/time mappings, plus BCE range and multirange coverage.

BCE JSON-to-date casts remain a pre-existing limitation: JSON formatting and query translation are unchanged by this fix.

Fixes #3532

Use PostgreSQL year-of-era notation and a BC suffix for BCE scalar, range and multirange SQL literals while preserving ISO JSON serialization. Add paired SQL and JSON date/time coverage.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 233c3a0c-6558-4c6a-86f8-d65a5488801b
Copilot AI balanced review requested due to automatic review settings October 18, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues, and focused regression coverage exercises the affected paths; tests were not executed.

No open issues 🎉

What changed in this PR

Fixes #3532 by generating PostgreSQL-compatible BCE NodaTime SQL literals while preserving ISO JSON formatting and infinity handling.

Changes:

  • Uses year-of-era formatting with a BC suffix for BCE dates and timestamps.
  • Applies formatting to legacy Instant mappings, ranges, and multiranges.
  • Adds SQL/JSON regression coverage for NodaTime and BCL date/time mappings.
File Description
test/​EFCore.PG.Tests/​Storage/​NpgsqlTypeMappingTest.cs Adds paired BCL SQL/JSON tests.
test/​EFCore.PG.Tests/​Storage/​NpgsqlNodaTimeTypeMappingTest.cs Covers BCE literals, ranges, multiranges, and JSON preservation.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​TimestampTzZonedDateTimeMapping.cs Formats BCE zoned timestamps.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​TimestampTzOffsetDateTimeMapping.cs Separates BCE SQL formatting from JSON.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​TimestampTzInstantMapping.cs Adds shared Instant SQL formatting.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​TimestampLocalDateTimeMapping.cs Formats BCE local timestamps without changing JSON.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​LegacyTimestampInstantMapping.cs Reuses Instant SQL formatting.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​IntervalRangeMapping.cs Formats BCE interval bounds.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​DateMapping.cs Adds BCE date SQL formatting while preserving JSON.
src/​EFCore.PG.NodaTime/​Storage/​Internal/​DateIntervalRangeMapping.cs Reuses date SQL formatting for interval bounds.

Review effort: Balanced

@roji
roji merged commit 00b5456 into main Oct 18, 2026
16 checks passed
@roji
roji deleted the roji-triage-issue-3532 branch October 18, 2026 12:57
roji added a commit that referenced this pull request Oct 18, 2026
Backport #4023 (00b5456) to 10.0. Format BCE NodaTime SQL literals with year-of-era notation and a BC suffix while preserving JSON serialization and infinity behavior.

Fixes #3532

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: ad20383a-8f78-4bcc-955b-1c00522588b0
roji added a commit that referenced this pull request Oct 18, 2026
Backport #4023 to 9.0, preserving ISO JSON serialization and infinity handling while formatting BCE SQL literals with year-of-era and BC.

(cherry picked from commit 00b5456)

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 113c1bef-4117-4954-bc8c-8da076bdf6c1
roji added a commit that referenced this pull request Oct 18, 2026
Backport #4023 (00b5456) to hotfix/8.0.12. Preserve ISO JSON serialization and infinity handling, adapt test placement and LocalDateTime extrema to the 8.0 branch, and cover the original 384 BCE date.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 23da65c3-017a-4188-99fc-477970542012
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.

Invalid PostgreSQL SQL literals for BCE NodaTime dates and timestamps

2 participants