-
Notifications
You must be signed in to change notification settings - Fork 254
Implement support for PG18 WITHOUT OVERLAPS #3709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Closes #3708