Skip to content

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

Closed

Description

@CaffeinatedCoder

docs/efcore.md promises that HasPostgresRange("timerange", "time") "generates CREATE TYPE timerange AS RANGE (SUBTYPE = time) in your migrations" and that PostgreSQL 14+ auto-creates timemultirange. Verified 2026-10-18 that it holds: Npgsql's NpgsqlDatabaseCreator.CreateTables (what EnsureCreated calls) runs the model differ through the migrations SQL generator, the same generator migrations use, and the integration suite round-trips TimeRange columns and a RangeSet<TimeRange> as timemultirange. But no test states it: nothing asserts the script text or the pg_type rows, so the sentence is held only indirectly.

  • Preferred: scaffold the migration operations for the model through the design-time services and assert the generated SQL contains CREATE TYPE … AS RANGE ahead of the tables (an independent review scaffolded and applied a real migration on 2026-10-18 and confirmed the statement and the catalogue rows). Fallback, if hosting the design-time services is not cheap: Database.GenerateCreateScript() (translation-test project, no database).
  • Assert pg_type has timerange and timemultirange after EnsureCreated (integration).
  • Name both in claims.json as the holders of the doc sentence; a seed that drops the HasPostgresRange call must fail both.

Activity

  1. added
    tests
    area/ranges
    area/range-set
    package/efcore
    on Oct 18, 2026
  2. CaffeinatedCoder commented on Oct 18, 2026

    @CaffeinatedCoder
    OwnerAuthor

    An independent review (GPT 6 Astra, 2026-10-18) scaffolded a real EF migration from a consumer project, applied it to PostgreSQL 17, and confirmed CREATE TYPE timerange AS RANGE in the migration SQL and timerange → timemultirange in the catalogue. So the stronger form of this test is available: a design-time migration scaffold assertion, not only GenerateCreateScript. Prefer it if the translation-test project can host the design-time services cheaply.

  3. CaffeinatedCoder commented on Oct 18, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Implemented in #158. The scaffold assertion is the design-time form: DesignTimeServicesBuilder, the same services dotnet ef migrations add builds, hosted in the translation-test project through one test-only Microsoft.EntityFrameworkCore.Design 10.0.0 reference. So there is no GenerateCreateScript fallback. CustomRangeCatalogueTests reads pg_type/pg_range and the column types after EnsureCreated in a database of its own. Both hold E39.

    One deviation from the issue text. A seed may only change src/ (OracleSeedTests.EverySeed_TouchesOnlySource), and the HasPostgresRange call lives in test models. So the kept seed (timerange-store-type-not-created.patch) renames TimeRange's store types to time_range/time_multirange, which HasPostgresRange never creates. oracles.cs seeds reports it CAUGHT by both classes. Dropping HasPostgresRange itself was run once by hand: both classes fail (no annotation and no CREATE TYPE; 42704: type "timerange" does not exist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/range-setarea/rangespackage/efcoretests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions