Skip to content

The accepted constructs and the spelling move to the provider's package #184

Done

Description

@CaffeinatedCoder

2026-11-25: in PR #186 (feat/184-spelling). Offline: 751 of the kernel's tests, 195 of the PostgreSQL package's, 87 of the second provider's. Live: 4 and 73 on PostgreSQL 16 and on 18, 86 on SQL Server 2022, the consumer smoke test's 47 rows.

What is there:

  • 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:

Fourteen rules were changed in turn and a test failed for each:

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

Split from #180 on 2026-11-24; what is left of #112, point 1, and of #114.

Problem

The kernel holds one spelling, PostgreSQL's, with the tables it is made of (StringMethods, ValueMembers, the operator sets, LiteralTypes, SilentConversions), and SqlSpelling names a provider, which nothing else in the kernel's surface does. A package for another database has no value to pass.

Change

  • SqlSpelling becomes what a provider's package implements or builds: its functions, its operators, how it writes what the kernel's translator asks it to.
  • The PostgreSQL tables move to the PostgreSQL package. The parity sweep, the probes and the analyzer (Analyzer: the translator's refusals as build errors, in 11.0.0 #31) read them there.
  • The kernel keeps the walk over the lambda and the rules that are C#'s: null compensation, the conversions that keep a value.

Done when

The kernel names no provider and holds no SQL of one, PublicSurfaceTests holds it, and the second provider's tests spell a lambda for SQL Server without going around the contract.

Activity

  1. added this to the 11.0.0 milestone on Nov 24, 2026
  2. added
    enhancement
    breaking
    package/core
    package/postgresql
    area/expression-indexes
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/expression-indexesbreakingenhancementpackage/corepackage/postgresql

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions