Repository navigation
Description
Problem
A typed filter or typed expression index is useful only if it renders the way EF Core's query translation renders the same lambda: PostgreSQL uses an expression index only for a query whose expression matches, and a filter with different null semantics indexes different rows. Each divergence so far was found one at a time, by reading:
- Typed filters use SQL null semantics: != and ! on a nullable operand drop NULL rows, a captured null renders = NULL #68 (silent): SQL null semantics instead of C#'s
- Typed filters double braces in string literals: x.Code != "{draft}" renders '{{draft}}' #70 (silent): doubled braces in string literals
- Typed expression indexes render Substring and Trim differently from EF Core's queries, so no query uses them #72 (silent):
substr/btriminstead ofsubstring/btrim(…, E' \t\n\r') - Typed filters: char comparisons render an integer, and HasValue and other scalar members fail at migrations add, not at the declaration #80:
charcomparisons render an integer - Typed expression indexes: string concatenation with a nullable operand differs from EF Core (COALESCE) #94 (silent): string concatenation with a nullable operand lacks
COALESCE
The existing ToQueryString() comparisons (NpgsqlTypedFilterTests, NpgsqlLinqExpressionIndexTests, NpgsqlJsonMemberRenderingTests) cover hand-picked lambdas. NpgsqlLinqIndexTranslator is the least-covered file in the repository: 138 of its 548 branches never run.
Change
A differential sweep, in the manner of CodoMetis.ValueRanges' ShapeMatrixParityTests:
- The catalogue: every construct the translator accepts (each operator, each string method,
HasValue/.Value, negation, captured values including null, constants of each portable type,char) is crossed with each operand shape: non-nullable, nullable value type, nullable reference,ToJson()member of each store type, converter member. The catalogue is derived from the translator's own accepted set, so a construct added later is swept without an edit. - The comparison: for each pair, compare the package's rendering with what Npgsql renders for the same lambda in
Where(…)(filters) orSelect(…)(expressions), normalized only for aliasing. - Disagreements: each one is either fixed or listed with its reason in a waiver file, never skipped silently. Constructs the translator refuses must be refused at the declaration, never at
migrations add(Typed filters: char comparisons render an integer, and HasValue and other scalar members fail at migrations add, not at the declaration #80'sHasValue). - Live check: a few rows run against the live PostgreSQL integration container, so a pair that renders alike but answers differently (null rows in a unique index) is caught too.
- Seeds: prove the sweep catches Typed filters use SQL null semantics: != and ! on a nullable operand drop NULL rows, a captured null renders = NULL #68, Typed filters double braces in string literals: x.Code != "{draft}" renders '{{draft}}' #70, Typed expression indexes render Substring and Trim differently from EF Core's queries, so no query uses them #72 and Typed expression indexes: string concatenation with a nullable operand differs from EF Core (COALESCE) #94, each fix reverted in turn.
Done when
The sweep runs in the unit suite, every disagreement it finds is fixed or waived with a reason, and the four seeds fail it.
Activity