Repository navigation
feat: btree_gist is injected where an exclusion constraint needs it, once per migration and first - #79
Merged
Conversation
…once per migration and first Closes #78. Co-Authored-By: Claude Fable 5.2 <[email protected]>
CaffeinatedCoder
force-pushed
the
feat/btree-gist-injection
branch
from
November 12, 2026 11:15
b5911e1 to
18877be
Compare
This was referenced Nov 12, 2026
Closed
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 #78
Was stacked on #77; rebased onto
mainafter that merged.Problem
An exclusion constraint with
=on a scalar column needsbtree_gist. After #77 a model had to declare the extension itself; without it the migration scaffolds and fails at apply:data type integer has no default operator class for access method "gist".Change
Kernel
SchemaResolver.StoreType(path): the column's type as the model states it, asked of the declared property in the table, like its column. A snapshot records it, so both sides answer alike.Dependency.Extension: for what it creates, one call per extension toISchemaDialect.EnsureExtension(extension, targetModel, sql), ahead of every other statement. The kernel's own dialect refuses.PostgreSQL
btree_gistby 5.x's rule, unchanged: GiST only; a column by its store type; an expression by its operator. It sits in anOperational<>field, so it is never compared.NpgsqlSchemaDialect.EnsureExtensionwritesCREATE EXTENSION IF NOT EXISTS btree_gist, and nothing when the model declares the extension withHasPostgresExtensionor carries the suppress annotation.modelBuilder.SuppressBtreeGistInjection()sets 5.x's annotation,CustomTemporal:SuppressAutoExtension.Decisions to confirm
ISchemaDialect.EnsureExtensionis a new member of the contract, and the dialect, not the contributor, decides whether a statement is needed. The alternative was the contributor writing the statement inCreate, which gives one per constraint and no access to the model.SchemaResolver.StoreTypereturns the store type as text, not the design'sStoreFactsrecord. Enough for this rule;StoreFactscan come with the first rule that needs a mapping.IF NOT EXISTS, once per migration), as 5.x did for every add.btree_gistalone. Onlybtree_gistexists today.CASCADEon the statement, unlike Npgsql's own;btree_gistdepends on nothing.Found on the way
[]) before the range suffix was dead: no array type ends inrangeor is in the list. Removed; the rows forinteger[]anddaterange[]hold the answer.ltreeby itself for a column of that type, so a diff to it carries anAlterDatabaseOperation.Tests
420 kernel, 61 PostgreSQL offline, 24 live on PostgreSQL 16.15 and 18.6, 125 probes.
=, absent for a range, for SP-GiST, for a model that declares the extension, and for one that suppresses; a type change that flips the need leaves the constraint alone; the snapshot leads to the same statements as the model.Each guard shown to fail, 15 mutations in a scratch copy. Two survived the first run and are closed: SP-GiST counted like GiST (no test had a scalar under SP-GiST;
TextSpGistadded) and the dead array check (removed).Two_constraints_…_once_and_first,An_extension_…_ensured_once_and_firstAnother_deferral_is_a_rebuild,A_dropped_condition_column_…, the kernel'sThe_kernels_dialect_refuses_a_dependency_on_an_extension×3A_paths_store_type_…×3, two PostgreSQL testsA_type_change_that_ends_the_need_…The_extension_is_added_for_what_needs_it_and_for_nothing_elseA_store_type_has_a_gist_operator_class_…and 5 moreA_model_that_suppresses_…, liveSuppressed_…;A_model_that_declares_the_extension_itself_…The_suppress_switch_is_the_annotation_5x_wrote🤖 Generated with Claude Code