Skip to content

feat: the lambda factories take the provider's spelling and carry the contract's mark - #134

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/lambda-factories-take-a-spelling
Nov 14, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/lambda-factories-take-a-spelling

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #132

Problem

KeyTarget.Of(LambdaExpression) and Predicate.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) and Predicate.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.
  • A consumer reaches the translator through the provider's factory only. pg.Equal(…), pg.Overlaps(…) and where: are as they were. For a condition that several entity types share, or that a convention adds with AndWhere, the PostgreSQL package gains PgSchema.Where<TEntity>(x => …), which returns a Predicate and takes the place of a consumer's Predicate.Of<TEntity>; TEntity may be an interface, as before.
  • Predicate and KeyTarget stay 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 a SqlSpelling, each is marked. A third, or one without either, fails it.
  • ConsumerCompileTests, against the shipped assemblies with nothing suppressed: the consumer's convention compiles with PgSchema.Where<IWithdrawable>(…); the same condition through Predicate.Of(…, SqlSpelling.PostgreSql) reports SK9001, for the method and for the spelling.
  • DeclarationValueTests: a null spelling is refused by both; every template is what it was.
  • The pinned list of public types gains SqlSpelling among the contract's.

Guards shown to fail, six defects seeded one at a time in a scratch copy:

Seed Tests that fail
Predicate.Of not marked the surface rule, the factories' test, the consumer's opt-in test
KeyTarget.Of not marked the surface rule, the factories' test
SqlSpelling not marked Every_contract_type_is_marked_experimental, the consumer's opt-in test
A factory that takes anything for a spelling the surface rule, the factories' test
No spelling required the factories' test
No factory for a shared condition in the PostgreSQL package the consumer's compile test

Two 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

Not in this PR

🤖 Generated with Claude Code

…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]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 14, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request breaking Changes an answer or a signature package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL area/expression-indexes Expression, typed lambda and JSON member indexes labels Nov 14, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 826163e into main Nov 14, 2026
8 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/lambda-factories-take-a-spelling branch November 14, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/expression-indexes Expression, typed lambda and JSON member indexes breaking Changes an answer or a signature enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The lambda factories take the provider's spelling and carry the contract's mark

1 participant