Skip to content

Overlaps over a plain array compiles and fails at apply: no GiST operator class (42704) #104

Closed

Description

@CaffeinatedCoder

Found by the pre-preview sweep of main @ 948496a (GPT's read of the factory; reproduced on PostgreSQL 18).

What happens

pg.Exclusion(pg.Overlaps(x => x.Tags), name: "ex_tags")   // Tags is an int[]

compiles, scaffolds CREATE EXTENSION IF NOT EXISTS btree_gist; and the constraint, and fails at apply:

42704: data type integer[] has no default operator class for access method "gist"

Why

PgSchema<T>.Overlaps<T>(Expression<Func<TEntity, T[]>> arrayOrMultirange) and its List<T> twin (PgSchema.cs:44-48) take any array. A multirange mapped as an array of ranges has a GiST operator class; a plain array has none without intarray, and btree_gist does not bring one. NeedsBtreeGist sees an array, finds it in neither set and asks for the extension, which is no help here (PgExclusionContributor.cs:86-112).

The rule of the API is that a declaration PostgreSQL would reject does not compile. This one compiles.

To decide

  1. The overloads take arrays and lists of NpgsqlRange<T> only, which is what a multirange is on the CLR side. A plain array then does not compile, and a probe holds it.
  2. Keep the signature and refuse at resolve by the column's store type, naming the operator class that is missing.

Test

A compile probe for int[] beside its allowed twin (a multirange), and a live row in PgExclusionLiveTests that creates a constraint over a multirange column and refuses the overlapping write.

Activity

  1. added this to the 11.0.0 milestone on Nov 14, 2026
  2. added
    bug
    package/postgresql
    area/constraints
    severity/medium
    on Nov 14, 2026
  3. CaffeinatedCoder commented on Nov 16, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Decided: option 1 (the maintainer's choice). Done in #162.

    • The array and list overloads of Overlaps (on PgSchema<T>, ExclusionDraft<T>, ExclusionElements<T>) take NpgsqlRange<T>[] and List<NpgsqlRange<T>>, what Npgsql maps to a multirange. A plain int[] or List<int> no longer compiles (CS0411). && over a plain array with an operator class of the database's own (intarray) stays possible through WithUncheckedOperator.
    • Held by ConsumerCompileTests.Overlaps_over_a_plain_array_does_not_compile beside Overlaps_over_a_multirange_compiles, compiled against the shipped assemblies; the first fails with the old overloads.
    • PgExclusionLiveTests.A_constraint_on_a_multirange_refuses_overlapping_rows creates constraints over an array and a list of ranges (datemultirange in the catalog) and asserts the overlapping writes are refused with 23P01, on PostgreSQL 16 and 18 in CI.
    • No 5.x fixture or stored form is touched. The README's known-defect line is gone.
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/constraintsbugpackage/postgresqlseverity/medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions