-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The future of optional dependents sharing table with principal #23564
Comments
I am in favor of the first proposal as it's less breaking. We should throw in model validation for any nested types on optional dependents that don't have required non-shared properties and gather feedback. |
Agreed. First proposal seems good. Thanks for writing all this down, Smit. |
An optional dependent considered present If all non-nullable non-PK properties have a non-null value, or If all non-nullable non-PK properties are shared with principal then at least one nullable non shared property has a non-null value If there are no non-shared properties then it is always present and act like a required dependent Resolves #23564 Resolves #21488 Resolves #23198
An optional dependent considered present If all non-nullable non-PK properties have a non-null value, or If all non-nullable non-PK properties are shared with principal then at least one nullable non shared property has a non-null value If there are no non-shared properties then it is always present and act like a required dependent Resolves #23564 Resolves #21488 Resolves #23198
Next set of decisions
|
Also warn when there's no nested dependent and no identifying required column. |
@AndriySvyryd - Does #23229 (comment) covers everything in validation? |
An optional dependent considered present If all non-nullable non-PK properties have a non-null value, or If all non-nullable non-PK properties are shared with principal then at least one nullable non shared property has a non-null value If there are no non-shared properties then it is always present and act like a required dependent Resolves #23564
An optional dependent considered present If all non-nullable non-PK properties have a non-null value, or If all non-nullable non-PK properties are shared with principal then at least one nullable non shared property has a non-null value If there are no non-shared properties then it is always present and act like a required dependent Resolves #23564
@smitpatel @ajcvickers Are you planning a release with this fix before 6.0? |
Sorry for adding this late in the process (thanks smitpatel for refering me here!). A third proposal would be to automatically add a "hidden" column/field which separates a existing dependent with all values set to null from a non-existing dependent. Pros (that I can see):
Cons:
|
@cjblomqvist - Because this feature was already shipped in past without having automatically added column, we cannot add a column automatically now. A user who has created database with EF Core, without making any change to their model will have their query failed because EF Core decided to change the schema altogether. We went with warning/error mechanism so user will know they need to update the model, generate migration and update their database. |
The optional dependents which are sharing table with principal has few technicalities around how they are retrieved and materialized.
There are mainly 2 stages where such determination needs to be made.
The basic set of conditions for optional dependents right now is
Issues:
Examples
Now SQL side,
#23230 - we need to integrate conditions for existence of dependent when accessing any property which is sharing table with any principal.
So major issue right now in SQL/correct SQL we need for conditional property access & materialization w.r.t nested dependent when dependent does not have at least one non-PK, optional/required property.
Proposals:
We stop checking nested dependents. We utilize first 2 conditions only else we consider it always true.
We guide people have at least one non-nullable property as a discriminator like for existence of dependent.
SQL property access would be written as "existence check ? property access : null" (potentially expanded in check AND property == value")
In first proposal, the existence check will be possible (since no longer joins needed).
In second proposal, the check would be much simpler.
The text was updated successfully, but these errors were encountered: