Repository navigation
docs: PostgreSQL 18 temporal keys over a range column (10.x) - #193
Merged
Merged
Conversation
A docs/efcore.md section next to the exclusion constraint: UNIQUE (… WITHOUT OVERLAPS) through EFCore.ComplexIndexes.PostgreSQL's HasTemporalConstraint, and FOREIGN KEY (… PERIOD …) through its HasTemporalForeignKey, over this package's range and multirange columns. The exclusion constraint box names UseNpgsqlComplexIndexes() as the third way to get the constraints from EnsureCreated(). Every sentence is measured in ComplexIndexesCrossTests, which gains the temporal foreign key (covered across two adjacent principal rows is saved, past them or for an unknown key is 23503), the btree_gist extension check, and the syntax error on PostgreSQL 16. Claims E48–E53; the two postgres-surface rows are waived to the section, with Npgsql 11's native API on the 11.x line (#150) named as the other form. Closes #97 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # src/CodoMetis.ValueRanges.EFCore.PostgreSQL/CHANGELOG.md # test/oracles/claims.json
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 #97
Problem
PostgreSQL 18's temporal keys,
UNIQUE (… WITHOUT OVERLAPS)andFOREIGN KEY (… PERIOD …), were undocumented. They are the built-in form of the exclusion-constraint recipe, and the foreign key adds referential integrity across time, which an exclusion constraint cannot give. On the 10.x line (Npgsql 10),EFCore.ComplexIndexes.PostgreSQLdeclares both. Twopostgres-surface.jsonrows were open under this issue. The exclusion-constraint box also gave only migrations and raw SQL as ways to get the constraint, whileUseNpgsqlComplexIndexes()makesEnsureCreated()create it as well (#97's last comment).Change
docs/efcore.md#reject-overlapping-rows-with-a-temporal-key-postgresql-18(new, next to the exclusion constraint) coversHasTemporalConstraintand the constraint text PostgreSQL reads back, plus the23P01failure shape and which rows are still saved. It then coversHasTemporalForeignKeyand itsFOREIGN KEY … PERIODtext: coverage across adjacent principal rows,23503for an uncovered period or unknown key, and why the principal needs a temporal key. Good to know: PostgreSQL 18 only,btree_gistcreated for you,EnsureCreated()needsUseNpgsqlComplexIndexes(), and the API is ComplexIndexes' (this package adds none, as the issue says).UseNpgsqlComplexIndexes()as the third way. The sentences E42 quotes are unchanged.docs/getting-started.mdnow says the constraint can be a temporal key on 18.ComplexIndexesCrossTests. ThePRIMARY KEY … WITHOUT OVERLAPSandFOREIGN KEY … PERIODsurface rows are waived to the new section, as the exclusion-constraint row is. The waivers name Npgsql 11'sHasWithoutOverlaps/HasPeriod(Native temporal keys over ValueRanges columns on the 11 line: implement INpgsqlRangeTypeMapping, document WithoutOverlaps and WithPeriod #150) as the native form on the 11.x line.Docs:line under 10.0.0### Addedin the root and EF Core changelogs.Tests
Every statement in the section is measured in
ComplexIndexesCrossTests(PostgreSQL 18.x alpine, ComplexIndexes 5.4.0). The measurements already in place from #159 cover the temporal key overDateRange,RangeSet<DateRange, DateOnly>andTimeRange: the rendered and read-backUNIQUEtext,23P01withConstraintName, adjacent rows and other keys saved, and nothing created without the runtime differ. This PR adds:TemporalForeignKey_AcceptsACoveredPeriod_AndRejectsOneThatIsNot. It checks the rendered and read-backFOREIGN KEY ("RoomId", PERIOD "Period") REFERENCES "Availabilities"("RoomId", PERIOD "Period")and thatbtree_gistwas created. A booking covered only by two adjacent availabilities together is saved. One past them, or for a room with no availability, fails as23503naming the constraint. WithoutUseNpgsqlComplexIndexes()the test fails (checked).TemporalConstraint_IsASyntaxError_BeforePostgres18checks that the same schema on PostgreSQL 16 throws42601.UNIQUEtest now also asserts thatbtree_gistexists.Conventions (catalogue, surface, changelog) and the full integration suite (233) pass locally.
🤖 Generated with Claude Code