Skip to content

test: the translator's parity sweep against EF Core's query SQL, and the same rows answered on PostgreSQL 18 - #75

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
test/translator-parity-sweep
Nov 12, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
test/translator-parity-sweep

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #74

The second slice of #26.

Problem

The translator (#71) was held by rule tests: each says what a lambda is written as. Nothing checked that this is what EF Core's own queries write for the same lambda, which is the point of the translator: PostgreSQL uses an expression index only for a query whose expression matches it, and a predicate with other null semantics covers other rows.

Change

5.x's differential sweep, ported as files into test/CodoMetis.EFCore.SchemaKit.Tests/TranslatorParity, about 1,900 lines:

  • ParityCatalogue, ParityModel, ParitySeed, PostgresCanonicalForm, ParityWaivers, TranslatorParitySweepTests: as they were, namespaces and names aside.
  • ParitySweep: the SchemaKit side is written anew. 5.x declared an index per template and read the SQL from its differ. Here a template goes through the kernel's resolver, against the same model EF Core's query is written for.
  • waivers.txt: 5.x's file with its reasons, less the rows over a JSON document.
  • Integration/TranslatorParityLiveTests: the answers-alike run on PostgreSQL 18, and the unique index on a concatenation with a nullable operand.

The sweep was green on its first run with 5.x's waivers: Npgsql 11 writes every swept construct as Npgsql 10 did, and the port of the translator (#72) changed none.

Rows
Agree with EF Core 1,199
Differ, waived by one of PostgreSQL's own rewrites (negator, boolean-equality, integer-length) 317
Differ, waived as rendering differently and answering alike (the live run checks it) 31
Differ, unchecked: a concatenation with a ulong 1
Rendered by the translator only (a member of a converted value object, which EF Core cannot translate) 121
Refused at the declaration 906
Total 2,575

Not here

Members of a JSON document. The kernel's resolver refuses a path into one until a provider package renders it (#43), so every such row would be accepted at the declaration and fail at resolution. The catalogue leaves that operand shape out behind ParityCatalogue.JsonMembers; 5.x swept it, and its waivers for it are in its repository.

Tests

On SDK 11.0.100 in the checkout: 398 kernel tests before, 405 after, without a server (the 4 integration tests go inconclusive). Against postgres:18 in Docker: the 4 integration tests pass, among them the live run over more than 1,400 rows.

One test is new and not from 5.x: The_sweep_is_not_hollow puts a floor under what is compared, since a sweep that compares nothing agrees with everything.

Undone in a scratch copy, with the sweep and the live run:

Undone The sweep On PostgreSQL 18
No null compensation for != fails, 159 rows fails
A nullable operand of a concatenation is not coalesced fails, 35 rows fails, and the unique index lets the duplicate in
Trim without the provider's characters fails, 50 rows passes
substr for substring fails, 16 rows passes
A rule taken out of waivers.txt fails, 26 rows
A waiver added for a row that agrees No waiver outlives the disagreement it waives fails

The two rows that pass on the server are what the sweep is for: btrim(x) and substr give the same answers on the seed rows and are not the expression EF Core's query has, so an index on them would not be used. Only the comparison of renderings sees that.

Found on the way: the live test class threw in its cleanup when no server was configured, which made the two tests fail and not go inconclusive. The cleanup now does nothing when the test never connected.

🤖 Generated with Claude Code

…the same rows answered on PostgreSQL 18

5.x's differential sweep, ported as files. The catalogue reads the
translator's tables and crosses every construct with every operand shape;
the rows are compiled by Roslyn; the translator and the kernel's resolver
are compared with EF Core's ToQueryString(), both parsed with PostgreSQL's
precedence. A disagreement is listed in waivers.txt with its reason, and a
waiver nothing needs fails. The live test runs the same rows on PostgreSQL
18 and builds an index for each expression a waiver calls equivalent.

The part written anew is how SchemaKit's side is rendered. Members of a
JSON document are left out behind one switch until a provider renders them.

Closes #74

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 12, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (harnesses, parity suites); no library code package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/expression-indexes Expression, typed lambda and JSON member indexes labels Nov 12, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 8b29549 into main Nov 12, 2026
7 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the test/translator-parity-sweep branch November 12, 2026 10:18
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 package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) tests Adds or changes tests only (harnesses, parity suites); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lambda translator, second slice: the parity sweep against EF Core's query SQL, and the same rows answered on PostgreSQL 18

1 participant