Skip to content

Commit

Permalink
Query: Add regression test for Contains on skip collection navigation (
Browse files Browse the repository at this point in the history
…#25578)

Resolves #24470
  • Loading branch information
smitpatel authored Aug 19, 2021
1 parent 9632814 commit fa90834
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,19 @@ from t in r.TwoSkip.Where(x => x.Id != r.Id).DefaultIfEmpty()
entryCount: 20);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Contains_on_skip_collection_navigation(bool async)
{
var two = new EntityTwo { Id = 1 };

return AssertQuery(
async,
ss => ss.Set<EntityOne>().Where(e => e.TwoSkip.Contains(two)),
ss => ss.Set<EntityOne>().Where(e => e.TwoSkip.Select(i => i.Id).Contains(two.Id)),
entryCount: 11);
}

// When adding include test here always add a tracking version and a split version in relational layer.
// Keep this line at the bottom for next dev writing tests to see.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,22 @@ FROM [JoinOneToTwo] AS [j]
) AS [t] ON ([e].[Id] = [t].[OneId]) AND ([e].[Id] <> [t].[Id])");
}

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

AssertSql(
@"@__entity_equality_two_0_Id='1' (Nullable = true)
SELECT [e].[Id], [e].[Name]
FROM [EntityOnes] AS [e]
WHERE EXISTS (
SELECT 1
FROM [JoinOneToTwo] AS [j]
INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id]
WHERE ([e].[Id] = [j].[OneId]) AND ([e0].[Id] = @__entity_equality_two_0_Id))");
}

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

0 comments on commit fa90834

Please sign in to comment.