Repository navigation
feat: the PostgreSQL package, its dialect, and exclusion constraints from the declaration to the database - #77
Merged
Conversation
…from the declaration to the database Closes #76. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 12, 2026
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 #76
Problem
No package had a real contributor: the kernel could store, resolve and plan a declaration, and nothing could be declared with it. #25 is the first feature, and this is its first slice.
Change
Kernel
KeyTarget(Column | Template) andPredicate, public, built from a lambda byKeyTarget.OfandPredicate.Of<T>: the translator's only public entry points.Predicate.Andkeeps 5.x's rule for a convention that runs twice.ValueList<T>loses its experimental mark.PublicSurfaceTestshas a third list, the declaration values, and holds that none of them is marked.src/CodoMetis.EFCore.SchemaKit.PostgreSQL, written against the kernel's public contract alone (noInternalsVisibleTo)UseNpgsql(cs, o => o.UseSchemaKit()), andAddEntityFrameworkSchemaKitNpgsql()for a caller-owned provider.NpgsqlSchemaDialectcounts an identifier's bytes (from feat: the SQL vocabulary, statements with no hole for a string #42). Registered withReplace, so it holds in either order of the two extensions.PgExclusion(Gist | SpGist),ExclusionElement,ExclusionOperator,Deferral;PgSchema<T>withEqual,Overlaps(range, nullable range, array, list),WithUncheckedOperator,Exclusion(…, where:, deferral:, name:);DeclarePostgres;PgSchema.For<T>();AndWhere.ALTER TABLE … ADD CONSTRAINT … EXCLUDE USING …,DROP CONSTRAINTwithoutIF EXISTS, a rename in place and a rebuild for anything else,ImpactOfas the plan's section 3.7 measured it.CI: both lanes run both test projects, and each project has to have run a test.
Decisions to confirm
None is expensive to change before
preview.1; all are permanent after 11.0.0.Pg.Exclusion: kindsgistandspgist;elements(orelement), each withcolumnorsqlandop;whereas a string;deferralasnotDeferrable | initiallyImmediate | initiallyDeferred.KeyTarget,PredicateandValueList<T>are not experimental. A consumer writes and reads them.CodoMetis.EFCore.SchemaKit.PostgreSQL, extension methods included, so a consumer needs thatusingbeside the kernel's.AddEntityFrameworkSchemaKitNpgsql()as the name of the caller-owned-provider registration.WithUncheckedOperatorrefuses=, andSpGistrefuses an equality element, asGistdoes.RebuildAround: right whether the constraint read it or not.Found on the way
ALTER TABLE role_grants, not"role_grants".withgoes throughinitand not the constructor: the first version of the new values letwith { Template = "" }through. Every one checks ininitnow.Tests
413 kernel tests, 40 PostgreSQL tests without a server, and 18 on a live one, green on PostgreSQL 16.15 and 18.6 locally. 125 probes unchanged.
EnsureCreated(), the applied create script and a first migration each leave the same catalog entry. Overlapping rows are refused (23P01) and rows that differ in grantee, role, period or revocation are not. A deferred constraint passes inside a transaction and fails at commit. Eleven model pairs are migrated and compared with whatEnsureCreated()builds for the target, bypg_get_constraintdef. A rename keeps the constraint's OID. A taken name fails and replaces nothing. A drop leaves the namesake in another schema.Each guard shown to fail, in a scratch copy, 22 mutations, none survived:
The_dialect_counts_a_names_bytes,A_constraint_name_the_server_would_shorten_…TryAddThe_kernels_call_before_or_after_changes_nothing,A_caller_owned_provider_…A_drop_names_the_table_with_its_schema; liveDropping_a_constraint_leaves_its_namesake_in_another_schemaLostA_dropped_condition_column_…; liveDropping_a_column_only_the_condition_readsRebuildAroundA_dropped_element_column_…UnaffectedPlanalways rebuildsAnother_name_is_a_rename_in_place, the default-name rename; liveRenaming_a_constraint_keeps_the_constraintA_renamed_column_of_the_condition_alone_…A_constraint_without_a_name_gets_the_default_oneA_deferred_constraint_is_checked_at_commitamong themA_renamed_column_renames_a_constraint_that_is_named_after_itWithUncheckedOperatortakes=No_way_around_the_factory_…;An_unchecked_operator_…wherenot written;deferralread as its default; an element with both targets read as a columnwithbypasses the empty-text rule;Andalways appends;ValueListmarked againDeclarationValueTests,PublicSurfaceTestsNot covered here: PostgreSQL 16 in CI (#5), SQL Server, the compile probes against the shipped assemblies.
🤖 Generated with Claude Code