You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Overlaps over a plain array compiles and fails at apply: no GiST operator class (42704) #104
area/constraintsExclusion constraints, row guards and other constraint-like objectsbugSomething isn't workingpackage/postgresqlAffects CodoMetis.EFCore.SchemaKit.PostgreSQLseverity/mediumInconsistency or failure in a narrow scenario
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
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.
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.
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.
area/constraintsExclusion constraints, row guards and other constraint-like objectsbugSomething isn't workingpackage/postgresqlAffects CodoMetis.EFCore.SchemaKit.PostgreSQLseverity/mediumInconsistency or failure in a narrow scenario
Activity
CaffeinatedCoder commentedon Nov 16, 2026
Decided: option 1 (the maintainer's choice). Done in #162.
Overlaps(onPgSchema<T>,ExclusionDraft<T>,ExclusionElements<T>) takeNpgsqlRange<T>[]andList<NpgsqlRange<T>>, what Npgsql maps to a multirange. A plainint[]orList<int>no longer compiles (CS0411).&&over a plain array with an operator class of the database's own (intarray) stays possible throughWithUncheckedOperator.ConsumerCompileTests.Overlaps_over_a_plain_array_does_not_compilebesideOverlaps_over_a_multirange_compiles, compiled against the shipped assemblies; the first fails with the old overloads.PgExclusionLiveTests.A_constraint_on_a_multirange_refuses_overlapping_rowscreates constraints over an array and a list of ranges (datemultirangein the catalog) and asserts the overlapping writes are refused with 23P01, on PostgreSQL 16 and 18 in CI.