Skip to content

feat!: the spelling of a lambda is the provider's package's - #186

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/184-spelling
Nov 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/184-spelling

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #184

The last piece of the binder (#114) and of #112.

Problem

The kernel held one spelling, PostgreSQL's, with the tables it is made of, and SqlSpelling named a provider. A package for another database had no value to pass to KeyTarget.Of and Predicate.Of, and what it got by passing the one there was PostgreSQL's SQL.

Change

  • SqlSpelling is an abstract class of the contract, and the kernel holds none. A package derives its own: the methods and members a lambda may use and what each is written as, the literals written without a column, concatenation and its operands, ??, a boolean where a condition stands (and its negation), and the negation of a comparison that can be null. SQL goes in and out in the grammar of SqlTemplate.FromPlaceholders.
  • The kernel keeps the walk and what is C#'s or the same SQL everywhere: SilentConversions, null compensation, the comparison and boolean operators, NULL, Nullable<T>.Value and HasValue.
  • PostgreSQL's tables are NpgsqlSpelling in its package, unchanged in what they write: LambdaTranslatorTests and the parity sweep pass with waivers.txt untouched. PgSchema.Spelling hands it out, marked SK9001, for a package that takes lambdas for PostgreSQL declarations of its own; SqlSpelling.PostgreSql is gone.
  • The second provider's tests have a spelling for SQL Server and one for SQLite, a handful of constructs each, through the public contract. SpellingParityTests compares 16 conditions on SQL Server and 6 expressions on SQLite with EF Core's ToQueryString(), but for the kernel's parentheses around a group.
  • PublicSurfaceTests holds that the kernel has no spelling of its own and that no public name of it names a provider.

What the second provider changed in the contract's shape:

  • SQL Server has no boolean that is a condition, and its queries write !x.Active as [Active] = CAST(0 AS bit). So Condition takes the negation, and the kernel hands a boolean negated once to it. A boolean under a negation that is already pushed down is still wrapped in NOT (…), as before: changing that would change what PostgreSQL stores.
  • SQL Server's queries do not fold a substring's start (1 + 1), Npgsql's do. So an argument reaches the spelling as SQL and, when it reads nothing from the entity, as its value.
  • SQL Server writes ISNULL where Npgsql writes coalesce, for ?? and for a nullable operand of a concatenation.

Decided here, to be confirmed:

  • The comparison and boolean operators stay in the kernel (=, <>, <, AND, OR, NOT, IS NULL). They are the same on the three databases, and the null compensation is built from them.
  • The translator's tests and the sweep stay in the kernel's test project, which now references the PostgreSQL package and reads its spelling through PgSchema.Spelling. Moving them to the package's tests needs the kernel's internals there.
  • SQL passes between the kernel and a spelling as text with {Path}, not as segments. It is the grammar FromPlaceholders has already.

Not here:

Tests

Offline: 751 (kernel), 195 (PostgreSQL package), 87 (second provider). Live: 4 and 73 on PostgreSQL 16 and on 18, 86 on SQL Server 2022. The consumer smoke test: 47 rows.

Fourteen rules were changed in turn and a test failed for each. For PgSchema.Spelling without the mark the kept log shows the SK9001 diagnostic and not the test's name; the name below is inferred.

Changed Fails
A negation of a boolean is not handed to the spelling A_condition_is_spelled_as_SQL_Servers_queries_spell_it, A_package_spells_a_lambda_with_a_spelling_of_its_own
A boolean stands as a column on every database the same two
The negated comparison written as PostgreSQL's CASE in the kernel A_condition_is_spelled_as_SQL_Servers_queries_spell_it
Concatenation written in the kernel that, and An_expression_is_spelled_as_SQLites_queries_spell_it
?? written in the kernel the same two
A string literal written in the kernel A_condition_is_spelled_as_SQL_Servers_queries_spell_it
The spelling's members not asked four of the kernel's, the sweep among them, and both parity tests
An argument never handed over as a value A_substring_starts_one_later, the sweep
A static spelling on SqlSpelling The_kernel_holds_no_spelling_and_its_surface_names_no_provider
PgSchema.Spelling without the mark The_kernels_lambda_factories_ask_for_the_opt_in
lower in capitals in PostgreSQL's table 6 of the kernel's, 11 of the PostgreSQL package's
COALESCE for ISNULL in SQL Server's spelling A_condition_is_spelled_as_SQL_Servers_queries_spell_it
SQL Server's spelling folds the start the same
btrim in SQLite's spelling SQLite_takes_what_its_spelling_writes_for_Trim and two more

breaking: SqlSpelling.PostgreSql is gone and SqlSpelling is abstract; both are the contract's (SK9001).

🤖 Generated with Claude Code

SqlSpelling is an abstract class of the contract, and the kernel holds
none: a package derives its own. It says which methods and members a
lambda may use and what each is written as, the literals written without
a column, concatenation and its operands, ??, a boolean where a condition
stands, and the negation of a comparison that can be null.

The kernel keeps the walk over the lambda and what is C#'s or the same
SQL everywhere: the conversions that keep a value, null compensation, the
comparison and boolean operators.

PostgreSQL's tables are NpgsqlSpelling in its package and write what they
wrote; PgSchema.Spelling hands it out, marked SK9001. SqlSpelling.PostgreSql
is gone.

The second provider's tests have a spelling for SQL Server and one for
SQLite through the public contract, compared with EF Core's
ToQueryString(). SQL Server gave two members their shape: Condition takes
the negation, and an argument arrives as SQL and as its value.

Closes #184

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 25, 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 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 58fef11 into main Nov 25, 2026
10 of 11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/184-spelling branch November 25, 2026 09:38
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 accepted constructs and the spelling move to the provider's package

1 participant