Repository navigation
Fix null propagation in date/time interval construction - #4008
Merged
Merged
Conversation
Use PostgreSQL concatenation semantics for generated intervals instead of C# null-to-empty-string compensation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e276a054-0cc7-4d2f-9aff-fede72016c44
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix uses existing expression handling and includes regression coverage; no blocking issues were identified, though tests were not executed.
No open issues 🎉
What changed in this PR
Fixes interval construction so null date/time arguments propagate as SQL nulls instead of causing PostgreSQL error 22007.
Changes:
- Uses
PgUnknownBinaryExpressionwithout changing normal C# string-concatenation semantics. - Adds nullable-argument regression tests.
- Updates the parameterized-interval SQL baseline.
| File | Description |
|---|---|
| test/EFCore.PG.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsNpgsqlTest.cs | Tests nullable AddDays arguments. |
| test/EFCore.PG.FunctionalTests/Query/Translations/Temporal/DateOnlyTranslationsNpgsqlTest.cs | Tests nullable AddYears and AddMonths arguments. |
| test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs | Updates interval SQL parentheses. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs | Preserves null propagation during interval construction. |
Review effort: Balanced
This was referenced Oct 18, 2026
roji
added a commit
that referenced
this pull request
Oct 18, 2026
Backport 6c1f5e4 from #4008. Preserve PostgreSQL null propagation for generated intervals without changing C# string concatenation. Retain the 10.0 DateOnly SQL casts in the regression baseline. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a2ba80a3-f573-4220-abd4-dab46ef11490
roji
added a commit
that referenced
this pull request
Oct 18, 2026
Backport #4008 to hotfix/9.0.5, adapting regression coverage to the existing ad hoc query test infrastructure. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4380d91d-c065-4628-b4b6-a7b941d89577
roji
added a commit
that referenced
this pull request
Oct 18, 2026
Backport 6c1f5e4 from #4008, adapting nullable-argument regression coverage to the existing 8.0 operators test infrastructure. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e3176f61-58ea-453d-94b3-fa642f2c42ab
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.
EF's string-concatenation null compensation turns null interval arguments into strings such as
' days', causing PostgreSQL error 22007.Use the existing
PgUnknownBinaryExpressionfor interval concatenation so nulls propagate without changing normal C# string-concatenation semantics. Add regression coverage for nullableDateTime.AddDaysandDateOnly.AddYears/AddMonthsarguments, and update the existing parameterized-interval SQL baseline.Fixes #2889