Skip to content

Fix null propagation in date/time interval construction - #4008

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

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

Conversation

@roji

@roji roji commented Oct 18, 2026

Copy link
Copy Markdown
Member

EF's string-concatenation null compensation turns null interval arguments into strings such as ' days', causing PostgreSQL error 22007.

Use the existing PgUnknownBinaryExpression for interval concatenation so nulls propagate without changing normal C# string-concatenation semantics. Add regression coverage for nullable DateTime.AddDays and DateOnly.AddYears/AddMonths arguments, and update the existing parameterized-interval SQL baseline.

Fixes #2889

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
Copilot AI balanced review requested due to automatic review settings October 18, 2026 10:13

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

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 PgUnknownBinaryExpression without 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

@roji
roji merged commit e86b243 into main Oct 18, 2026
16 checks passed
@roji
roji deleted the roji-triage-issue-2889 branch October 18, 2026 11:31
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
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.

PostgresException: 22007: invalid input syntax for type interval: " days"

2 participants