Repository navigation
test: cross-test EFCore.ComplexIndexes constraints and GiST indexes over mapped range columns - #159
Merged
Merged
Conversation
…ver mapped range columns ComplexIndexesCrossTests (integration, test-only reference to EFCore.ComplexIndexes.PostgreSQL 5.4.0) proves that the package's temporal constraints (PostgreSQL 18), exclusion constraints (16 and 18) and GiST indexes work over a DateRange, a RangeSet<DateRange, DateOnly> and a TimeRange column: the create script and pg_get_constraintdef render UNIQUE (... WITHOUT OVERLAPS) and EXCLUDE USING gist (... WITH &&), adjacent rows and other keys are saved, an overlap in each column is a DbUpdateException over 23P01 naming its constraint, without UseNpgsqlComplexIndexes() EnsureCreated creates none, and the GiST index serves every range operator. A fourth smoke consumer installs the EF package beside ComplexIndexes from nuget.org and asserts the create script. E40-E43 hold the doc sentences; the seed drops the range store type names and is caught by every test. Closes #154 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 18, 2026
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 #154
Stacked on #158 (
test/timerange-migration-claim). It uses that PR'sContainerLifecycle.RequireServer, and its claims follow E39.Problem
EFCore.ComplexIndexes.PostgreSQLaccepts a temporal-constraint period by its store type name (anything ending inrange), anddocs/efcore.mdrecommends it for exclusion constraints over this package's columns. Nothing proved the pairing. The only exclusion test (ExclusionConstraintTests) adds the constraint with raw SQL over aDateRangeon PostgreSQL 17. The sentences about the package, the23P01shape, the silentEnsureCreatedand the operators a GiST index serves were held partly or not at all.Change
ComplexIndexesCrossTests(integration project, test-onlyPackageReferencetoEFCore.ComplexIndexes.PostgreSQL5.4.0). The columns are aDateRange, aRangeSet<DateRange, DateOnly>(datemultirange) and aTimeRange(customtimerange), with room as the key. Each test gets a database of its own, andUseNpgsqlComplexIndexes()registers that package's differ soEnsureCreatedsees the declarations (its README, "EnsureCreated, GenerateCreateScript, and the pending-changes check"). The servers arepostgres:16-alpineandpostgres:18-alpinecontainers of their own, started on first use. Docker is the same precondition as the rest of the suite (RequireServer).HasTemporalConstraintover each column rendersUNIQUE ("RoomId", "<col>" WITHOUT OVERLAPS)inGenerateCreateScript(), andpg_get_constraintdefreads back the same text. Adjacent rows and another room's rows are saved. An overlap in each column alone is aDbUpdateExceptionwrappingPostgresException23P01 that names that column's constraint.HasExclusionConstraint(builder overload for two columns, shorthand for the third) renderingEXCLUDE USING gist ("RoomId" WITH =, "<col>" WITH &&).EnsureCreatedcreates nocontype = 'x'constraint, and overlapping rows are saved: the doc's warning, measured.HasIndex().HasMethod("gist")(the doc's recipe) on thedaterange, andHasComplexIndex(…, i => i.UseGist())on the multirange and thetimerange. Withenable_seqscan = off, the plan uses the index for&&,@>,<@,<<,>>,&<,&>and-|-on all three columns.Overlapstranslates to&&and returns the expected rows.test/consumer-smoke-test.sh: a fourth consumer installsCodoMetis.ValueRanges.EFCore.PostgreSQLfrom the local feed andEFCore.ComplexIndexes.PostgreSQL5.4.0 from nuget.org. The existing source mapping already routes it there. The consumer asserts both resolved versions, plusCREATE TYPE timerange, theEXCLUDEand bothWITHOUT OVERLAPSclauses in the create script.scaffold_consumertakes extraid@versionpackages for this. That is the only structural change, so the script keeps its shape, which is why the consumer went in rather than being deferred.claims.json: E40 (accepts a mapped range column), E41 (the 23P01 /DbUpdateExceptionshape, also held byExclusionConstraintTests), E42 (EnsureCreatedwithout the differ: silent), E43 (the GiST index serves&&,@>,<@and the positional operators, which fills the unquoted#indexing-a-range-column-and-preventing-overlapsheading).ComplexIndexesCrossTestsis added to E12's holders, and is registered inoracles.json(kindclaim, needs docker).range-mapping-drops-store-type-name.patch: the range and multirange mappings carry the element store type (date,time without time zone) instead of their range store type name.AGENTS.mdanddocs/testing.mddescribe the new class and the fourth consumer.Scope boundaries (#97, #150).
docs/efcore.mdhas no temporal-constraint sentence yet. #97 writes that section for the 10.x line, and on the 11 line #150 replaces it with the native API. So the temporal measurements are recorded under E40/E41 and in #97, and no new doc text is added here. One measured fact goes to #97 as well: withUseNpgsqlComplexIndexes(),EnsureCreateddoes create the constraints. The doc's box says only "Use migrations, or add the constraint with explicit SQL".Tests
dotnet run tools/oracles.cs seeds range-mapping-drops-store-type-name: CAUGHT, 6 of 6 tests fail. The temporal ones fail on ComplexIndexes' own validation (… does not appear to be a range or multirange type. Found CLR type 'DateRange' (store type: 'date')). The exclusion ones fail with42883: operator does not exist: date && date, the GiST one with42704: data type date has no default operator class for access method "gist", and the unwired one with Npgsql refusing the write.SMOKE_AOT_LINKER_ARGS): passes. With the seed applied, the new consumer fails onHasTemporalConstraint's refusal ofDays(store type: 'date').🤖 Generated with Claude Code