Repository navigation
feat!: a lambda is bound from the model's facts - #185
Merged
Merged
Conversation
When its model is finalized, a lambda in a declaration is translated with the model's facts instead of the C# types': a column can be null when the property, or a complex property on its path, is nullable in the model, and a value compared with a property is written by that property's type mapping, through its converter. An enum, a value object, a DateTime, a Guid and a bool stored as something else are written that way; at the call they are a mark that is never stored. An order comparison on what a converter stores as text is refused at finalization, and so is a value the mapping refuses. Each declaration is bound a second time on the finalized model, and a different result is refused: a convention that runs after the binding can change a column's nullability or a property's conversion. ModelFactsBindingTests compares each condition with EF Core's ToQueryString() for the same lambda on the same model, and the parity sweep translates with the model's facts. Closes #180 Co-Authored-By: Claude Fable 5.2 <[email protected]>
CaffeinatedCoder
enabled auto-merge
November 25, 2026 08:26
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 #180
Slice 3 of the binder (#114, decided 2026-11-24), after #178 and #179.
Problem
Since #179 a lambda in a declaration becomes SQL when its model is finalized, but it was still translated from the C# types alone. So:
IsRequired()on astring?still gotOR … IS NULL, andIsRequired(false)on astringgot none.DateTime, aGuid.boolstored as something else (HasConversion<string>(), a converter to'Y'/'N') was written as a boolean column.Change
TranslationFactsis what the translator asks for what a lambda cannot say. At the call the facts are the C# types', and a value only the model can write is the markLambdaTranslator.BoundLater, which is never stored. At finalization they areModelFacts: a column can be null when the property or a complex property on its path is nullable in the model, and a value compared with a property is written by that property's type mapping, through its converter.IRelationalTypeMappingSource. No property holds its mapping while a model is finalized (spike F).SchemaKitBindingCheckConventionbinds every declaration a second time, first on the finalized model, and refuses a different result: a convention of another package that runs after the binding can change a column's nullability or a property's conversion.PropertyPaths.Findis the one walk from a path to a property, for the resolver and for the facts.On SQL Server a value compared with a property is now SQL Server's own literal (
CAST(1 AS bit),N'blocked'), since the mapping writes it. The second provider's tests said the one spelling'sTRUEis refused there; that comparison is accepted now.A
DateTimethat is not UTC cannot be written for Npgsql'stimestamp with time zoneand is refused by the mapping.Not here: the move of the accepted constructs and the spelling to the provider's package, #184.
breaking: a condition bound from a lambda can come out differently than underpreview.1and the earlier slices (nullability from the model, literals from the mapping).Tests
ModelFactsBindingTests: 13 conditions, each asserted as bound text and compared with EF Core'sToQueryString()for the same lambda on the same model; the two refusals at finalization; a convention registered after SchemaKit's that makes a column nullable, which the second binding refuses.main: 72 fewer refusals at the declaration, 60 more rows that agree with EF Core, 12 more that differ.waivers.txtis unchanged and the sweep passes.Each rule was changed in place and the tests run; a test failed for each of eleven:
A_condition_is_bound_from_the_models_facts,Each_is_what_EF_Core_writes_for_the_lambda_in_a_query,A_fact_that_changes_after_the_binding_is_refused_on_the_finalized_modelA_condition_is_bound_from_the_models_facts,Each_is_what_EF_Core_writes_for_the_lambda_in_a_query,A_value_the_columns_type_cannot_hold_is_refusedAn_order_by_what_a_converter_stores_as_text_is_refusedA_condition_is_bound_from_the_models_facts,Each_is_what_EF_Core_writes_for_the_lambda_in_a_queryNOTA_fact_that_changes_after_the_binding_is_refused_on_the_finalized_modelA_value_the_columns_type_cannot_hold_is_refusedWhat_a_predicate_cannot_say_is_refusedand two more in the kernel, three inModelFactsBindingTestsFor the last three the run that failed was a second one whose output I did not keep; the first eight are from the kept log.
🤖 Generated with Claude Code