From a0bb25fec68c07e7c123ffba28224548099f4ea9 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 6 Sep 2021 22:09:50 +0200 Subject: [PATCH] Add test for projected Contains(null) (#25893) Closes #19702 --- .../NorthwindAggregateOperatorsQueryCosmosTest.cs | 6 ++++++ .../Query/NorthwindAggregateOperatorsQueryTestBase.cs | 11 +++++++++++ .../NorthwindAggregateOperatorsQuerySqlServerTest.cs | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs index 09075a44b51..f96336902a4 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs @@ -1398,6 +1398,12 @@ public override Task Contains_over_entityType_with_null_should_rewrite_to_false( return base.Contains_over_entityType_with_null_should_rewrite_to_false(async); } + [ConditionalTheory(Skip = "Issue#17246 (Contains over subquery is not supported)")] + public override Task Contains_over_entityType_with_null_in_projection(bool async) + { + return base.Contains_over_entityType_with_null_in_projection(async); + } + public override async Task String_FirstOrDefault_in_projection_does_not_do_client_eval(bool async) { await base.String_FirstOrDefault_in_projection_does_not_do_client_eval(async); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs index 693fe96d132..3cf6a34a649 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs @@ -1579,6 +1579,17 @@ public virtual Task Contains_over_entityType_with_null_should_rewrite_to_identit ss => ss.Set().Where(o => ss.Set().Where(o => o.CustomerID == "VINET").Contains(null))); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Contains_over_entityType_with_null_in_projection(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Where( + o => ss.Set().Where(o => o.CustomerID == "VINET") + .Contains(null))); + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Contains_over_scalar_with_null_should_rewrite_to_identity_equality_subquery(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index b0d6857f651..61492642b27 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -1177,6 +1177,16 @@ FROM [Orders] AS [o] WHERE 0 = 1"); } + public override async Task Contains_over_entityType_with_null_in_projection(bool async) + { + await base.Contains_over_entityType_with_null_in_projection(async); + + AssertSql( + @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Orders] AS [o] +WHERE 0 = 1"); + } + public override async Task Contains_over_scalar_with_null_should_rewrite_to_identity_equality_subquery(bool async) { await base.Contains_over_scalar_with_null_should_rewrite_to_identity_equality_subquery(async);