Repository navigation
fix: inject btree_gist for any scalar element under gist (#81) - #104
Merged
Merged
Conversation
btree_gist was injected only for a gist exclusion constraint with an '='
element, compared case-sensitively. A scalar element compared with '<>'
(or any other operator) got no CREATE EXTENSION, and UseMethod("GiST")
skipped it; on a database without the extension both failed at apply with
42704 "data type integer has no default operator class for access method
gist".
The differ now injects it when the method is gist in any spelling and an
element is a column whose store type has no default GiST operator class of
its own, or an expression under a B-tree operator. Range elements alone no
longer inject it, since ranges carry their own.
Postgres16IntegrationTests applies each case to a fresh database on
PostgreSQL 16; the shared PostgreSQL 18 database usually has btree_gist
installed by an earlier test, which hid the failure. Proven by restoring
the old rule: three differ tests and three PostgreSQL 16 tests fail, two
with 42704; restoring only the case-sensitive comparison fails both
UseMethod("GiST") tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # src/EFCore.ComplexIndexes.PostgreSQL/CHANGELOG.md
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 #81
Problem
btree_gistwas injected only for a GiST exclusion constraint with an=element, and the method was compared case-sensitively:Both scaffolded without
CREATE EXTENSION, and on a database without the extension both failed at apply with42704: data type integer has no default operator class for access method "gist".Change
NpgsqlComplexIndexMigrationsModelDiffer:NeedsBtreeGistreplaces the=check. It applies when the method isgist(ordinal-ignore-case) and an element is either a column whose store type has no default GiST operator class of its own, or an expression compared with a B-tree operator (=,<>,!=,<,<=,>,>=). Types with their own: ranges and multiranges (by suffix),box,circle,point,polygon,tsvector,tsquery, and the extension typesgeometry,geography,box2d,box3d,ltree,cube,hstore,seg. Anything else, an unknown store type and arrays included, injects. Over-injecting costs anIF NOT EXISTSno-op; under-injecting fails the migration.ResolvedExclusionPartcarries the column's store type, kept out of equality so a column type change does not rebuild the constraint (PostgreSQL rebuilds its index with the column).period WITH =, period WITH &&) no longer injectsbtree_gist. The PostgreSQL 16 test shows it applies without the extension.Postgres16IntegrationTestsis new, with its ownpostgres:16container and one fresh database per test.PostgresIntegrationTests' "inconclusive locally, fail on CI" rule moved intoRequireDatabaseso both classes share it. The CI job keeps its name,Integration (PostgreSQL 18), and runs both throughTestCategory=Integration.docs/postgresql-constraints.md, the packed PostgreSQL README, the XML doc onNpgsqlExclusionConstraintExtensions, CLAUDE.md and CONTRIBUTING.md now say "scalar elements, whatever the operator". One### Fixedline goes into the root and PostgreSQL changelogs.Tests
NpgsqlExclusionConstraintDifferTests:<>on an integer injects first,UseMethod("GiST")injects, and range elements alone do not.Postgres16IntegrationTests: on a fresh database, the<>constraint applies and rejects an overlapping row on another desk (23P01),UseMethod("GiST")applies and installsbtree_gist, and range-only applies without it.<>andGiSTfail on PostgreSQL 16 with 42704, and range-only fails because the old rule injects. With only the case-insensitive comparison reverted, bothGiSTtests fail.🤖 Generated with Claude Code