Skip to content

Commit

Permalink
Fix to #8216 - Query: navigation rewrite fails for queries with navig…
Browse files Browse the repository at this point in the history
…ation inside a subquery inside join inner key selector

Problem was that navigation inside inner key selector of a JoinClause was always being rewritten to subquery (needed for #3103). However, we should only be doing this for "naked" navs - if the nav itself is inside a subquery it can be safely rewritten into a join.

Fix is to "reset" the state indicating whether we are inside join inner key selector every time we visit SubQuery.
  • Loading branch information
maumar committed May 17, 2017
1 parent 99d6df6 commit 9f75b44
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ protected ComplexNavigationsOwnedQueryTestBase(TFixture fixture)
{
}

[ConditionalFact(Skip = "issue #8216")]
public override void Query_source_materialization_bug_4547()
{
base.Query_source_materialization_bug_4547();
}

[ConditionalFact(Skip = "issue #8216")]
public override void Select_join_with_key_selector_being_a_subquery()
{
base.Select_join_with_key_selector_being_a_subquery();
}

[ConditionalFact(Skip = "issue #8248")]
public override void Required_navigation_on_a_subquery_with_First_in_projection()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,7 @@ join subQuery3 in l3s
into
grouping
from subQuery3 in grouping.DefaultIfEmpty()
orderby subQuery3 != null ? (int?)subQuery3.Id : null
select subQuery3 != null ? (int?)subQuery3.Id : null
).FirstOrDefault()
select e1.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,13 @@ protected override Expression VisitUnary(UnaryExpression node)
/// </summary>
protected override Expression VisitSubQuery(SubQueryExpression expression)
{
var oldInsideInnerKeySelector = _insideInnerKeySelector;
_insideInnerKeySelector = false;

Rewrite(expression.QueryModel, _queryModel);

_insideInnerKeySelector = oldInsideInnerKeySelector;

return expression;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ FROM [Level3] AS [e3]
SELECT TOP(1) [subQuery30].[Id]
FROM [Level2] AS [subQuery20]
LEFT JOIN [Level3] AS [subQuery30] ON [subQuery20].[Id] = [subQuery30].[Level2_Optional_Id]
ORDER BY [subQuery30].[Id]
)");
}

Expand Down

0 comments on commit 9f75b44

Please sign in to comment.