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: Don't skip any parameter in projection #27008

Merged
1 commit merged into from
Jan 20, 2022
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 @@ -99,14 +99,6 @@ public override Expression Visit(Expression expression)
return base.Visit(expression);
}

// This skips the group parameter from GroupJoin
if (expression is ParameterExpression parameter
&& parameter.Type.IsGenericType
&& parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
return parameter;
}

if (_clientEval)
{
switch (expression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ public virtual Expression Translate(InMemoryQueryExpression queryExpression, Exp
|| expression is EntityShaperExpression
|| expression is IncludeExpression))
{
// This skips the group parameter from GroupJoin
if (expression is ParameterExpression parameter
&& parameter.Type.IsGenericType
&& parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
return parameter;
}

if (_indexBasedBinding)
{
switch (expression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio
|| expression is EntityShaperExpression
|| expression is IncludeExpression))
{
// This skips the group parameter from GroupJoin
if (expression is ParameterExpression parameter
&& parameter.Type.IsGenericType
&& parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
return parameter;
}

if (_indexBasedBinding)
{
switch (expression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,80 +318,80 @@ public override async Task Select_nested_collection(bool async)

public override void Select_nested_collection_multi_level()
{
// Cosmos client evaluation. Issue #17246.
AssertTranslationFailed(
() =>
{
base.Select_nested_collection_multi_level();
return Task.CompletedTask;
});
//// Cosmos client evaluation. Issue #17246.
//AssertTranslationFailed(
// () =>
// {
// base.Select_nested_collection_multi_level();
// return Task.CompletedTask;
// });

AssertSql();
//AssertSql();
}

public override void Select_nested_collection_multi_level2()
{
// Cosmos client evaluation. Issue #17246.
AssertTranslationFailed(
() =>
{
base.Select_nested_collection_multi_level2();
return Task.CompletedTask;
});
//// Cosmos client evaluation. Issue #17246.
//AssertTranslationFailed(
// () =>
// {
// base.Select_nested_collection_multi_level2();
// return Task.CompletedTask;
// });

AssertSql();
//AssertSql();
}

public override void Select_nested_collection_multi_level3()
{
// Cosmos client evaluation. Issue #17246.
AssertTranslationFailed(
() =>
{
base.Select_nested_collection_multi_level3();
return Task.CompletedTask;
});
//// Cosmos client evaluation. Issue #17246.
//AssertTranslationFailed(
// () =>
// {
// base.Select_nested_collection_multi_level3();
// return Task.CompletedTask;
// });

AssertSql();
//AssertSql();
}

public override void Select_nested_collection_multi_level4()
{
// Cosmos client evaluation. Issue #17246.
AssertTranslationFailed(
() =>
{
base.Select_nested_collection_multi_level4();
return Task.CompletedTask;
});
//// Cosmos client evaluation. Issue #17246.
//AssertTranslationFailed(
// () =>
// {
// base.Select_nested_collection_multi_level4();
// return Task.CompletedTask;
// });

AssertSql();
//AssertSql();
}

public override void Select_nested_collection_multi_level5()
{
// Cosmos client evaluation. Issue #17246.
AssertTranslationFailed(
() =>
{
base.Select_nested_collection_multi_level5();
return Task.CompletedTask;
});
//// Cosmos client evaluation. Issue #17246.
//AssertTranslationFailed(
// () =>
// {
// base.Select_nested_collection_multi_level5();
// return Task.CompletedTask;
// });

AssertSql();
//AssertSql();
}

public override void Select_nested_collection_multi_level6()
{
// Cosmos client evaluation. Issue #17246.
AssertTranslationFailed(
() =>
{
base.Select_nested_collection_multi_level6();
return Task.CompletedTask;
});
//// Cosmos client evaluation. Issue #17246.
//AssertTranslationFailed(
// () =>
// {
// base.Select_nested_collection_multi_level6();
// return Task.CompletedTask;
// });

AssertSql();
//AssertSql();
}

public override async Task Select_nested_collection_count_using_anonymous_type(bool async)
Expand Down Expand Up @@ -1397,8 +1397,6 @@ public override async Task Reverse_in_join_inner_with_skip(bool async)
() => base.Reverse_in_join_inner_with_skip(async))).Message);

AssertSql();

AssertSql();
}

public override async Task Reverse_in_SelectMany(bool async)
Expand Down Expand Up @@ -1469,9 +1467,13 @@ public override async Task Reverse_after_orderBy_and_take(bool async)
Assert.Equal(CosmosStrings.ReverseAfterSkipTakeNotSupported, message);
}

[ConditionalTheory(Skip = "Cross collection join Issue#17246")]
public override Task List_of_list_of_anonymous_type(bool async)
=> base.List_of_list_of_anonymous_type(async);
public override async Task List_of_list_of_anonymous_type(bool async)
{
// Cosmos client evaluation. Issue #17246.
await AssertTranslationFailed(() => base.List_of_list_of_anonymous_type(async));

AssertSql();
}

public override async Task
SelectMany_with_collection_being_correlated_subquery_which_references_non_mapped_properties_from_inner_and_outer_entity(
Expand Down Expand Up @@ -1680,6 +1682,16 @@ FROM root c
WHERE (c[""Discriminator""] = ""Customer"")");
}

public override async Task Using_enumerable_parameter_in_projection(bool async)
{
await base.Using_enumerable_parameter_in_projection(async);

AssertSql(
@"SELECT c[""CustomerID""]
FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND ((c[""CustomerID""] != null) AND ((""F"" != null) AND STARTSWITH(c[""CustomerID""], ""F""))))");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2416,4 +2416,30 @@ public virtual Task List_of_list_of_anonymous_type(bool async)
AssertCollection(e.ListWithSubList, a.ListWithSubList, ordered: true,
elementAsserter: (ee, aa) => AssertCollection(ee, aa, elementSorter: i => (i.OrderID, i.ProductID)));
});

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Using_enumerable_parameter_in_projection(bool async)
smitpatel marked this conversation as resolved.
Show resolved Hide resolved
{
var customersToLoad = new List<string> { "A" };
var results = new List<OrderDto>();

return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID.StartsWith("F"))
.Select(c => new
{
c.CustomerID,
Orders = customersToLoad.Contains("FISSA")
? c.Orders.Select(e => new OrderDto())
: results
}),
elementSorter: e => e.CustomerID,
elementAsserter: (e, a) =>
{
AssertEqual(e.CustomerID, a.CustomerID);
AssertEqual(e.Orders.Count(), a.Orders.Count());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,16 @@ WHERE [c].[CustomerID] LIKE N'F%'
ORDER BY [c].[CustomerID], [t].[OrderID], [t].[OrderID0]");
}

public override async Task Using_enumerable_parameter_in_projection(bool async)
{
await base.Using_enumerable_parameter_in_projection(async);

AssertSql(
@"SELECT [c].[CustomerID]
FROM [Customers] AS [c]
WHERE [c].[CustomerID] LIKE N'F%'");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down