-
Notifications
You must be signed in to change notification settings - Fork 255
Implement support for PG18 PERIOD #3711
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 PERIOD feature for foreign keys with temporal tables, closing issue #3710. The PERIOD feature allows foreign keys to reference temporal data by treating the last column (which must be a range type) as a temporal period, enabling proper referential integrity for time-based relationships.
Changes:
- Added
WithPeriod()extension methods for configuring foreign keys with the PERIOD feature - Implemented validation to ensure PERIOD is only used with PostgreSQL 18+, requires the principal key to have WITHOUT OVERLAPS, and requires the last column to be a range type
- Extended migration SQL generation to produce correct PERIOD syntax in foreign key constraints
- Added scaffolding support to detect and preserve PERIOD annotation when reverse-engineering databases
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlForeignKeyBuilderExtensions.cs | New file providing WithPeriod() fluent API methods for configuring foreign keys |
| src/EFCore.PG/Extensions/MetadataExtensions/NpgsqlForeignKeyExtensions.cs | New file with metadata extension methods for getting/setting PERIOD annotation |
| src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationNames.cs | Added Period annotation constant |
| src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs | Added annotation propagation for foreign key constraints with PERIOD |
| src/EFCore.PG/Infrastructure/Internal/NpgsqlModelValidator.cs | Added validation for PERIOD feature requirements (version, range type, WITHOUT OVERLAPS on principal) |
| src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs | Overrode ForeignKeyConstraint to generate proper PERIOD syntax in SQL |
| src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs | Added detection of conperiod field when scaffolding foreign keys |
| src/EFCore.PG/Properties/NpgsqlStrings.resx | Added error message resources for PERIOD validation, plus whitespace cleanup |
| src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs | Generated code for new error message accessors |
| test/EFCore.PG.Tests/Infrastructure/NpgsqlModelValidatorTest.cs | Added test for WITHOUT OVERLAPS validation on PERIOD foreign keys |
| test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs | Added tests for creating and altering foreign keys with PERIOD |
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.
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 #3710