Skip to content

test: hold the timerange migration claim with a design-time scaffold and the catalogue - #158

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
test/timerange-migration-claim
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
test/timerange-migration-claim

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #155

Problem

docs/efcore.md#timerange-and-the-custom-timerange-type promises that HasPostgresRange("timerange", "time") generates CREATE TYPE timerange AS RANGE (SUBTYPE = time) in your migrations, and that PostgreSQL 14+ creates timemultirange beside it. It held, but only indirectly: the integration suite round-trips TimeRange columns, and no test stated the script or the catalogue rows. claims.json had no claim for the sentence.

Change

  • MigrationScaffoldTests (translation-test project, no database). This is the stronger form Hold the timerange claim: the generated create script contains CREATE TYPE timerange AS RANGE and the multirange exists #155's comment asks for. It builds the design-time services dotnet ef migrations add builds (DesignTimeServicesBuilder over the context, which picks up Npgsql's DesignTimeProviderServices), then:

    • scaffolds the migration and asserts the file carries .Annotation("Npgsql:Range:timerange", "time,,,,") and declares the two columns as timerange / timemultirange;
    • diffs the model against an empty one with that provider's differ, generates the SQL, and asserts CREATE TYPE timerange AS RANGE (subtype = time…) comes before the CREATE TABLE, with "OpeningHours" timerange and "OpeningWindows" timemultirange.

    Hosting the design-time services was cheap: one test-only Microsoft.EntityFrameworkCore.Design 10.0.0 reference, pinned at the EF Core version the provider resolves. So there's no fallback to GenerateCreateScript(). The reference brings NU1902/NU1903 advisories for System.Security.Cryptography.Pkcs/Xml 9.0.0 through MSBuild. Directory.Build.props keeps those as warnings, and the project is never packed. 10.0.12 would drop them, but it would also move the whole translation-test project to EF Core 10.0.12.

  • CustomRangeCatalogueTests (integration). Runs EnsureCreated of the integration model in a fresh database on the shared server, then reads pg_type/pg_range (timerange over time without time zone, multirange timemultirange) and information_schema.columns (both columns use those types).

  • ContainerLifecycle.RequireServer / ServerConnectionString, and an optional connection string on IntegrationDbContext. A defect that breaks the shared EnsureCreated used to null the connection string, which turned every test Inconclusive locally. A test that creates its own database now fails with PostgreSQL's error instead. Existing tests are unchanged.

  • claims.json: E39-timerange-type-created-by-migrations quotes the doc comment verbatim and names both classes. oracles.json registers both (kind claim) so the seed rule reaches them.

  • Seed timerange-store-type-not-created.patch.

  • docs/testing.md: one sentence for each class.

About the seed

#155 asks for a seed that drops the HasPostgresRange call. That call lives in test models, and OracleSeedTests.EverySeed_TouchesOnlySource requires that a seed changes src/ only. So the kept seed plants the library-side form of the same defect: TimeRange's definition names time_range / time_multirange, types HasPostgresRange("timerange", …) never creates. The literal revert was run once by hand (below).

Tests

  • dotnet run tools/oracles.cs seeds timerange-store-type-not-created: CAUGHT by MigrationScaffoldTests (2 of 3 fail: the scaffolded column type and the column declaration) and by CustomRangeCatalogueTests (42704: type "time_range" does not exist).
  • Literal revert, by hand: with HasPostgresRange removed from both test models, MigrationScaffoldTests fails 2 of 3 (no annotation; no CREATE TYPE) and CustomRangeCatalogueTests fails with 42704: type "timerange" does not exist.
  • EFCore.PostgreSQL.Tests: 245/245. Oracle* conventions: 31/31. Integration suite against Docker locally (see the stacked PR for the full run).

🤖 Generated with Claude Code

…and the catalogue

MigrationScaffoldTests builds the design-time services dotnet ef migrations add
builds and asserts the scaffolded migration and its SQL create timerange ahead of
the table whose TimeRange and RangeSet<TimeRange> columns use it and timemultirange.
CustomRangeCatalogueTests reads pg_type, pg_range and the column types after
EnsureCreated of the integration model in a database of its own, so a defect
that breaks the shared schema fails it instead of leaving it inconclusive
(ContainerLifecycle.RequireServer).

E39 names both; the seed renames TimeRange's store types away from what
HasPostgresRange creates and is caught by both.

Closes #155

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder merged commit 8b88aa3 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the test/timerange-migration-claim branch October 18, 2026 11:34
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.

Hold the timerange claim: the generated create script contains CREATE TYPE timerange AS RANGE and the multirange exists

1 participant