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: Add regression test for #12603 #19463

Merged
merged 1 commit into from
Jan 2, 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 @@ -4039,6 +4039,24 @@ public override Task Collection_projection_skip_take(bool async)
return base.Collection_projection_skip_take(async);
}

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

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

[ConditionalTheory(Skip = "Issue #17246")]
public override Task Anonymous_projection_skip_take_empty_collection_FirstOrDefault(bool async)
{
return base.Anonymous_projection_skip_take_empty_collection_FirstOrDefault(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 @@ -5651,5 +5651,45 @@ public virtual Task Collection_projection_skip_take(bool async)
assertOrder: true,
elementAsserter: (e, a) => { AssertEqual(e.Order, a.Order); AssertCollection(e.OrderDetails, a.OrderDetails); });
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Anonymous_projection_skip_empty_collection_FirstOrDefault(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID == "FISSA")
.Select(c => new { Customer = c })
.Skip(0)
.Select(e => e.Customer.Orders.FirstOrDefault()));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Anonymous_projection_take_empty_collection_FirstOrDefault(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID == "FISSA")
.Select(c => new { Customer = c })
.Take(1)
.Select(e => e.Customer.Orders.FirstOrDefault()));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Anonymous_projection_skip_take_empty_collection_FirstOrDefault(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID == "FISSA")
.Select(c => new { Customer = c })
.Skip(0)
.Take(1)
.Select(e => e.Customer.Orders.FirstOrDefault()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4899,6 +4899,80 @@ OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY
ORDER BY [t].[OrderID], [o0].[OrderID], [o0].[ProductID]");
}

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

AssertSql(
@"@__p_0='0'

SELECT [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate]
FROM (
SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
FROM [Customers] AS [c]
WHERE [c].[CustomerID] = N'FISSA'
ORDER BY (SELECT 1)
OFFSET @__p_0 ROWS
) AS [t]
LEFT JOIN (
SELECT [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate]
FROM (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], ROW_NUMBER() OVER(PARTITION BY [o].[CustomerID] ORDER BY [o].[OrderID]) AS [row]
FROM [Orders] AS [o]
) AS [t0]
WHERE [t0].[row] <= 1
) AS [t1] ON [t].[CustomerID] = [t1].[CustomerID]");
}

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

AssertSql(
@"@__p_0='1'

SELECT [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate]
FROM (
SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
FROM [Customers] AS [c]
WHERE [c].[CustomerID] = N'FISSA'
) AS [t]
LEFT JOIN (
SELECT [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate]
FROM (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], ROW_NUMBER() OVER(PARTITION BY [o].[CustomerID] ORDER BY [o].[OrderID]) AS [row]
FROM [Orders] AS [o]
) AS [t0]
WHERE [t0].[row] <= 1
) AS [t1] ON [t].[CustomerID] = [t1].[CustomerID]");
}

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

AssertSql(
@"@__p_0='0'
@__p_1='1'

SELECT [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate]
FROM (
SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
FROM [Customers] AS [c]
WHERE [c].[CustomerID] = N'FISSA'
ORDER BY (SELECT 1)
OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY
) AS [t]
LEFT JOIN (
SELECT [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate]
FROM (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], ROW_NUMBER() OVER(PARTITION BY [o].[CustomerID] ORDER BY [o].[OrderID]) AS [row]
FROM [Orders] AS [o]
) AS [t0]
WHERE [t0].[row] <= 1
) AS [t1] ON [t].[CustomerID] = [t1].[CustomerID]");
}

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

Expand Down