Skip to content

Commit

Permalink
Query: Add regression test for #21490 (#25667)
Browse files Browse the repository at this point in the history
Resolves #21490

By 5.0 we expanded navigation correctly but failed in translation
in 6.0 we translate correctly too
  • Loading branch information
smitpatel authored Aug 23, 2021
1 parent c84f898 commit 9aef1e7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,12 @@ public override Task Client_projection_via_ctor_arguments(bool async)
return base.Client_projection_via_ctor_arguments(async);
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2373,5 +2373,53 @@ public OrderInfo(int orderID, DateTime? orderDate)
public DateTime? OrderDate { get; }
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Client_projection_with_string_initialization_with_scalar_subquery(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID.StartsWith("F"))
.Select(c => new
{
c.CustomerID,
Order = c.Orders.FirstOrDefault(o => o.OrderID < 11000).OrderDate,
InterpolatedString = $"test{c.City}",
NonInterpolatedString = "test" + c.City,
Collection = new List<string>
{
$"{c.CustomerID}@test1.com",
$"{c.CustomerID}@test2.com",
$"{c.CustomerID}@test3.com",
$"{c.CustomerID}@test4.com"
}
}),
ss => ss.Set<Customer>()
.Where(c => c.CustomerID.StartsWith("F"))
.Select(c => new
{
c.CustomerID,
Order = c.Orders.FirstOrDefault(o => o.OrderID < 11000).MaybeScalar(e => e.OrderDate),
InterpolatedString = $"test{c.City}",
NonInterpolatedString = "test" + c.City,
Collection = new List<string>
{
$"{c.CustomerID}@test1.com",
$"{c.CustomerID}@test2.com",
$"{c.CustomerID}@test3.com",
$"{c.CustomerID}@test4.com"
}
}),
elementSorter: e => e.CustomerID,
elementAsserter: (e, a) =>
{
AssertEqual(e.CustomerID, a.CustomerID);
AssertEqual(e.Order, a.Order);
AssertEqual(e.InterpolatedString, a.InterpolatedString);
AssertEqual(e.NonInterpolatedString, a.NonInterpolatedString);
AssertCollection(e.Collection, a.Collection, ordered: true);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,19 @@ FROM [Customers] AS [c]
ORDER BY [t].[CustomerID]");
}

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

AssertSql(
@"SELECT [c].[CustomerID], (
SELECT TOP(1) [o].[OrderDate]
FROM [Orders] AS [o]
WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] < 11000)), [c].[City], N'test' + COALESCE([c].[City], N'')
FROM [Customers] AS [c]
WHERE [c].[CustomerID] LIKE N'F%'");
}

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

Expand Down

0 comments on commit 9aef1e7

Please sign in to comment.