Repository navigation
Conversation
Correct negative PostgreSQL date/time years to NodaTime astronomical numbering without changing Period.Years or LocalDate subtraction. Partially addresses #4089. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
Folded back into #4109 |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in the narrowly scoped correction or its regression coverage; tests were not independently executed.
No open issues 🎉
What changed in this PR
Corrects NodaTime calendar-year extraction to match astronomical year numbering, including BCE dates and year zero. This addresses the year-extraction portion of #4089 independently of the subtraction change in #4109.
Changes:
- Adds one to negative PostgreSQL calendar years while leaving
Period.Yearsunchanged. - Adds sync/async regression coverage for years
-100,0, and1, including explicit time-zone conversion and negative interval years. - Updates existing positive-year SQL baselines.
| File | Description |
|---|---|
| test/EFCore.PG.FunctionalTests/Query/Translations/NodaTime/ZonedDateTimeTranslationsTest.cs | Tests astronomical years in UTC and an explicit time zone; updates SQL expectations. |
| test/EFCore.PG.FunctionalTests/Query/Translations/NodaTime/PeriodTranslationsTest.cs | Verifies negative interval years remain unchanged. |
| test/EFCore.PG.FunctionalTests/Query/Translations/NodaTime/LocalDateTranslationsTest.cs | Tests astronomical date years and updates SQL expectations. |
| test/EFCore.PG.FunctionalTests/Query/Translations/NodaTime/LocalDateTimeTranslationsTest.cs | Tests astronomical timestamp years and updates SQL expectations. |
| src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs | Corrects calendar-year extraction without changing interval-year extraction. |
Review effort: Balanced
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.
PostgreSQL has no year zero, whereas NodaTime uses astronomical year numbering. Correct date/time
.Yearextraction with aCASEthat adds one to negative PostgreSQL years, sonew LocalDate(-100, 12, 31).Yearreturns-100and ISO year zero returns0.Applies to
LocalDate,LocalDateTime, andZonedDateTime, including explicit time-zone conversion.Period.Yearsremains unchanged.Adds sync/async regression coverage for years
-100,0, and1, plus negative interval years, and updates the existing positive-year SQL baselines. All 233 NodaTime translation tests pass using an isolated PostgreSQL testcontainer.Partially addresses #4089. This PR is based directly on
mainand deliberately excludes the LocalDate subtraction /age()change in #4109, allowing this fix to be backported independently.