Repository navigation
Support NodaTime ranges in temporal constraints - #3975
Merged
Merged
Conversation
Allow range mappings to supply their current-value comparers for model validation and update ordering. Support Interval and DateInterval temporal keys and foreign keys, including unbounded intervals. Co-authored-by: Copilot App <[email protected]> Copilot-Session: df0d9290-49c9-4f4b-a74d-cb3824f85429
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Both new NodaTime comparers ignore value converters, causing command sorting failures for converted keys.
2 open findings
What changed in this PR
Enables NodaTime ranges in PostgreSQL temporal constraints, addressing #3824 while keeping NodaTime-specific ordering in the plugin.
Changes:
- Introduces a shared range-mapping interface for validation and comparer creation.
- Adds
IntervalandDateIntervalordering, including unboundedIntervalendpoints. - Adds comparer tests and temporal-constraint integration coverage.
| File | Description |
|---|---|
| test/EFCore.PG.Tests/Storage/NpgsqlNodaTimeTypeMappingTest.cs | Tests NodaTime comparer ordering. |
| test/EFCore.PG.FunctionalTests/TemporalConstraintNodaTimeTest.cs | Exercises temporal keys, foreign keys, and persistence. |
| src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs | Implements the shared comparer factory. |
| src/EFCore.PG/Storage/Internal/Mapping/INpgsqlRangeTypeMapping.cs | Defines the shared range-mapping contract. |
| src/EFCore.PG/Metadata/Conventions/NpgsqlRuntimeModelConvention.cs | Uses mapping-provided runtime comparers. |
| src/EFCore.PG/Metadata/Conventions/NpgsqlPostgresModelFinalizingConvention.cs | Installs mapping-provided comparers during finalization. |
| src/EFCore.PG/Infrastructure/Internal/NpgsqlModelValidator.cs | Recognizes plugin range mappings. |
| src/EFCore.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs | Adds interval ordering with unbounded endpoints. |
| src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs | Adds date-interval ordering. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
roji
disabled auto-merge
October 16, 2026 10:29
Only install range-specific current-value comparers for unconverted mappings, preserving EF's existing model/provider ordering for converted keys. Cover int and long keys converted to NodaTime ranges with and without temporal constraints. Co-authored-by: Copilot App <[email protected]> Copilot-Session: df0d9290-49c9-4f4b-a74d-cb3824f85429
Preserve range-valued key ordering across same-type and cross-type value conversions, while leaving comparable scalar model values to EF's comparer. Cover model validation and multiple-row saves for both range conversion cases. Co-authored-by: Copilot App <[email protected]> Copilot-Session: df0d9290-49c9-4f4b-a74d-cb3824f85429
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues, and regression coverage addresses temporal operations and converted-key compatibility; tests were not executed.
0 open findings
1 resolved since last review
🧠 Review effort: Balanced
This was referenced Oct 19, 2026
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.


IntervalandDateIntervalcurrently fail model validation when used inWITHOUT OVERLAPSkeys orPERIODforeign keys because they lack ordering comparers and their mappings are not recognized as range mappings.Introduce a shared range-mapping interface so each mapping supplies its current-value comparer. Model validation and both model-finalizing and runtime-model conventions use this interface, keeping NodaTime-specific ordering in the plugin. Unbounded
Intervalendpoints are supported.Adds comparer coverage and PostgreSQL integration coverage for primary and alternate keys, temporal foreign keys, and insert/update/delete operations for both NodaTime types.
Fixes #3824