Repository navigation
test: hold the timerange migration claim with a design-time scaffold and the catalogue - #158
Merged
Merged
Conversation
…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]>
This was referenced Oct 18, 2026
Merged
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 #155
Problem
docs/efcore.md#timerange-and-the-custom-timerange-typepromises thatHasPostgresRange("timerange", "time")generatesCREATE TYPE timerange AS RANGE (SUBTYPE = time)in your migrations, and that PostgreSQL 14+ createstimemultirangebeside it. It held, but only indirectly: the integration suite round-tripsTimeRangecolumns, and no test stated the script or the catalogue rows.claims.jsonhad 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 servicesdotnet ef migrations addbuilds (DesignTimeServicesBuilderover the context, which picks up Npgsql'sDesignTimeProviderServices), then:.Annotation("Npgsql:Range:timerange", "time,,,,")and declares the two columns astimerange/timemultirange;CREATE TYPE timerange AS RANGE (subtype = time…)comes before theCREATE TABLE, with"OpeningHours" timerangeand"OpeningWindows" timemultirange.Hosting the design-time services was cheap: one test-only
Microsoft.EntityFrameworkCore.Design10.0.0 reference, pinned at the EF Core version the provider resolves. So there's no fallback toGenerateCreateScript(). The reference brings NU1902/NU1903 advisories forSystem.Security.Cryptography.Pkcs/Xml9.0.0 through MSBuild.Directory.Build.propskeeps 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). RunsEnsureCreatedof the integration model in a fresh database on the shared server, then readspg_type/pg_range(timerangeovertime without time zone, multirangetimemultirange) andinformation_schema.columns(both columns use those types).ContainerLifecycle.RequireServer/ServerConnectionString, and an optional connection string onIntegrationDbContext. A defect that breaks the sharedEnsureCreatedused 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-migrationsquotes the doc comment verbatim and names both classes.oracles.jsonregisters both (kindclaim) 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
HasPostgresRangecall. That call lives in test models, andOracleSeedTests.EverySeed_TouchesOnlySourcerequires that a seed changessrc/only. So the kept seed plants the library-side form of the same defect:TimeRange's definition namestime_range/time_multirange, typesHasPostgresRange("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 byMigrationScaffoldTests(2 of 3 fail: the scaffolded column type and the column declaration) and byCustomRangeCatalogueTests(42704: type "time_range" does not exist).HasPostgresRangeremoved from both test models,MigrationScaffoldTestsfails 2 of 3 (no annotation; noCREATE TYPE) andCustomRangeCatalogueTestsfails with42704: 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