Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Jan 23, 2026

Closes #3708

Copilot AI review requested due to automatic review settings January 23, 2026 11:39
@roji roji enabled auto-merge (squash) January 23, 2026 11:39
Copy link

Copilot AI left a 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.

@roji roji disabled auto-merge January 23, 2026 12:27
Copilot AI review requested due to automatic review settings January 23, 2026 12:48
Copy link

Copilot AI left a 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.

@roji roji enabled auto-merge (squash) January 23, 2026 13:50
@roji roji merged commit 789f55a into npgsql:main Jan 23, 2026
10 checks passed
@roji roji deleted the WithoutOverlaps branch January 23, 2026 14:02
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.

Support WITHOUT OVERLAPS for primary keys and unique indexes on temporal tables

1 participant