Skip to content
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: Throw error for unhandled derived query root expression #26579

Merged
merged 1 commit into from
Nov 19, 2021

Conversation

smitpatel
Copy link
Member

Query root design

Core exposes QueryRootExpression which is base class for any query root so we can access EntityType out of it. This is needed for nav expansion and any potential future use case.
Since any derived query root would derive from it, core assembly translates it only when type is exact match to QueryRootExpression.
Relational layer also processes QueryRootExpression when they are mapped to default SqlQuery, which also uses exact type match now.

Apart from QueryRootExpression, no other kind of query root which can appear in different providers should be derivable (else they need to use exact type match too).
This rule makes relational ones sealed class. In case any one needs to derive from it, they need to add additional processing anyway.

Provider specific derived query roots can be non-sealed. If anyone is deriving from it then they should be using their derived provider which process those nodes too and if the derived provider wasn't used and shipped provider is used then it is an error from user perspective. If derived query root is used on other provider (targeting diff database) then it will fail since even the base shipped query root is unknown.

Resolves #26502

@smitpatel smitpatel requested review from maumar and roji November 8, 2021 20:41
@smitpatel
Copy link
Member Author

No testing since it needs test assembly with multiple providers. Let me know if we have such assembly. (or if someone else could manually verify the change works).

@ajcvickers
Copy link
Member

No testing since it needs test assembly with multiple providers.

This is what the cross-store functional tests are for.

@smitpatel
Copy link
Member Author

Will add test there. Thanks.

Query root design

Core exposes QueryRootExpression which is base class for any query root so we can access EntityType out of it. This is needed for nav expansion and any potential future use case.
Since any derived query root would derive from it, core assembly translates it only when type is exact match to QueryRootExpression.
Relational layer also processes QueryRootExpression when they are mapped to default SqlQuery, which also uses exact type match now.

Apart from QueryRootExpression, no other kind of query root which can appear in different providers should be derivable (else they need to use exact type match too).
This rule makes relational ones sealed class. In case any one needs to derive from it, they need to add additional processing anyway.

Provider specific derived query roots can be non-sealed. If anyone is deriving from it then they should be using their derived provider which process those nodes too and if the derived provider wasn't used and shipped provider is used then it is an error from user perspective. If derived query root is used on other provider (targeting diff database) then it will fail since even the base shipped query root is unknown.

Resolves #26502
@smitpatel
Copy link
Member Author

Added test for cross provider methods (including AsSplitQuery/AsSingleQuery no-op in InMemory)

@smitpatel smitpatel requested a review from a team November 11, 2021 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throw when using relational FromSqlRaw with Cosmos, or vice-versa
4 participants