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: Process client eval in join when collection shaper #21236

Merged
merged 1 commit into from
Jun 12, 2020
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 @@ -291,6 +291,13 @@ protected override Expression VisitExtension(Expression extensionExpression)
: null;
}

if (extensionExpression is CollectionShaperExpression)
{
return _clientEval
? extensionExpression
: null;
}

throw new InvalidOperationException(
CoreStrings.QueryFailed(extensionExpression.Print(), GetType().Name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,18 @@ public override Task SelectMany_with_client_eval(bool async)
return base.SelectMany_with_client_eval(async);
}

[ConditionalTheory(Skip = "Issue#17246")]
public override Task SelectMany_with_client_eval_with_collection_shaper(bool async)
{
return base.SelectMany_with_client_eval_with_collection_shaper(async);
}

[ConditionalTheory(Skip = "Issue#17246")]
public override Task SelectMany_with_client_eval_with_collection_shaper_ignored(bool async)
{
return base.SelectMany_with_client_eval_with_collection_shaper_ignored(async);
}

[ConditionalTheory(Skip = "Issue#17246")]
public override Task SelectMany_with_client_eval_with_constructor(bool async)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public override Task SelectMany_with_client_eval(bool async)
return base.SelectMany_with_client_eval(async);
}

[ConditionalTheory(Skip = "Issue#21200")]
public override Task SelectMany_with_client_eval_with_collection_shaper(bool async)
{
return base.SelectMany_with_client_eval_with_collection_shaper(async);
}

[ConditionalTheory(Skip = "Issue#21200")]
public override Task SelectMany_with_client_eval_with_collection_shaper_ignored(bool async)
{
return base.SelectMany_with_client_eval_with_collection_shaper_ignored(async);
}

[ConditionalTheory(Skip = "Issue#21200")]
public override Task SelectMany_with_client_eval_with_constructor(bool async)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,41 @@ public virtual Task SelectMany_with_client_eval(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>()
ss => ss.Set<Customer>().Where(c => c.CustomerID.StartsWith("F"))
.SelectMany(c => c.Orders.Select(o => new { OrderProperty = ClientMethod(o), CustomerProperty = c.ContactName })),
elementSorter: e => e.OrderProperty,
entryCount: 830);
entryCount: 63);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task SelectMany_with_client_eval_with_collection_shaper(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>().Where(c => c.CustomerID.StartsWith("F"))
.SelectMany(c => c.Orders.Select(o => new { OrderProperty = ClientMethod(o), o.OrderDetails, CustomerProperty = c.ContactName })),
elementSorter: e => e.OrderProperty,
elementAsserter: (e, a) =>
{
AssertEqual(e.OrderProperty, a.OrderProperty);
AssertEqual(e.CustomerProperty, a.CustomerProperty);
AssertCollection(e.OrderDetails, a.OrderDetails);
},
entryCount: 227);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task SelectMany_with_client_eval_with_collection_shaper_ignored(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>().Where(c => c.CustomerID.StartsWith("F"))
.SelectMany(c => c.Orders.Select(o => new { OrderProperty = ClientMethod(o), o.OrderDetails, CustomerProperty = c.ContactName }))
.Select(e => new { e.OrderProperty, e.CustomerProperty }),
elementSorter: e => e.OrderProperty,
entryCount: 63);
}

private static int ClientMethod(Order order) => order.OrderID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,40 @@ CROSS APPLY (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[ContactName]
FROM [Orders] AS [o]
WHERE [c].[CustomerID] = [o].[CustomerID]
) AS [t]");
) AS [t]
WHERE [c].[CustomerID] LIKE N'F%'");
}

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

AssertSql(
@"SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [t].[ContactName], [c].[CustomerID], [t].[OrderID], [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice]
FROM [Customers] AS [c]
CROSS APPLY (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[ContactName]
FROM [Orders] AS [o]
WHERE [c].[CustomerID] = [o].[CustomerID]
) AS [t]
LEFT JOIN [Order Details] AS [o0] ON [t].[OrderID] = [o0].[OrderID]
WHERE [c].[CustomerID] LIKE N'F%'
ORDER BY [c].[CustomerID], [t].[OrderID], [o0].[OrderID], [o0].[ProductID]");
}

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

AssertSql(
@"SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [t].[ContactName]
FROM [Customers] AS [c]
CROSS APPLY (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[ContactName]
FROM [Orders] AS [o]
WHERE [c].[CustomerID] = [o].[CustomerID]
) AS [t]
WHERE [c].[CustomerID] LIKE N'F%'");
}

public override async Task SelectMany_with_client_eval_with_constructor(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public NorthwindJoinQuerySqliteTest(NorthwindQuerySqliteFixture<NoopModelCustomi

// CROSS APPLY is not supported
public override Task SelectMany_with_client_eval(bool async) => Task.CompletedTask;
public override Task SelectMany_with_client_eval_with_collection_shaper(bool async) => Task.CompletedTask;
public override Task SelectMany_with_client_eval_with_collection_shaper_ignored(bool async) => Task.CompletedTask;
}
}