Skip to content

test: cross-test EFCore.ComplexIndexes constraints and GiST indexes over mapped range columns - #159

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
test/complexindexes-cross-tests
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
test/complexindexes-cross-tests

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #154

Stacked on #158 (test/timerange-migration-claim). It uses that PR's ContainerLifecycle.RequireServer, and its claims follow E39.

Problem

EFCore.ComplexIndexes.PostgreSQL accepts a temporal-constraint period by its store type name (anything ending in range), and docs/efcore.md recommends 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 a DateRange on PostgreSQL 17. The sentences about the package, the 23P01 shape, the silent EnsureCreated and the operators a GiST index serves were held partly or not at all.

Change

  • ComplexIndexesCrossTests (integration project, test-only PackageReference to EFCore.ComplexIndexes.PostgreSQL 5.4.0). The columns are a DateRange, a RangeSet<DateRange, DateOnly> (datemultirange) and a TimeRange (custom timerange), with room as the key. Each test gets a database of its own, and UseNpgsqlComplexIndexes() registers that package's differ so EnsureCreated sees the declarations (its README, "EnsureCreated, GenerateCreateScript, and the pending-changes check"). The servers are postgres:16-alpine and postgres:18-alpine containers of their own, started on first use. Docker is the same precondition as the rest of the suite (RequireServer).
    • Temporal, PostgreSQL 18. HasTemporalConstraint over each column renders UNIQUE ("RoomId", "<col>" WITHOUT OVERLAPS) in GenerateCreateScript(), and pg_get_constraintdef reads back the same text. Adjacent rows and another room's rows are saved. An overlap in each column alone is a DbUpdateException wrapping PostgresException 23P01 that names that column's constraint.
    • Exclusion, PostgreSQL 16 and 18. The same, with HasExclusionConstraint (builder overload for two columns, shorthand for the third) rendering EXCLUDE USING gist ("RoomId" WITH =, "<col>" WITH &&).
    • Without the runtime differ. EnsureCreated creates no contype = 'x' constraint, and overlapping rows are saved: the doc's warning, measured.
    • GiST index. HasIndex().HasMethod("gist") (the doc's recipe) on the daterange, and HasComplexIndex(…, i => i.UseGist()) on the multirange and the timerange. With enable_seqscan = off, the plan uses the index for &&, @>, <@, <<, >>, &<, &> and -|- on all three columns. Overlaps translates to && and returns the expected rows.
  • test/consumer-smoke-test.sh: a fourth consumer installs CodoMetis.ValueRanges.EFCore.PostgreSQL from the local feed and EFCore.ComplexIndexes.PostgreSQL 5.4.0 from nuget.org. The existing source mapping already routes it there. The consumer asserts both resolved versions, plus CREATE TYPE timerange, the EXCLUDE and both WITHOUT OVERLAPS clauses in the create script. scaffold_consumer takes extra id@version packages 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 / DbUpdateException shape, also held by ExclusionConstraintTests), E42 (EnsureCreated without the differ: silent), E43 (the GiST index serves &&, @>, <@ and the positional operators, which fills the unquoted #indexing-a-range-column-and-preventing-overlaps heading). ComplexIndexesCrossTests is added to E12's holders, and is registered in oracles.json (kind claim, needs docker).
  • Seed 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.md and docs/testing.md describe the new class and the fourth consumer.

Scope boundaries (#97, #150). docs/efcore.md has 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: with UseNpgsqlComplexIndexes(), EnsureCreated does 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 with 42883: operator does not exist: date && date, the GiST one with 42704: data type date has no default operator class for access method "gist", and the unwired one with Npgsql refusing the write.
  • Smoke test locally (Homebrew dotnet, SMOKE_AOT_LINKER_ARGS): passes. With the seed applied, the new consumer fails on HasTemporalConstraint's refusal of Days (store type: 'date').
  • Full solution run with Docker: 2,040 tests, 0 failed, 0 skipped: integration 209, InfinityDisabled 3, conventions 299, core 923, EF translation 245, NodaTime EF 81, NodaTime 196, AspNetCore 84.

🤖 Generated with Claude Code

…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]>
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (oracles, harnesses); no library code area/ranges Range unions, variants and the shape engines area/range-set RangeSet and multirange algebra package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL stacked Base is another open PR; merge in order, CI does not run until it targets main labels Oct 18, 2026
Base automatically changed from test/timerange-migration-claim to main October 18, 2026 11:34
@CaffeinatedCoder CaffeinatedCoder removed the stacked Base is another open PR; merge in order, CI does not run until it targets main label Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit b9a9969 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the test/complexindexes-cross-tests branch October 18, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/range-set RangeSet and multirange algebra area/ranges Range unions, variants and the shape engines package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL tests Adds or changes tests only (oracles, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-tests with EFCore.ComplexIndexes: temporal and exclusion constraints over DateRange, RangeSet and TimeRange columns, plus a joint smoke consumer

1 participant