-
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
Query: Filter out entities that are using table splitting with a derived type #8973
Comments
@AndriySvyryd What does this mean? |
I think we should consider reworking discriminators to be in-terms of QueryModel rewrites (like entity filters). |
@anpete to write a note on details. |
@smitpatel The fix to try is to modify the two places in relational that apply discriminator predicates to
Where B inherits A ,and B references C, and A, B, C all share the same table, then any direct query for Cs necessarily needs to have a B's discriminator predicate applied. Note, no join should be required because we are always table splitting. @AndriySvyryd has some context on this, too. |
@anpete - I prefer the idea of converting discriminators to where predicates at query model level. At present, we are in the world where creating SelectExpression for EntityQueryable can give rise to "where" clause in Select. That causes issues with joins where a flat QM can also generated a complex Select which requires to be pushdown. Both above manifest from the fact that a random where predicate can arise for TPH scenario. With table splitting like above, that case becomes even more expanded since now, a shared type of a derived type will start having where. It would be much more easier for our translation pipeline to work, if QM is modified instead of working around while translating. Though that will be decent amount of work with not enough time and then throw becomes the solution for 2.0. If we want to support this for 2.0, then we can go with suggestion above and make additional check for owners. Your call what we should do for 2.0 ⌚️ |
I'll add a validation rule for 2.0 so we don't waste time on a temporary solution. |
Sounds good to me. |
Thanks for investigating. Validation rule seems appropriate for 2.0. |
@smitpatel This is a decent amount of work, so marking as priority high for 2.1 to indicate that it should be done soon. |
DRY code to generate discriminator for a query for materialize & non-materialized case Find identifying relationship chain to root and add discriminator of relavent types Resolves #8973
DRY code to generate discriminator for a query for materialize & non-materialized case Find identifying relationship chain to root and add discriminator of relavent types Resolves #8973
DRY code to generate discriminator for a query for materialize & non-materialized case Find identifying relationship chain to root and add discriminator of relavent types Resolves #8973
DRY code to generate discriminator for a query for materialize & non-materialized case Find identifying relationship chain to root and add discriminator of relavent types Resolves #8973
Entities that are splitting the table with a derived type need to be queried with a filter on the principal type discriminator.
See
TableSplittingTestBase.Can_query_shared_derived()
andOwnedQuerySqlServerTest
The text was updated successfully, but these errors were encountered: