Repository navigation
feat: the lambda factories take the provider's spelling and carry the contract's mark - #134
Merged
Merged
Conversation
…e contract's mark KeyTarget.Of and Predicate.Of were public statics of the kernel with no experimental mark. They took no provider and returned SQL spelled as Npgsql's queries spell it, so a declaration for another database built through them would have stored PostgreSQL's text. Both now take a SqlSpelling and are marked SK9001: a lambda is translated for one provider, by that provider's package. The kernel holds one spelling, PostgreSQL's, until the tables move to the provider's package with the binder (#114); a provider without a spelling has no value to pass. A consumer writes a lambda into the provider's factory and names no spelling. For a condition that several entity types share, the PostgreSQL package gains PgSchema.Where<T>, which takes the place of a consumer's Predicate.Of<T>. Predicate and KeyTarget stay unmarked values. PublicSurfaceTests holds that nothing public in the kernel takes a lambda without a spelling and the mark. Closes #132 Co-Authored-By: Claude Fable 5.2 <[email protected]>
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 #132
Problem
KeyTarget.Of(LambdaExpression)andPredicate.Of<TEntity>(…)were public statics of the kernel with no experimental mark. They took no provider and returned SQL spelled as Npgsql's queries spell it, character for character:||over coalesced operands,substring, PostgreSQL's literals. Any consumer on any provider could call them, and a declaration for SQL Server built through them would have stored PostgreSQL's text. The maintainer's criterion for the first public release is that nothing of one provider's behaviour sits in an unmarked public entry point of the kernel.This is the small step of #112, decided 2026-11-14: the factories become the contract's and take the spelling now; the spelling tables stay in the kernel until the binder (#114) moves them to the provider's package.
Change
SqlSpelling, a new type of the contract (SK9001): how one provider's queries spell what a lambda holds. The kernel has one value,SqlSpelling.PostgreSql, named for what it is. Nothing else in the kernel's surface names a provider, and the type's remarks say when this one stops.KeyTarget.Of(key, spelling)andPredicate.Of<TEntity>(predicate, spelling)take it and carry the mark on the method. A provider's package for which no spelling exists has no value to pass, so a lambda cannot be translated for it by accident.pg.Equal(…),pg.Overlaps(…)andwhere:are as they were. For a condition that several entity types share, or that a convention adds withAndWhere, the PostgreSQL package gainsPgSchema.Where<TEntity>(x => …), which returns aPredicateand takes the place of a consumer'sPredicate.Of<TEntity>;TEntitymay be an interface, as before.PredicateandKeyTargetstay unmarked values a consumer reads and amends. Their remarks say that the SQL is one provider's and that its stored form is not final before 11.0.0 (SchemaKit: snapshot format v2 and CodoMetis: annotation keys ship in 11.0.0; the 5.x format is read forever (D11) #9).Breaking: the two signatures. Nothing is published, so no consumer has them.
Tests
Locally: 624 kernel tests, 199 of the PostgreSQL package with the live ones on PostgreSQL 16 and 18, 125 probes.
PublicSurfaceTests.Whatever_takes_a_lambda_takes_the_providers_spelling_and_is_marked: the public methods of the kernel that take a lambda are these two, each takes aSqlSpelling, each is marked. A third, or one without either, fails it.ConsumerCompileTests, against the shipped assemblies with nothing suppressed: the consumer's convention compiles withPgSchema.Where<IWithdrawable>(…); the same condition throughPredicate.Of(…, SqlSpelling.PostgreSql)reportsSK9001, for the method and for the spelling.DeclarationValueTests: a null spelling is refused by both; every template is what it was.SqlSpellingamong the contract's.Guards shown to fail, six defects seeded one at a time in a scratch copy:
Predicate.Ofnot markedKeyTarget.Ofnot markedSqlSpellingnot markedEvery_contract_type_is_marked_experimental, the consumer's opt-in testTwo tests of
PackagingConventionTests(the commit in the nuspec, the PDB's source link) fail in such a copy for every seed, since it has no.git: they need a repository, not this change.Decisions in this PR that are not confirmed
SqlSpelling, and that the kernel's one value is calledPostgreSql.PgSchema.Where<TEntity>for a condition as a value. It reads like thewhere:parameter it feeds.Declareis marked and the read model is not.Not in this PR
design/schemakit-api.mdstill showsPredicate.Of<T>(…)as a consumer's call (sections 7, 8 and 13). Its rewrite is Rewrite design/schemakit-api.md sections 9 and 10 to the decided core #36.PgSchema.cstoo and comes after this.🤖 Generated with Claude Code