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

[SMALL] Adding tests for #24726 - Bug with Take() #24772

Merged
1 commit merged into from
Apr 27, 2021
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 @@ -1988,6 +1988,49 @@ public virtual async Task Filtered_include_calling_methods_directly_on_parameter
.ThenInclude(l2 => l2.AsQueryable().Where(xx => xx.Id != 42))))).Message;
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Filtered_include_Take_with_another_Take_on_top_level(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Level1>()
.Include(l1 => l1.OneToMany_Optional1.OrderByDescending(x => x.Name).Take(4))
.ThenInclude(l2 => l2.OneToOne_Optional_FK2)
.OrderBy(l1 => l1.Id)
.Take(5),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
new ExpectedFilteredInclude<Level1, Level2>(
x => x.OneToMany_Optional1,
includeFilter: x => x.OrderByDescending(xx => xx.Name).Take(4)),
new ExpectedInclude<Level2>(x => x.OneToOne_Optional_FK2, "OneToMany_Optional1")));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Level1>()
.Include(l1 => l1.OneToMany_Optional1.OrderByDescending(x => x.Name).Skip(2).Take(4))
.ThenInclude(l2 => l2.OneToOne_Optional_FK2)
.OrderByDescending(l1 => l1.Id)
.Skip(10)
.Take(5),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
new ExpectedFilteredInclude<Level1, Level2>(
x => x.OneToMany_Optional1,
includeFilter: x => x.OrderByDescending(xx => xx.Name).Skip(2).Take(4)),
new ExpectedInclude<Level2>(x => x.OneToOne_Optional_FK2, "OneToMany_Optional1")));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Projecting_collection_with_FirstOrDefault(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,61 @@ FROM [LevelOne] AS [l]
ORDER BY [t].[Id], [l0].[Id]");
}

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

AssertSql(
@"@__p_0='5'

SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id]
FROM (
SELECT TOP(@__p_0) [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id]
FROM [LevelOne] AS [l]
ORDER BY [l].[Id]
) AS [t]
OUTER APPLY (
SELECT [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id]
FROM (
SELECT TOP(4) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id]
FROM [LevelTwo] AS [l1]
WHERE [t].[Id] = [l1].[OneToMany_Optional_Inverse2Id]
ORDER BY [l1].[Name] DESC
) AS [t1]
LEFT JOIN [LevelThree] AS [l0] ON [t1].[Id] = [l0].[Level2_Optional_Id]
) AS [t0]
ORDER BY [t].[Id], [t0].[Name] DESC, [t0].[Id], [t0].[Id0]");
}

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

AssertSql(
@"@__p_0='10'
@__p_1='5'

SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id]
FROM (
SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id]
FROM [LevelOne] AS [l]
ORDER BY [l].[Id] DESC
OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY
) AS [t]
OUTER APPLY (
SELECT [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id]
FROM (
SELECT [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id]
FROM [LevelTwo] AS [l1]
WHERE [t].[Id] = [l1].[OneToMany_Optional_Inverse2Id]
ORDER BY [l1].[Name] DESC
OFFSET 2 ROWS FETCH NEXT 4 ROWS ONLY
) AS [t1]
LEFT JOIN [LevelThree] AS [l0] ON [t1].[Id] = [l0].[Level2_Optional_Id]
) AS [t0]
ORDER BY [t].[Id] DESC, [t0].[Name] DESC, [t0].[Id], [t0].[Id0]");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,83 @@ public override async Task Filtered_include_calling_methods_directly_on_paramete
);
}

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

AssertSql(
@"@__p_0='5'

SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id]
FROM (
SELECT TOP(@__p_0) [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id]
FROM [LevelOne] AS [l]
ORDER BY [l].[Id]
) AS [t]
ORDER BY [t].[Id]",
//
@"@__p_0='5'

SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t].[Id]
FROM (
SELECT TOP(@__p_0) [l].[Id]
FROM [LevelOne] AS [l]
ORDER BY [l].[Id]
) AS [t]
CROSS APPLY (
SELECT [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id]
FROM (
SELECT TOP(4) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id]
FROM [LevelTwo] AS [l1]
WHERE [t].[Id] = [l1].[OneToMany_Optional_Inverse2Id]
ORDER BY [l1].[Name] DESC
) AS [t1]
LEFT JOIN [LevelThree] AS [l0] ON [t1].[Id] = [l0].[Level2_Optional_Id]
) AS [t0]
ORDER BY [t].[Id], [t0].[Name] DESC");
}

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

AssertSql(
@"@__p_0='10'
@__p_1='5'

SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id]
FROM (
SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id]
FROM [LevelOne] AS [l]
ORDER BY [l].[Id] DESC
OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY
) AS [t]
ORDER BY [t].[Id] DESC",
//
@"@__p_0='10'
@__p_1='5'

SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t].[Id]
FROM (
SELECT [l].[Id]
FROM [LevelOne] AS [l]
ORDER BY [l].[Id] DESC
OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY
) AS [t]
CROSS APPLY (
SELECT [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id]
FROM (
SELECT [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id]
FROM [LevelTwo] AS [l1]
WHERE [t].[Id] = [l1].[OneToMany_Optional_Inverse2Id]
ORDER BY [l1].[Name] DESC
OFFSET 2 ROWS FETCH NEXT 4 ROWS ONLY
) AS [t1]
LEFT JOIN [LevelThree] AS [l0] ON [t1].[Id] = [l0].[Level2_Optional_Id]
) AS [t0]
ORDER BY [t].[Id] DESC, [t0].[Name] DESC");
}

public override async Task Projecting_collection_with_FirstOrDefault(bool async)
{
await base.Projecting_collection_with_FirstOrDefault(async);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,17 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async)
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Skip_Take_Select_collection_Skip_Take(async))).Message);

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

public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)
=> Assert.Equal(
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async))).Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,17 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async)
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Skip_Take_Select_collection_Skip_Take(async))).Message);

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

public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)
=> Assert.Equal(
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async))).Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,17 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async)
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Skip_Take_Select_collection_Skip_Take(async))).Message);

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

public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)
=> Assert.Equal(
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async))).Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,17 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async)
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Skip_Take_Select_collection_Skip_Take(async))).Message);

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

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