Repository navigation
feat: the lambda translator in the kernel, 5.x's expressions and predicates with null compensation - #72
Merged
Conversation
…icates with null compensation NpgsqlLinqIndexTranslator of 5.x, ported in full and internal. A lambda becomes a template where it is written: property paths stay placeholders for the resolver, string methods are spelled as Npgsql's queries spell them, and a comparison that can be NULL is written as EF Core writes it, so that a predicate keeps the rows C# keeps. Enums, DateTime and Guid literals, members of a scalar and methods outside the tables are refused at the declaration. The accepted constructs stay data. A literal is written as it is: the resolver has one grammar and takes nothing inside quotes for a placeholder, so 5.x's brace escape is gone. Closes #71 Co-Authored-By: Claude Fable 5.2 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #71
The first slice of #26, which stays open. It comes before the PostgreSQL package (#25) by the maintainer's decision of 2026-11-12, so that an exclusion constraint in
preview.1takes a lambda filter.Problem
A declaration holds SQL templates, and nothing in SchemaKit turned a lambda into one.
Change
Translation/Internal/LambdaTranslator.cs:NpgsqlLinqIndexTranslatorof 5.x, ported in full, internal.Expression(lambda)andPredicate(lambda)return a template in the resolver's grammar.ToLower,ToUpper,Trim,TrimStart,TrimEnd,Substring,Replace,Length, concatenation,??,Nullable<T>.Value, constants and captured values as literals.&&,||,!, boolean members,HasValue, comparisons with null, with EF Core's null compensation and the negation pushed down to a comparison that can be NULL.DateTimeorGuidliteral, a member of a scalar, a method outside the tables, a lambda over more than one parameter.StringMethods,ValueMembers,ValueOperators,ComparisonOperators,LogicalOperators,LiteralTypes), for the sweep and the analyzer.What differs from 5.x, on purpose:
'{x}'through the kernel's resolver on a model and on its snapshot.The spellings are PostgreSQL's. Nothing calls the translator yet: the declaration values that do (
Predicate.Of,Sql.Raw) come with the first provider vocabulary (#25).Not here (stays in #26)
ToQueryString()and the answers-alike run on PostgreSQL 18. Until it is ported, what holds the templates is these rule tests; that a template is what EF Core's queries write is not checked here.[SchemaFunction]markers for other packages.Tests
Kernel tests without a server, on SDK 11.0.100 in the checkout: 380 before, 398 after. Probes: 125 pass. The PostgreSQL integration tests did not run locally; CI runs them.
LambdaTranslatorTestshas a test per rule, with the failure the rule was written after in its comment. One expectation of mine was wrong and the port was right: a negated captured flag isNOT (TRUE), not folded toFALSE, as 5.x wrote it.Each rule undone in a scratch copy, 20 in all:
substrforsubstring!=; for==on two nullables🤖 Generated with Claude Code