Skip to content

Commit

Permalink
Adding regression test for #15279
Browse files Browse the repository at this point in the history
We already have regression tests for most of the scenarios mentioned in the issue report. Adding the one scenario that was missing.

Resolves #15279
  • Loading branch information
maumar committed Sep 16, 2021
1 parent 0816aba commit 99de4a6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3300,6 +3300,31 @@ public virtual Task Complex_query_with_groupBy_in_subquery4(bool async)
});
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Complex_query_with_group_by_in_subquery5(bool async)
{
return AssertQuery(
async,
ss => from od in ss.Set<OrderDetail>()
where od.Order.Customer.CustomerID == "ALFKI"
group od by od.ProductID into grouping
select new
{
Sum = grouping.Sum(x => x.ProductID + x.OrderID * 1000),
Subquery = (from c in ss.Set<Customer>()
where c.CustomerID.Length < grouping.Min(x => x.OrderID / 100)
orderby c.CustomerID
select new { c.CustomerID, c.City }).ToList()
},
elementSorter: e => e.Sum,
elementAsserter: (e, a) =>
{
AssertEqual(e.Sum, a.Sum);
AssertCollection(e.Subquery, a.Subquery, elementSorter: ee => ee.CustomerID);
});
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task GroupBy_scalar_subquery(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,33 @@ public override async Task Select_correlated_collection_after_GroupBy_aggregate_
//AssertSql(" ");
}

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

AssertSql(
@"SELECT [t].[c], [t].[ProductID], [t0].[CustomerID], [t0].[City]
FROM (
SELECT COALESCE(SUM([o].[ProductID] + ([o].[OrderID] * 1000)), 0) AS [c], [o].[ProductID]
FROM [Order Details] AS [o]
INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID]
LEFT JOIN [Customers] AS [c] ON [o0].[CustomerID] = [c].[CustomerID]
WHERE [c].[CustomerID] = N'ALFKI'
GROUP BY [o].[ProductID]
) AS [t]
OUTER APPLY (
SELECT [c0].[CustomerID], [c0].[City]
FROM [Customers] AS [c0]
WHERE CAST(LEN([c0].[CustomerID]) AS int) < (
SELECT MIN([o1].[OrderID] / 100)
FROM [Order Details] AS [o1]
INNER JOIN [Orders] AS [o2] ON [o1].[OrderID] = [o2].[OrderID]
LEFT JOIN [Customers] AS [c1] ON [o2].[CustomerID] = [c1].[CustomerID]
WHERE ([c1].[CustomerID] = N'ALFKI') AND ([t].[ProductID] = [o1].[ProductID]))
) AS [t0]
ORDER BY [t].[ProductID], [t0].[CustomerID]");
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public override async Task Select_nested_collection_with_groupby(bool async)
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Select_nested_collection_with_groupby(async))).Message);

public override async Task Complex_query_with_group_by_in_subquery5(bool async)
=> Assert.Equal(
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Complex_query_with_group_by_in_subquery5(async))).Message);

public override async Task Odata_groupby_empty_key(bool async)
=> await Assert.ThrowsAsync<NotSupportedException>(() => base.Odata_groupby_empty_key(async));
}
Expand Down

0 comments on commit 99de4a6

Please sign in to comment.