From 8efb229634230453e218c6ebc40d5b529f3f1021 Mon Sep 17 00:00:00 2001 From: Maurycy Markowski Date: Thu, 7 Nov 2019 12:02:29 -0800 Subject: [PATCH] Fix to #15994 - Query: investigate suspicious SQL generated by query tests Many tests are not producing expected SQL, tracked remaining ones with relevant issues. Resolves #15994 --- .../Query/NullSemanticsQueryTestBase.cs | 36 ++- .../Query/SimpleQueryTestBase.cs | 4 +- .../Query/NullSemanticsQuerySqlServerTest.cs | 192 ++++++++++++--- .../SimpleQuerySqlServerTest.Functions.cs | 128 ++++++---- ...impleQuerySqlServerTest.ResultOperators.cs | 108 ++++----- .../Query/SimpleQuerySqlServerTest.Where.cs | 149 +++++------- .../Query/SimpleQuerySqlServerTest.cs | 227 +++++++++--------- .../SpatialQuerySqlServerGeographyTest.cs | 200 +++++++-------- .../SpatialQuerySqlServerGeometryTest.cs | 60 ++--- 9 files changed, 622 insertions(+), 482 deletions(-) diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs index 20cdea548b8..62f411c36da 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs @@ -826,6 +826,31 @@ public virtual void Null_semantics_applied_when_comparing_function_with_nullable useRelationalNulls: false); } + [ConditionalFact] + public virtual void Where_IndexOf_empty() + { + // issue #18773 + AssertQuery( + es => es.Where(e => e.NullableStringA.IndexOf("") == e.NullableIntA), + es => es.Where(e => 0 == e.NullableIntA), + useRelationalNulls: false); + } + + [ConditionalFact(Skip = "issue #18772")] + public virtual void Select_IndexOf() + { + using (var ctx = CreateContext()) + { + var query = ctx.Entities1.OrderBy(e => e.Id).Select(e => e.NullableStringA.IndexOf("oo")).ToList(); + var expected = _clientData._entities1.OrderBy(e => e.Id).Select(e => MaybeScalar(e.NullableStringA, () => e.NullableStringA.IndexOf("oo"))).ToList(); + + for (var i = 0; i < query.Count; i++) + { + Assert.Equal(expected[i], query[i]); + } + } + } + [ConditionalFact] public virtual void Null_semantics_applied_when_comparing_two_functions_with_nullable_arguments() { @@ -933,8 +958,8 @@ join e2 in ctx.Entities2 var result = query.ToList(); - var expected = (from e1 in ctx.Entities1.ToList() - join e2 in ctx.Entities2.ToList() + var expected = (from e1 in _clientData._entities1 + join e2 in _clientData._entities2 on new { one = e1.NullableStringA, @@ -950,6 +975,13 @@ join e2 in ctx.Entities2.ToList() select new { e1, e2 }).ToList(); Assert.Equal(result.Count, expected.Count); + var orderedResult = result.OrderBy(x => x.e1.Id).ThenBy(x => x.e2.Id).ToList(); + var orderedExpected = expected.OrderBy(x => x.e1.Id).ThenBy(x => x.e2.Id).ToList(); + for (var i = 0; i < orderedExpected.Count; i++) + { + Assert.Equal(orderedExpected[i].e1.Id, orderedResult[i].e1.Id); + Assert.Equal(orderedExpected[i].e2.Id, orderedResult[i].e2.Id); + } } } diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs index 434331fed24..5a923d4bb0c 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs @@ -267,7 +267,7 @@ public virtual void Shaper_command_caching_when_parameter_names_different() } } - [ConditionalFact] // See issue #12771 + [ConditionalFact] public virtual void Can_convert_manually_build_expression_with_default() { using (var context = CreateContext()) @@ -278,7 +278,7 @@ public virtual void Can_convert_manually_build_expression_with_default() Expression.NotEqual( Expression.Property( parameter, - "CustomerID"), + "City"), Expression.Default(typeof(string))), parameter); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index 27045a28f8e..7df4f60dcfe 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -871,17 +871,16 @@ public override void Where_equal_with_conditional() { base.Where_equal_with_conditional(); - // issue #15994 -// AssertSql( -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE (CASE -// WHEN ([e].[NullableStringA] = [e].[NullableStringB]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) -// THEN [e].[NullableStringA] ELSE [e].[NullableStringB] -//END = [e].[NullableStringC]) OR (CASE -// WHEN ([e].[NullableStringA] = [e].[NullableStringB]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) -// THEN [e].[NullableStringA] ELSE [e].[NullableStringB] -//END IS NULL AND [e].[NullableStringC] IS NULL)"); + AssertSql( + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE (CASE + WHEN ([e].[NullableStringA] = [e].[NullableStringB]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[NullableStringA] + ELSE [e].[NullableStringB] +END = [e].[NullableStringC]) OR (CASE + WHEN ([e].[NullableStringA] = [e].[NullableStringB]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[NullableStringA] + ELSE [e].[NullableStringB] +END IS NULL AND [e].[NullableStringC] IS NULL)"); } public override void Where_not_equal_with_conditional() @@ -1213,38 +1212,147 @@ public override void Null_semantics_applied_when_comparing_function_with_nullabl { base.Null_semantics_applied_when_comparing_function_with_nullable_argument_to_a_nullable_column(); - // issue #15994 -// AssertSql( -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE ((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) = [e].[NullableIntA]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableIntA] IS NULL)", -// // -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE ((CHARINDEX(N'ar', [e].[NullableStringA]) - 1) = [e].[NullableIntA]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableIntA] IS NULL)", -// // -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE (((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) <> [e].[NullableIntB]) OR ([e].[NullableStringA] IS NULL OR [e].[NullableIntB] IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL)"); + AssertSql( + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END = [e].[NullableIntA]) OR (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NULL AND [e].[NullableIntA] IS NULL)", + // + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE (CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringA]) - 1 +END = [e].[NullableIntA]) OR (CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringA]) - 1 +END IS NULL AND [e].[NullableIntA] IS NULL)", + // + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE ((CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END <> [e].[NullableIntB]) OR (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NULL OR [e].[NullableIntB] IS NULL)) AND (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NOT NULL OR [e].[NullableIntB] IS NOT NULL)"); + // issue #18773 + // AssertSql( + // @"SELECT [e].[Id] + //FROM [Entities1] AS [e] + //WHERE ((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) = [e].[NullableIntA]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableIntA] IS NULL)", + // // + // @"SELECT [e].[Id] + //FROM [Entities1] AS [e] + //WHERE ((CHARINDEX(N'ar', [e].[NullableStringA]) - 1) = [e].[NullableIntA]) OR ([e].[NullableStringA] IS NULL AND [e].[NullableIntA] IS NULL)", + // // + // @"SELECT [e].[Id] + //FROM [Entities1] AS [e] + //WHERE (((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) <> [e].[NullableIntB]) OR ([e].[NullableStringA] IS NULL OR [e].[NullableIntB] IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL)"); + } + + public override void Where_IndexOf_empty() + { + base.Where_IndexOf_empty(); + + AssertSql( + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE (CASE + WHEN N'' = N'' THEN 0 + ELSE CHARINDEX(N'', [e].[NullableStringA]) - 1 +END = [e].[NullableIntA]) OR (CASE + WHEN N'' = N'' THEN 0 + ELSE CHARINDEX(N'', [e].[NullableStringA]) - 1 +END IS NULL AND [e].[NullableIntA] IS NULL)"); } public override void Null_semantics_applied_when_comparing_two_functions_with_nullable_arguments() { base.Null_semantics_applied_when_comparing_two_functions_with_nullable_arguments(); - // issue #15994 -// AssertSql( -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE ((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) = (CHARINDEX(N'ar', [e].[NullableStringB]) - 1)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL)", -// // -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE (((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) <> (CHARINDEX(N'ar', [e].[NullableStringB]) - 1)) OR ([e].[NullableStringA] IS NULL OR [e].[NullableStringB] IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR [e].[NullableStringB] IS NOT NULL)", -// // -// @"SELECT [e].[Id] -//FROM [Entities1] AS [e] -//WHERE (((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) <> (CHARINDEX(N'ar', [e].[NullableStringA]) - 1)) OR [e].[NullableStringA] IS NULL) AND [e].[NullableStringA] IS NOT NULL"); + AssertSql( + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END = CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringB]) - 1 +END) OR (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NULL AND CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringB]) - 1 +END IS NULL)", + // + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE ((CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END <> CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringB]) - 1 +END) OR (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NULL OR CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringB]) - 1 +END IS NULL)) AND (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NOT NULL OR CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringB]) - 1 +END IS NOT NULL)", + // + @"SELECT [e].[Id] +FROM [Entities1] AS [e] +WHERE ((CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END <> CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringA]) - 1 +END) OR (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NULL OR CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringA]) - 1 +END IS NULL)) AND (CASE + WHEN N'oo' = N'' THEN 0 + ELSE CHARINDEX(N'oo', [e].[NullableStringA]) - 1 +END IS NOT NULL OR CASE + WHEN N'ar' = N'' THEN 0 + ELSE CHARINDEX(N'ar', [e].[NullableStringA]) - 1 +END IS NOT NULL)"); + // issue #18773 + // AssertSql( + // @"SELECT [e].[Id] + //FROM [Entities1] AS [e] + //WHERE ((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) = (CHARINDEX(N'ar', [e].[NullableStringB]) - 1)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL)", + // // + // @"SELECT [e].[Id] + //FROM [Entities1] AS [e] + //WHERE (((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) <> (CHARINDEX(N'ar', [e].[NullableStringB]) - 1)) OR ([e].[NullableStringA] IS NULL OR [e].[NullableStringB] IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR [e].[NullableStringB] IS NOT NULL)", + // // + // @"SELECT [e].[Id] + //FROM [Entities1] AS [e] + //WHERE (((CHARINDEX(N'oo', [e].[NullableStringA]) - 1) <> (CHARINDEX(N'ar', [e].[NullableStringA]) - 1)) OR [e].[NullableStringA] IS NULL) AND [e].[NullableStringA] IS NOT NULL"); } public override void Null_semantics_applied_when_comparing_two_functions_with_multiple_nullable_arguments() @@ -1333,9 +1441,13 @@ public override void Null_semantics_join_with_composite_key() { base.Null_semantics_join_with_composite_key(); - // issue #15994 - //AssertSql( - // @""); + AssertSql( + @"SELECT [e].[Id], [e].[BoolA], [e].[BoolB], [e].[BoolC], [e].[IntA], [e].[IntB], [e].[IntC], [e].[NullableBoolA], [e].[NullableBoolB], [e].[NullableBoolC], [e].[NullableIntA], [e].[NullableIntB], [e].[NullableIntC], [e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC], [e].[StringA], [e].[StringB], [e].[StringC], [e0].[Id], [e0].[BoolA], [e0].[BoolB], [e0].[BoolC], [e0].[IntA], [e0].[IntB], [e0].[IntC], [e0].[NullableBoolA], [e0].[NullableBoolB], [e0].[NullableBoolC], [e0].[NullableIntA], [e0].[NullableIntB], [e0].[NullableIntC], [e0].[NullableStringA], [e0].[NullableStringB], [e0].[NullableStringC], [e0].[StringA], [e0].[StringB], [e0].[StringC] +FROM [Entities1] AS [e] +INNER JOIN [Entities2] AS [e0] ON ((([e].[NullableStringA] = [e0].[NullableStringB]) OR ([e].[NullableStringA] IS NULL AND [e0].[NullableStringB] IS NULL)) AND (CASE + WHEN (([e].[NullableStringB] <> [e].[NullableStringC]) OR ([e].[NullableStringB] IS NULL OR [e].[NullableStringC] IS NULL)) AND ([e].[NullableStringB] IS NOT NULL OR [e].[NullableStringC] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = COALESCE([e0].[NullableBoolA], [e0].[BoolC]))) AND (CAST(1 AS bit) = CAST(1 AS bit))"); } public override void Null_semantics_contains() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs index 90ce7580a26..f393a4d26ae 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs @@ -98,11 +98,10 @@ await AssertQuery( ss => ss.Set().Where(c => c.ContactName.Contains("M") || c.ContactName.Contains("m")), // case-sensitive entryCount: 34); - // issue #15994 -// AssertSql( -// @"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 CHARINDEX(N'M', [c].[ContactName]) > 0"); + AssertSql( + @"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 CHARINDEX(N'M', [c].[ContactName]) > 0"); } public override async Task String_Contains_Identity(bool isAsync) @@ -145,7 +144,7 @@ public override async Task String_Compare_simple_zero(bool isAsync) { await base.String_Compare_simple_zero(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -176,7 +175,7 @@ public override async Task String_Compare_simple_one(bool isAsync) { await base.String_Compare_simple_one(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -207,7 +206,7 @@ public override async Task String_compare_with_parameter(bool isAsync) { await base.String_compare_with_parameter(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"@__customer_CustomerID_0='ALFKI' (Size = 4000) @@ -250,23 +249,37 @@ public override async Task String_Compare_simple_more_than_one(bool isAsync) { await base.String_Compare_simple_more_than_one(isAsync); - // issue #15994 -// AssertSql( -// @"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]", -// // -// @"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]", -// // -// @"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]"); + AssertSql( + @"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 CASE + WHEN [c].[CustomerID] = N'ALFKI' THEN 0 + WHEN [c].[CustomerID] > N'ALFKI' THEN 1 + WHEN [c].[CustomerID] < N'ALFKI' THEN -1 +END = 42", + // + @"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 CASE + WHEN [c].[CustomerID] = N'ALFKI' THEN 0 + WHEN [c].[CustomerID] > N'ALFKI' THEN 1 + WHEN [c].[CustomerID] < N'ALFKI' THEN -1 +END > 42", + // + @"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 42 > CASE + WHEN [c].[CustomerID] = N'ALFKI' THEN 0 + WHEN [c].[CustomerID] > N'ALFKI' THEN 1 + WHEN [c].[CustomerID] < N'ALFKI' THEN -1 +END"); } public override async Task String_Compare_nested(bool isAsync) { await base.String_Compare_nested(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -297,7 +310,7 @@ public override async Task String_Compare_multi_predicate(bool isAsync) { await base.String_Compare_multi_predicate(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -312,7 +325,7 @@ public override async Task String_Compare_to_simple_zero(bool isAsync) { await base.String_Compare_to_simple_zero(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -343,7 +356,7 @@ public override async Task String_Compare_to_simple_one(bool isAsync) { await base.String_Compare_to_simple_one(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -374,7 +387,7 @@ public override async Task String_compare_to_with_parameter(bool isAsync) { await base.String_compare_to_with_parameter(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"@__customer_CustomerID_0='ALFKI' (Size = 4000) @@ -417,23 +430,37 @@ public override async Task String_Compare_to_simple_more_than_one(bool isAsync) { await base.String_Compare_to_simple_more_than_one(isAsync); - // issue #15994 -// AssertSql( -// @"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]", -// // -// @"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]", -// // -// @"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]"); + AssertSql( + @"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 CASE + WHEN [c].[CustomerID] = N'ALFKI' THEN 0 + WHEN [c].[CustomerID] > N'ALFKI' THEN 1 + WHEN [c].[CustomerID] < N'ALFKI' THEN -1 +END = 42", + // + @"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 CASE + WHEN [c].[CustomerID] = N'ALFKI' THEN 0 + WHEN [c].[CustomerID] > N'ALFKI' THEN 1 + WHEN [c].[CustomerID] < N'ALFKI' THEN -1 +END > 42", + // + @"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 42 > CASE + WHEN [c].[CustomerID] = N'ALFKI' THEN 0 + WHEN [c].[CustomerID] > N'ALFKI' THEN 1 + WHEN [c].[CustomerID] < N'ALFKI' THEN -1 +END"); } public override async Task String_Compare_to_nested(bool isAsync) { await base.String_Compare_to_nested(isAsync); - //issue #15994 + //issue #16092 // AssertSql( // @"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] @@ -464,7 +491,7 @@ public override async Task String_Compare_to_multi_predicate(bool isAsync) { await base.String_Compare_to_multi_predicate(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"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] @@ -479,7 +506,7 @@ public override async Task DateTime_Compare_to_simple_zero(bool isAsync, bool co { await base.DateTime_Compare_to_simple_zero(isAsync, compareTo); - // issue #15994 + // issue #16092 // AssertSql( // @"@__myDatetime_0='1998-05-04T00:00:00' @@ -522,7 +549,7 @@ public override async Task Int_Compare_to_simple_zero(bool isAsync) { await base.Int_Compare_to_simple_zero(isAsync); - // issue #15994 + // issue #16092 // AssertSql( // @"@__orderId_0='10250' @@ -1164,33 +1191,30 @@ public override async Task Substring_with_zero_startindex(bool isAsync) { await base.Substring_with_zero_startindex(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT SUBSTRING([c].[ContactName], 1, 3) -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] = N'ALFKI'"); + AssertSql( + @"SELECT SUBSTRING([c].[ContactName], 0 + 1, 3) +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'"); } public override async Task Substring_with_zero_length(bool isAsync) { await base.Substring_with_zero_length(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT SUBSTRING([c].[ContactName], 3, 0) -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] = N'ALFKI'"); + AssertSql( + @"SELECT SUBSTRING([c].[ContactName], 2 + 1, 0) +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'"); } public override async Task Substring_with_constant(bool isAsync) { await base.Substring_with_constant(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT SUBSTRING([c].[ContactName], 2, 3) -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] = N'ALFKI'"); + AssertSql( + @"SELECT SUBSTRING([c].[ContactName], 1 + 1, 3) +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'"); } public override async Task Substring_with_closure(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs index 1041108f52c..34ad36db71c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs @@ -562,15 +562,13 @@ public override async Task FirstOrDefault_inside_subquery_gets_server_evaluated( { await base.FirstOrDefault_inside_subquery_gets_server_evaluated(isAsync); - // issue #15994 -// AssertSql( -// @"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'ALFKI') AND (( -// SELECT TOP(1) [o].[CustomerID] -// FROM [Orders] AS [o] -// WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[CustomerID] = N'ALFKI') -//) = N'ALFKI')"); + AssertSql( + @"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'ALFKI') AND (( + SELECT TOP(1) [o].[CustomerID] + FROM [Orders] AS [o] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[CustomerID] = N'ALFKI')) = N'ALFKI')"); } public override async Task Multiple_collection_navigation_with_FirstOrDefault_chained(bool isAsync) @@ -611,21 +609,22 @@ public override async Task Multiple_collection_navigation_with_FirstOrDefault_ch { await base.Multiple_collection_navigation_with_FirstOrDefault_chained_projecting_scalar(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT ( -// SELECT TOP(1) [od].[ProductID] -// FROM [Order Details] AS [od] -// WHERE [od].[OrderID] = COALESCE(( -// SELECT TOP(1) [o].[OrderID] -// FROM [Orders] AS [o] -// WHERE [c].[CustomerID] = [o].[CustomerID] -// ORDER BY [o].[OrderID] -// ), 0) -// ORDER BY [od].[ProductID] -//) -//FROM [Customers] AS [c] -//ORDER BY [c].[CustomerID]"); + AssertSql( + @"SELECT ( + SELECT TOP(1) [o].[ProductID] + FROM [Order Details] AS [o] + WHERE ( + SELECT TOP(1) [o0].[OrderID] + FROM [Orders] AS [o0] + WHERE [c].[CustomerID] = [o0].[CustomerID] + ORDER BY [o0].[OrderID]) IS NOT NULL AND (( + SELECT TOP(1) [o1].[OrderID] + FROM [Orders] AS [o1] + WHERE [c].[CustomerID] = [o1].[CustomerID] + ORDER BY [o1].[OrderID]) = [o].[OrderID]) + ORDER BY [o].[ProductID]) +FROM [Customers] AS [c] +ORDER BY [c].[CustomerID]"); } public override async Task First_inside_subquery_gets_client_evaluated(bool isAsync) @@ -872,11 +871,10 @@ public override async Task Contains_with_local_collection_false(bool isAsync) { await base.Contains_with_local_collection_false(isAsync); - // issue #15994 -// AssertSql( -// @"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] NOT IN (N'ABCDE', N'ALFKI')"); + AssertSql( + @"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] NOT IN (N'ABCDE', N'ALFKI')"); } public override async Task Contains_with_local_collection_complex_predicate_and(bool isAsync) @@ -893,33 +891,33 @@ public override async Task Contains_with_local_collection_complex_predicate_or(b { await base.Contains_with_local_collection_complex_predicate_or(isAsync); - // issue #15994 -// AssertSql( -// @"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] IN (N'ABCDE', N'ALFKI', N'ALFKI', N'ABCDE')"); + // issue #18791 + // AssertSql( + // @"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] IN (N'ABCDE', N'ALFKI', N'ALFKI', N'ABCDE')"); } public override async Task Contains_with_local_collection_complex_predicate_not_matching_ins1(bool isAsync) { await base.Contains_with_local_collection_complex_predicate_not_matching_ins1(isAsync); - // issue #15994 -// AssertSql( -// @"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] IN (N'ALFKI', N'ABCDE') OR [c].[CustomerID] NOT IN (N'ABCDE', N'ALFKI')"); + // issue #18791 + // AssertSql( + // @"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] IN (N'ALFKI', N'ABCDE') OR [c].[CustomerID] NOT IN (N'ABCDE', N'ALFKI')"); } public override async Task Contains_with_local_collection_complex_predicate_not_matching_ins2(bool isAsync) { await base.Contains_with_local_collection_complex_predicate_not_matching_ins2(isAsync); - // issue #15944 -// AssertSql( -// @"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] IN (N'ABCDE', N'ALFKI') AND [c].[CustomerID] NOT IN (N'ALFKI', N'ABCDE')"); + // issue #18791 + // AssertSql( + // @"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] IN (N'ABCDE', N'ALFKI') AND [c].[CustomerID] NOT IN (N'ALFKI', N'ABCDE')"); } public override async Task Contains_with_local_collection_sql_injection(bool isAsync) @@ -956,17 +954,17 @@ public override async Task Contains_top_level(bool isAsync) { await base.Contains_top_level(isAsync); - // issue #15994 -// AssertSql( -// @"@__p_0='ALFKI' (Size = 4000) - -//SELECT CASE -// WHEN @__p_0 IN ( -// SELECT [c].[CustomerID] -// FROM [Customers] AS [c] -// ) -// THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -//END"); + AssertSql( + @"@__p_0='ALFKI' (Size = 4000) + +SELECT CASE + WHEN @__p_0 IN ( + SELECT [c].[CustomerID] + FROM [Customers] AS [c] + ) + THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END"); } public override async Task Contains_with_local_anonymous_type_array_closure(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs index 263bc97b6c6..5d7edc058ac 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs @@ -451,15 +451,16 @@ public override async Task Where_shadow_subquery_FirstOrDefault(bool isAsync) { await base.Where_shadow_subquery_FirstOrDefault(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] -//FROM [Employees] AS [e] -//WHERE [e].[Title] = ( -// SELECT TOP(1) [e2].[Title] -// FROM [Employees] AS [e2] -// ORDER BY [e2].[Title] -//)"); + AssertSql( + @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] +FROM [Employees] AS [e] +WHERE ([e].[Title] = ( + SELECT TOP(1) [e0].[Title] + FROM [Employees] AS [e0] + ORDER BY [e0].[Title])) OR ([e].[Title] IS NULL AND ( + SELECT TOP(1) [e0].[Title] + FROM [Employees] AS [e0] + ORDER BY [e0].[Title]) IS NULL)"); } public override async Task Where_subquery_correlated(bool isAsync) @@ -690,26 +691,24 @@ public override async Task Where_datetime_now(bool isAsync) { await base.Where_datetime_now(isAsync); - // issue #15994 -// AssertSql( -// @"@__myDatetime_0='2015-04-10T00:00:00' + AssertSql( + @"@__myDatetime_0='2015-04-10T00:00:00' -//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 GETDATE() <> @__myDatetime_0"); +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 (GETDATE() <> @__myDatetime_0) OR GETDATE() IS NULL"); } public override async Task Where_datetime_utcnow(bool isAsync) { await base.Where_datetime_utcnow(isAsync); - // issue #15994 -// AssertSql( -// @"@__myDatetime_0='2015-04-10T00:00:00' + AssertSql( + @"@__myDatetime_0='2015-04-10T00:00:00' -//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 GETUTCDATE() <> @__myDatetime_0"); +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 (GETUTCDATE() <> @__myDatetime_0) OR GETUTCDATE() IS NULL"); } public override async Task Where_datetime_today(bool isAsync) @@ -828,22 +827,20 @@ public override async Task Where_datetimeoffset_now_component(bool isAsync) { await base.Where_datetimeoffset_now_component(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -//FROM [Orders] AS [o] -//WHERE [o].[OrderDate] = SYSDATETIMEOFFSET()"); + AssertSql( + @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Orders] AS [o] +WHERE (CAST([o].[OrderDate] AS datetimeoffset) = SYSDATETIMEOFFSET()) OR ([o].[OrderDate] IS NULL AND SYSDATETIMEOFFSET() IS NULL)"); } public override async Task Where_datetimeoffset_utcnow_component(bool isAsync) { await base.Where_datetimeoffset_utcnow_component(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -//FROM [Orders] AS [o] -//WHERE [o].[OrderDate] = CAST(SYSUTCDATETIME() AS datetimeoffset)"); + AssertSql( + @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Orders] AS [o] +WHERE (CAST([o].[OrderDate] AS datetimeoffset) = CAST(SYSUTCDATETIME() AS datetimeoffset)) OR ([o].[OrderDate] IS NULL AND SYSUTCDATETIME() IS NULL)"); } public override async Task Where_simple_reversed(bool isAsync) @@ -1019,23 +1016,12 @@ public override async Task Where_bool_member_false(bool isAsync) { await base.Where_bool_member_false(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -//FROM [Products] AS [p] -//WHERE [p].[Discontinued] = CAST(0 AS bit)"); + AssertSql( + @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] +FROM [Products] AS [p] +WHERE [p].[Discontinued] <> CAST(1 AS bit)"); } - // public override async Task Where_bool_client_side_negated(bool isAsync) - // { - // await base.Where_bool_client_side_negated(isAsync); - - // AssertSql( - // @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] - //FROM [Products] AS [p] - //WHERE [p].[Discontinued] = 1"); - // } - public override async Task Where_bool_member_negated_twice(bool isAsync) { await base.Where_bool_member_negated_twice(isAsync); @@ -1367,53 +1353,42 @@ public override async Task Where_ternary_boolean_condition_false(bool isAsync) { await base.Where_ternary_boolean_condition_false(isAsync); - // issue #15994 -// AssertSql( -// @"@__flag_0='False' - -//SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -//FROM [Products] AS [p] -//WHERE ((@__flag_0 = CAST(1 AS bit)) AND ([p].[UnitsInStock] >= CAST(20 AS smallint))) OR ((@__flag_0 <> CAST(1 AS bit)) AND ([p].[UnitsInStock] < CAST(20 AS smallint)))"); + AssertSql( + @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] +FROM [Products] AS [p] +WHERE [p].[UnitsInStock] < CAST(20 AS smallint)"); } public override async Task Where_ternary_boolean_condition_with_another_condition(bool isAsync) { await base.Where_ternary_boolean_condition_with_another_condition(isAsync); - // issue #15994 -// AssertSql( -// @"@__productId_0='15' -//@__flag_1='True' + AssertSql( + @"@__productId_0='15' -//SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -//FROM [Products] AS [p] -//WHERE ([p].[ProductID] < @__productId_0) AND (((@__flag_1 = CAST(1 AS bit)) AND ([p].[UnitsInStock] >= CAST(20 AS smallint))) OR ((@__flag_1 <> CAST(1 AS bit)) AND ([p].[UnitsInStock] < CAST(20 AS smallint))))"); +SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] +FROM [Products] AS [p] +WHERE ([p].[ProductID] < @__productId_0) AND ([p].[UnitsInStock] >= CAST(20 AS smallint))"); } public override async Task Where_ternary_boolean_condition_with_false_as_result_true(bool isAsync) { await base.Where_ternary_boolean_condition_with_false_as_result_true(isAsync); - // issue #15994 -// AssertSql( -// @"@__flag_0='True' - -//SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -//FROM [Products] AS [p] -//WHERE (@__flag_0 = CAST(1 AS bit)) AND ([p].[UnitsInStock] >= CAST(20 AS smallint))"); + AssertSql( + @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] +FROM [Products] AS [p] +WHERE [p].[UnitsInStock] >= CAST(20 AS smallint)"); } public override async Task Where_ternary_boolean_condition_with_false_as_result_false(bool isAsync) { await base.Where_ternary_boolean_condition_with_false_as_result_false(isAsync); - // issue #15994 -// AssertSql( -// @"@__flag_0='False' - -//SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -//FROM [Products] AS [p] -//WHERE (@__flag_0 = CAST(1 AS bit)) AND ([p].[UnitsInStock] >= CAST(20 AS smallint))"); + AssertSql( + @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] +FROM [Products] AS [p] +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Where_compare_constructed_equal(bool isAsync) @@ -1584,19 +1559,19 @@ public override async Task Where_multiple_contains_in_subquery_with_or(bool isAs { await base.Where_multiple_contains_in_subquery_with_or(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -//FROM [Order Details] AS [od] -//WHERE [od].[ProductID] IN ( -// SELECT TOP(1) [p].[ProductID] -// FROM [Products] AS [p] -// ORDER BY [p].[ProductID] -//) OR [od].[OrderID] IN ( -// SELECT TOP(1) [o].[OrderID] -// FROM [Orders] AS [o] -// ORDER BY [o].[OrderID] -//)"); + AssertSql( + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE [o].[ProductID] IN ( + SELECT TOP(1) [p].[ProductID] + FROM [Products] AS [p] + ORDER BY [p].[ProductID] +) + OR [o].[OrderID] IN ( + SELECT TOP(1) [o0].[OrderID] + FROM [Orders] AS [o0] + ORDER BY [o0].[OrderID] +)"); } public override async Task Where_multiple_contains_in_subquery_with_and(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs index 06906ffd802..dce5ea7fc06 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs @@ -40,15 +40,14 @@ public override void Can_convert_manually_build_expression_with_default() { base.Can_convert_manually_build_expression_with_default(); - // issue #15994 -// AssertSql( -// @"SELECT COUNT(*) -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] IS NOT NULL", -// // -// @"SELECT COUNT(*) -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] IS NOT NULL"); + AssertSql( + @"SELECT COUNT(*) +FROM [Customers] AS [c] +WHERE [c].[City] IS NOT NULL", + // + @"SELECT COUNT(*) +FROM [Customers] AS [c] +WHERE [c].[City] IS NOT NULL"); } public override void Lifting_when_subquery_nested_order_by_anonymous() @@ -252,22 +251,18 @@ public override async Task Entity_equality_not_null(bool isAsync) { await base.Entity_equality_not_null(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [c].[CustomerID] -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] IS NOT NULL"); + AssertSql( + @"SELECT [c].[CustomerID] +FROM [Customers] AS [c]"); } public override async Task Entity_equality_not_null_composite_key(bool isAsync) { await base.Entity_equality_not_null_composite_key(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [o].[ProductID] -//FROM [Order Details] AS [o] -//WHERE CAST(1 AS bit) = CAST(1 AS bit)"); + AssertSql( + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o]"); } public override async Task Entity_equality_through_nested_anonymous_type_projection(bool isAsync) @@ -430,15 +425,16 @@ public override async Task Where_query_composition(bool isAsync) { await base.Where_query_composition(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [e1].[EmployeeID], [e1].[City], [e1].[Country], [e1].[FirstName], [e1].[ReportsTo], [e1].[Title] -//FROM [Employees] AS [e1] -//WHERE [e1].[FirstName] = ( -// SELECT TOP(1) [e].[FirstName] -// FROM [Employees] AS [e] -// ORDER BY [e].[EmployeeID] -//)"); + AssertSql( + @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] +FROM [Employees] AS [e] +WHERE ([e].[FirstName] = ( + SELECT TOP(1) [e0].[FirstName] + FROM [Employees] AS [e0] + ORDER BY [e0].[EmployeeID])) OR ([e].[FirstName] IS NULL AND ( + SELECT TOP(1) [e0].[FirstName] + FROM [Employees] AS [e0] + ORDER BY [e0].[EmployeeID]) IS NULL)"); } public override async Task Where_query_composition_is_null(bool isAsync) @@ -664,40 +660,42 @@ public override async Task Where_query_composition2_FirstOrDefault(bool isAsync) { await base.Where_query_composition2_FirstOrDefault(isAsync); - // issue #15994 -// AssertSql( -// @"@__p_0='3' + AssertSql( + @"@__p_0='3' -//SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] -//FROM ( -// SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] -// FROM [Employees] AS [e] -//) AS [t] -//WHERE [t].[FirstName] = ( -// SELECT TOP(1) [e0].[FirstName] -// FROM [Employees] AS [e0] -// ORDER BY [e0].[EmployeeID] -//)"); +SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] +FROM ( + SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + FROM [Employees] AS [e] +) AS [t] +WHERE ([t].[FirstName] = ( + SELECT TOP(1) [e0].[FirstName] + FROM [Employees] AS [e0] + ORDER BY [e0].[EmployeeID])) OR ([t].[FirstName] IS NULL AND ( + SELECT TOP(1) [e0].[FirstName] + FROM [Employees] AS [e0] + ORDER BY [e0].[EmployeeID]) IS NULL)"); } public override async Task Where_query_composition2_FirstOrDefault_with_anonymous(bool isAsync) { await base.Where_query_composition2_FirstOrDefault_with_anonymous(isAsync); - // issue #15994 -// AssertSql( -// @"@__p_0='3' + AssertSql( + @"@__p_0='3' -//SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] -//FROM ( -// SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] -// FROM [Employees] AS [e] -//) AS [t] -//WHERE [t].[FirstName] = ( -// SELECT TOP(1) [e0].[FirstName] -// FROM [Employees] AS [e0] -// ORDER BY [e0].[EmployeeID] -//)"); +SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] +FROM ( + SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + FROM [Employees] AS [e] +) AS [t] +WHERE ([t].[FirstName] = ( + SELECT TOP(1) [e0].[FirstName] + FROM [Employees] AS [e0] + ORDER BY [e0].[EmployeeID])) OR ([t].[FirstName] IS NULL AND ( + SELECT TOP(1) [e0].[FirstName] + FROM [Employees] AS [e0] + ORDER BY [e0].[EmployeeID]) IS NULL)"); } public override void Select_Subquery_Single() @@ -913,14 +911,14 @@ public override async Task OrderBy_ternary_conditions(bool isAsync) { await base.OrderBy_ternary_conditions(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -//FROM [Products] AS [p] -//ORDER BY CASE -// WHEN (([p].[UnitsInStock] > CAST(10 AS smallint)) AND ([p].[ProductID] > 40)) OR (([p].[UnitsInStock] <= CAST(10 AS smallint)) AND ([p].[ProductID] <= 40)) -// THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -//END, [p].[ProductID]"); + // issue #18774 + // AssertSql( + // @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] + //FROM [Products] AS [p] + //ORDER BY CASE + // WHEN (([p].[UnitsInStock] > CAST(10 AS smallint)) AND ([p].[ProductID] > 40)) OR (([p].[UnitsInStock] <= CAST(10 AS smallint)) AND ([p].[ProductID] <= 40)) + // THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + //END, [p].[ProductID]"); } public override void OrderBy_any() @@ -1421,15 +1419,14 @@ public override async Task All_top_level(bool isAsync) { await base.All_top_level(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT CASE -// WHEN NOT EXISTS ( -// SELECT 1 -// FROM [Customers] AS [c] -// WHERE NOT ([c].[ContactName] LIKE N'A%')) -// THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -//END"); + AssertSql( + @"SELECT CASE + WHEN NOT EXISTS ( + SELECT 1 + FROM [Customers] AS [c] + WHERE [c].[ContactName] IS NULL OR NOT ([c].[ContactName] LIKE N'A%')) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END"); } public override async Task All_top_level_column(bool isAsync) @@ -2334,16 +2331,15 @@ public override void Select_DTO_with_member_init_distinct_in_subquery_used_in_pr { base.Select_DTO_with_member_init_distinct_in_subquery_used_in_projection_translated_to_server(); - // issue #15994 -// AssertSql( -// @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t].[Id], [t].[Count] -//FROM [Customers] AS [c] -//CROSS JOIN ( -// SELECT DISTINCT [o].[CustomerID] AS [Id], [o].[OrderID] AS [Count] -// FROM [Orders] AS [o] -// WHERE [o].[OrderID] < 10300 -//) AS [t] -//WHERE [c].[CustomerID] LIKE N'A%'"); + AssertSql( + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t].[CustomerID] AS [Id], [t].[OrderID] AS [Count] +FROM [Customers] AS [c] +CROSS JOIN ( + SELECT DISTINCT [o].[CustomerID], [o].[OrderID] + FROM [Orders] AS [o] + WHERE [o].[OrderID] < 10300 +) AS [t] +WHERE [c].[CustomerID] LIKE N'A%'"); } public override async Task Select_correlated_subquery_projection(bool isAsync) @@ -3786,11 +3782,11 @@ public override async Task DTO_complex_orderby(bool isAsync) { await base.DTO_complex_orderby(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [c].[CustomerID] + [c].[City] AS [Property] -//FROM [Customers] AS [c] -//ORDER BY [Property]"); + // issue #18775 + // AssertSql( + // @"SELECT [c].[CustomerID] + [c].[City] AS [Property] + //FROM [Customers] AS [c] + //ORDER BY [Property]"); } public override async Task DTO_subquery_orderby(bool isAsync) @@ -4291,11 +4287,10 @@ public override async Task Comparing_collection_navigation_to_null(bool isAsync) { await base.Comparing_collection_navigation_to_null(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [c].[CustomerID] -//FROM [Customers] AS [c] -//WHERE [c].[CustomerID] IS NULL"); + AssertSql( + @"SELECT [c].[CustomerID] +FROM [Customers] AS [c] +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Comparing_collection_navigation_to_null_complex(bool isAsync) @@ -4347,14 +4342,13 @@ public override async Task Compare_two_collection_navigations_with_different_pro { await base.Compare_two_collection_navigations_with_different_property_chains(isAsync); - // issue #15994 -// AssertSql( -// @"SELECT [c].[CustomerID] AS [Id1], [o].[OrderID] AS [Id2] -//FROM [Customers] AS [c] -//CROSS JOIN [Orders] AS [o] -//LEFT JOIN [Customers] AS [join.Customer] ON [o].[CustomerID] = [join.Customer].[CustomerID] -//WHERE ([c].[CustomerID] = N'ALFKI') AND ([c].[CustomerID] = [join.Customer].[CustomerID]) -//ORDER BY [Id1], [Id2]"); + AssertSql( + @"SELECT [c].[CustomerID] AS [Id1], [o].[OrderID] AS [Id2] +FROM [Customers] AS [c] +CROSS JOIN [Orders] AS [o] +LEFT JOIN [Customers] AS [c0] ON [o].[CustomerID] = [c0].[CustomerID] +WHERE ([c].[CustomerID] = N'ALFKI') AND ([c].[CustomerID] = [c0].[CustomerID]) +ORDER BY [c].[CustomerID], [o].[OrderID]"); } public override async Task OrderBy_ThenBy_same_column_different_direction(bool isAsync) @@ -4590,21 +4584,26 @@ public override async Task Collection_navigation_equality_rewrite_for_subquery(b { await base.Collection_navigation_equality_rewrite_for_subquery(isAsync); - // issue #15994 -// AssertSql( -// @"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] LIKE N'A%' AND (( -// SELECT TOP(1) [o].[OrderID] -// FROM [Orders] AS [o] -// WHERE [o].[OrderID] < 10300 -// ORDER BY [o].[OrderID] -//) = ( -// SELECT TOP(1) [o0].[OrderID] -// FROM [Orders] AS [o0] -// WHERE [o0].[OrderID] > 10500 -// ORDER BY [o0].[OrderID] -//))"); + AssertSql( + @"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] LIKE N'A%') AND ((( + SELECT TOP(1) [o].[OrderID] + FROM [Orders] AS [o] + WHERE [o].[OrderID] < 10300 + ORDER BY [o].[OrderID]) = ( + SELECT TOP(1) [o0].[OrderID] + FROM [Orders] AS [o0] + WHERE [o0].[OrderID] > 10500 + ORDER BY [o0].[OrderID])) OR (( + SELECT TOP(1) [o].[OrderID] + FROM [Orders] AS [o] + WHERE [o].[OrderID] < 10300 + ORDER BY [o].[OrderID]) IS NULL AND ( + SELECT TOP(1) [o0].[OrderID] + FROM [Orders] AS [o0] + WHERE [o0].[OrderID] > 10500 + ORDER BY [o0].[OrderID]) IS NULL))"); } public override async Task Inner_parameter_in_nested_lambdas_gets_preserved(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs index d8e9c687da7..61624b4ed18 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs @@ -50,20 +50,20 @@ public override async Task AsBinary(bool isAsync) { await base.AsBinary(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] - //FROM [PointEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] +//FROM [PointEntity] AS [e]"); } public override async Task AsText(bool isAsync) { await base.AsText(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] - //FROM [PointEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] +//FROM [PointEntity] AS [e]"); } // No SqlServer Translation @@ -76,10 +76,10 @@ public override async Task Buffer(bool isAsync) { await base.Buffer(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] - //FROM [PolygonEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] +//FROM [PolygonEntity] AS [e]"); } // No SqlServer Translation @@ -98,22 +98,22 @@ public override async Task Contains(bool isAsync) { await base.Contains(isAsync); - // issue #15994 - // AssertSql( - // @"@__point_0='0xE6100000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Binary) + // issue #16050 +// AssertSql( +// @"@__point_0='0xE6100000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Binary) - //SELECT [e].[Id], [e].[Polygon].STContains(@__point_0) AS [Contains] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STContains(@__point_0) AS [Contains] +//FROM [PolygonEntity] AS [e]"); } public override async Task ConvexHull(bool isAsync) { await base.ConvexHull(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] - //FROM [PolygonEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] +//FROM [PolygonEntity] AS [e]"); } public override async Task IGeometryCollection_Count(bool isAsync) @@ -156,12 +156,12 @@ public override async Task Difference(bool isAsync) { await base.Difference(isAsync); - // issue #15994 - // AssertSql( - // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) - //SELECT [e].[Id], [e].[Polygon].STDifference(@__polygon_0) AS [Difference] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STDifference(@__polygon_0) AS [Difference] +//FROM [PolygonEntity] AS [e]"); } public override async Task Dimension(bool isAsync) @@ -177,36 +177,36 @@ public override async Task Disjoint(bool isAsync) { await base.Disjoint(isAsync); - // issue #15994 - // AssertSql( - // @"@__point_0='0xE6100000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Binary) + // issue #16050 +// AssertSql( +// @"@__point_0='0xE6100000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Binary) - //SELECT [e].[Id], [e].[Polygon].STDisjoint(@__point_0) AS [Disjoint] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STDisjoint(@__point_0) AS [Disjoint] +//FROM [PolygonEntity] AS [e]"); } public override async Task Distance(bool isAsync) { await base.Distance(isAsync); - // issue #15994 - // AssertSql( - // @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // issue #16050 +// AssertSql( +// @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) - //SELECT [e].[Id], [e].[Point].STDistance(@__point_0) AS [Distance] - //FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], [e].[Point].STDistance(@__point_0) AS [Distance] +//FROM [PointEntity] AS [e]"); } public override async Task Distance_geometry(bool isAsync) { await base.Distance_geometry(isAsync); - // issue #15994 - // AssertSql( - // @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // issue #16050 +// AssertSql( +// @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) - //SELECT [e].[Id], [e].[Geometry].STDistance(@__point_0) AS [Distance] - //FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], [e].[Geometry].STDistance(@__point_0) AS [Distance] +//FROM [PointEntity] AS [e]"); } // Mixing SRIDs not supported @@ -219,10 +219,10 @@ public override async Task Distance_constant_srid_4326(bool isAsync) { await base.Distance_constant_srid_4326(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Point].STDistance('POINT (1 1)') AS [Distance] - //FROM [PointEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STDistance('POINT (1 1)') AS [Distance] +//FROM [PointEntity] AS [e]"); } // Mixing SRIDs not supported @@ -284,12 +284,12 @@ public override async Task EqualsTopologically(bool isAsync) { await base.EqualsTopologically(isAsync); - // issue #15994 - // AssertSql( - // @"@__point_0='0xE6100000010C00000000000000000000000000000000' (Size = 22) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__point_0='0xE6100000010C00000000000000000000000000000000' (Size = 22) (DbType = Object) - //SELECT [e].[Id], [e].[Point].STEquals(@__point_0) AS [EqualsTopologically] - //FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], [e].[Point].STEquals(@__point_0) AS [EqualsTopologically] +//FROM [PointEntity] AS [e]"); } public override async Task ExteriorRing(bool isAsync) @@ -314,10 +314,10 @@ public override async Task GetGeometryN(bool isAsync) { await base.GetGeometryN(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] - //FROM [MultiLineStringEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] +//FROM [MultiLineStringEntity] AS [e]"); } public override async Task GetInteriorRingN(bool isAsync) @@ -336,10 +336,10 @@ public override async Task GetPointN(bool isAsync) { await base.GetPointN(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] - //FROM [LineStringEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] +//FROM [LineStringEntity] AS [e]"); } // No SqlServer Translation @@ -352,24 +352,24 @@ public override async Task Intersection(bool isAsync) { await base.Intersection(isAsync); - // issue #15994 - // AssertSql( - // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) - //SELECT [e].[Id], [e].[Polygon].STIntersection(@__polygon_0) AS [Intersection] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STIntersection(@__polygon_0) AS [Intersection] +//FROM [PolygonEntity] AS [e]"); } public override async Task Intersects(bool isAsync) { await base.Intersects(isAsync); - // issue #15994 - // AssertSql( - // @"@__lineString_0='0xE61000000114000000000000E0BF000000000000E03F000000000000E03F0000...' (Size = 38) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__lineString_0='0xE61000000114000000000000E0BF000000000000E03F000000000000E03F0000...' (Size = 38) (DbType = Object) - //SELECT [e].[Id], [e].[LineString].STIntersects(@__lineString_0) AS [Intersects] - //FROM [LineStringEntity] AS [e]"); +//SELECT [e].[Id], [e].[LineString].STIntersects(@__lineString_0) AS [Intersects] +//FROM [LineStringEntity] AS [e]"); } public override async Task ICurve_IsClosed(bool isAsync) @@ -441,10 +441,10 @@ public override async Task Item(bool isAsync) { await base.Item(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] - //FROM [MultiLineStringEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] +//FROM [MultiLineStringEntity] AS [e]"); } public override async Task Length(bool isAsync) @@ -517,12 +517,12 @@ public override async Task Overlaps(bool isAsync) { await base.Overlaps(isAsync); - // issue #15994 - // AssertSql( - // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) - //SELECT [e].[Id], [e].[Polygon].STOverlaps(@__polygon_0) AS [Overlaps] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STOverlaps(@__polygon_0) AS [Overlaps] +//FROM [PolygonEntity] AS [e]"); } // No SqlServer Translation @@ -574,32 +574,32 @@ public override async Task SymmetricDifference(bool isAsync) { await base.SymmetricDifference(isAsync); - // issue #15994 - // AssertSql( - // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) - //SELECT [e].[Id], [e].[Polygon].STSymDifference(@__polygon_0) AS [SymmetricDifference] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STSymDifference(@__polygon_0) AS [SymmetricDifference] +//FROM [PolygonEntity] AS [e]"); } public override async Task ToBinary(bool isAsync) { await base.ToBinary(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] - //FROM [PointEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] +//FROM [PointEntity] AS [e]"); } public override async Task ToText(bool isAsync) { await base.ToText(isAsync); - // issue #15994 - // AssertSql( - // @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] - //FROM [PointEntity] AS [e]"); + // issue #16050 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] +//FROM [PointEntity] AS [e]"); } // No SqlServer Translation @@ -612,12 +612,12 @@ public override async Task Union(bool isAsync) { await base.Union(isAsync); - // issue #15994 - // AssertSql( - // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) - //SELECT [e].[Id], [e].[Polygon].STUnion(@__polygon_0) AS [Union] - //FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STUnion(@__polygon_0) AS [Union] +//FROM [PolygonEntity] AS [e]"); } // No SqlServer Translation @@ -630,12 +630,12 @@ public override async Task Within(bool isAsync) { await base.Within(isAsync); - // issue #15994 - // AssertSql( - // @"@__polygon_0='0xE6100000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Object) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0xE6100000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Object) - //SELECT [e].[Id], [e].[Point].STWithin(@__polygon_0) AS [Within] - //FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], [e].[Point].STWithin(@__polygon_0) AS [Within] +//FROM [PointEntity] AS [e]"); } public override async Task X(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs index a2f9f4ae20f..451c6bff0b0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs @@ -50,7 +50,7 @@ public override async Task AsBinary(bool isAsync) { await base.AsBinary(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] //FROM [PointEntity] AS [e]"); @@ -60,7 +60,7 @@ public override async Task AsText(bool isAsync) { await base.AsText(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] //FROM [PointEntity] AS [e]"); @@ -79,7 +79,7 @@ public override async Task Buffer(bool isAsync) { await base.Buffer(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] //FROM [PolygonEntity] AS [e]"); @@ -104,7 +104,7 @@ public override async Task Contains(bool isAsync) { await base.Contains(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Object) @@ -116,7 +116,7 @@ public override async Task ConvexHull(bool isAsync) { await base.ConvexHull(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] //FROM [PolygonEntity] AS [e]"); @@ -156,7 +156,7 @@ public override async Task Crosses(bool isAsync) { await base.Crosses(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__lineString_0='0x000000000114000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 38) (DbType = Object) @@ -168,7 +168,7 @@ public override async Task Difference(bool isAsync) { await base.Difference(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) @@ -180,7 +180,7 @@ public override async Task Distance_on_converted_geometry_type(bool isAsync) { await base.Distance_on_converted_geometry_type(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C000000000000F03F0000000000000000' (Nullable = false) (Size = 22) (DbType = Object) @@ -192,7 +192,7 @@ public override async Task Distance_on_converted_geometry_type_lhs(bool isAsync) { await base.Distance_on_converted_geometry_type_lhs(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C000000000000F03F0000000000000000' (Nullable = false) (Size = 22) (DbType = Object) @@ -222,7 +222,7 @@ public override async Task Distance_constant(bool isAsync) { await base.Distance_constant(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Point].STDistance('POINT (0 1)') AS [Distance] //FROM [PointEntity] AS [e]"); @@ -241,7 +241,7 @@ await AssertQuery( Assert.Null(a.Distance); }); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Point].STDistance(geometry::STGeomFromText('POINT (1 1)', 4326)) AS [Distance] //FROM [PointEntity] AS [e]"); @@ -251,7 +251,7 @@ public override async Task Distance_constant_lhs(bool isAsync) { await base.Distance_constant_lhs(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], geometry::Parse('POINT (0 1)').STDistance([e].[Point]) AS [Distance] //FROM [PointEntity] AS [e]"); @@ -270,7 +270,7 @@ public override async Task Disjoint(bool isAsync) { await base.Disjoint(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Object) @@ -282,7 +282,7 @@ public override async Task Distance(bool isAsync) { await base.Distance(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Object) @@ -294,7 +294,7 @@ public override async Task Distance_geometry(bool isAsync) { await base.Distance_geometry(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Object) @@ -324,7 +324,7 @@ public override async Task EqualsTopologically(bool isAsync) { await base.EqualsTopologically(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C00000000000000000000000000000000' (Size = 22) (DbType = Object) @@ -354,7 +354,7 @@ public override async Task GetGeometryN(bool isAsync) { await base.GetGeometryN(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] //FROM [MultiLineStringEntity] AS [e]"); @@ -376,7 +376,7 @@ public override async Task GetPointN(bool isAsync) { await base.GetPointN(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] //FROM [LineStringEntity] AS [e]"); @@ -395,7 +395,7 @@ public override async Task Intersection(bool isAsync) { await base.Intersection(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) @@ -407,7 +407,7 @@ public override async Task Intersects(bool isAsync) { await base.Intersects(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__lineString_0='0x000000000114000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 38) (DbType = Object) @@ -473,7 +473,7 @@ public override async Task IsWithinDistance(bool isAsync) { await base.IsWithinDistance(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Object) @@ -488,7 +488,7 @@ public override async Task Item(bool isAsync) { await base.Item(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] //FROM [MultiLineStringEntity] AS [e]"); @@ -563,7 +563,7 @@ public override async Task Overlaps(bool isAsync) { await base.Overlaps(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) @@ -584,7 +584,7 @@ public override async Task Relate(bool isAsync) { await base.Relate(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) @@ -629,7 +629,7 @@ public override async Task SymmetricDifference(bool isAsync) { await base.SymmetricDifference(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) @@ -641,7 +641,7 @@ public override async Task ToBinary(bool isAsync) { await base.ToBinary(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] //FROM [PointEntity] AS [e]"); @@ -651,7 +651,7 @@ public override async Task ToText(bool isAsync) { await base.ToText(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] //FROM [PointEntity] AS [e]"); @@ -661,7 +661,7 @@ public override async Task Touches(bool isAsync) { await base.Touches(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x000000000104040000000000000000000000000000000000F03F000000000000...' (Size = 96) (DbType = Object) @@ -673,7 +673,7 @@ public override async Task Union(bool isAsync) { await base.Union(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) @@ -691,7 +691,7 @@ public override async Task Within(bool isAsync) { await base.Within(isAsync); - // issue #15994 + // issue #16050 // AssertSql( // @"@__polygon_0='0x00000000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Object)