Skip to content

Commit

Permalink
Fix tags for final GroupBy queries
Browse files Browse the repository at this point in the history
Fixes #33794
  • Loading branch information
roji committed Oct 7, 2024
1 parent a0443c1 commit 3ac0e5f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery

if (shapedQueryExpression.ShaperExpression is RelationalGroupByResultExpression relationalGroupByResultExpression)
{
var elementSelector = new ShaperProcessingExpressionVisitor(this, selectExpression, selectExpression.Tags, splitQuery, false)
var elementSelector = new ShaperProcessingExpressionVisitor(this, selectExpression, _tags, splitQuery, indexMap: false)
.ProcessRelationalGroupingResult(
relationalGroupByResultExpression,
out var relationalCommandResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ public override Task Final_GroupBy_property_entity_projecting_collection_and_sin
=> AssertTranslationFailedWithDetails(
() => base.Final_GroupBy_property_entity_projecting_collection_and_single_result(async),
InMemoryStrings.NonComposedGroupByNotSupported);

public override Task Final_GroupBy_TagWith(bool async)
=> AssertTranslationFailedWithDetails(
() => base.Final_GroupBy_TagWith(async),
InMemoryStrings.NonComposedGroupByNotSupported);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,15 @@ public virtual Task Final_GroupBy_property_entity_projecting_collection_and_sing
AssertEqual(ee.LastOrder, aa.LastOrder);
}));
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Final_GroupBy_TagWith(bool async)
=> AssertQuery(
async,
ss => ss.Set<Customer>().TagWith("foo").GroupBy(c => c.City),
elementSorter: e => e.Key,
elementAsserter: (e, a) => AssertGrouping(e, a));
#endregion
#region GroupByWithoutAggregate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ var customer
Assert.NotNull(customer);
}

// See also NorthwindGroupByQueryTestBase.Final_GroupBy_TagWith

protected NorthwindContext CreateContext()
=> Fixture.CreateContext();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,8 @@ public override async Task GroupBy_aggregate_SelectMany(bool async)
AssertSql();
}

#region FinalGroupBy

public override async Task Final_GroupBy_property_entity(bool async)
{
await base.Final_GroupBy_property_entity(async);
Expand Down Expand Up @@ -3772,6 +3774,22 @@ FROM [Orders] AS [o0]
""");
}

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

AssertSql(
"""
-- foo

SELECT [c].[City], [c].[CustomerID], [c].[Address], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
FROM [Customers] AS [c]
ORDER BY [c].[City]
""");
}

#endregion FinalGroupBy

public override async Task GroupBy_Where_with_grouping_result(bool async)
{
await base.GroupBy_Where_with_grouping_result(async);
Expand Down

0 comments on commit 3ac0e5f

Please sign in to comment.