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: Apply unique projection names in the subquery #15885

Merged
merged 1 commit into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,44 +254,45 @@ protected override ShapedQueryExpression TranslateFirstOrDefault(ShapedQueryExpr

protected override ShapedQueryExpression TranslateGroupJoin(ShapedQueryExpression outer, ShapedQueryExpression inner, LambdaExpression outerKeySelector, LambdaExpression innerKeySelector, LambdaExpression resultSelector)
{
var outerSelectExpression = (SelectExpression)outer.QueryExpression;
if (outerSelectExpression.Limit != null
|| outerSelectExpression.Offset != null
|| outerSelectExpression.IsDistinct)
{
outerSelectExpression.PushdownIntoSubQuery();
}

var innerSelectExpression = (SelectExpression)inner.QueryExpression;
if (innerSelectExpression.Orderings.Any()
|| innerSelectExpression.Limit != null
|| innerSelectExpression.Offset != null
|| innerSelectExpression.IsDistinct
|| innerSelectExpression.Predicate != null)
{
innerSelectExpression.PushdownIntoSubQuery();
}

var joinPredicate = CreateJoinPredicate(outer, outerKeySelector, inner, innerKeySelector);
if (joinPredicate != null)
{
outer = TranslateThenBy(outer, outerKeySelector, true);

var innerTransparentIdentifierType = CreateTransparentIdentifierType(
resultSelector.Parameters[0].Type,
resultSelector.Parameters[1].Type.TryGetSequenceType());

outerSelectExpression.AddLeftJoin(
innerSelectExpression, joinPredicate, innerTransparentIdentifierType);

return TranslateResultSelectorForGroupJoin(
outer,
inner.ShaperExpression,
outerKeySelector,
innerKeySelector,
resultSelector,
innerTransparentIdentifierType);
}
//var outerSelectExpression = (SelectExpression)outer.QueryExpression;
//if (outerSelectExpression.Limit != null
// || outerSelectExpression.Offset != null
// || outerSelectExpression.IsDistinct)
//{
// outerSelectExpression.PushdownIntoSubQuery();
//}

//var innerSelectExpression = (SelectExpression)inner.QueryExpression;
//if (innerSelectExpression.Orderings.Any()
// || innerSelectExpression.Limit != null
// || innerSelectExpression.Offset != null
// || innerSelectExpression.IsDistinct
// || innerSelectExpression.Predicate != null
// || innerSelectExpression.Tables.Count > 1)
//{
// innerSelectExpression.PushdownIntoSubQuery();
//}

//var joinPredicate = CreateJoinPredicate(outer, outerKeySelector, inner, innerKeySelector);
//if (joinPredicate != null)
//{
// outer = TranslateThenBy(outer, outerKeySelector, true);

// var innerTransparentIdentifierType = CreateTransparentIdentifierType(
// resultSelector.Parameters[0].Type,
// resultSelector.Parameters[1].Type.TryGetSequenceType());

// outerSelectExpression.AddLeftJoin(
// innerSelectExpression, joinPredicate, innerTransparentIdentifierType);

// return TranslateResultSelectorForGroupJoin(
// outer,
// inner.ShaperExpression,
// outerKeySelector,
// innerKeySelector,
// resultSelector,
// innerTransparentIdentifierType);
//}

throw new NotImplementedException();
}
Expand All @@ -305,6 +306,7 @@ protected override ShapedQueryExpression TranslateJoin(
LambdaExpression innerKeySelector,
LambdaExpression resultSelector)
{
// TODO: write a test which has distinct on outer so that we can verify pushdown
var innerSelectExpression = (SelectExpression)inner.QueryExpression;
if (innerSelectExpression.Orderings.Any()
|| innerSelectExpression.Limit != null
Expand Down Expand Up @@ -353,7 +355,8 @@ protected override ShapedQueryExpression TranslateLeftJoin(ShapedQueryExpression
|| innerSelectExpression.Limit != null
|| innerSelectExpression.Offset != null
|| innerSelectExpression.IsDistinct
|| innerSelectExpression.Predicate != null)
|| innerSelectExpression.Predicate != null
|| innerSelectExpression.Tables.Count > 1)
{
innerSelectExpression.PushdownIntoSubQuery();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public virtual void Multi_level_include_with_short_circuiting()
}
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_key_access_optional(bool isAsync)
{
Expand All @@ -375,7 +375,7 @@ join e2 in l2s on e1.Id equals MaybeScalar<int>(
e => e.Id1 + " " + e.Id2);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_key_access_required(bool isAsync)
{
Expand Down Expand Up @@ -759,7 +759,7 @@ join e1 in l1s on MaybeScalar<int>(
e => e.Id1 + " " + e.Id3);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_in_inner_selector_translated_to_subquery(bool isAsync)
{
Expand All @@ -784,7 +784,7 @@ join e1 in l1s on e2.Id equals MaybeScalar<int>(e1.OneToOne_Optional_FK1, () =>
e => e.Id2 + " " + e.Id1);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigations_in_inner_selector_translated_to_multiple_subquery_without_collision(bool isAsync)
{
Expand Down Expand Up @@ -814,7 +814,7 @@ join e3 in l3s on e2.Id equals MaybeScalar<int>(
e => e.Id2 + " " + e.Id1 + " " + e.Id3);
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_translated_to_subquery_non_key_join(bool isAsync)
{
Expand Down Expand Up @@ -874,7 +874,7 @@ join e1 in l1s.OrderBy(l1 => l1.Id) on e2.Name equals Maybe(
e => e.Id2 + " " + e.Name2 + " " + e.Id1 + " " + e.Name1);
}

[ConditionalTheory(Skip = "Issue# 15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_translated_to_subquery_self_ref(bool isAsync)
{
Expand All @@ -900,7 +900,7 @@ join e2 in l1s on e1.Id equals MaybeScalar<int>(
e => e.Id1 + " " + e.Id2);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_translated_to_subquery_nested(bool isAsync)
{
Expand Down Expand Up @@ -959,7 +959,7 @@ join e1 in l1s.OrderBy(ll => ll.Id) on e3.Id equals MaybeScalar(
e => e.Id3 + " " + e.Id1);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_translated_to_subquery_deeply_nested_non_key_join(bool isAsync)
{
Expand Down Expand Up @@ -994,7 +994,7 @@ join e1 in l1s on e4.Name equals Maybe(
e => e.Id4 + " " + e.Name4 + " " + e.Id1 + " " + e.Name1);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_translated_to_subquery_deeply_nested_required(bool isAsync)
{
Expand Down Expand Up @@ -2407,7 +2407,7 @@ public virtual Task Null_protection_logic_work_for_inner_key_access_of_manually_
(e, a) => Assert.Equal(e.Id, a.Id));
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory(Skip = "Issue#15872")]
[MemberData(nameof(IsAsyncData))]
public virtual Task Null_protection_logic_work_for_inner_key_access_of_manually_created_GroupJoin2(bool isAsync)
{
Expand Down Expand Up @@ -3680,7 +3680,7 @@ from l1 in grouping.DefaultIfEmpty()
elementSorter: e => e.Id1);
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Optional_navigation_propagates_nullability_to_manually_created_left_join2(bool isAsync)
{
Expand Down Expand Up @@ -3708,7 +3708,7 @@ from l2_nav in grouping.DefaultIfEmpty()
elementSorter: e => e.Name1 + e.Name2);
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Null_reference_protection_complex(bool isAsync)
{
Expand Down Expand Up @@ -3736,7 +3736,7 @@ from l2_outer in grouping_outer.DefaultIfEmpty()
select Maybe(l2_outer, () => l2_outer.Name));
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Null_reference_protection_complex_materialization(bool isAsync)
{
Expand Down Expand Up @@ -3783,7 +3783,7 @@ private static TResult ClientMethodReturnSelf<TResult>(TResult element)
return element;
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Null_reference_protection_complex_client_eval(bool isAsync)
{
Expand Down Expand Up @@ -3811,7 +3811,7 @@ from l2_outer in grouping_outer.DefaultIfEmpty()
select ClientMethodReturnSelf(Maybe(l2_outer, () => l2_outer.Name)));
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened(bool isAsync)
{
Expand Down Expand Up @@ -3841,7 +3841,7 @@ from subquery in grouping.DefaultIfEmpty()
select MaybeScalar<int>(subquery, () => subquery.Id));
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened2(bool isAsync)
{
Expand Down Expand Up @@ -3871,7 +3871,7 @@ from subquery in grouping.DefaultIfEmpty()
select MaybeScalar<int>(subquery, () => subquery.Id));
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened3(bool isAsync)
{
Expand Down Expand Up @@ -5851,7 +5851,7 @@ public virtual void Include16()
}
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include17()
{
using (var ctx = CreateContext())
Expand Down Expand Up @@ -5909,7 +5909,7 @@ public virtual Task Include18_2(bool isAsync)
expectedIncludes);
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include18_3()
{
using (var ctx = CreateContext())
Expand All @@ -5920,7 +5920,7 @@ public virtual void Include18_3()
}
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include18_3_1()
{
using (var ctx = CreateContext())
Expand All @@ -5931,7 +5931,7 @@ public virtual void Include18_3_1()
}
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include18_3_2()
{
using (var ctx = CreateContext())
Expand All @@ -5957,7 +5957,7 @@ public virtual Task Include18_3_3(bool isAsync)
expectedIncludes);
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include18_4()
{
using (var ctx = CreateContext())
Expand All @@ -5968,7 +5968,7 @@ public virtual void Include18_4()
}
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include18()
{
using (var ctx = CreateContext())
Expand All @@ -5979,7 +5979,7 @@ public virtual void Include18()
}
}

[ConditionalFact(Skip = "issue #15833")]
[ConditionalFact]
public virtual void Include19()
{
using (var ctx = CreateContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ from g in grouping
select g);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_navigation_translated_to_subquery_composite_key(bool isAsync)
{
Expand Down Expand Up @@ -6137,7 +6137,7 @@ join w2 in ws on w1.SynergyWith equals w2
elementSorter: e => e.Name1 + " " + e.Name2);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory(Skip = "Issue#15588")]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool isAsync)
{
Expand Down Expand Up @@ -6188,7 +6188,7 @@ join w in ws.Where(ww => ww.IsAutomatic) on s equals w.Owner.Squad
elementSorter: e => e.SquadName + " " + e.WeaponName);
}

[ConditionalTheory(Skip = "Issue #15833")]
[ConditionalTheory(Skip = "Issue#15588")]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool isAsync)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ orderby o.OrderID
elementSorter: e => e.OrderID);
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupJoin_with_complex_subquery_and_LOJ_gets_flattened(bool isAsync)
{
Expand All @@ -1339,7 +1339,7 @@ from subquery in result.DefaultIfEmpty()
entryCount: 91);
}

[ConditionalTheory(Skip = "issue #15833")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupJoin_with_complex_subquery_and_LOJ_gets_flattened2(bool isAsync)
{
Expand Down