Repository navigation
feat: translate the DateRange calendar factories over a column (10.x, port of #191) - #449
Merged
CaffeinatedCoder merged 1 commit intoOct 25, 2026
Conversation
DateRange.Month, Quarter, Year and IsoWeek failed translation in a Where when their argument was a column. They now run as SQL with memory's answers: daterange(<first day>, <last day>, '[]') The first and last periods of DateOnly are constants taken from memory's own factory and written through the date mapping, so they are -infinity and infinity as Npgsql binds DateOnly.MinValue and MaxValue (the days themselves with DisableDateTimeInfinityConversions). A date column at or past them takes them too, so date_trunc never sees an infinity. Otherwise date_trunc(unit, d::timestamp) and that plus '<n> <unit> -1 day'. Measured on PostgreSQL 16 and 18 first (#191): to_date(..., 'IYYY-IW') rolls week 53 of a 52-week year over, make_date accepts the years 10000 and -1, and the proposed [) form over date_trunc(infinity) is empty. So the integer forms use make_date with a guard for the year, IsoWeek counts from January 4 and checks the week against date_part('week', Dec 28), and every argument memory rejects raises: a message cast to the type it stands in for, which always holds an argument, since PostgreSQL folds a constant cast while planning, even in a CASE arm no row reaches. LocalDateRange and YearMonthRange stay in memory: a LocalDate at -infinity (-9998-01-01) and the years before 4713 BC have no PostgreSQL date, so the server would fail where memory answers. CalendarFactoryParityTests holds every condition on #408's parity list; CalendarFactoryExtremesTests the extremes with the infinity conversions off. translation-support.json classifies DateRange server, and the docs move the row. Port to release/10.x (#448): DeclaredNullabilityTests isn't on this line, so its hunk and its entry in claim E76's heldBy drop out. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 879c82a)
This was referenced Oct 25, 2026
Closed
CaffeinatedCoder
deleted the
feat/448-translate-calendar-factories-10.x
branch
October 25, 2026 18:07
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 #448
Port of #191 (PR #447, merged into
mainas 7503c18) torelease/10.x, for 10.3.0 (#408). This lands only on this branch, so #448 gets closed by hand after the merge.Problem
On this line,
DateRange.Month,Quarter,YearandIsoWeekfail translation in aWherewhen they read a column. A query can't filter or order byDateRange.Month(b.Day).Change
f3ecbed: cherry-pick of 879c82a (-x):ValueRangesMethodCallTranslator:daterange(first, last, '[]'), with memory's first and last periods as constants. The integer forms usemake_date, guarded for the year and the ISO week. Every argument memory rejects raises an error.CalendarFactoryTranslationTestsandCalendarFactoryParityTests, with its seed.CalendarFactoryExtremesTestsin the infinity-disabled project.NodaCalendarFactoryClientSideTests.translation-support.json, claims E46 and E76,docs/efcore.md#what-runs-where,docs/ranges.mdand the EF Core README.[10.3.0]### Added, after theClamprow from 10.x: translate Clamp on Int32Range, Int64Range and DecimalRange (port of #406) #441, in both changelogs.DeclaredNullabilityTests, which isn't on this line. Its hunk is dropped, and so is its entry in claim E76'sheldBy. The parity test still checks that the filters and the projection agree.Tests
Run on
release/10.xwith SDK 10.0.402 and EF Core 10.0.0:CalendarFactoryParityTests,CalendarFactoryExtremesTestsandTranslationSupportProbeTests. All passed.dotnet run tools/oracles.cs seeds calendarreports CAUGHT.🤖 Generated with Claude Code