Skip to content

Commit

Permalink
Add primitive collection regression test (#32330)
Browse files Browse the repository at this point in the history
  • Loading branch information
roji authored Nov 17, 2023
1 parent 54e0df0 commit f55b4a0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,14 @@ public virtual Task Project_collection_of_nullable_ints_with_distinct(bool async
assertOrder: true,
elementAsserter: (e, a) => AssertCollection(e, a, elementSorter: ee => ee));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Project_collection_of_ints_with_ToList_and_FirstOrDefault(bool async)
=> AssertFirstOrDefault(
async,
ss => ss.Set<PrimitiveCollectionsEntity>().OrderBy(x => x.Id).Select(x => x.Ints.ToList()),
asserter: (e, a) => AssertCollection(e, a, elementSorter: ee => ee));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Project_empty_collection_of_nullables_and_collection_only_containing_nulls(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,18 @@ public override async Task Project_collection_of_nullable_ints_with_distinct(boo
AssertSql("");
}

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

AssertSql(
"""
SELECT TOP(1) [p].[Ints]
FROM [PrimitiveCollectionsEntity] AS [p]
ORDER BY [p].[Id]
""");
}

public override Task Project_multiple_collections(bool async)
// we don't propagate error details from projection
=> AssertTranslationFailed(() => base.Project_multiple_collections(async));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,23 @@ public override async Task Project_collection_of_nullable_ints_with_distinct(boo
AssertSql("");
}

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

AssertSql(
"""
SELECT [t].[Id], CAST([i].[value] AS int) AS [value], [i].[key]
FROM (
SELECT TOP(1) [p].[Id], [p].[Ints]
FROM [PrimitiveCollectionsEntity] AS [p]
ORDER BY [p].[Id]
) AS [t]
OUTER APPLY OPENJSON([t].[Ints]) AS [i]
ORDER BY [t].[Id], CAST([i].[key] AS int)
""");
}

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

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

public override async Task Project_multiple_collections(bool async)
=> Assert.Equal(
SqliteStrings.ApplyNotSupported,
Expand Down

0 comments on commit f55b4a0

Please sign in to comment.