Implement support for PG18 WITHOUT OVERLAPS#3709
Merged
roji merged 1 commit intonpgsql:mainfrom Jan 23, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements support for PostgreSQL 18's WITHOUT OVERLAPS feature, which prevents overlapping ranges in primary keys and unique constraints. This is commonly used for temporal tables where you want to ensure that date ranges don't overlap for the same entity.
Changes:
- Added
WithoutOverlaps()extension methods for keys and indexes to configure the WITHOUT OVERLAPS constraint - Implemented migration SQL generation to include WITHOUT OVERLAPS in PRIMARY KEY and UNIQUE constraints
- Added model validation to ensure WITHOUT OVERLAPS is only used with PostgreSQL 18+, on range-type columns, and on unique indexes
- Implemented database scaffolding support to reverse-engineer WITHOUT OVERLAPS from existing databases
- Added automatic discovery of the btree_gist extension when WITHOUT OVERLAPS is used
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs | Added comprehensive migration tests for creating and altering tables with WITHOUT OVERLAPS constraints |
| src/EFCore.PG/Strings.resx | Added error messages for WITHOUT OVERLAPS validation and fixed whitespace formatting |
| src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs | Generated code for the new error message strings |
| src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs | Added support for reading WITHOUT OVERLAPS from PostgreSQL's conperiod column when scaffolding databases |
| src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs | Implemented SQL generation for WITHOUT OVERLAPS in PRIMARY KEY and UNIQUE constraints |
| src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs | Added annotation propagation for WITHOUT OVERLAPS on indexes and unique constraints |
| src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationNames.cs | Defined the WithoutOverlaps annotation constant |
| src/EFCore.PG/Metadata/Conventions/NpgsqlPostgresModelFinalizingConvention.cs | Added automatic discovery of btree_gist extension for keys/indexes using WITHOUT OVERLAPS |
| src/EFCore.PG/Infrastructure/Internal/NpgsqlModelValidator.cs | Implemented validation for WITHOUT OVERLAPS requirements (PG18+, range types, unique indexes) |
| src/EFCore.PG/Extensions/MetadataExtensions/NpgsqlKeyExtensions.cs | Added GetWithoutOverlaps and SetWithoutOverlaps extension methods for keys |
| src/EFCore.PG/Extensions/MetadataExtensions/NpgsqlIndexExtensions.cs | Added GetWithoutOverlaps and SetWithoutOverlaps extension methods for indexes |
| src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlKeyBuilderExtensions.cs | Added fluent API methods for configuring WITHOUT OVERLAPS on keys |
| src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlIndexBuilderExtensions.cs | Added fluent API methods for configuring WITHOUT OVERLAPS on indexes |
| src/EFCore.PG/Design/Internal/NpgsqlAnnotationCodeGenerator.cs | Added code generation support for WITHOUT OVERLAPS in scaffolded DbContext code |
Files not reviewed (1)
- src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs
Outdated
Show resolved
Hide resolved
src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlKeyBuilderExtensions.cs
Show resolved
Hide resolved
src/EFCore.PG/Extensions/MetadataExtensions/NpgsqlIndexExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlIndexBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.PG/Metadata/Conventions/NpgsqlPostgresModelFinalizingConvention.cs
Show resolved
Hide resolved
src/EFCore.PG/Metadata/Conventions/NpgsqlPostgresModelFinalizingConvention.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/EFCore.PG.Tests/Infrastructure/NpgsqlModelValidatorTest.cs
Outdated
Show resolved
Hide resolved
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 #3708