Skip to content

Commit

Permalink
CodePlex dotnet#2252: Regression from 6.0.2 - generated SQL uses CROS…
Browse files Browse the repository at this point in the history
…S APPLY instead of INNER JOIN.

We defer FilterOpRules.Rule_FilterOverOuterApply to allow the NullSemantics phase to expand EQ operations. However we do not re-run ApplyOpRules.Rule_CrossApplyOverFilter which converts the CROSS APPLY to INNER JOIN when conditions are met.
The fix adds ApplyOpRules and JoinOpRules to the deferred transformation rules.
  • Loading branch information
Emil Cicos committed May 14, 2014
1 parent b40bb16 commit 1508ef4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ private static List<Rule> DeferredRules
deferredRules = new List<Rule>();
deferredRules.Add(FilterOpRules.Rule_FilterOverLeftOuterJoin);
deferredRules.Add(FilterOpRules.Rule_FilterOverOuterApply);
deferredRules.AddRange(ApplyOpRules.Rules);
deferredRules.AddRange(JoinOpRules.Rules);
}
return deferredRules;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,12 +688,11 @@ public void EQ_is_not_expanded_when_rewriting_navigation_properties()
[Extent1].[Id] AS [Id],
[Extent1].[Group] AS [Group]
FROM [dbo].[Orders] AS [Extent1]
CROSS APPLY (SELECT [Extent2].[Group] AS [Group]
INNER JOIN (SELECT [Extent2].[Group] AS [Group], [Extent4].[Id] AS [Id1]
FROM [dbo].[Orders] AS [Extent2]
LEFT OUTER JOIN [dbo].[Invoices] AS [Extent3] ON [Extent2].[Id] = [Extent3].[Id]
INNER JOIN [dbo].[Invoices] AS [Extent4] ON [Extent4].[Id] = [Extent3].[Id]
WHERE [Extent1].[Id] = [Extent4].[Id] ) AS [Filter1]
WHERE [Filter1].[Group] < 10");
INNER JOIN [dbo].[Invoices] AS [Extent4] ON [Extent4].[Id] = [Extent3].[Id] ) AS [Join2] ON [Extent1].[Id] = [Join2].[Id1]
WHERE [Join2].[Group] < 10");

Assert.Equal(0, query.Count());
}
Expand Down

0 comments on commit 1508ef4

Please sign in to comment.