-
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: incorrect results for queries with optional navigation followed by collection navigation with skip/take/distinct #17531
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
Comments
related to #15798 |
25 tasks
smitpatel
changed the title
Query: incorrect results for queries with optional navigation followed by collection navigation with skip/take/distinct
InMemory: Collection navigation matches null == null
Aug 31, 2019
@smitpatel this is not exclusive to InMemory, previous title was correct |
maumar
changed the title
InMemory: Collection navigation matches null == null
Query: incorrect results for queries with optional navigation followed by collection navigation with skip/take/distinct
Sep 3, 2019
maumar
added a commit
that referenced
this issue
Sep 6, 2019
…vigation followed by collection navigation with skip/take/distinct Problem was that when expanding collection navigations we convert them into subqueries with a correlation predicate being outerKey == innerKey. For relational, most of those queries would later be converted into joins, however for some complex cases e.g. with Skip/Take (and also on InMemory) the query would stay in the form of subquery with correlation predicate. Then, null semantics kicks in and converts the correlation predicate to a form that returns true when both keys are null. This is incorrect in the context of chaining navigations - if the parent entity is null then it should never return any children. Fix is to add null check to the correlation predicate during nav rewrite, like so: outerKey != null && outerKey == innerKey Additionally, when trying to convert those subqueries into joins we need to account for a new pattern and remove the null check, since its irrelevant when it comes to join key comparison on relational
maumar
added a commit
that referenced
this issue
Sep 9, 2019
…vigation followed by collection navigation with skip/take/distinct Problem was that when expanding collection navigations we convert them into subqueries with a correlation predicate being outerKey == innerKey. For relational, most of those queries would later be converted into joins, however for some complex cases e.g. with Skip/Take (and also on InMemory) the query would stay in the form of subquery with correlation predicate. Then, null semantics kicks in and converts the correlation predicate to a form that returns true when both keys are null. This is incorrect in the context of chaining navigations - if the parent entity is null then it should never return any children. Fix is to add null check to the correlation predicate during nav rewrite, like so: outerKey != null && outerKey == innerKey Additionally, when trying to convert those subqueries into joins we need to account for a new pattern and remove the null check, since its irrelevant when it comes to join key comparison on relational
maumar
added a commit
that referenced
this issue
Sep 10, 2019
…vigation followed by collection navigation with skip/take/distinct Problem was that when expanding collection navigations we convert them into subqueries with a correlation predicate being outerKey == innerKey. For relational, most of those queries would later be converted into joins, however for some complex cases e.g. with Skip/Take (and also on InMemory) the query would stay in the form of subquery with correlation predicate. Then, null semantics kicks in and converts the correlation predicate to a form that returns true when both keys are null. This is incorrect in the context of chaining navigations - if the parent entity is null then it should never return any children. Fix is to add null check to the correlation predicate during nav rewrite, like so: outerKey != null && outerKey == innerKey Additionally, when trying to convert those subqueries into joins we need to account for a new pattern and remove the null check, since its irrelevant when it comes to join key comparison on relational
maumar
added a commit
that referenced
this issue
Sep 10, 2019
…vigation followed by collection navigation with skip/take/distinct Problem was that when expanding collection navigations we convert them into subqueries with a correlation predicate being outerKey == innerKey. For relational, most of those queries would later be converted into joins, however for some complex cases e.g. with Skip/Take (and also on InMemory) the query would stay in the form of subquery with correlation predicate. Then, null semantics kicks in and converts the correlation predicate to a form that returns true when both keys are null. This is incorrect in the context of chaining navigations - if the parent entity is null then it should never return any children. Fix is to add null check to the correlation predicate during nav rewrite, like so: outerKey != null && outerKey == innerKey Additionally, when trying to convert those subqueries into joins we need to account for a new pattern and remove the null check, since its irrelevant when it comes to join key comparison on relational
maumar
added a commit
that referenced
this issue
Sep 10, 2019
…vigation followed by collection navigation with skip/take/distinct Problem was that when expanding collection navigations we convert them into subqueries with a correlation predicate being outerKey == innerKey. For relational, most of those queries would later be converted into joins, however for some complex cases e.g. with Skip/Take (and also on InMemory) the query would stay in the form of subquery with correlation predicate. Then, null semantics kicks in and converts the correlation predicate to a form that returns true when both keys are null. This is incorrect in the context of chaining navigations - if the parent entity is null then it should never return any children. Fix is to add null check to the correlation predicate during nav rewrite, like so: outerKey != null && outerKey == innerKey Additionally, when trying to convert those subqueries into joins we need to account for a new pattern and remove the null check, since its irrelevant when it comes to join key comparison on relational
maumar
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Sep 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
query:
generated sql:
Problem is that initially in nav rewrite for collection navigation we introduce correlation predicate in form of equality. In simple case (i.e. without Skip/Take/Distinct) that gets converted into join, and the correlation predicate gets converted to join condition.
However here, we can't do that, so the collection remains as a subquery and the correlation predicate remains equality. Then, null semantics gets applied and if both sides of the correlation predicate are null, the result is a match - which is incorrect in case of correlating navigations.
We should add condition to the correlation predicate that would filter out cases where outer key is null. We should do it in nav rewrite and then compensate accordingly in relational for the new shape of the correlation predicate
The text was updated successfully, but these errors were encountered: