From 82715fdd1716c9cc1779f62c4852857164388f37 Mon Sep 17 00:00:00 2001 From: maumar Date: Mon, 10 Jun 2019 23:11:23 -0700 Subject: [PATCH] Enabling sql asserts in query tests --- .../TestUtilities/TestSqlLoggerFactory.cs | 4 +- .../FindSqlServerTest.cs | 102 +- .../ComplexNavigationsQuerySqlServerTest.cs | 98 +- .../Query/DbFunctionsSqlServerTest.cs | 36 +- .../Query/FromSqlQuerySqlServerTest.cs | 151 +-- .../Query/GearsOfWarQuerySqlServerTest.cs | 82 +- ...eritanceRelationshipsQuerySqlServerTest.cs | 454 +++---- .../Query/NullSemanticsQuerySqlServerTest.cs | 404 +++--- .../Query/QueryBugsTest.cs | 100 +- .../Query/RowNumberPagingTest.cs | 34 +- .../SimpleQuerySqlServerTest.Functions.cs | 1051 ++++++++------- .../SimpleQuerySqlServerTest.JoinGroupJoin.cs | 91 +- .../SimpleQuerySqlServerTest.QueryTypes.cs | 2 +- ...impleQuerySqlServerTest.ResultOperators.cs | 238 ++-- .../Query/SimpleQuerySqlServerTest.Select.cs | 147 +- .../Query/SimpleQuerySqlServerTest.Where.cs | 446 ++++--- .../Query/SimpleQuerySqlServerTest.cs | 1185 ++++++++--------- .../SpatialQuerySqlServerGeographyTest.cs | 306 +++-- .../SpatialQuerySqlServerGeometryTest.cs | 392 +++--- .../Query/UdfDbFunctionSqlServerTests.cs | 38 +- .../Query/SimpleQuerySqliteTest.cs | 127 +- .../Query/SpatialQuerySqliteTest.cs | 487 +++---- 22 files changed, 3036 insertions(+), 2939 deletions(-) diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index 19803217365..97c2a9ad810 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -97,9 +97,9 @@ public void AssertBaseline(string[] expected, bool assertOrder = true) var contents = testInfo + newBaseLine + FileNewLine + FileNewLine; - //File.AppendAllText(logFile, contents); + File.AppendAllText(logFile, contents); - //throw; + throw; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs index de97acec05d..89b8fe0779c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs @@ -71,9 +71,9 @@ public override void Find_int_key_from_store() AssertSql( @"@__p_0='77' -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [IntKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [i].[Id], [i].[Foo] +FROM [IntKey] AS [i] +WHERE ([i].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Returns_null_for_int_key_not_in_store() @@ -83,9 +83,9 @@ public override void Returns_null_for_int_key_not_in_store() AssertSql( @"@__p_0='99' -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [IntKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [i].[Id], [i].[Foo] +FROM [IntKey] AS [i] +WHERE ([i].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Find_nullable_int_key_tracked() @@ -102,9 +102,9 @@ public override void Find_nullable_int_key_from_store() AssertSql( @"@__p_0='77' -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [IntKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [i].[Id], [i].[Foo] +FROM [IntKey] AS [i] +WHERE ([i].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Returns_null_for_nullable_int_key_not_in_store() @@ -114,9 +114,9 @@ public override void Returns_null_for_nullable_int_key_not_in_store() AssertSql( @"@__p_0='99' -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [IntKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [i].[Id], [i].[Foo] +FROM [IntKey] AS [i] +WHERE ([i].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Find_string_key_tracked() @@ -133,9 +133,9 @@ public override void Find_string_key_from_store() AssertSql( @"@__p_0='Cat' (Size = 450) -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [StringKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [s].[Id], [s].[Foo] +FROM [StringKey] AS [s] +WHERE ([s].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Returns_null_for_string_key_not_in_store() @@ -145,9 +145,9 @@ public override void Returns_null_for_string_key_not_in_store() AssertSql( @"@__p_0='Fox' (Size = 450) -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [StringKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [s].[Id], [s].[Foo] +FROM [StringKey] AS [s] +WHERE ([s].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Find_composite_key_tracked() @@ -165,9 +165,9 @@ public override void Find_composite_key_from_store() @"@__p_0='77' @__p_1='Dog' (Size = 450) -SELECT TOP(1) [e].[Id1], [e].[Id2], [e].[Foo] -FROM [CompositeKey] AS [e] -WHERE ([e].[Id1] = @__p_0) AND ([e].[Id2] = @__p_1)"); +SELECT TOP(1) [c].[Id1], [c].[Id2], [c].[Foo] +FROM [CompositeKey] AS [c] +WHERE (([c].[Id1] = @__p_0) AND @__p_0 IS NOT NULL) AND (([c].[Id2] = @__p_1) AND @__p_1 IS NOT NULL)"); } public override void Returns_null_for_composite_key_not_in_store() @@ -178,9 +178,9 @@ public override void Returns_null_for_composite_key_not_in_store() @"@__p_0='77' @__p_1='Fox' (Size = 450) -SELECT TOP(1) [e].[Id1], [e].[Id2], [e].[Foo] -FROM [CompositeKey] AS [e] -WHERE ([e].[Id1] = @__p_0) AND ([e].[Id2] = @__p_1)"); +SELECT TOP(1) [c].[Id1], [c].[Id2], [c].[Foo] +FROM [CompositeKey] AS [c] +WHERE (([c].[Id1] = @__p_0) AND @__p_0 IS NOT NULL) AND (([c].[Id2] = @__p_1) AND @__p_1 IS NOT NULL)"); } public override void Find_base_type_tracked() @@ -197,9 +197,9 @@ public override void Find_base_type_from_store() AssertSql( @"@__p_0='77' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE [e].[Discriminator] IN (N'DerivedType', N'BaseType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE [b].[Discriminator] IN (N'BaseType', N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Returns_null_for_base_type_not_in_store() @@ -209,9 +209,9 @@ public override void Returns_null_for_base_type_not_in_store() AssertSql( @"@__p_0='99' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE [e].[Discriminator] IN (N'DerivedType', N'BaseType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE [b].[Discriminator] IN (N'BaseType', N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Find_derived_type_tracked() @@ -228,9 +228,9 @@ public override void Find_derived_type_from_store() AssertSql( @"@__p_0='78' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE ([e].[Discriminator] = N'DerivedType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE ([b].[Discriminator] = N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Returns_null_for_derived_type_not_in_store() @@ -240,9 +240,9 @@ public override void Returns_null_for_derived_type_not_in_store() AssertSql( @"@__p_0='99' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE ([e].[Discriminator] = N'DerivedType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE ([b].[Discriminator] = N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Find_base_type_using_derived_set_tracked() @@ -252,9 +252,9 @@ public override void Find_base_type_using_derived_set_tracked() AssertSql( @"@__p_0='88' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE ([e].[Discriminator] = N'DerivedType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE ([b].[Discriminator] = N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Find_base_type_using_derived_set_from_store() @@ -264,9 +264,9 @@ public override void Find_base_type_using_derived_set_from_store() AssertSql( @"@__p_0='77' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE ([e].[Discriminator] = N'DerivedType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE ([b].[Discriminator] = N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Find_derived_type_using_base_set_tracked() @@ -283,9 +283,9 @@ public override void Find_derived_using_base_set_type_from_store() AssertSql( @"@__p_0='78' -SELECT TOP(1) [e].[Id], [e].[Discriminator], [e].[Foo], [e].[Boo] -FROM [BaseType] AS [e] -WHERE [e].[Discriminator] IN (N'DerivedType', N'BaseType') AND ([e].[Id] = @__p_0)"); +SELECT TOP(1) [b].[Id], [b].[Discriminator], [b].[Foo], [b].[Boo] +FROM [BaseType] AS [b] +WHERE [b].[Discriminator] IN (N'BaseType', N'DerivedType') AND (([b].[Id] = @__p_0) AND @__p_0 IS NOT NULL)"); } public override void Find_shadow_key_tracked() @@ -302,9 +302,9 @@ public override void Find_shadow_key_from_store() AssertSql( @"@__p_0='77' -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [ShadowKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [s].[Id], [s].[Foo] +FROM [ShadowKey] AS [s] +WHERE ([s].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Returns_null_for_shadow_key_not_in_store() @@ -314,9 +314,9 @@ public override void Returns_null_for_shadow_key_not_in_store() AssertSql( @"@__p_0='99' -SELECT TOP(1) [e].[Id], [e].[Foo] -FROM [ShadowKey] AS [e] -WHERE [e].[Id] = @__p_0"); +SELECT TOP(1) [s].[Id], [s].[Foo] +FROM [ShadowKey] AS [s] +WHERE ([s].[Id] = @__p_0) AND @__p_0 IS NOT NULL"); } private string Sql => Fixture.TestSqlLoggerFactory.Sql; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 837186ac919..9361ee95885 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -273,10 +273,10 @@ public override async Task Join_navigation_key_access_optional(bool isAsync) await base.Join_navigation_key_access_optional(isAsync); AssertSql( - @"SELECT [l].[Id], [t].[Id] + @"SELECT [l].[Id] AS [Id1], [t].[Id] AS [Id2] FROM [LevelOne] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Name] AS Name0, [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id] + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id] FROM [LevelTwo] AS [l0] LEFT JOIN [LevelOne] AS [l1] ON [l0].[Level1_Optional_Id] = [l1].[Id] ) AS [t] ON [l].[Id] = [t].[Id0]"); @@ -287,10 +287,10 @@ public override async Task Join_navigation_key_access_required(bool isAsync) await base.Join_navigation_key_access_required(isAsync); AssertSql( - @"SELECT [l].[Id], [t].[Id] + @"SELECT [l].[Id] AS [Id1], [t].[Id] AS [Id2] FROM [LevelOne] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Name] AS Name0, [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id] + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id] FROM [LevelTwo] AS [l0] INNER JOIN [LevelOne] AS [l1] ON [l0].[Level1_Required_Id] = [l1].[Id] ) AS [t] ON [l].[Id] = [t].[Id0]"); @@ -425,7 +425,7 @@ public override async Task Join_navigation_in_outer_selector_translated_to_extra await base.Join_navigation_in_outer_selector_translated_to_extra_join(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id2] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] INNER JOIN [LevelTwo] AS [l0] ON [l1].[Id] = [l0].[Id]"); @@ -436,7 +436,7 @@ public override async Task Join_navigation_in_outer_selector_translated_to_extra await base.Join_navigation_in_outer_selector_translated_to_extra_join_nested(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id3] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [l1].[Id] = [l2].[Level2_Optional_Id] @@ -448,7 +448,7 @@ public override async Task Join_navigation_in_outer_selector_translated_to_extra await base.Join_navigation_in_outer_selector_translated_to_extra_join_nested2(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id3], [l0].[Id] AS [Id1] FROM [LevelThree] AS [l] INNER JOIN [LevelTwo] AS [l1] ON [l].[Level2_Required_Id] = [l1].[Id] LEFT JOIN [LevelOne] AS [l2] ON [l1].[Level1_Optional_Id] = [l2].[Id] @@ -460,10 +460,10 @@ public override async Task Join_navigation_in_inner_selector(bool isAsync) await base.Join_navigation_in_inner_selector(isAsync); AssertSql( - @"SELECT [l].[Id], [t].[Id] + @"SELECT [l].[Id] AS [Id2], [t].[Id] AS [Id1] FROM [LevelTwo] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS Name0, [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] + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS [Name0], [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 [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Optional_Id] ) AS [t] ON [l].[Id] = [t].[Id0]"); @@ -474,15 +474,15 @@ public override async Task Join_navigations_in_inner_selector_translated_without await base.Join_navigations_in_inner_selector_translated_without_collision(isAsync); AssertSql( - @"SELECT [l].[Id], [t].[Id], [t0].[Id] + @"SELECT [l].[Id] AS [Id2], [t].[Id] AS [Id1], [t0].[Id] AS [Id3] FROM [LevelTwo] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS Name0, [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] + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS [Name0], [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 [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Optional_Id] ) AS [t] ON [l].[Id] = [t].[Id0] INNER JOIN ( - SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Id] AS Id0, [l3].[Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Name] AS Name0, [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Optional_Self_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToMany_Required_Self_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l3].[OneToOne_Optional_Self2Id] + SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Id] AS [Id0], [l3].[Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Optional_Self_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToMany_Required_Self_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l3].[OneToOne_Optional_Self2Id] FROM [LevelThree] AS [l2] LEFT JOIN [LevelTwo] AS [l3] ON [l2].[Level2_Optional_Id] = [l3].[Id] ) AS [t0] ON [l].[Id] = [t0].[Id0]"); @@ -493,10 +493,10 @@ public override async Task Join_navigation_non_key_join(bool isAsync) await base.Join_navigation_non_key_join(isAsync); AssertSql( - @"SELECT [l].[Id], [l].[Name], [t].[Id], [t].[Name] + @"SELECT [l].[Id] AS [Id2], [l].[Name] AS [Name2], [t].[Id] AS [Id1], [t].[Name] AS [Name1] FROM [LevelTwo] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS Name0, [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] + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS [Name0], [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 [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Optional_Id] ) AS [t] ON [l].[Name] = [t].[Name0]"); @@ -515,10 +515,10 @@ public override async Task Join_navigation_self_ref(bool isAsync) await base.Join_navigation_self_ref(isAsync); AssertSql( - @"SELECT [l].[Id], [t].[Id] + @"SELECT [l].[Id] AS [Id1], [t].[Id] AS [Id2] FROM [LevelOne] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Name] AS Name0, [l1].[OneToMany_Optional_Self_Inverse1Id] AS OneToMany_Optional_Self_Inverse1Id0, [l1].[OneToMany_Required_Self_Inverse1Id] AS OneToMany_Required_Self_Inverse1Id0, [l1].[OneToOne_Optional_Self1Id] AS OneToOne_Optional_Self1Id0 + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Self_Inverse1Id] AS [OneToMany_Optional_Self_Inverse1Id0], [l1].[OneToMany_Required_Self_Inverse1Id] AS [OneToMany_Required_Self_Inverse1Id0], [l1].[OneToOne_Optional_Self1Id] AS [OneToOne_Optional_Self1Id0] FROM [LevelOne] AS [l0] LEFT JOIN [LevelOne] AS [l1] ON [l0].[OneToMany_Optional_Self_Inverse1Id] = [l1].[Id] ) AS [t] ON [l].[Id] = [t].[Id0]"); @@ -529,10 +529,10 @@ public override async Task Join_navigation_nested(bool isAsync) await base.Join_navigation_nested(isAsync); AssertSql( - @"SELECT [l].[Id], [t].[Id] + @"SELECT [l].[Id] AS [Id3], [t].[Id] AS [Id1] FROM [LevelThree] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS Name0, [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], [l2].[Id] AS Id1, [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name] AS Name1, [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id] + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS [Name0], [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], [l2].[Id] AS [Id1], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id] FROM [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [l1].[Id] = [l2].[Level2_Optional_Id] @@ -552,10 +552,10 @@ public override async Task Join_navigation_deeply_nested_non_key_join(bool isAsy await base.Join_navigation_deeply_nested_non_key_join(isAsync); AssertSql( - @"SELECT [l].[Id], [l].[Name], [t].[Id], [t].[Name] + @"SELECT [l].[Id] AS [Id4], [l].[Name] AS [Name4], [t].[Id] AS [Id1], [t].[Name] AS [Name1] FROM [LevelFour] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS Id0, [l1].[Date] AS Date0, [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS Name0, [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], [l2].[Id] AS Id1, [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name] AS Name1, [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Id] AS Id2, [l3].[Level3_Optional_Id], [l3].[Level3_Required_Id], [l3].[Name] AS Name2, [l3].[OneToMany_Optional_Inverse4Id], [l3].[OneToMany_Optional_Self_Inverse4Id], [l3].[OneToMany_Required_Inverse4Id], [l3].[OneToMany_Required_Self_Inverse4Id], [l3].[OneToOne_Optional_PK_Inverse4Id], [l3].[OneToOne_Optional_Self4Id] + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id] AS [Id0], [l1].[Date] AS [Date0], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS [Name0], [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], [l2].[Id] AS [Id1], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Id] AS [Id2], [l3].[Level3_Optional_Id], [l3].[Level3_Required_Id], [l3].[Name] AS [Name2], [l3].[OneToMany_Optional_Inverse4Id], [l3].[OneToMany_Optional_Self_Inverse4Id], [l3].[OneToMany_Required_Inverse4Id], [l3].[OneToMany_Required_Self_Inverse4Id], [l3].[OneToOne_Optional_PK_Inverse4Id], [l3].[OneToOne_Optional_Self4Id] FROM [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [l1].[Id] = [l2].[Level2_Optional_Id] @@ -568,10 +568,10 @@ public override async Task Join_navigation_deeply_nested_required(bool isAsync) await base.Join_navigation_deeply_nested_required(isAsync); AssertSql( - @"SELECT [t].[Id], [t].[Name], [l3].[Id], [l3].[Name] + @"SELECT [t].[Id] AS [Id4], [t].[Name] AS [Name4], [l3].[Id] AS [Id1], [l3].[Name] AS [Name1] FROM [LevelOne] AS [l3] INNER JOIN ( - SELECT [l].[Id], [l].[Level3_Optional_Id], [l].[Level3_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse4Id], [l].[OneToMany_Optional_Self_Inverse4Id], [l].[OneToMany_Required_Inverse4Id], [l].[OneToMany_Required_Self_Inverse4Id], [l].[OneToOne_Optional_PK_Inverse4Id], [l].[OneToOne_Optional_Self4Id], [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], [l1].[Id] AS Id1, [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS Name1, [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], [l2].[Id] AS Id2, [l2].[Date] AS Date0, [l2].[Name] AS Name2, [l2].[OneToMany_Optional_Self_Inverse1Id], [l2].[OneToMany_Required_Self_Inverse1Id], [l2].[OneToOne_Optional_Self1Id] + SELECT [l].[Id], [l].[Level3_Optional_Id], [l].[Level3_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse4Id], [l].[OneToMany_Optional_Self_Inverse4Id], [l].[OneToMany_Required_Inverse4Id], [l].[OneToMany_Required_Self_Inverse4Id], [l].[OneToOne_Optional_PK_Inverse4Id], [l].[OneToOne_Optional_Self4Id], [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], [l1].[Id] AS [Id1], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name] AS [Name1], [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], [l2].[Id] AS [Id2], [l2].[Date] AS [Date0], [l2].[Name] AS [Name2], [l2].[OneToMany_Optional_Self_Inverse1Id], [l2].[OneToMany_Required_Self_Inverse1Id], [l2].[OneToOne_Optional_Self1Id] FROM [LevelFour] AS [l] INNER JOIN [LevelThree] AS [l0] ON [l].[Level3_Required_Id] = [l0].[Id] INNER JOIN [LevelTwo] AS [l1] ON [l0].[Level2_Required_Id] = [l1].[Id] @@ -911,7 +911,7 @@ public override async Task SelectMany_navigation_comparison1(bool isAsync) await base.SelectMany_navigation_comparison1(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id2] FROM [LevelOne] AS [l] CROSS JOIN [LevelOne] AS [l0] WHERE [l].[Id] = [l0].[Id]"); @@ -922,7 +922,7 @@ public override async Task SelectMany_navigation_comparison2(bool isAsync) await base.SelectMany_navigation_comparison2(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id2] FROM [LevelOne] AS [l] CROSS JOIN [LevelTwo] AS [l0] LEFT JOIN [LevelOne] AS [l1] ON [l0].[Level1_Optional_Id] = [l1].[Id] @@ -934,7 +934,7 @@ public override async Task SelectMany_navigation_comparison3(bool isAsync) await base.SelectMany_navigation_comparison3(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id2] FROM [LevelOne] AS [l] CROSS JOIN [LevelTwo] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] @@ -946,7 +946,7 @@ public override async Task Where_complex_predicate_with_with_nav_prop_and_OrElse await base.Where_complex_predicate_with_with_nav_prop_and_OrElse1(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id2] FROM [LevelOne] AS [l] CROSS JOIN [LevelTwo] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] @@ -2664,7 +2664,7 @@ public override async Task Optional_navigation_propagates_nullability_to_manuall await base.Optional_navigation_propagates_nullability_to_manually_created_left_join1(isAsync); AssertSql( - @"SELECT [l].[Id], [l0].[Id] + @"SELECT [l].[Id] AS [Id1], [l0].[Id] AS [Id2] FROM [LevelOne] AS [l1] LEFT JOIN [LevelTwo] AS [l] ON [l1].[Id] = [l].[Level1_Optional_Id] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Level1_Required_Id] = [l0].[Id]"); @@ -2675,7 +2675,7 @@ public override async Task Optional_navigation_propagates_nullability_to_manuall await base.Optional_navigation_propagates_nullability_to_manually_created_left_join2(isAsync); AssertSql( - @"SELECT [l].[Name], [t].[Name] + @"SELECT [l].[Name] AS [Name1], [t].[Name] AS [Name2] FROM [LevelThree] AS [l] LEFT JOIN ( SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] @@ -2703,7 +2703,7 @@ public override async Task Null_reference_protection_complex_materialization(boo await base.Null_reference_protection_complex_materialization(isAsync); AssertSql( - @"SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Name] + @"SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] FROM [LevelThree] AS [l1] LEFT JOIN ( SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id] @@ -2865,15 +2865,15 @@ public override async Task GroupJoin_on_left_side_being_a_subquery(bool isAsync) AssertSql( @"@__p_0='2' -SELECT [t].[Id], [l].[Name] +SELECT [t].[Id], [l].[Name] AS [Brand] FROM ( - SELECT TOP(@__p_0) [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Name] AS c + SELECT TOP(@__p_0) [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Name] AS [Name0] FROM [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Optional_Id] ORDER BY [l1].[Name], [l0].[Id] ) AS [t] LEFT JOIN [LevelTwo] AS [l] ON [t].[Id] = [l].[Level1_Optional_Id] -ORDER BY [t].[c], [t].[Id]"); +ORDER BY [t].[Name0], [t].[Id]"); } public override async Task GroupJoin_on_right_side_being_a_subquery(bool isAsync) @@ -4329,7 +4329,7 @@ public override void Include17() AssertSql( @"SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [t].[Id0], [t].[Date0], [t].[Level1_Optional_Id0], [t].[Level1_Required_Id0], [t].[Name0], [t].[OneToMany_Optional_Inverse2Id0], [t].[OneToMany_Optional_Self_Inverse2Id0], [t].[OneToMany_Required_Inverse2Id0], [t].[OneToMany_Required_Self_Inverse2Id0], [t].[OneToOne_Optional_PK_Inverse2Id0], [t].[OneToOne_Optional_Self2Id0] FROM ( - SELECT DISTINCT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id] AS Id0, [l0].[Date] AS Date0, [l0].[Level1_Optional_Id] AS Level1_Optional_Id0, [l0].[Level1_Required_Id] AS Level1_Required_Id0, [l0].[Name] AS Name0, [l0].[OneToMany_Optional_Inverse2Id] AS OneToMany_Optional_Inverse2Id0, [l0].[OneToMany_Optional_Self_Inverse2Id] AS OneToMany_Optional_Self_Inverse2Id0, [l0].[OneToMany_Required_Inverse2Id] AS OneToMany_Required_Inverse2Id0, [l0].[OneToMany_Required_Self_Inverse2Id] AS OneToMany_Required_Self_Inverse2Id0, [l0].[OneToOne_Optional_PK_Inverse2Id] AS OneToOne_Optional_PK_Inverse2Id0, [l0].[OneToOne_Optional_Self2Id] AS OneToOne_Optional_Self2Id0 + SELECT DISTINCT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Date] AS [Date0], [l0].[Level1_Optional_Id] AS [Level1_Optional_Id0], [l0].[Level1_Required_Id] AS [Level1_Required_Id0], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse2Id] AS [OneToMany_Optional_Inverse2Id0], [l0].[OneToMany_Optional_Self_Inverse2Id] AS [OneToMany_Optional_Self_Inverse2Id0], [l0].[OneToMany_Required_Inverse2Id] AS [OneToMany_Required_Inverse2Id0], [l0].[OneToMany_Required_Self_Inverse2Id] AS [OneToMany_Required_Self_Inverse2Id0], [l0].[OneToOne_Optional_PK_Inverse2Id] AS [OneToOne_Optional_PK_Inverse2Id0], [l0].[OneToOne_Optional_Self2Id] AS [OneToOne_Optional_Self2Id0] FROM [LevelOne] AS [l1] LEFT JOIN [LevelTwo] AS [l] ON [l1].[Id] = [l].[Level1_Optional_Id] LEFT JOIN [LevelTwo] AS [l0] ON [l1].[Id] = [l0].[OneToOne_Optional_PK_Inverse2Id] @@ -4390,16 +4390,16 @@ public override void Include18_3() AssertSql( @"@__p_0='10' -SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [t].[Id0], [t].[Date0], [t].[Name0], [t].[OneToMany_Optional_Self_Inverse1Id0], [t].[OneToMany_Required_Self_Inverse1Id0], [t].[OneToOne_Optional_Self1Id0], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] +SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] 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], [l].[Id] AS Id0, [l].[Date] AS Date0, [l].[Name] AS Name0, [l].[OneToMany_Optional_Self_Inverse1Id] AS OneToMany_Optional_Self_Inverse1Id0, [l].[OneToMany_Required_Self_Inverse1Id] AS OneToMany_Required_Self_Inverse1Id0, [l].[OneToOne_Optional_Self1Id] AS OneToOne_Optional_Self1Id0, [l0].[Name] AS c + SELECT TOP(@__p_0) [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Name] AS [Name0] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] ORDER BY [l0].[Name] ) AS [t] LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l2] ON [t].[Id0] = [l2].[Level1_Optional_Id] -ORDER BY [t].[c]"); +LEFT JOIN [LevelTwo] AS [l2] ON [t].[Id] = [l2].[Level1_Optional_Id] +ORDER BY [t].[Name0]"); } public override void Include18_3_1() @@ -4410,16 +4410,16 @@ public override void Include18_3_1() AssertSql( @"@__p_0='10' -SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [t].[Id0], [t].[Date0], [t].[Name0], [t].[OneToMany_Optional_Self_Inverse1Id0], [t].[OneToMany_Required_Self_Inverse1Id0], [t].[OneToOne_Optional_Self1Id0], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] +SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] 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], [l].[Id] AS Id0, [l].[Date] AS Date0, [l].[Name] AS Name0, [l].[OneToMany_Optional_Self_Inverse1Id] AS OneToMany_Optional_Self_Inverse1Id0, [l].[OneToMany_Required_Self_Inverse1Id] AS OneToMany_Required_Self_Inverse1Id0, [l].[OneToOne_Optional_Self1Id] AS OneToOne_Optional_Self1Id0, [l0].[Name] AS c + SELECT TOP(@__p_0) [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Name] AS [Name0] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] ORDER BY [l0].[Name] ) AS [t] LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l2] ON [t].[Id0] = [l2].[Level1_Optional_Id] -ORDER BY [t].[c]"); +LEFT JOIN [LevelTwo] AS [l2] ON [t].[Id] = [l2].[Level1_Optional_Id] +ORDER BY [t].[Name0]"); } public override void Include18_3_2() @@ -4430,16 +4430,16 @@ public override void Include18_3_2() AssertSql( @"@__p_0='10' -SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [t].[c], [t].[Id0], [t].[Date0], [t].[Name0], [t].[OneToMany_Optional_Self_Inverse1Id0], [t].[OneToMany_Required_Self_Inverse1Id0], [t].[OneToOne_Optional_Self1Id0], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] +SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] 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], [l].[Name] AS c, [l].[Id] AS Id0, [l].[Date] AS Date0, [l].[Name] AS Name0, [l].[OneToMany_Optional_Self_Inverse1Id] AS OneToMany_Optional_Self_Inverse1Id0, [l].[OneToMany_Required_Self_Inverse1Id] AS OneToMany_Required_Self_Inverse1Id0, [l].[OneToOne_Optional_Self1Id] AS OneToOne_Optional_Self1Id0, [l0].[Name] AS c0 + SELECT TOP(@__p_0) [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Name] AS [Name0] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] ORDER BY [l0].[Name] ) AS [t] LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l2] ON [t].[Id0] = [l2].[Level1_Optional_Id] -ORDER BY [t].[c0]"); +LEFT JOIN [LevelTwo] AS [l2] ON [t].[Id] = [l2].[Level1_Optional_Id] +ORDER BY [t].[Name0]"); } public override async Task Include18_3_3(bool isAsync) @@ -4462,13 +4462,13 @@ public override void Include18_4() // issue #15783 AssertSql( - @"SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Date0], [t].[Name0], [t].[OneToMany_Optional_Self_Inverse1Id0], [t].[OneToMany_Required_Self_Inverse1Id0], [t].[OneToOne_Optional_Self1Id0], [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] + @"SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [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 ( - SELECT DISTINCT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l].[Id] AS Id0, [l].[Date] AS Date0, [l].[Name] AS Name0, [l].[OneToMany_Optional_Self_Inverse1Id] AS OneToMany_Optional_Self_Inverse1Id0, [l].[OneToMany_Required_Self_Inverse1Id] AS OneToMany_Required_Self_Inverse1Id0, [l].[OneToOne_Optional_Self1Id] AS OneToOne_Optional_Self1Id0 + SELECT DISTINCT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] FROM [LevelOne] AS [l] ) AS [t] LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id0] = [l1].[Level1_Optional_Id]"); +LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Optional_Id]"); } public override void Include18() @@ -4480,7 +4480,7 @@ public override void Include18() SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [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], [t].[Id0], [t].[Date0], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] 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], [l0].[Id] AS Id0, [l0].[Date] AS Date0, [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name] AS Name0, [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + SELECT TOP(@__p_0) [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id] AS [Id0], [l0].[Date] AS [Date0], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToOne_Optional_PK_Inverse2Id] ORDER BY [l].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs index 784db1fa40e..7d05b892e5e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs @@ -423,8 +423,8 @@ public virtual void DateDiff_Year() AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(YEAR, [c].[OrderDate], GETDATE()) = 0"); +FROM [Orders] AS [o] +WHERE (DATEDIFF(YEAR, [o].[OrderDate], GETDATE()) = 0) AND DATEDIFF(YEAR, [o].[OrderDate], GETDATE()) IS NOT NULL"); } } @@ -439,8 +439,8 @@ public virtual void DateDiff_Month() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(MONTH, [c].[OrderDate], GETDATE()) = 0"); +FROM [Orders] AS [o] +WHERE (DATEDIFF(MONTH, [o].[OrderDate], GETDATE()) = 0) AND DATEDIFF(MONTH, [o].[OrderDate], GETDATE()) IS NOT NULL"); } } @@ -455,8 +455,8 @@ public virtual void DateDiff_Day() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(DAY, [c].[OrderDate], GETDATE()) = 0"); +FROM [Orders] AS [o] +WHERE (DATEDIFF(DAY, [o].[OrderDate], GETDATE()) = 0) AND DATEDIFF(DAY, [o].[OrderDate], GETDATE()) IS NOT NULL"); } } @@ -471,8 +471,8 @@ public virtual void DateDiff_Hour() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(HOUR, [c].[OrderDate], GETDATE()) = 0"); +FROM [Orders] AS [o] +WHERE (DATEDIFF(HOUR, [o].[OrderDate], GETDATE()) = 0) AND DATEDIFF(HOUR, [o].[OrderDate], GETDATE()) IS NOT NULL"); } } @@ -487,8 +487,8 @@ public virtual void DateDiff_Minute() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(MINUTE, [c].[OrderDate], GETDATE()) = 0"); +FROM [Orders] AS [o] +WHERE (DATEDIFF(MINUTE, [o].[OrderDate], GETDATE()) = 0) AND DATEDIFF(MINUTE, [o].[OrderDate], GETDATE()) IS NOT NULL"); } } @@ -503,8 +503,8 @@ public virtual void DateDiff_Second() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(SECOND, [c].[OrderDate], GETDATE()) = 0"); +FROM [Orders] AS [o] +WHERE (DATEDIFF(SECOND, [o].[OrderDate], GETDATE()) = 0) AND DATEDIFF(SECOND, [o].[OrderDate], GETDATE()) IS NOT NULL"); } } @@ -519,8 +519,8 @@ public virtual void DateDiff_Millisecond() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(MILLISECOND, GETDATE(), DATEADD(day, 1.0E0, GETDATE())) = 0"); +FROM [Orders] AS [o] +WHERE DATEDIFF(MILLISECOND, GETDATE(), DATEADD(day, CAST(1.0E0 AS int), GETDATE())) = 0"); } } @@ -535,8 +535,8 @@ public virtual void DateDiff_Microsecond() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(MICROSECOND, GETDATE(), DATEADD(second, 1.0E0, GETDATE())) = 0"); +FROM [Orders] AS [o] +WHERE DATEDIFF(MICROSECOND, GETDATE(), DATEADD(second, CAST(1.0E0 AS int), GETDATE())) = 0"); } } @@ -551,8 +551,8 @@ public virtual void DateDiff_Nanosecond() Assert.Equal(0, count); AssertSql( @"SELECT COUNT(*) -FROM [Orders] AS [c] -WHERE DATEDIFF(NANOSECOND, GETDATE(), DATEADD(second, 1.0E0, GETDATE())) = 0"); +FROM [Orders] AS [o] +WHERE DATEDIFF(NANOSECOND, GETDATE(), DATEADD(second, CAST(1.0E0 AS int), GETDATE())) = 0"); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs index fd0c9588483..a32a8af8597 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs @@ -46,29 +46,31 @@ public override void FromSqlRaw_queryable_composed() { base.FromSqlRaw_queryable_composed(); - 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 ( - SELECT * FROM ""Customers"" -) AS [c] -WHERE CHARINDEX(N'z', [c].[ContactName]) > 0"); + // 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 ( +// SELECT * FROM ""Customers"" +//) AS [c] +//WHERE CHARINDEX(N'z', [c].[ContactName]) > 0"); } public override void FromSqlRaw_queryable_composed_after_removing_whitespaces() { base.FromSqlRaw_queryable_composed_after_removing_whitespaces(); - 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 ( + // 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 ( - SELECT - * FROM ""Customers"" -) AS [c] -WHERE CHARINDEX(N'z', [c].[ContactName]) > 0"); +// SELECT +// * FROM ""Customers"" +//) AS [c] +//WHERE CHARINDEX(N'z', [c].[ContactName]) > 0"); } public override void FromSqlRaw_queryable_composed_compiled() @@ -125,7 +127,7 @@ public override void FromSqlRaw_queryable_multiple_composed() CROSS JOIN ( SELECT * FROM ""Orders"" ) AS [o] -WHERE [c].[CustomerID] = [o].[CustomerID]"); +WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL"); } public override void FromSqlRaw_queryable_multiple_composed_with_closure_parameters() @@ -133,8 +135,8 @@ public override void FromSqlRaw_queryable_multiple_composed_with_closure_paramet base.FromSqlRaw_queryable_multiple_composed_with_closure_parameters(); AssertSql( - @"@p0='1997-01-01T00:00:00' -@p1='1998-01-01T00:00:00' + @"p0='1997-01-01T00:00:00' +p1='1998-01-01T00: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], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( @@ -143,7 +145,7 @@ public override void FromSqlRaw_queryable_multiple_composed_with_closure_paramet CROSS JOIN ( SELECT * FROM ""Orders"" WHERE ""OrderDate"" BETWEEN @p0 AND @p1 ) AS [o] -WHERE [c].[CustomerID] = [o].[CustomerID]"); +WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL"); } public override void FromSqlRaw_queryable_multiple_composed_with_parameters_and_closure_parameters() @@ -151,9 +153,9 @@ public override void FromSqlRaw_queryable_multiple_composed_with_parameters_and_ base.FromSqlRaw_queryable_multiple_composed_with_parameters_and_closure_parameters(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='1997-01-01T00:00:00' -@p2='1998-01-01T00:00:00' + @"p0='London' (Size = 4000) +p1='1997-01-01T00:00:00' +p2='1998-01-01T00: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], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( @@ -162,11 +164,11 @@ public override void FromSqlRaw_queryable_multiple_composed_with_parameters_and_ CROSS JOIN ( SELECT * FROM ""Orders"" WHERE ""OrderDate"" BETWEEN @p1 AND @p2 ) AS [o] -WHERE [c].[CustomerID] = [o].[CustomerID]", +WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL", // - @"@p0='Berlin' (Size = 4000) -@p1='1998-04-01T00:00:00' -@p2='1998-05-01T00:00:00' + @"p0='Berlin' (Size = 4000) +p1='1998-04-01T00:00:00' +p2='1998-05-01T00: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], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( @@ -175,7 +177,7 @@ CROSS JOIN ( CROSS JOIN ( SELECT * FROM ""Orders"" WHERE ""OrderDate"" BETWEEN @p1 AND @p2 ) AS [o] -WHERE [c].[CustomerID] = [o].[CustomerID]"); +WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL"); } public override void FromSqlRaw_queryable_multiple_line_query() @@ -198,7 +200,7 @@ public override void FromSqlRaw_queryable_composed_multiple_line_query() SELECT * FROM ""Customers"" ) AS [c] -WHERE [c].[City] = N'London'"); +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL"); } public override void FromSqlRaw_queryable_with_parameters() @@ -206,8 +208,8 @@ public override void FromSqlRaw_queryable_with_parameters() base.FromSqlRaw_queryable_with_parameters(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='Sales Representative' (Size = 4000) + @"p0='London' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @p1"); } @@ -217,8 +219,8 @@ public override void FromSqlRaw_queryable_with_parameters_inline() base.FromSqlRaw_queryable_with_parameters_inline(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='Sales Representative' (Size = 4000) + @"p0='London' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @p1"); } @@ -228,8 +230,8 @@ public override void FromSqlInterpolated_queryable_with_parameters_interpolated( base.FromSqlInterpolated_queryable_with_parameters_interpolated(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='Sales Representative' (Size = 4000) + @"p0='London' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @p1"); } @@ -239,8 +241,8 @@ public override void FromSqlInterpolated_queryable_with_parameters_inline_interp base.FromSqlInterpolated_queryable_with_parameters_inline_interpolated(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='Sales Representative' (Size = 4000) + @"p0='London' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @p1"); } @@ -250,9 +252,9 @@ public override void FromSqlInterpolated_queryable_multiple_composed_with_parame base.FromSqlInterpolated_queryable_multiple_composed_with_parameters_and_closure_parameters_interpolated(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='1997-01-01T00:00:00' -@p2='1998-01-01T00:00:00' + @"p0='London' (Size = 4000) +p1='1997-01-01T00:00:00' +p2='1998-01-01T00: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], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( @@ -261,11 +263,11 @@ public override void FromSqlInterpolated_queryable_multiple_composed_with_parame CROSS JOIN ( SELECT * FROM ""Orders"" WHERE ""OrderDate"" BETWEEN @p1 AND @p2 ) AS [o] -WHERE [c].[CustomerID] = [o].[CustomerID]", +WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL", // - @"@p0='Berlin' (Size = 4000) -@p1='1998-04-01T00:00:00' -@p2='1998-05-01T00:00:00' + @"p0='Berlin' (Size = 4000) +p1='1998-04-01T00:00:00' +p2='1998-05-01T00: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], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( @@ -274,7 +276,7 @@ CROSS JOIN ( CROSS JOIN ( SELECT * FROM ""Orders"" WHERE ""OrderDate"" BETWEEN @p1 AND @p2 ) AS [o] -WHERE [c].[CustomerID] = [o].[CustomerID]"); +WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL"); } public override void FromSqlRaw_queryable_with_null_parameter() @@ -282,7 +284,7 @@ public override void FromSqlRaw_queryable_with_null_parameter() base.FromSqlRaw_queryable_with_null_parameter(); AssertSql( - @"@p0='' (Nullable = false) + @"p0='' (Nullable = false) SELECT * FROM ""Employees"" WHERE ""ReportsTo"" = @p0 OR (""ReportsTo"" IS NULL AND @p0 IS NULL)"); } @@ -292,14 +294,14 @@ public override void FromSqlRaw_queryable_with_parameters_and_closure() base.FromSqlRaw_queryable_with_parameters_and_closure(); AssertSql( - @"@p0='London' (Size = 4000) + @"p0='London' (Size = 4000) @__contactTitle_1='Sales Representative' (Size = 4000) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM ( SELECT * FROM ""Customers"" WHERE ""City"" = @p0 ) AS [c] -WHERE [c].[ContactTitle] = @__contactTitle_1"); +WHERE (([c].[ContactTitle] = @__contactTitle_1) AND ([c].[ContactTitle] IS NOT NULL AND @__contactTitle_1 IS NOT NULL)) OR ([c].[ContactTitle] IS NULL AND @__contactTitle_1 IS NULL)"); } public override void FromSqlRaw_queryable_simple_cache_key_includes_query_string() @@ -317,13 +319,13 @@ public override void FromSqlRaw_queryable_with_parameters_cache_key_includes_par base.FromSqlRaw_queryable_with_parameters_cache_key_includes_parameters(); AssertSql( - @"@p0='London' (Size = 4000) -@p1='Sales Representative' (Size = 4000) + @"p0='London' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @p1", // - @"@p0='Madrid' (Size = 4000) -@p1='Accounting Manager' (Size = 4000) + @"p0='Madrid' (Size = 4000) +p1='Accounting Manager' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @p1"); } @@ -340,14 +342,15 @@ public override void FromSqlRaw_queryable_simple_projection_composed() { base.FromSqlRaw_queryable_simple_projection_composed(); - AssertSql( - @"SELECT [p].[ProductName] -FROM ( - SELECT * - FROM ""Products"" - WHERE ""Discontinued"" <> CAST(1 AS bit) - AND ((""UnitsInStock"" + ""UnitsOnOrder"") < ""ReorderLevel"") -) AS [p]"); + // issue #15994 +// AssertSql( +// @"SELECT [p].[ProductName] +//FROM ( +// SELECT * +// FROM ""Products"" +// WHERE ""Discontinued"" <> CAST(1 AS bit) +// AND ((""UnitsInStock"" + ""UnitsOnOrder"") < ""ReorderLevel"") +//) AS [p]"); } public override void FromSqlRaw_queryable_simple_include() @@ -416,7 +419,8 @@ public override void FromSqlRaw_composed_with_nullable_predicate() FROM ( SELECT * FROM ""Customers"" ) AS [c] -WHERE ([c].[ContactName] = [c].[CompanyName]) OR ([c].[ContactName] IS NULL AND [c].[CompanyName] IS NULL)"); +WHERE (([c].[ContactName] = [c].[CompanyName]) AND ([c].[ContactName] IS NOT NULL AND [c].[CompanyName] IS NOT NULL)) OR ([c].[ContactName] IS NULL AND [c].[CompanyName] IS NULL)"); + ; } public override void FromSqlRaw_with_dbParameter() @@ -434,13 +438,13 @@ public override void FromSqlRaw_with_dbParameter_mixed() base.FromSqlRaw_with_dbParameter_mixed(); AssertSql( - @"@p0='London' (Size = 4000) + @"p0='London' (Size = 4000) @title='Sales Representative' (Nullable = false) (Size = 20) SELECT * FROM ""Customers"" WHERE ""City"" = @p0 AND ""ContactTitle"" = @title", // @"@city='London' (Nullable = false) (Size = 6) -@p1='Sales Representative' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT * FROM ""Customers"" WHERE ""City"" = @city AND ""ContactTitle"" = @p1"); } @@ -579,7 +583,7 @@ public virtual void FromSqlRaw_in_subquery_with_positional_dbParameter_without_n Assert.Equal(46, actual.Length); AssertSql( - @"@p0='London' (Nullable = false) (Size = 6) + @"p0='London' (Nullable = false) (Size = 6) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] @@ -661,7 +665,7 @@ public virtual void FromSqlRaw_with_dbParameter_mixed_in_subquery() Assert.Equal(26, actual.Length); AssertSql( - @"@p0='London' (Size = 4000) + @"p0='London' (Size = 4000) @title='Sales Representative' (Nullable = false) (Size = 20) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] @@ -674,7 +678,7 @@ SELECT [c].[CustomerID] )", // @"@city='London' (Nullable = false) (Size = 6) -@p1='Sales Representative' (Size = 4000) +p1='Sales Representative' (Size = 4000) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] @@ -692,35 +696,32 @@ public override void FromSqlInterpolated_parameterization_issue_12213() base.FromSqlInterpolated_parameterization_issue_12213(); AssertSql( - @"@p0='10300' + @"p0='10300' -SELECT [i].[OrderID] -FROM ( - SELECT * FROM ""Orders"" WHERE ""OrderID"" >= @p0 -) AS [i]", +SELECT * FROM ""Orders"" WHERE ""OrderID"" >= @p0", // @"@__max_0='10400' -@p0='10300' +p0='10300' SELECT [o].[OrderID] FROM [Orders] AS [o] WHERE ([o].[OrderID] <= @__max_0) AND [o].[OrderID] IN ( - SELECT [i].[OrderID] + SELECT [o0].[OrderID] FROM ( SELECT * FROM ""Orders"" WHERE ""OrderID"" >= @p0 - ) AS [i] + ) AS [o0] )", // @"@__max_0='10400' -@p0='10300' +p0='10300' SELECT [o].[OrderID] FROM [Orders] AS [o] WHERE ([o].[OrderID] <= @__max_0) AND [o].[OrderID] IN ( - SELECT [i].[OrderID] + SELECT [o0].[OrderID] FROM ( SELECT * FROM ""Orders"" WHERE ""OrderID"" >= @p0 - ) AS [i] + ) AS [o0] )"); } @@ -729,7 +730,7 @@ public override void FromSqlRaw_does_not_parameterize_interpolated_string() base.FromSqlRaw_does_not_parameterize_interpolated_string(); AssertSql( - @"@p0='10250' + @"p0='10250' SELECT * FROM ""Orders"" WHERE ""OrderID"" < @p0"); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index d55a330dc37..10ff163add5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -710,10 +710,10 @@ public override async Task Bitwise_projects_values_in_select(bool isAsync) @"SELECT TOP(1) CASE WHEN ([g].[Rank] & 1) = 1 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END, CASE +END AS [BitwiseTrue], CASE WHEN ([g].[Rank] & 1) = 2 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END, [g].[Rank] & 1 +END AS [BitwiseFalse], [g].[Rank] & 1 AS [BitwiseValue] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[Rank] & 1) = 1)"); } @@ -882,10 +882,10 @@ public override async Task Select_enum_has_flag(bool isAsync) @"SELECT TOP(1) CASE WHEN ([g].[Rank] & 1) = 1 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END, CASE +END AS [hasFlagTrue], CASE WHEN ([g].[Rank] & 2) = 2 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END +END AS [hasFlagFalse] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[Rank] & 1) = 1)"); } @@ -943,7 +943,7 @@ public override async Task Select_comparison_with_null(bool isAsync) SELECT [w].[Id], CASE WHEN (([w].[AmmunitionType] = @__ammunitionType_0) AND ([w].[AmmunitionType] IS NOT NULL AND @__ammunitionType_0 IS NOT NULL)) OR ([w].[AmmunitionType] IS NULL AND @__ammunitionType_0 IS NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END +END AS [Cartidge] FROM [Weapons] AS [w] WHERE (([w].[AmmunitionType] = @__ammunitionType_0) AND ([w].[AmmunitionType] IS NOT NULL AND @__ammunitionType_0 IS NOT NULL)) OR ([w].[AmmunitionType] IS NULL AND @__ammunitionType_0 IS NULL)", // @@ -952,7 +952,7 @@ FROM [Weapons] AS [w] SELECT [w].[Id], CASE WHEN (([w].[AmmunitionType] = @__ammunitionType_0) AND ([w].[AmmunitionType] IS NOT NULL AND @__ammunitionType_0 IS NOT NULL)) OR ([w].[AmmunitionType] IS NULL AND @__ammunitionType_0 IS NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END +END AS [Cartidge] FROM [Weapons] AS [w] WHERE (([w].[AmmunitionType] = @__ammunitionType_0) AND ([w].[AmmunitionType] IS NOT NULL AND @__ammunitionType_0 IS NOT NULL)) OR ([w].[AmmunitionType] IS NULL AND @__ammunitionType_0 IS NULL)"); } @@ -965,7 +965,7 @@ public override async Task Select_ternary_operation_with_boolean(bool isAsync) @"SELECT [w].[Id], CASE WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 ELSE 0 -END +END AS [Num] FROM [Weapons] AS [w]"); } @@ -977,7 +977,7 @@ public override async Task Select_ternary_operation_with_inverted_boolean(bool i @"SELECT [w].[Id], CASE WHEN NOT ([w].[IsAutomatic] = CAST(1 AS bit)) THEN 1 ELSE 0 -END +END AS [Num] FROM [Weapons] AS [w]"); } @@ -989,7 +989,7 @@ public override async Task Select_ternary_operation_with_has_value_not_null(bool @"SELECT [w].[Id], CASE WHEN [w].[AmmunitionType] IS NOT NULL AND (([w].[AmmunitionType] = 1) AND [w].[AmmunitionType] IS NOT NULL) THEN N'Yes' ELSE N'No' -END +END AS [IsCartidge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NOT NULL AND (([w].[AmmunitionType] = 1) AND [w].[AmmunitionType] IS NOT NULL)"); } @@ -1002,7 +1002,7 @@ public override async Task Select_ternary_operation_multiple_conditions(bool isA @"SELECT [w].[Id], CASE WHEN (([w].[AmmunitionType] = 2) AND [w].[AmmunitionType] IS NOT NULL) AND (([w].[SynergyWithId] = 1) AND [w].[SynergyWithId] IS NOT NULL) THEN N'Yes' ELSE N'No' -END +END AS [IsCartidge] FROM [Weapons] AS [w]"); } @@ -1014,7 +1014,7 @@ public override async Task Select_ternary_operation_multiple_conditions_2(bool i @"SELECT [w].[Id], CASE WHEN NOT ([w].[IsAutomatic] = CAST(1 AS bit)) AND (([w].[SynergyWithId] = 1) AND [w].[SynergyWithId] IS NOT NULL) THEN N'Yes' ELSE N'No' -END +END AS [IsCartidge] FROM [Weapons] AS [w]"); } @@ -1026,7 +1026,7 @@ public override async Task Select_multiple_conditions(bool isAsync) @"SELECT [w].[Id], CASE WHEN NOT ([w].[IsAutomatic] = CAST(1 AS bit)) AND (([w].[SynergyWithId] = 1) AND [w].[SynergyWithId] IS NOT NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END +END AS [IsCartidge] FROM [Weapons] AS [w]"); } @@ -1041,7 +1041,7 @@ WHEN NOT ([w].[IsAutomatic] = CAST(1 AS bit)) THEN CASE ELSE N'Manual' END ELSE N'Auto' -END +END AS [IsManualCartidge] FROM [Weapons] AS [w]"); } @@ -1185,7 +1185,7 @@ WHEN [t].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL -END +END AS [Condition] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -1436,9 +1436,8 @@ public override async Task Select_Singleton_Navigation_With_Member_Access(bool i { await base.Select_Singleton_Navigation_With_Member_Access(isAsync); - AssertSql( - @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOrBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [t].[CityOrBirthName] + @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOrBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Tags] AS [t0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -1534,7 +1533,7 @@ public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scal await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(isAsync); AssertSql( - @"SELECT [t].[Id], [t0].[Id] + @"SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] FROM [Tags] AS [t] CROSS JOIN [Tags] AS [t0] LEFT JOIN ( @@ -1555,7 +1554,7 @@ public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool is await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(isAsync); AssertSql( - @"SELECT TOP(1) COALESCE([w].[IsAutomatic], CAST(0 AS bit)) + @"SELECT TOP(1) COALESCE([w].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] FROM [Weapons] AS [w0] LEFT JOIN [Weapons] AS [w] ON [w0].[SynergyWithId] = [w].[Id] ORDER BY [w0].[Id]"); @@ -2065,7 +2064,7 @@ public override async Task Singleton_Navigation_With_Member_Access(bool isAsync) await base.Singleton_Navigation_With_Member_Access(isAsync); AssertSql( - @"SELECT [t].[CityOrBirthName] + @"SELECT [t].[CityOrBirthName] AS [B] FROM [Tags] AS [t0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -2690,7 +2689,7 @@ public override async Task Optional_navigation_type_compensation_works_with_proj await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(isAsync); AssertSql( - @"SELECT CAST([t].[SquadId] AS int) + @"SELECT CAST([t].[SquadId] AS int) AS [SquadId] FROM [Tags] AS [t0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -2705,7 +2704,7 @@ public override async Task Optional_navigation_type_compensation_works_with_DTOs await base.Optional_navigation_type_compensation_works_with_DTOs(isAsync); AssertSql( - @"SELECT CAST([t].[SquadId] AS int) + @"SELECT CAST([t].[SquadId] AS int) AS [Id] FROM [Tags] AS [t0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -3122,10 +3121,11 @@ public override async Task Where_datetimeoffset_date_component(bool isAsync) { await base.Where_datetimeoffset_date_component(isAsync); - AssertSql( - @"SELECT [m].[Id], [m].[CodeName], [m].[Rating], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) > '0001-01-01T00:00:00.0000000-08:00'"); + // issue #16057 +// AssertSql( +// @"SELECT [m].[Id], [m].[CodeName], [m].[Rating], [m].[Timeline] +//FROM [Missions] AS [m] +//WHERE CONVERT(date, [m].[Timeline]) > '0001-01-01T00:00:00.0000000-08:00'"); } public override async Task Where_datetimeoffset_year_component(bool isAsync) @@ -3716,7 +3716,7 @@ public override async Task Select_length_of_string_property(bool isAsync) await base.Select_length_of_string_property(isAsync); AssertSql( - @"SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) + @"SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] FROM [Weapons] AS [w]"); } @@ -3884,7 +3884,7 @@ public override void Member_access_on_derived_entity_using_cast() AssertSql( @"SELECT [f].[Name], [f].[Eradicated] -FROM [ConditionalFactions] AS [f] +FROM [Factions] AS [f] WHERE ([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde') ORDER BY [f].[Name]"); } @@ -3894,8 +3894,8 @@ public override void Member_access_on_derived_materialized_entity_using_cast() base.Member_access_on_derived_materialized_entity_using_cast(); AssertSql( - @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated], [f].[Eradicated] -FROM [ConditionalFactions] AS [f] + @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] WHERE ([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde') ORDER BY [f].[Name]"); } @@ -3906,7 +3906,7 @@ public override void Member_access_on_derived_entity_using_cast_and_let() AssertSql( @"SELECT [f].[Name], [f].[Eradicated] -FROM [ConditionalFactions] AS [f] +FROM [Factions] AS [f] WHERE ([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde') ORDER BY [f].[Name]"); } @@ -3917,7 +3917,7 @@ public override void Property_access_on_derived_entity_using_cast() AssertSql( @"SELECT [f].[Name], [f].[Eradicated] -FROM [ConditionalFactions] AS [f] +FROM [Factions] AS [f] WHERE ([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde') ORDER BY [f].[Name]"); } @@ -4337,7 +4337,7 @@ public override void Select_null_conditional_with_inheritance_negative() WHEN [f].[CommanderName] IS NOT NULL THEN [f].[Eradicated] ELSE NULL END -FROM [ConditionalFactions] AS [f] +FROM [Factions] AS [f] WHERE ([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde')"); } @@ -4874,7 +4874,7 @@ public override async Task Projecting_nullable_bool_in_conditional_works(bool is @"SELECT CASE WHEN [t].[Nickname] IS NOT NULL THEN CAST([t].[HasSoulPatch] AS bit) ELSE CAST(0 AS bit) -END +END AS [Prop] FROM [Tags] AS [t0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -6523,7 +6523,7 @@ public override async Task Null_semantics_on_nullable_bool_from_inner_join_subue FROM [LocustLeaders] AS [l] INNER JOIN ( SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] - FROM [ConditionalFactions] AS [f] + FROM [Factions] AS [f] WHERE (([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde')) AND (([f].[Name] = N'Swarm') AND [f].[Name] IS NOT NULL) ) AS [t] ON [l].[Name] = [t].[CommanderName] WHERE [l].[Discriminator] IN (N'LocustLeader', N'LocustCommander') AND (([t].[Eradicated] <> CAST(1 AS bit)) OR [t].[Eradicated] IS NULL)"); @@ -6538,7 +6538,7 @@ public override async Task Null_semantics_on_nullable_bool_from_left_join_subuer FROM [LocustLeaders] AS [l] LEFT JOIN ( SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] - FROM [ConditionalFactions] AS [f] + FROM [Factions] AS [f] WHERE (([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde')) AND (([f].[Name] = N'Swarm') AND [f].[Name] IS NOT NULL) ) AS [t] ON [l].[Name] = [t].[CommanderName] WHERE [l].[Discriminator] IN (N'LocustLeader', N'LocustCommander') AND (([t].[Eradicated] <> CAST(1 AS bit)) OR [t].[Eradicated] IS NULL)"); @@ -6774,7 +6774,7 @@ WHEN CAST([t].[HasSoulPatch] AS bit) = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE COALESCE([t].[HasSoulPatch], CAST(1 AS bit)) END = CAST(1 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END +END AS [c] FROM [Tags] AS [t0] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -6850,7 +6850,7 @@ public override async Task Join_on_entity_qsre_keys(bool isAsync) await base.Join_on_entity_qsre_keys(isAsync); AssertSql( - @"SELECT [w].[Name], [w0].[Name] + @"SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] FROM [Weapons] AS [w] INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id]"); } @@ -6884,7 +6884,7 @@ public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool await base.Join_on_entity_qsre_keys_outer_key_is_navigation(isAsync); AssertSql( - @"SELECT [w].[Name], [w0].[Name] + @"SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w1] ON [w].[SynergyWithId] = [w1].[Id] INNER JOIN [Weapons] AS [w0] ON [w1].[Id] = [w0].[Id]"); @@ -7176,7 +7176,7 @@ public override async Task Select_subquery_projecting_single_constant_string(boo @"SELECT [s].[Name], ( SELECT TOP(1) N'Foo' FROM [Gears] AS [g] - WHERE ([g].[Discriminator] IN (N'Gear', N'Officer') AND ([s].[Id] = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit))) + WHERE ([g].[Discriminator] IN (N'Gear', N'Officer') AND ([s].[Id] = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit))) AS [Gear] FROM [Squads] AS [s]"); } @@ -7990,7 +7990,7 @@ public override async Task Double_order_by_binary_expression(bool isAsync) await base.Double_order_by_binary_expression(isAsync); AssertSql( - @"SELECT [w].[Id] + 2 + @"SELECT [w].[Id] + 2 AS [Binary] FROM [Weapons] AS [w] ORDER BY [w].[Id] + 2"); } @@ -8355,7 +8355,7 @@ public override async Task Query_with_complex_let_containing_ordering_and_filter SELECT TOP(1) [w].[Name] FROM [Weapons] AS [w] WHERE (([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL) AND ([w].[IsAutomatic] = CAST(1 AS bit)) - ORDER BY [w].[AmmunitionType] DESC) + ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[Nickname] <> N'Dom')"); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs index 26c54e04044..977b5c2d397 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs @@ -20,14 +20,14 @@ public override void Include_reference_with_inheritance1() base.Include_reference_with_inheritance1(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase].* - FROM [BaseReferencesOnBase] AS [e.BaseReferenceOnBase] - WHERE [e.BaseReferenceOnBase].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[Id] = [t].[BaseParentId] -WHERE [e].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity')"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name] + FROM [BaseReferencesOnBase] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [b].[Id] = [t].[BaseParentId] +WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity')"); } public override void Include_reference_with_inheritance_reverse() @@ -35,14 +35,14 @@ public override void Include_reference_with_inheritance_reverse() base.Include_reference_with_inheritance_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[BaseParentId], [e].[Discriminator], [e].[Name], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseReferencesOnBase] AS [e] + @"SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseReferencesOnBase] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[BaseParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase')"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [b].[BaseParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase')"); } public override void Include_self_refence_with_inheritence() @@ -50,14 +50,14 @@ public override void Include_self_refence_with_inheritence() base.Include_self_refence_with_inheritence(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.DerivedSefReferenceOnBase].* - FROM [BaseEntities] AS [e.DerivedSefReferenceOnBase] - WHERE [e.DerivedSefReferenceOnBase].[Discriminator] = N'DerivedInheritanceRelationshipEntity' -) AS [t] ON [e].[Id] = [t].[BaseId] -WHERE [e].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity')"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] = N'DerivedInheritanceRelationshipEntity' +) AS [t] ON [b].[Id] = [t].[BaseId] +WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity')"); } public override void Include_self_refence_with_inheritence_reverse() @@ -65,14 +65,14 @@ public override void Include_self_refence_with_inheritence_reverse() base.Include_self_refence_with_inheritence_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseSelfReferenceOnDerived].* - FROM [BaseEntities] AS [e.BaseSelfReferenceOnDerived] - WHERE [e.BaseSelfReferenceOnDerived].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[BaseId] = [t].[Id] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [b].[BaseId] = [t].[Id] +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Include_reference_with_inheritance_with_filter1() @@ -80,14 +80,14 @@ public override void Include_reference_with_inheritance_with_filter1() base.Include_reference_with_inheritance_with_filter1(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase].* - FROM [BaseReferencesOnBase] AS [e.BaseReferenceOnBase] - WHERE [e.BaseReferenceOnBase].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[Id] = [t].[BaseParentId] -WHERE [e].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name] + FROM [BaseReferencesOnBase] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [b].[Id] = [t].[BaseParentId] +WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_with_inheritance_with_filter_reverse() @@ -95,14 +95,14 @@ public override void Include_reference_with_inheritance_with_filter_reverse() base.Include_reference_with_inheritance_with_filter_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[BaseParentId], [e].[Discriminator], [e].[Name], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseReferencesOnBase] AS [e] + @"SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseReferencesOnBase] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[BaseParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [b].[BaseParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_without_inheritance() @@ -110,10 +110,10 @@ public override void Include_reference_without_inheritance() base.Include_reference_without_inheritance(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [e.ReferenceOnBase].[Id], [e.ReferenceOnBase].[Name], [e.ReferenceOnBase].[ParentId] -FROM [BaseEntities] AS [e] -LEFT JOIN [ReferencesOnBase] AS [e.ReferenceOnBase] ON [e].[Id] = [e.ReferenceOnBase].[ParentId] -WHERE [e].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity')"); + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [r].[Id], [r].[Name], [r].[ParentId] +FROM [BaseEntities] AS [b] +LEFT JOIN [ReferencesOnBase] AS [r] ON [b].[Id] = [r].[ParentId] +WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity')"); } public override void Include_reference_without_inheritance_reverse() @@ -121,13 +121,13 @@ public override void Include_reference_without_inheritance_reverse() base.Include_reference_without_inheritance_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Name], [e].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [ReferencesOnBase] AS [e] + @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [ReferencesOnBase] AS [r] LEFT JOIN ( - SELECT [e.Parent].* - FROM [BaseEntities] AS [e.Parent] - WHERE [e.Parent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[ParentId] = [t].[Id]"); + SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId] + FROM [BaseEntities] AS [b] + WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [r].[ParentId] = [t].[Id]"); } public override void Include_reference_without_inheritance_with_filter() @@ -135,10 +135,10 @@ public override void Include_reference_without_inheritance_with_filter() base.Include_reference_without_inheritance_with_filter(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [e.ReferenceOnBase].[Id], [e.ReferenceOnBase].[Name], [e.ReferenceOnBase].[ParentId] -FROM [BaseEntities] AS [e] -LEFT JOIN [ReferencesOnBase] AS [e.ReferenceOnBase] ON [e].[Id] = [e.ReferenceOnBase].[ParentId] -WHERE [e].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [r].[Id], [r].[Name], [r].[ParentId] +FROM [BaseEntities] AS [b] +LEFT JOIN [ReferencesOnBase] AS [r] ON [b].[Id] = [r].[ParentId] +WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_without_inheritance_with_filter_reverse() @@ -146,14 +146,14 @@ public override void Include_reference_without_inheritance_with_filter_reverse() base.Include_reference_without_inheritance_with_filter_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Name], [e].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [ReferencesOnBase] AS [e] + @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [ReferencesOnBase] AS [r] LEFT JOIN ( - SELECT [e.Parent].* - FROM [BaseEntities] AS [e.Parent] - WHERE [e.Parent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[ParentId] = [t].[Id] -WHERE ([e].[Name] <> N'Bar') OR [e].[Name] IS NULL"); + SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId] + FROM [BaseEntities] AS [b] + WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [r].[ParentId] = [t].[Id] +WHERE ([r].[Name] <> N'Bar') OR [r].[Name] IS NULL"); } public override void Include_collection_with_inheritance1() @@ -182,14 +182,14 @@ public override void Include_collection_with_inheritance_reverse() base.Include_collection_with_inheritance_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[BaseParentId], [e].[Discriminator], [e].[Name], [e].[DerivedProperty], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseCollectionsOnBase] AS [e] + @"SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedProperty], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseCollectionsOnBase] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[BaseParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedCollectionOnBase', N'BaseCollectionOnBase')"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [b].[BaseParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseCollectionOnBase', N'DerivedCollectionOnBase')"); } public override void Include_collection_with_inheritance_with_filter1() @@ -218,14 +218,14 @@ public override void Include_collection_with_inheritance_with_filter_reverse() base.Include_collection_with_inheritance_with_filter_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[BaseParentId], [e].[Discriminator], [e].[Name], [e].[DerivedProperty], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseCollectionsOnBase] AS [e] + @"SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedProperty], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseCollectionsOnBase] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[BaseParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedCollectionOnBase', N'BaseCollectionOnBase') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [b].[BaseParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseCollectionOnBase', N'DerivedCollectionOnBase') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_collection_without_inheritance() @@ -253,13 +253,13 @@ public override void Include_collection_without_inheritance_reverse() base.Include_collection_without_inheritance_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Name], [e].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [CollectionsOnBase] AS [e] + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [CollectionsOnBase] AS [c] LEFT JOIN ( - SELECT [e.Parent].* - FROM [BaseEntities] AS [e.Parent] - WHERE [e.Parent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[ParentId] = [t].[Id]"); + SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId] + FROM [BaseEntities] AS [b] + WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [c].[ParentId] = [t].[Id]"); } public override void Include_collection_without_inheritance_with_filter() @@ -287,14 +287,14 @@ public override void Include_collection_without_inheritance_with_filter_reverse( base.Include_collection_without_inheritance_with_filter_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Name], [e].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [CollectionsOnBase] AS [e] + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [CollectionsOnBase] AS [c] LEFT JOIN ( - SELECT [e.Parent].* - FROM [BaseEntities] AS [e.Parent] - WHERE [e.Parent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') -) AS [t] ON [e].[ParentId] = [t].[Id] -WHERE ([e].[Name] <> N'Bar') OR [e].[Name] IS NULL"); + SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId] + FROM [BaseEntities] AS [b] + WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') +) AS [t] ON [c].[ParentId] = [t].[Id] +WHERE ([c].[Name] <> N'Bar') OR [c].[Name] IS NULL"); } public override void Include_reference_with_inheritance_on_derived1() @@ -302,14 +302,14 @@ public override void Include_reference_with_inheritance_on_derived1() base.Include_reference_with_inheritance_on_derived1(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase].* - FROM [BaseReferencesOnBase] AS [e.BaseReferenceOnBase] - WHERE [e.BaseReferenceOnBase].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[Id] = [t].[BaseParentId] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name] + FROM [BaseReferencesOnBase] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [b].[Id] = [t].[BaseParentId] +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Include_reference_with_inheritance_on_derived2() @@ -317,14 +317,14 @@ public override void Include_reference_with_inheritance_on_derived2() base.Include_reference_with_inheritance_on_derived2(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnDerived].* - FROM [BaseReferencesOnDerived] AS [e.BaseReferenceOnDerived] - WHERE [e.BaseReferenceOnDerived].[Discriminator] IN (N'DerivedReferenceOnDerived', N'BaseReferenceOnDerived') -) AS [t] ON [e].[Id] = [t].[BaseParentId] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name], [b0].[DerivedInheritanceRelationshipEntityId] + FROM [BaseReferencesOnDerived] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnDerived', N'DerivedReferenceOnDerived') +) AS [t] ON [b].[Id] = [t].[BaseParentId] +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Include_reference_with_inheritance_on_derived4() @@ -332,14 +332,14 @@ public override void Include_reference_with_inheritance_on_derived4() base.Include_reference_with_inheritance_on_derived4(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.DerivedReferenceOnDerived].* - FROM [BaseReferencesOnDerived] AS [e.DerivedReferenceOnDerived] - WHERE [e.DerivedReferenceOnDerived].[Discriminator] = N'DerivedReferenceOnDerived' -) AS [t] ON [e].[Id] = [t].[DerivedInheritanceRelationshipEntityId] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name], [b0].[DerivedInheritanceRelationshipEntityId] + FROM [BaseReferencesOnDerived] AS [b0] + WHERE [b0].[Discriminator] = N'DerivedReferenceOnDerived' +) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId] +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Include_reference_with_inheritance_on_derived_reverse() @@ -347,14 +347,14 @@ public override void Include_reference_with_inheritance_on_derived_reverse() base.Include_reference_with_inheritance_on_derived_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[BaseParentId], [e].[Discriminator], [e].[Name], [e].[DerivedInheritanceRelationshipEntityId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseReferencesOnDerived] AS [e] + @"SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedInheritanceRelationshipEntityId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseReferencesOnDerived] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] = N'DerivedInheritanceRelationshipEntity' -) AS [t] ON [e].[BaseParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedReferenceOnDerived', N'BaseReferenceOnDerived')"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] = N'DerivedInheritanceRelationshipEntity' +) AS [t] ON [b].[BaseParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseReferenceOnDerived', N'DerivedReferenceOnDerived')"); } public override void Include_reference_with_inheritance_on_derived_with_filter1() @@ -362,14 +362,14 @@ public override void Include_reference_with_inheritance_on_derived_with_filter1( base.Include_reference_with_inheritance_on_derived_with_filter1(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase].* - FROM [BaseReferencesOnBase] AS [e.BaseReferenceOnBase] - WHERE [e.BaseReferenceOnBase].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[Id] = [t].[BaseParentId] -WHERE ([e].[Discriminator] = N'DerivedInheritanceRelationshipEntity') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name] + FROM [BaseReferencesOnBase] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [b].[Id] = [t].[BaseParentId] +WHERE ([b].[Discriminator] = N'DerivedInheritanceRelationshipEntity') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_with_inheritance_on_derived_with_filter2() @@ -377,14 +377,14 @@ public override void Include_reference_with_inheritance_on_derived_with_filter2( base.Include_reference_with_inheritance_on_derived_with_filter2(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnDerived].* - FROM [BaseReferencesOnDerived] AS [e.BaseReferenceOnDerived] - WHERE [e.BaseReferenceOnDerived].[Discriminator] IN (N'DerivedReferenceOnDerived', N'BaseReferenceOnDerived') -) AS [t] ON [e].[Id] = [t].[BaseParentId] -WHERE ([e].[Discriminator] = N'DerivedInheritanceRelationshipEntity') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name], [b0].[DerivedInheritanceRelationshipEntityId] + FROM [BaseReferencesOnDerived] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnDerived', N'DerivedReferenceOnDerived') +) AS [t] ON [b].[Id] = [t].[BaseParentId] +WHERE ([b].[Discriminator] = N'DerivedInheritanceRelationshipEntity') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_with_inheritance_on_derived_with_filter4() @@ -392,14 +392,14 @@ public override void Include_reference_with_inheritance_on_derived_with_filter4( base.Include_reference_with_inheritance_on_derived_with_filter4(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.DerivedReferenceOnDerived].* - FROM [BaseReferencesOnDerived] AS [e.DerivedReferenceOnDerived] - WHERE [e.DerivedReferenceOnDerived].[Discriminator] = N'DerivedReferenceOnDerived' -) AS [t] ON [e].[Id] = [t].[DerivedInheritanceRelationshipEntityId] -WHERE ([e].[Discriminator] = N'DerivedInheritanceRelationshipEntity') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name], [b0].[DerivedInheritanceRelationshipEntityId] + FROM [BaseReferencesOnDerived] AS [b0] + WHERE [b0].[Discriminator] = N'DerivedReferenceOnDerived' +) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId] +WHERE ([b].[Discriminator] = N'DerivedInheritanceRelationshipEntity') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_with_inheritance_on_derived_with_filter_reverse() @@ -407,14 +407,14 @@ public override void Include_reference_with_inheritance_on_derived_with_filter_r base.Include_reference_with_inheritance_on_derived_with_filter_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[BaseParentId], [e].[Discriminator], [e].[Name], [e].[DerivedInheritanceRelationshipEntityId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseReferencesOnDerived] AS [e] + @"SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedInheritanceRelationshipEntityId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseReferencesOnDerived] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] = N'DerivedInheritanceRelationshipEntity' -) AS [t] ON [e].[BaseParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedReferenceOnDerived', N'BaseReferenceOnDerived') AND (([e].[Name] <> N'Bar') OR [e].[Name] IS NULL)"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] = N'DerivedInheritanceRelationshipEntity' +) AS [t] ON [b].[BaseParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseReferenceOnDerived', N'DerivedReferenceOnDerived') AND (([b].[Name] <> N'Bar') OR [b].[Name] IS NULL)"); } public override void Include_reference_without_inheritance_on_derived1() @@ -422,10 +422,10 @@ public override void Include_reference_without_inheritance_on_derived1() base.Include_reference_without_inheritance_on_derived1(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [e.ReferenceOnBase].[Id], [e.ReferenceOnBase].[Name], [e.ReferenceOnBase].[ParentId] -FROM [BaseEntities] AS [e] -LEFT JOIN [ReferencesOnBase] AS [e.ReferenceOnBase] ON [e].[Id] = [e.ReferenceOnBase].[ParentId] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [r].[Id], [r].[Name], [r].[ParentId] +FROM [BaseEntities] AS [b] +LEFT JOIN [ReferencesOnBase] AS [r] ON [b].[Id] = [r].[ParentId] +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Include_reference_without_inheritance_on_derived2() @@ -433,10 +433,10 @@ public override void Include_reference_without_inheritance_on_derived2() base.Include_reference_without_inheritance_on_derived2(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [e.ReferenceOnDerived].[Id], [e.ReferenceOnDerived].[Name], [e.ReferenceOnDerived].[ParentId] -FROM [BaseEntities] AS [e] -LEFT JOIN [ReferencesOnDerived] AS [e.ReferenceOnDerived] ON [e].[Id] = [e.ReferenceOnDerived].[ParentId] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [r].[Id], [r].[Name], [r].[ParentId] +FROM [BaseEntities] AS [b] +LEFT JOIN [ReferencesOnDerived] AS [r] ON [b].[Id] = [r].[ParentId] +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Include_reference_without_inheritance_on_derived_reverse() @@ -444,13 +444,13 @@ public override void Include_reference_without_inheritance_on_derived_reverse() base.Include_reference_without_inheritance_on_derived_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Name], [e].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [ReferencesOnDerived] AS [e] + @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [ReferencesOnDerived] AS [r] LEFT JOIN ( - SELECT [e.Parent].* - FROM [BaseEntities] AS [e.Parent] - WHERE [e.Parent].[Discriminator] = N'DerivedInheritanceRelationshipEntity' -) AS [t] ON [e].[ParentId] = [t].[Id]"); + SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId] + FROM [BaseEntities] AS [b] + WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' +) AS [t] ON [r].[ParentId] = [t].[Id]"); } public override void Include_collection_with_inheritance_on_derived1() @@ -521,14 +521,14 @@ public override void Include_collection_with_inheritance_on_derived_reverse() base.Include_collection_with_inheritance_on_derived_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[ParentId], [e].[DerivedInheritanceRelationshipEntityId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] -FROM [BaseCollectionsOnDerived] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[ParentId], [b].[DerivedInheritanceRelationshipEntityId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[BaseId] +FROM [BaseCollectionsOnDerived] AS [b] LEFT JOIN ( - SELECT [e.BaseParent].* - FROM [BaseEntities] AS [e.BaseParent] - WHERE [e.BaseParent].[Discriminator] = N'DerivedInheritanceRelationshipEntity' -) AS [t] ON [e].[ParentId] = [t].[Id] -WHERE [e].[Discriminator] IN (N'DerivedCollectionOnDerived', N'BaseCollectionOnDerived')"); + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] = N'DerivedInheritanceRelationshipEntity' +) AS [t] ON [b].[ParentId] = [t].[Id] +WHERE [b].[Discriminator] IN (N'BaseCollectionOnDerived', N'DerivedCollectionOnDerived')"); } public override void Nested_include_with_inheritance_reference_reference1() @@ -536,19 +536,19 @@ public override void Nested_include_with_inheritance_reference_reference1() base.Nested_include_with_inheritance_reference_reference1(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase].* - FROM [BaseReferencesOnBase] AS [e.BaseReferenceOnBase] - WHERE [e.BaseReferenceOnBase].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[Id] = [t].[BaseParentId] + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name] + FROM [BaseReferencesOnBase] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [b].[Id] = [t].[BaseParentId] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase.NestedReference].* - FROM [NestedReferences] AS [e.BaseReferenceOnBase.NestedReference] - WHERE [e.BaseReferenceOnBase.NestedReference].[Discriminator] IN (N'NestedReferenceDerived', N'NestedReferenceBase') + SELECT [n].[Id], [n].[Discriminator], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId] + FROM [NestedReferences] AS [n] + WHERE [n].[Discriminator] IN (N'NestedReferenceBase', N'NestedReferenceDerived') ) AS [t0] ON [t].[Id] = [t0].[ParentReferenceId] -WHERE [e].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity')"); +WHERE [b].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity')"); } public override void Nested_include_with_inheritance_reference_reference3() @@ -556,19 +556,19 @@ public override void Nested_include_with_inheritance_reference_reference3() base.Nested_include_with_inheritance_reference_reference3(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId] -FROM [BaseEntities] AS [e] + @"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId] +FROM [BaseEntities] AS [b] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase].* - FROM [BaseReferencesOnBase] AS [e.BaseReferenceOnBase] - WHERE [e.BaseReferenceOnBase].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[Id] = [t].[BaseParentId] + SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Discriminator], [b0].[Name] + FROM [BaseReferencesOnBase] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [b].[Id] = [t].[BaseParentId] LEFT JOIN ( - SELECT [e.BaseReferenceOnBase.NestedReference].* - FROM [NestedReferences] AS [e.BaseReferenceOnBase.NestedReference] - WHERE [e.BaseReferenceOnBase.NestedReference].[Discriminator] IN (N'NestedReferenceDerived', N'NestedReferenceBase') + SELECT [n].[Id], [n].[Discriminator], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId] + FROM [NestedReferences] AS [n] + WHERE [n].[Discriminator] IN (N'NestedReferenceBase', N'NestedReferenceDerived') ) AS [t0] ON [t].[Id] = [t0].[ParentReferenceId] -WHERE [e].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity'"); } public override void Nested_include_with_inheritance_reference_reference_reverse() @@ -576,19 +576,19 @@ public override void Nested_include_with_inheritance_reference_reference_reverse base.Nested_include_with_inheritance_reference_reference_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[ParentCollectionId], [e].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] -FROM [NestedReferences] AS [e] + @"SELECT [n].[Id], [n].[Discriminator], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] +FROM [NestedReferences] AS [n] LEFT JOIN ( - SELECT [e.ParentReference].* - FROM [BaseReferencesOnBase] AS [e.ParentReference] - WHERE [e.ParentReference].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[ParentReferenceId] = [t].[Id] + SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name] + FROM [BaseReferencesOnBase] AS [b] + WHERE [b].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [n].[ParentReferenceId] = [t].[Id] LEFT JOIN ( - SELECT [e.ParentReference.BaseParent].* - FROM [BaseEntities] AS [e.ParentReference.BaseParent] - WHERE [e.ParentReference.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] -WHERE [e].[Discriminator] IN (N'NestedReferenceDerived', N'NestedReferenceBase')"); +WHERE [n].[Discriminator] IN (N'NestedReferenceBase', N'NestedReferenceDerived')"); } public override void Nested_include_with_inheritance_reference_collection1() @@ -658,19 +658,19 @@ public override void Nested_include_with_inheritance_reference_collection_revers base.Nested_include_with_inheritance_reference_collection_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[ParentCollectionId], [e].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] -FROM [NestedCollections] AS [e] + @"SELECT [n].[Id], [n].[Discriminator], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] +FROM [NestedCollections] AS [n] LEFT JOIN ( - SELECT [e.ParentReference].* - FROM [BaseReferencesOnBase] AS [e.ParentReference] - WHERE [e.ParentReference].[Discriminator] IN (N'DerivedReferenceOnBase', N'BaseReferenceOnBase') -) AS [t] ON [e].[ParentReferenceId] = [t].[Id] + SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name] + FROM [BaseReferencesOnBase] AS [b] + WHERE [b].[Discriminator] IN (N'BaseReferenceOnBase', N'DerivedReferenceOnBase') +) AS [t] ON [n].[ParentReferenceId] = [t].[Id] LEFT JOIN ( - SELECT [e.ParentReference.BaseParent].* - FROM [BaseEntities] AS [e.ParentReference.BaseParent] - WHERE [e.ParentReference.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] -WHERE [e].[Discriminator] IN (N'NestedCollectionDerived', N'NestedCollectionBase')"); +WHERE [n].[Discriminator] IN (N'NestedCollectionBase', N'NestedCollectionDerived')"); } public override void Nested_include_with_inheritance_collection_reference1() @@ -704,19 +704,19 @@ public override void Nested_include_with_inheritance_collection_reference_revers base.Nested_include_with_inheritance_collection_reference_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[ParentCollectionId], [e].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedProperty], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] -FROM [NestedReferences] AS [e] + @"SELECT [n].[Id], [n].[Discriminator], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedProperty], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] +FROM [NestedReferences] AS [n] LEFT JOIN ( - SELECT [e.ParentCollection].* - FROM [BaseCollectionsOnBase] AS [e.ParentCollection] - WHERE [e.ParentCollection].[Discriminator] IN (N'DerivedCollectionOnBase', N'BaseCollectionOnBase') -) AS [t] ON [e].[ParentCollectionId] = [t].[Id] + SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedProperty] + FROM [BaseCollectionsOnBase] AS [b] + WHERE [b].[Discriminator] IN (N'BaseCollectionOnBase', N'DerivedCollectionOnBase') +) AS [t] ON [n].[ParentCollectionId] = [t].[Id] LEFT JOIN ( - SELECT [e.ParentCollection.BaseParent].* - FROM [BaseEntities] AS [e.ParentCollection.BaseParent] - WHERE [e.ParentCollection.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] -WHERE [e].[Discriminator] IN (N'NestedReferenceDerived', N'NestedReferenceBase')"); +WHERE [n].[Discriminator] IN (N'NestedReferenceBase', N'NestedReferenceDerived')"); } public override void Nested_include_with_inheritance_collection_collection1() @@ -760,19 +760,19 @@ public override void Nested_include_with_inheritance_collection_collection_rever base.Nested_include_with_inheritance_collection_collection_reverse(); AssertSql( - @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[ParentCollectionId], [e].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedProperty], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] -FROM [NestedCollections] AS [e] + @"SELECT [n].[Id], [n].[Discriminator], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], [t].[Id], [t].[BaseParentId], [t].[Discriminator], [t].[Name], [t].[DerivedProperty], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[BaseId] +FROM [NestedCollections] AS [n] LEFT JOIN ( - SELECT [e.ParentCollection].* - FROM [BaseCollectionsOnBase] AS [e.ParentCollection] - WHERE [e.ParentCollection].[Discriminator] IN (N'DerivedCollectionOnBase', N'BaseCollectionOnBase') -) AS [t] ON [e].[ParentCollectionId] = [t].[Id] + SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedProperty] + FROM [BaseCollectionsOnBase] AS [b] + WHERE [b].[Discriminator] IN (N'BaseCollectionOnBase', N'DerivedCollectionOnBase') +) AS [t] ON [n].[ParentCollectionId] = [t].[Id] LEFT JOIN ( - SELECT [e.ParentCollection.BaseParent].* - FROM [BaseEntities] AS [e.ParentCollection.BaseParent] - WHERE [e.ParentCollection.BaseParent].[Discriminator] IN (N'DerivedInheritanceRelationshipEntity', N'BaseInheritanceRelationshipEntity') + SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId] + FROM [BaseEntities] AS [b0] + WHERE [b0].[Discriminator] IN (N'BaseInheritanceRelationshipEntity', N'DerivedInheritanceRelationshipEntity') ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] -WHERE [e].[Discriminator] IN (N'NestedCollectionDerived', N'NestedCollectionBase')"); +WHERE [n].[Discriminator] IN (N'NestedCollectionBase', N'NestedCollectionDerived')"); } public override void Nested_include_collection_reference_on_non_entity_base() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index 187c08428ed..49850a1d6a1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -28,15 +28,15 @@ FROM [Entities1] AS [e] // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] = [e].[NullableBoolB]", +WHERE ([e].[BoolA] = [e].[NullableBoolB]) AND [e].[NullableBoolB] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] = [e].[BoolB]", +WHERE ([e].[NullableBoolA] = [e].[BoolB]) AND [e].[NullableBoolA] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); +WHERE (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); } public override void Compare_negated_bool_with_bool_equal() @@ -292,15 +292,15 @@ FROM [Entities1] AS [e] // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] = [e].[NullableBoolB]", +WHERE ([e].[BoolA] = [e].[NullableBoolB]) AND [e].[NullableBoolB] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] = [e].[BoolB]", +WHERE ([e].[NullableBoolA] = [e].[BoolB]) AND [e].[NullableBoolA] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); +WHERE (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); } public override void Compare_negated_bool_with_bool_not_equal_negated() @@ -380,15 +380,15 @@ FROM [Entities1] AS [e] // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] = [e].[NullableBoolB]", +WHERE ([e].[BoolA] = [e].[NullableBoolB]) AND [e].[NullableBoolB] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] = [e].[BoolB]", +WHERE ([e].[NullableBoolA] = [e].[BoolB]) AND [e].[NullableBoolA] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); +WHERE (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); } public override void Compare_equals_method_static() @@ -402,15 +402,15 @@ FROM [Entities1] AS [e] // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] = [e].[NullableBoolB]", +WHERE ([e].[BoolA] = [e].[NullableBoolB]) AND [e].[NullableBoolB] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] = [e].[BoolB]", +WHERE ([e].[NullableBoolA] = [e].[BoolB]) AND [e].[NullableBoolA] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); +WHERE (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)"); } public override void Compare_equals_method_negated() @@ -465,31 +465,31 @@ public override void Compare_complex_equal_equal_equal() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[BoolA] = [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[BoolA] = [e].[BoolB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN [e].[IntA] = [e].[IntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[IntA] = [e].[IntB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[NullableBoolA] = [e].[BoolB]) AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN [e].[IntA] = [e].[NullableIntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[IntA] = [e].[NullableIntB]) AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN ([e].[NullableIntA] = [e].[NullableIntB]) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableIntA] = [e].[NullableIntB]) AND ([e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL)) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -501,31 +501,31 @@ public override void Compare_complex_equal_not_equal_equal() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[BoolA] = [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[BoolA] = [e].[BoolB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN [e].[IntA] = [e].[IntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[IntA] = [e].[IntB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[NullableBoolA] = [e].[BoolB]) AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN [e].[IntA] = [e].[NullableIntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[IntA] = [e].[NullableIntB]) AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN ([e].[NullableIntA] = [e].[NullableIntB]) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableIntA] = [e].[NullableIntB]) AND ([e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL)) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -537,31 +537,31 @@ public override void Compare_complex_not_equal_equal_equal() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[BoolA] <> [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[BoolB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN [e].[IntA] = [e].[IntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[IntA] = [e].[IntB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN [e].[IntA] = [e].[NullableIntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[IntA] = [e].[NullableIntB]) AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN (([e].[NullableIntA] = [e].[NullableIntB]) AND ([e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL)) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableIntA] = [e].[NullableIntB]) AND ([e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL)) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -573,31 +573,31 @@ public override void Compare_complex_not_equal_not_equal_equal() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[BoolA] <> [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[BoolB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN [e].[IntA] = [e].[IntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[IntA] = [e].[IntB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN [e].[IntA] = [e].[NullableIntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[IntA] = [e].[NullableIntB]) AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN (([e].[NullableIntA] = [e].[NullableIntB]) AND ([e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL)) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableIntA] = [e].[NullableIntB]) AND ([e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL)) OR ([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -609,31 +609,31 @@ public override void Compare_complex_not_equal_equal_not_equal() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[BoolA] <> [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[BoolB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN [e].[IntA] <> [e].[IntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[IntA] <> [e].[IntB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN ([e].[IntA] <> [e].[NullableIntB]) OR [e].[NullableIntB] IS NULL - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[IntA] <> [e].[NullableIntB]) OR [e].[NullableIntB] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN (([e].[NullableIntA] <> [e].[NullableIntB]) OR ([e].[NullableIntA] IS NULL OR [e].[NullableIntB] IS NULL)) AND ([e].[NullableIntA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableIntA] <> [e].[NullableIntB]) OR ([e].[NullableIntA] IS NULL OR [e].[NullableIntB] IS NULL)) AND ([e].[NullableIntA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -645,31 +645,31 @@ public override void Compare_complex_not_equal_not_equal_not_equal() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[BoolA] <> [e].[BoolB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[BoolB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN [e].[IntA] <> [e].[IntB] - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[IntA] <> [e].[IntB] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[NullableBoolA] <> [e].[BoolB]) OR [e].[NullableBoolA] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN ([e].[IntA] <> [e].[NullableIntB]) OR [e].[NullableIntB] IS NULL - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([e].[IntA] <> [e].[NullableIntB]) OR [e].[NullableIntB] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END", // @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableBoolA] <> [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL OR [e].[NullableBoolB] IS NULL)) AND ([e].[NullableBoolA] IS NOT NULL OR [e].[NullableBoolB] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END <> CASE - WHEN (([e].[NullableIntA] <> [e].[NullableIntB]) OR ([e].[NullableIntA] IS NULL OR [e].[NullableIntB] IS NULL)) AND ([e].[NullableIntA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (([e].[NullableIntA] <> [e].[NullableIntB]) OR ([e].[NullableIntA] IS NULL OR [e].[NullableIntB] IS NULL)) AND ([e].[NullableIntA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -678,9 +678,11 @@ public override void Compare_nullable_with_null_parameter_equal() base.Compare_nullable_with_null_parameter_equal(); AssertSql( - @"SELECT [e].[Id] + @"@__prm_0='' (Size = 4000) + +SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IS NULL"); +WHERE (([e].[NullableStringA] = @__prm_0) AND ([e].[NullableStringA] IS NOT NULL AND @__prm_0 IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND @__prm_0 IS NULL)"); } public override void Compare_nullable_with_non_null_parameter_not_equal() @@ -692,7 +694,7 @@ public override void Compare_nullable_with_non_null_parameter_not_equal() SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] = @__prm_0"); +WHERE (([e].[NullableStringA] = @__prm_0) AND ([e].[NullableStringA] IS NOT NULL AND @__prm_0 IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND @__prm_0 IS NULL)"); } public override void Join_uses_database_semantics() @@ -700,9 +702,9 @@ public override void Join_uses_database_semantics() base.Join_uses_database_semantics(); AssertSql( - @"SELECT [e1].[Id] AS [Id1], [e2].[Id] AS [Id2], [e1].[NullableIntA], [e2].[NullableIntB] -FROM [Entities1] AS [e1] -INNER JOIN [Entities2] AS [e2] ON [e1].[NullableIntA] = [e2].[NullableIntB]"); + @"SELECT [e].[Id] AS [Id1], [e0].[Id] AS [Id2], [e].[NullableIntA], [e0].[NullableIntB] +FROM [Entities1] AS [e] +INNER JOIN [Entities2] AS [e0] ON [e].[NullableIntA] = [e0].[NullableIntB]"); } public override void Contains_with_local_array_closure_with_null() @@ -722,7 +724,7 @@ public override void Contains_with_local_array_closure_false_with_null() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] NOT IN (N'Foo') AND [e].[NullableStringA] IS NOT NULL"); +WHERE NOT ([e].[NullableStringA] IN (N'Foo') OR [e].[NullableStringA] IS NULL)"); } public override void Contains_with_local_array_closure_with_multiple_nulls() @@ -742,7 +744,7 @@ public override void Where_multiple_ors_with_null() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IN (N'Foo', N'Blah') OR [e].[NullableStringA] IS NULL"); +WHERE ((([e].[NullableStringA] = N'Foo') AND [e].[NullableStringA] IS NOT NULL) OR (([e].[NullableStringA] = N'Blah') AND [e].[NullableStringA] IS NOT NULL)) OR [e].[NullableStringA] IS NULL"); } public override void Where_multiple_ands_with_null() @@ -752,7 +754,7 @@ public override void Where_multiple_ands_with_null() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] NOT IN (N'Foo', N'Blah') AND [e].[NullableStringA] IS NOT NULL"); +WHERE ((([e].[NullableStringA] <> N'Foo') OR [e].[NullableStringA] IS NULL) AND (([e].[NullableStringA] <> N'Blah') OR [e].[NullableStringA] IS NULL)) AND [e].[NullableStringA] IS NOT NULL"); } public override void Where_multiple_ors_with_nullable_parameter() @@ -760,9 +762,11 @@ public override void Where_multiple_ors_with_nullable_parameter() base.Where_multiple_ors_with_nullable_parameter(); AssertSql( - @"SELECT [e].[Id] + @"@__prm_0='' (Size = 4000) + +SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IN (N'Foo') OR [e].[NullableStringA] IS NULL"); +WHERE (([e].[NullableStringA] = N'Foo') AND [e].[NullableStringA] IS NOT NULL) OR ((([e].[NullableStringA] = @__prm_0) AND ([e].[NullableStringA] IS NOT NULL AND @__prm_0 IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND @__prm_0 IS NULL))"); } public override void Where_multiple_ands_with_nullable_parameter_and_constant() @@ -770,11 +774,13 @@ public override void Where_multiple_ands_with_nullable_parameter_and_constant() base.Where_multiple_ands_with_nullable_parameter_and_constant(); AssertSql( - @"@__prm3_2='Blah' (Size = 4000) + @"@__prm1_0='' (Size = 4000) +@__prm2_1='' (Size = 4000) +@__prm3_2='Blah' (Size = 4000) SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] NOT IN (N'Foo', @__prm3_2) AND [e].[NullableStringA] IS NOT NULL"); +WHERE (((([e].[NullableStringA] <> N'Foo') OR [e].[NullableStringA] IS NULL) AND ((([e].[NullableStringA] <> @__prm1_0) OR ([e].[NullableStringA] IS NULL OR @__prm1_0 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm1_0 IS NOT NULL))) AND ((([e].[NullableStringA] <> @__prm2_1) OR ([e].[NullableStringA] IS NULL OR @__prm2_1 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm2_1 IS NOT NULL))) AND ((([e].[NullableStringA] <> @__prm3_2) OR ([e].[NullableStringA] IS NULL OR @__prm3_2 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm3_2 IS NOT NULL))"); } public override void Where_multiple_ands_with_nullable_parameter_and_constant_not_optimized() @@ -782,11 +788,13 @@ public override void Where_multiple_ands_with_nullable_parameter_and_constant_no base.Where_multiple_ands_with_nullable_parameter_and_constant_not_optimized(); AssertSql( - @"@__prm3_2='Blah' (Size = 4000) + @"@__prm1_0='' (Size = 4000) +@__prm2_1='' (Size = 4000) +@__prm3_2='Blah' (Size = 4000) SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ((([e].[NullableStringB] IS NOT NULL AND (([e].[NullableStringA] <> N'Foo') OR [e].[NullableStringA] IS NULL)) AND [e].[NullableStringA] IS NOT NULL) AND [e].[NullableStringA] IS NOT NULL) AND (([e].[NullableStringA] <> @__prm3_2) OR [e].[NullableStringA] IS NULL)"); +WHERE ((([e].[NullableStringB] IS NOT NULL AND (([e].[NullableStringA] <> N'Foo') OR [e].[NullableStringA] IS NULL)) AND ((([e].[NullableStringA] <> @__prm1_0) OR ([e].[NullableStringA] IS NULL OR @__prm1_0 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm1_0 IS NOT NULL))) AND ((([e].[NullableStringA] <> @__prm2_1) OR ([e].[NullableStringA] IS NULL OR @__prm2_1 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm2_1 IS NOT NULL))) AND ((([e].[NullableStringA] <> @__prm3_2) OR ([e].[NullableStringA] IS NULL OR @__prm3_2 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm3_2 IS NOT NULL))"); } public override void Where_coalesce() @@ -804,9 +812,11 @@ public override void Where_equal_nullable_with_null_value_parameter() base.Where_equal_nullable_with_null_value_parameter(); AssertSql( - @"SELECT [e].[Id] + @"@__prm_0='' (Size = 4000) + +SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IS NULL"); +WHERE (([e].[NullableStringA] = @__prm_0) AND ([e].[NullableStringA] IS NOT NULL AND @__prm_0 IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND @__prm_0 IS NULL)"); } public override void Where_not_equal_nullable_with_null_value_parameter() @@ -814,9 +824,11 @@ public override void Where_not_equal_nullable_with_null_value_parameter() base.Where_not_equal_nullable_with_null_value_parameter(); AssertSql( - @"SELECT [e].[Id] + @"@__prm_0='' (Size = 4000) + +SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IS NOT NULL"); +WHERE (([e].[NullableStringA] <> @__prm_0) OR ([e].[NullableStringA] IS NULL OR @__prm_0 IS NULL)) AND ([e].[NullableStringA] IS NOT NULL OR @__prm_0 IS NOT NULL)"); } public override void Where_equal_with_coalesce() @@ -826,7 +838,7 @@ public override void Where_equal_with_coalesce() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE (COALESCE([e].[NullableStringA], [e].[NullableStringB]) = [e].[NullableStringC]) OR (([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) AND [e].[NullableStringC] IS NULL)"); +WHERE ((COALESCE([e].[NullableStringA], [e].[NullableStringB]) = [e].[NullableStringC]) AND (COALESCE([e].[NullableStringA], [e].[NullableStringB]) IS NOT NULL AND [e].[NullableStringC] IS NOT NULL)) OR (COALESCE([e].[NullableStringA], [e].[NullableStringB]) IS NULL AND [e].[NullableStringC] IS NULL)"); } public override void Where_not_equal_with_coalesce() @@ -836,7 +848,7 @@ public override void Where_not_equal_with_coalesce() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ((COALESCE([e].[NullableStringA], [e].[NullableStringB]) <> [e].[NullableStringC]) OR (([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) OR [e].[NullableStringC] IS NULL)) AND (([e].[NullableStringA] IS NOT NULL OR [e].[NullableStringB] IS NOT NULL) OR [e].[NullableStringC] IS NOT NULL)"); +WHERE ((COALESCE([e].[NullableStringA], [e].[NullableStringB]) <> [e].[NullableStringC]) OR (COALESCE([e].[NullableStringA], [e].[NullableStringB]) IS NULL OR [e].[NullableStringC] IS NULL)) AND (COALESCE([e].[NullableStringA], [e].[NullableStringB]) IS NOT NULL OR [e].[NullableStringC] IS NOT NULL)"); } public override void Where_equal_with_coalesce_both_sides() @@ -846,7 +858,7 @@ public override void Where_equal_with_coalesce_both_sides() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE COALESCE([e].[NullableStringA], [e].[NullableStringB]) = COALESCE([e].[StringA], [e].[StringB])"); +WHERE (COALESCE([e].[NullableStringA], [e].[NullableStringB]) = COALESCE([e].[StringA], [e].[StringB])) AND COALESCE([e].[NullableStringA], [e].[NullableStringB]) IS NOT NULL"); } public override void Where_not_equal_with_coalesce_both_sides() @@ -856,23 +868,24 @@ public override void Where_not_equal_with_coalesce_both_sides() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ((COALESCE([e].[NullableIntA], [e].[NullableIntB]) <> COALESCE([e].[NullableIntC], [e].[NullableIntB])) OR (([e].[NullableIntA] IS NULL AND [e].[NullableIntB] IS NULL) OR ([e].[NullableIntC] IS NULL AND [e].[NullableIntB] IS NULL))) AND (([e].[NullableIntA] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL) OR ([e].[NullableIntC] IS NOT NULL OR [e].[NullableIntB] IS NOT NULL))"); +WHERE ((COALESCE([e].[NullableIntA], [e].[NullableIntB]) <> COALESCE([e].[NullableIntC], [e].[NullableIntB])) OR (COALESCE([e].[NullableIntA], [e].[NullableIntB]) IS NULL OR COALESCE([e].[NullableIntC], [e].[NullableIntB]) IS NULL)) AND (COALESCE([e].[NullableIntA], [e].[NullableIntB]) IS NOT NULL OR COALESCE([e].[NullableIntC], [e].[NullableIntB]) IS NOT NULL)"); } public override void Where_equal_with_conditional() { base.Where_equal_with_conditional(); - 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)"); + // 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)"); } public override void Where_not_equal_with_conditional() @@ -883,14 +896,14 @@ public override void Where_not_equal_with_conditional() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE (([e].[NullableStringC] <> CASE - WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) - THEN [e].[NullableStringA] ELSE [e].[NullableStringB] + WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[NullableStringA] + ELSE [e].[NullableStringB] END) OR ([e].[NullableStringC] IS NULL OR CASE - WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) - THEN [e].[NullableStringA] ELSE [e].[NullableStringB] + WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[NullableStringA] + ELSE [e].[NullableStringB] END IS NULL)) AND ([e].[NullableStringC] IS NOT NULL OR CASE - WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) - THEN [e].[NullableStringA] ELSE [e].[NullableStringB] + WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[NullableStringA] + ELSE [e].[NullableStringB] END IS NOT NULL)"); } @@ -902,8 +915,8 @@ public override void Where_equal_with_conditional_non_nullable() @"SELECT [e].[Id] FROM [Entities1] AS [e] WHERE ([e].[NullableStringC] <> CASE - WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) - THEN [e].[StringA] ELSE [e].[StringB] + WHEN (([e].[NullableStringA] = [e].[NullableStringB]) AND ([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[StringA] + ELSE [e].[StringB] END) OR [e].[NullableStringC] IS NULL"); } @@ -914,7 +927,7 @@ public override void Where_equal_with_and_and_contains() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ((CHARINDEX([e].[NullableStringB], [e].[NullableStringA]) > 0) OR ([e].[NullableStringB] = N'')) AND ([e].[BoolA] = CAST(1 AS bit))"); +WHERE ((([e].[NullableStringB] = N'') AND [e].[NullableStringB] IS NOT NULL) OR (CHARINDEX([e].[NullableStringB], [e].[NullableStringA]) > 0)) AND ([e].[BoolA] = CAST(1 AS bit))"); } public override void Null_comparison_in_selector_with_relational_nulls() @@ -923,8 +936,8 @@ public override void Null_comparison_in_selector_with_relational_nulls() AssertSql( @"SELECT CASE - WHEN [e].[NullableStringA] <> N'Foo' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[NullableStringA] <> N'Foo' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END FROM [Entities1] AS [e]"); } @@ -937,11 +950,11 @@ public override void Null_comparison_in_order_by_with_relational_nulls() @"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] FROM [Entities1] AS [e] ORDER BY CASE - WHEN [e].[NullableStringA] <> N'Foo' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[NullableStringA] <> N'Foo' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END, CASE - WHEN [e].[NullableIntB] <> 10 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [e].[NullableIntB] <> 10 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -971,11 +984,11 @@ public override void Where_conditional_search_condition_in_result() SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN @__prm_0 = CAST(1 AS bit) - THEN CASE - WHEN [e].[StringA] IN (N'Foo', N'Bar') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END ELSE CAST(0 AS bit) + WHEN @__prm_0 = CAST(1 AS bit) THEN CASE + WHEN [e].[StringA] IN (N'Foo', N'Bar') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END + ELSE CAST(0 AS bit) END = CAST(1 AS bit)", // @"@__p_0='False' @@ -983,10 +996,10 @@ END ELSE CAST(0 AS bit) SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN @__p_0 = CAST(1 AS bit) - THEN CAST(1 AS bit) ELSE CASE - WHEN [e].[StringA] LIKE N'A%' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN @__p_0 = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CASE + WHEN [e].[StringA] LIKE N'A%' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END END = CAST(1 AS bit)"); } @@ -1002,24 +1015,24 @@ public override void Where_nested_conditional_search_condition_in_result() SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN @__prm1_0 = CAST(1 AS bit) - THEN CASE - WHEN @__prm2_1 = CAST(1 AS bit) - THEN CASE - WHEN [e].[BoolA] = CAST(1 AS bit) - THEN CASE - WHEN [e].[StringA] LIKE N'A%' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END ELSE CAST(0 AS bit) - END ELSE CAST(1 AS bit) - END ELSE CASE - WHEN [e].[BoolB] = CAST(1 AS bit) - THEN CASE - WHEN [e].[StringA] IN (N'Foo', N'Bar') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END ELSE CASE - WHEN [e].[StringB] IN (N'Foo', N'Bar') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN @__prm1_0 = CAST(1 AS bit) THEN CASE + WHEN @__prm2_1 = CAST(1 AS bit) THEN CASE + WHEN [e].[BoolA] = CAST(1 AS bit) THEN CASE + WHEN [e].[StringA] LIKE N'A%' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END + ELSE CAST(0 AS bit) + END + ELSE CAST(1 AS bit) + END + ELSE CASE + WHEN [e].[BoolB] = CAST(1 AS bit) THEN CASE + WHEN [e].[StringA] IN (N'Foo', N'Bar') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END + ELSE CASE + WHEN [e].[StringB] IN (N'Foo', N'Bar') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END END END = CAST(1 AS bit)"); @@ -1052,7 +1065,7 @@ public override void Where_nullable_bool_equal_with_constant() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] = CAST(1 AS bit)"); +WHERE ([e].[NullableBoolA] = CAST(1 AS bit)) AND [e].[NullableBoolA] IS NOT NULL"); } public override void Where_nullable_bool_with_null_check() @@ -1178,9 +1191,11 @@ public override void Where_comparison_null_semantics_optimization_works_with_com base.Where_comparison_null_semantics_optimization_works_with_complex_predicates(); AssertSql( - @"SELECT [e].[Id] + @"@__prm_0='' (Size = 4000) + +SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IS NULL"); +WHERE (([e].[NullableStringA] = @__prm_0) AND ([e].[NullableStringA] IS NOT NULL AND @__prm_0 IS NOT NULL)) OR ([e].[NullableStringA] IS NULL AND @__prm_0 IS NULL)"); } public override void Switching_null_semantics_produces_different_cache_entry() @@ -1190,7 +1205,7 @@ public override void Switching_null_semantics_produces_different_cache_entry() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] = [e].[NullableBoolB]) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)", +WHERE (([e].[NullableBoolA] = [e].[NullableBoolB]) AND ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL)) OR ([e].[NullableBoolA] IS NULL AND [e].[NullableBoolB] IS NULL)", // @"SELECT [e].[Id] FROM [Entities1] AS [e] @@ -1249,36 +1264,38 @@ 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(); - 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)"); + // 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)"); } public override void Null_semantics_applied_when_comparing_two_functions_with_nullable_arguments() { base.Null_semantics_applied_when_comparing_two_functions_with_nullable_arguments(); - 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"); + // 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"); } public override void Null_semantics_applied_when_comparing_two_functions_with_multiple_nullable_arguments() @@ -1288,11 +1305,11 @@ public override void Null_semantics_applied_when_comparing_two_functions_with_mu AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE (REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) = [e].[NullableStringA]) OR ((([e].[NullableStringA] IS NULL OR [e].[NullableStringB] IS NULL) OR [e].[NullableStringC] IS NULL) AND [e].[NullableStringA] IS NULL)", +WHERE ((REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) = [e].[NullableStringA]) AND (REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) IS NOT NULL AND [e].[NullableStringA] IS NOT NULL)) OR (REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) IS NULL AND [e].[NullableStringA] IS NULL)", // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ((REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) <> [e].[NullableStringA]) OR ((([e].[NullableStringA] IS NULL OR [e].[NullableStringB] IS NULL) OR [e].[NullableStringC] IS NULL) OR [e].[NullableStringA] IS NULL)) AND ((([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL) AND [e].[NullableStringC] IS NOT NULL) OR [e].[NullableStringA] IS NOT NULL)"); +WHERE ((REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) <> [e].[NullableStringA]) OR (REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) IS NULL OR [e].[NullableStringA] IS NULL)) AND (REPLACE([e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC]) IS NOT NULL OR [e].[NullableStringA] IS NOT NULL)"); } public override void Null_semantics_coalesce() @@ -1302,7 +1319,7 @@ public override void Null_semantics_coalesce() AssertSql( @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] = CAST(COALESCE([e].[NullableBoolB], [e].[BoolC]) AS bit)) AND [e].[NullableBoolA] IS NOT NULL", +WHERE ([e].[NullableBoolA] = COALESCE([e].[NullableBoolB], [e].[BoolC])) AND [e].[NullableBoolA] IS NOT NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] @@ -1310,7 +1327,7 @@ FROM [Entities1] AS [e] // @"SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE (CAST(COALESCE([e].[NullableBoolB], [e].[BoolC]) AS bit) <> [e].[NullableBoolA]) OR [e].[NullableBoolA] IS NULL", +WHERE (COALESCE([e].[NullableBoolB], [e].[BoolC]) <> [e].[NullableBoolA]) OR [e].[NullableBoolA] IS NULL", // @"SELECT [e].[Id] FROM [Entities1] AS [e] @@ -1370,8 +1387,9 @@ public override void Null_semantics_join_with_composite_key() { base.Null_semantics_join_with_composite_key(); - AssertSql( - @""); + // issue #15994 + //AssertSql( + // @""); } public override void Null_semantics_contains() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs index 5c0a3dccc94..05f4169da37 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs @@ -850,18 +850,16 @@ public void Execute1742(CustomerDetails_1742 details) using (var ctx = new MyContext925(_options)) { var firstName = details.FirstName; - ctx.Customers.Where(c => c.FirstName == firstName && c.LastName == details.LastName).ToList(); - const string expectedSql - = @"@__firstName_0='Foo' (Size = 450) -@__8__locals1_details_LastName_1='Bar' (Size = 450) - -SELECT [c].[FirstName], [c].[LastName] -FROM [Customer] AS [c] -WHERE ([c].[FirstName] = @__firstName_0) AND ([c].[LastName] = @__8__locals1_details_LastName_1)"; + // issue #16057 +// AssertSql( +// @"@__firstName_0='Foo' (Size = 450) +//@__8__locals1_details_LastName_1='Bar' (Size = 450) - AssertSql(expectedSql); +//SELECT [c].[FirstName], [c].[LastName] +//FROM [Customer] AS [c] +//WHERE (([c].[FirstName] = @__firstName_0) AND @__firstName_0 IS NOT NULL) AND (([c].[LastName] = @__8__locals1_details_LastName_1) AND @__8__locals1_details_LastName_1 IS NOT NULL)"); } } } @@ -2280,15 +2278,15 @@ public virtual void Variable_from_closure_is_parametrized() AssertSql( @"@__id_0='1' -SELECT [c].[Id], [c].[Name] -FROM [Entities] AS [c] -WHERE [c].[Id] = @__id_0", +SELECT [e].[Id], [e].[Name] +FROM [Entities] AS [e] +WHERE ([e].[Id] = @__id_0) AND @__id_0 IS NOT NULL", // @"@__id_0='2' -SELECT [c].[Id], [c].[Name] -FROM [Entities] AS [c] -WHERE [c].[Id] = @__id_0"); +SELECT [e].[Id], [e].[Name] +FROM [Entities] AS [e] +WHERE ([e].[Id] = @__id_0) AND @__id_0 IS NOT NULL"); } } } @@ -2317,15 +2315,15 @@ public virtual void Variable_from_nested_closure_is_parametrized() AssertSql( @"@__id_0='1' -SELECT [c].[Id], [c].[Name] -FROM [Entities] AS [c] -WHERE [c].[Id] = @__id_0", +SELECT [e].[Id], [e].[Name] +FROM [Entities] AS [e] +WHERE ([e].[Id] = @__id_0) AND @__id_0 IS NOT NULL", // @"@__id_0='2' -SELECT [c].[Id], [c].[Name] -FROM [Entities] AS [c] -WHERE [c].[Id] = @__id_0"); +SELECT [e].[Id], [e].[Name] +FROM [Entities] AS [e] +WHERE ([e].[Id] = @__id_0) AND @__id_0 IS NOT NULL"); } } } @@ -4404,38 +4402,32 @@ public virtual void Average_with_cast() Assert.Equal(prices.Average(e => e.NullableDecimalColumn), context.Prices.Average(e => e.NullableDecimalColumn)); AssertSql( - @"SELECT AVG([e].[Price]) -FROM [Prices] AS [e]", - // - @"SELECT AVG(CAST([e].[IntColumn] AS float)) -FROM [Prices] AS [e]", - // - @"SELECT AVG(CAST([e].[NullableIntColumn] AS float)) -FROM [Prices] AS [e]", + @"SELECT AVG([p].[Price]) +FROM [Prices] AS [p]", // - @"SELECT AVG(CAST([e].[LongColumn] AS float)) -FROM [Prices] AS [e]", + @"SELECT AVG(CAST([p].[IntColumn] AS float)) +FROM [Prices] AS [p]", // - @"SELECT AVG(CAST([e].[NullableLongColumn] AS float)) -FROM [Prices] AS [e]", + @"SELECT AVG(CAST([p].[NullableIntColumn] AS float)) +FROM [Prices] AS [p]", // - @"SELECT CAST(AVG([e].[FloatColumn]) AS real) -FROM [Prices] AS [e]", + @"SELECT AVG(CAST([p].[LongColumn] AS float)) +FROM [Prices] AS [p]", // - @"SELECT CAST(AVG([e].[NullableFloatColumn]) AS real) -FROM [Prices] AS [e]", + @"SELECT AVG(CAST([p].[NullableLongColumn] AS float)) +FROM [Prices] AS [p]", // - @"SELECT AVG([e].[DoubleColumn]) -FROM [Prices] AS [e]", + @"SELECT CAST(AVG([p].[FloatColumn]) AS real) +FROM [Prices] AS [p]", // - @"SELECT AVG([e].[NullableDoubleColumn]) -FROM [Prices] AS [e]", + @"SELECT CAST(AVG([p].[NullableFloatColumn]) AS real) +FROM [Prices] AS [p]", // - @"SELECT AVG([e].[DecimalColumn]) -FROM [Prices] AS [e]", + @"SELECT AVG([p].[DoubleColumn]) +FROM [Prices] AS [p]", // - @"SELECT AVG([e].[NullableDecimalColumn]) -FROM [Prices] AS [e]"); + @"SELECT AVG([p].[NullableDoubleColumn]) +FROM [Prices] AS [p]"); } } } @@ -4971,9 +4963,9 @@ public virtual void DateTime_Contains_with_smalldatetime_generates_correct_liter Assert.Single(findRecordsWithDateInList); AssertSql( - @"SELECT [a].[Id], [a].[MyTime] -FROM [ReproEntity] AS [a] -WHERE [a].[MyTime] IN ('2018-10-07T00:00:00.000')"); + @"SELECT [r].[Id], [r].[MyTime] +FROM [ReproEntity] AS [r] +WHERE [r].[MyTime] IN ('2018-10-07T00:00:00.000')"); } } } @@ -5044,11 +5036,11 @@ public virtual void Nested_contains_with_enum() AssertSql( @"@__key_2='5f221fb9-66f4-442a-92c9-d97ed5989cc7' -SELECT [x].[Id], [x].[Type] -FROM [Todos] AS [x] +SELECT [t].[Id], [t].[Type] +FROM [Todos] AS [t] WHERE CASE - WHEN [x].[Type] IN (0) - THEN @__key_2 ELSE @__key_2 + WHEN [t].[Type] IN (0) THEN @__key_2 + ELSE @__key_2 END IN ('0a47bcb7-a1cb-4345-8944-c58f82d6aac7', '5f221fb9-66f4-442a-92c9-d97ed5989cc7')"); } } @@ -5360,8 +5352,8 @@ public virtual void Type_casting_inside_sum() var result = context.InventoryPools.Sum(p => (decimal)p.Quantity); AssertSql( - @"SELECT SUM(CAST([p].[Quantity] AS decimal(18,2))) -FROM [InventoryPools] AS [p]"); + @"SELECT SUM(CAST([i].[Quantity] AS decimal(18,2))) +FROM [InventoryPools] AS [i]"); } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/RowNumberPagingTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/RowNumberPagingTest.cs index 6383de8a3dc..09b24341355 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/RowNumberPagingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/RowNumberPagingTest.cs @@ -452,19 +452,17 @@ public override async Task OrderBy_skip_take_distinct_orderby_take(bool isAsync) @__p_0='5' @__p_1='15' -SELECT TOP(@__p_2) [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] +SELECT TOP(@__p_2) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT DISTINCT [t].* + SELECT DISTINCT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( - SELECT [t1].[CustomerID], [t1].[Address], [t1].[City], [t1].[CompanyName], [t1].[ContactName], [t1].[ContactTitle], [t1].[Country], [t1].[Fax], [t1].[Phone], [t1].[PostalCode], [t1].[Region] - FROM ( - SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], ROW_NUMBER() OVER(ORDER BY [c].[ContactTitle], [c].[ContactName]) AS [__RowNumber__] - FROM [Customers] AS [c] - ) AS [t1] - WHERE ([t1].[__RowNumber__] > @__p_0) AND ([t1].[__RowNumber__] <= (@__p_0 + @__p_1)) - ) AS [t] -) AS [t0] -ORDER BY [t0].[ContactTitle]"); + 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] + ORDER BY [c].[ContactTitle], [c].[ContactName] + OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY + ) AS [t0] +) AS [t] +ORDER BY [t].[ContactTitle]"); } public override async Task Skip_Take_Any(bool isAsync) @@ -543,15 +541,13 @@ SELECT CASE WHEN EXISTS ( SELECT 1 FROM ( - SELECT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] - FROM ( - SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], ROW_NUMBER() OVER(ORDER BY [c].[CustomerID]) AS [__RowNumber__] - FROM [Customers] AS [c] - ) AS [t0] - WHERE ([t0].[__RowNumber__] > @__p_0) AND ([t0].[__RowNumber__] <= (@__p_0 + @__p_1)) + 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] + ORDER BY [c].[CustomerID] + OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY ) AS [t] - WHERE [t].[CustomerID] LIKE N'C%') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE [t].[CustomerID] LIKE N'C%') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs index 4814af561d6..4a7c4caf0ae 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs @@ -16,7 +16,7 @@ public override async Task String_StartsWith_Literal(bool isAsync) 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].[ContactName] LIKE N'M%'"); +WHERE [c].[ContactName] IS NOT NULL AND ([c].[ContactName] LIKE N'M%')"); } public override async Task String_StartsWith_Identity(bool isAsync) @@ -26,7 +26,7 @@ public override async Task String_StartsWith_Identity(bool isAsync) 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].[ContactName] LIKE [c].[ContactName] + N'%' AND (LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName])) OR ([c].[ContactName] = N'')"); +WHERE (([c].[ContactName] = N'') AND [c].[ContactName] IS NOT NULL) OR ([c].[ContactName] IS NOT NULL AND ([c].[ContactName] IS NOT NULL AND (([c].[ContactName] LIKE [c].[ContactName] + N'%') AND (((LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName]) AND (LEFT([c].[ContactName], LEN([c].[ContactName])) IS NOT NULL AND [c].[ContactName] IS NOT NULL)) OR (LEFT([c].[ContactName], LEN([c].[ContactName])) IS NULL AND [c].[ContactName] IS NULL)))))"); } public override async Task String_StartsWith_Column(bool isAsync) @@ -36,7 +36,7 @@ public override async Task String_StartsWith_Column(bool isAsync) 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].[ContactName] LIKE [c].[ContactName] + N'%' AND (LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName])) OR ([c].[ContactName] = N'')"); +WHERE (([c].[ContactName] = N'') AND [c].[ContactName] IS NOT NULL) OR ([c].[ContactName] IS NOT NULL AND ([c].[ContactName] IS NOT NULL AND (([c].[ContactName] LIKE [c].[ContactName] + N'%') AND (((LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName]) AND (LEFT([c].[ContactName], LEN([c].[ContactName])) IS NOT NULL AND [c].[ContactName] IS NOT NULL)) OR (LEFT([c].[ContactName], LEN([c].[ContactName])) IS NULL AND [c].[ContactName] IS NULL)))))"); } public override async Task String_StartsWith_MethodCall(bool isAsync) @@ -46,7 +46,7 @@ public override async Task String_StartsWith_MethodCall(bool isAsync) 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].[ContactName] LIKE N'M%'"); +WHERE [c].[ContactName] IS NOT NULL AND ([c].[ContactName] LIKE N'M%')"); } public override async Task String_EndsWith_Literal(bool isAsync) @@ -56,7 +56,7 @@ public override async Task String_EndsWith_Literal(bool isAsync) 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].[ContactName] LIKE N'%b'"); +WHERE [c].[ContactName] IS NOT NULL AND ([c].[ContactName] LIKE N'%b')"); } public override async Task String_EndsWith_Identity(bool isAsync) @@ -66,7 +66,7 @@ public override async Task String_EndsWith_Identity(bool isAsync) 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 (RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName]) OR ([c].[ContactName] = N'')"); +WHERE (([c].[ContactName] = N'') AND [c].[ContactName] IS NOT NULL) OR ([c].[ContactName] IS NOT NULL AND ([c].[ContactName] IS NOT NULL AND (((RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName]) AND (RIGHT([c].[ContactName], LEN([c].[ContactName])) IS NOT NULL AND [c].[ContactName] IS NOT NULL)) OR (RIGHT([c].[ContactName], LEN([c].[ContactName])) IS NULL AND [c].[ContactName] IS NULL))))"); } public override async Task String_EndsWith_Column(bool isAsync) @@ -76,7 +76,7 @@ public override async Task String_EndsWith_Column(bool isAsync) 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 (RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName]) OR ([c].[ContactName] = N'')"); +WHERE (([c].[ContactName] = N'') AND [c].[ContactName] IS NOT NULL) OR ([c].[ContactName] IS NOT NULL AND ([c].[ContactName] IS NOT NULL AND (((RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName]) AND (RIGHT([c].[ContactName], LEN([c].[ContactName])) IS NOT NULL AND [c].[ContactName] IS NOT NULL)) OR (RIGHT([c].[ContactName], LEN([c].[ContactName])) IS NULL AND [c].[ContactName] IS NULL))))"); } public override async Task String_EndsWith_MethodCall(bool isAsync) @@ -86,7 +86,7 @@ public override async Task String_EndsWith_MethodCall(bool isAsync) 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].[ContactName] LIKE N'%m'"); +WHERE [c].[ContactName] IS NOT NULL AND ([c].[ContactName] LIKE N'%m')"); } public override async Task String_Contains_Literal(bool isAsync) @@ -97,10 +97,11 @@ await AssertQuery( cs => cs.Where(c => c.ContactName.Contains("M") || c.ContactName.Contains("m")), // case-sensitive entryCount: 34); - 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"); + // 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"); } public override async Task String_Contains_Identity(bool isAsync) @@ -110,7 +111,7 @@ public override async Task String_Contains_Identity(bool isAsync) 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([c].[ContactName], [c].[ContactName]) > 0) OR ([c].[ContactName] = N'')"); +WHERE (([c].[ContactName] = N'') AND [c].[ContactName] IS NOT NULL) OR (CHARINDEX([c].[ContactName], [c].[ContactName]) > 0)"); } public override async Task String_Contains_Column(bool isAsync) @@ -120,7 +121,7 @@ public override async Task String_Contains_Column(bool isAsync) 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([c].[ContactName], [c].[ContactName]) > 0) OR ([c].[ContactName] = N'')"); +WHERE (([c].[ContactName] = N'') AND [c].[ContactName] IS NOT NULL) OR (CHARINDEX([c].[ContactName], [c].[ContactName]) > 0)"); } public override async Task String_Contains_MethodCall(bool isAsync) @@ -136,413 +137,427 @@ await AssertQuery( 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"); +WHERE (N'M' = N'') OR (CHARINDEX(N'M', [c].[ContactName]) > 0)"); } public override async Task String_Compare_simple_zero(bool isAsync) { await base.String_Compare_simple_zero(isAsync); - 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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'"); + // 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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'"); } public override async Task String_Compare_simple_one(bool isAsync) { await base.String_Compare_simple_one(isAsync); - 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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'"); + // 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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'"); } public override async Task String_compare_with_parameter(bool isAsync) { await base.String_compare_with_parameter(isAsync); - AssertSql( - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] > @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] < @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] <= @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] <= @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] >= @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] >= @__customer_CustomerID_0"); + // issue #15994 +// AssertSql( +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] > @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] < @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] <= @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] <= @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] >= @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] >= @__customer_CustomerID_0"); } public override async Task String_Compare_simple_more_than_one(bool isAsync) { await base.String_Compare_simple_more_than_one(isAsync); - 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]"); + // 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]"); } public override async Task String_Compare_nested(bool isAsync) { await base.String_Compare_nested(isAsync); - 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'M' + [c].[CustomerID]", - // - @"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] <> UPPER([c].[CustomerID])", - // - @"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] > REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])", - // - @"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'M' + [c].[CustomerID]", - // - @"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] > UPPER([c].[CustomerID])", - // - @"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] < REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])"); + // 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'M' + [c].[CustomerID]", +// // +// @"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] <> UPPER([c].[CustomerID])", +// // +// @"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] > REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])", +// // +// @"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'M' + [c].[CustomerID]", +// // +// @"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] > UPPER([c].[CustomerID])", +// // +// @"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] < REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])"); } public override async Task String_Compare_multi_predicate(bool isAsync) { await base.String_Compare_multi_predicate(isAsync); - 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 [c].[CustomerID] < N'CACTU'", - // - @"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].[ContactTitle] = N'Owner' AND [c].[Country] <> N'USA'"); + // 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 [c].[CustomerID] < N'CACTU'", +// // +// @"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].[ContactTitle] = N'Owner' AND [c].[Country] <> N'USA'"); } public override async Task String_Compare_to_simple_zero(bool isAsync) { await base.String_Compare_to_simple_zero(isAsync); - 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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'"); + // 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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'"); } public override async Task String_Compare_to_simple_one(bool isAsync) { await base.String_Compare_to_simple_one(isAsync); - 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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'", - // - @"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'"); + // 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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'", +// // +// @"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'"); } public override async Task String_compare_to_with_parameter(bool isAsync) { await base.String_compare_to_with_parameter(isAsync); - AssertSql( - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] > @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] < @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] <= @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] <= @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] >= @__customer_CustomerID_0", - // - @"@__customer_CustomerID_0='ALFKI' (Size = 4000) - -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] >= @__customer_CustomerID_0"); + // issue #15994 +// AssertSql( +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] > @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] < @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] <= @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] <= @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] >= @__customer_CustomerID_0", +// // +// @"@__customer_CustomerID_0='ALFKI' (Size = 4000) + +//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] >= @__customer_CustomerID_0"); } public override async Task String_Compare_to_simple_more_than_one(bool isAsync) { await base.String_Compare_to_simple_more_than_one(isAsync); - 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]"); + // 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]"); } public override async Task String_Compare_to_nested(bool isAsync) { await base.String_Compare_to_nested(isAsync); - 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'M' + [c].[CustomerID]", - // - @"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] <> UPPER([c].[CustomerID])", - // - @"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] > REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])", - // - @"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'M' + [c].[CustomerID]", - // - @"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] > UPPER([c].[CustomerID])", - // - @"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] < REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])"); + //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'M' + [c].[CustomerID]", +// // +// @"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] <> UPPER([c].[CustomerID])", +// // +// @"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] > REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])", +// // +// @"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'M' + [c].[CustomerID]", +// // +// @"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] > UPPER([c].[CustomerID])", +// // +// @"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] < REPLACE(N'ALFKI', N'ALF', [c].[CustomerID])"); } public override async Task String_Compare_to_multi_predicate(bool isAsync) { await base.String_Compare_to_multi_predicate(isAsync); - 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 [c].[CustomerID] < N'CACTU'", - // - @"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].[ContactTitle] = N'Owner' AND [c].[Country] <> N'USA'"); + // 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 [c].[CustomerID] < N'CACTU'", +// // +// @"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].[ContactTitle] = N'Owner' AND [c].[Country] <> N'USA'"); } public override async Task DateTime_Compare_to_simple_zero(bool isAsync, bool compareTo) { await base.DateTime_Compare_to_simple_zero(isAsync, compareTo); - AssertSql( - @"@__myDatetime_0='1998-05-04T00:00:00' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderDate] = @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderDate] <> @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderDate] > @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderDate] <= @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderDate] > @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderDate] <= @__myDatetime_0"); + // issue #15994 +// AssertSql( +// @"@__myDatetime_0='1998-05-04T00:00:00' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderDate] = @__myDatetime_0", +// // +// @"@__myDatetime_0='1998-05-04T00:00:00' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderDate] <> @__myDatetime_0", +// // +// @"@__myDatetime_0='1998-05-04T00:00:00' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderDate] > @__myDatetime_0", +// // +// @"@__myDatetime_0='1998-05-04T00:00:00' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderDate] <= @__myDatetime_0", +// // +// @"@__myDatetime_0='1998-05-04T00:00:00' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderDate] > @__myDatetime_0", +// // +// @"@__myDatetime_0='1998-05-04T00:00:00' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderDate] <= @__myDatetime_0"); } public override async Task Int_Compare_to_simple_zero(bool isAsync) { await base.Int_Compare_to_simple_zero(isAsync); - AssertSql( - @"@__orderId_0='10250' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderID] = @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderID] <> @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderID] > @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderID] <= @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderID] > @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] -FROM [Orders] AS [c] -WHERE [c].[OrderID] <= @__orderId_0"); + // issue #15994 +// AssertSql( +// @"@__orderId_0='10250' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderID] = @__orderId_0", +// // +// @"@__orderId_0='10250' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderID] <> @__orderId_0", +// // +// @"@__orderId_0='10250' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderID] > @__orderId_0", +// // +// @"@__orderId_0='10250' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderID] <= @__orderId_0", +// // +// @"@__orderId_0='10250' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderID] > @__orderId_0", +// // +// @"@__orderId_0='10250' + +//SELECT [c].[OrderID], [c].[CustomerID], [c].[EmployeeID], [c].[OrderDate] +//FROM [Orders] AS [c] +//WHERE [c].[OrderID] <= @__orderId_0"); } public override async Task Where_math_abs1(bool isAsync) @@ -550,9 +565,9 @@ public override async Task Where_math_abs1(bool isAsync) await base.Where_math_abs1(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ABS([od].[ProductID]) > 10"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ABS([o].[ProductID]) > 10"); } public override async Task Where_math_abs2(bool isAsync) @@ -560,9 +575,9 @@ public override async Task Where_math_abs2(bool isAsync) await base.Where_math_abs2(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ABS([od].[Quantity]) > 10"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ABS([o].[Quantity]) > CAST(10 AS smallint)"); } public override async Task Where_math_abs3(bool isAsync) @@ -570,9 +585,9 @@ public override async Task Where_math_abs3(bool isAsync) await base.Where_math_abs3(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ABS([od].[UnitPrice]) > 10.0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ABS([o].[UnitPrice]) > 10.0"); } public override async Task Where_math_abs_uncorrelated(bool isAsync) @@ -580,9 +595,9 @@ public override async Task Where_math_abs_uncorrelated(bool isAsync) await base.Where_math_abs_uncorrelated(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE 10 < [od].[ProductID]"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE 10 < [o].[ProductID]"); } public override async Task Where_math_ceiling1(bool isAsync) @@ -590,9 +605,9 @@ public override async Task Where_math_ceiling1(bool isAsync) await base.Where_math_ceiling1(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE CEILING([od].[Discount]) > 0.0E0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE CEILING(CAST([o].[Discount] AS float)) > 0.0E0"); } public override async Task Where_math_ceiling2(bool isAsync) @@ -600,9 +615,9 @@ public override async Task Where_math_ceiling2(bool isAsync) await base.Where_math_ceiling2(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE CEILING([od].[UnitPrice]) > 10.0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE CEILING([o].[UnitPrice]) > 10.0"); } public override async Task Where_math_floor(bool isAsync) @@ -610,9 +625,9 @@ public override async Task Where_math_floor(bool isAsync) await base.Where_math_floor(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE FLOOR([od].[UnitPrice]) > 10.0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE FLOOR([o].[UnitPrice]) > 10.0"); } public override async Task Where_math_power(bool isAsync) @@ -620,9 +635,9 @@ public override async Task Where_math_power(bool isAsync) await base.Where_math_power(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE POWER([od].[Discount], 2.0E0) > 0.05000000074505806E0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE POWER(CAST([o].[Discount] AS float), 2.0E0) > 0.05000000074505806E0"); } public override async Task Where_math_round(bool isAsync) @@ -630,9 +645,9 @@ public override async Task Where_math_round(bool isAsync) await base.Where_math_round(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ROUND([od].[UnitPrice], 0) > 10.0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ROUND([o].[UnitPrice], 0) > 10.0"); } public override async Task Select_math_round_int(bool isAsync) @@ -660,9 +675,9 @@ public override async Task Where_math_round2(bool isAsync) await base.Where_math_round2(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ROUND([od].[UnitPrice], 2) > 100.0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ROUND([o].[UnitPrice], 2) > 100.0"); } public override async Task Where_math_truncate(bool isAsync) @@ -670,9 +685,9 @@ public override async Task Where_math_truncate(bool isAsync) await base.Where_math_truncate(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ROUND([od].[UnitPrice], 0, 1) > 10.0"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ROUND([o].[UnitPrice], 0, 1) > 10.0"); } public override async Task Where_math_exp(bool isAsync) @@ -680,9 +695,9 @@ public override async Task Where_math_exp(bool isAsync) await base.Where_math_exp(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (EXP([od].[Discount]) > 1.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (EXP(CAST([o].[Discount] AS float)) > 1.0E0)"); } public override async Task Where_math_log10(bool isAsync) @@ -690,9 +705,9 @@ public override async Task Where_math_log10(bool isAsync) await base.Where_math_log10(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE (([od].[OrderID] = 11077) AND ([od].[Discount] > CAST(0 AS real))) AND (LOG10([od].[Discount]) < 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE (([o].[OrderID] = 11077) AND ([o].[Discount] > CAST(0 AS real))) AND (LOG10(CAST([o].[Discount] AS float)) < 0.0E0)"); } public override async Task Where_math_log(bool isAsync) @@ -700,9 +715,9 @@ public override async Task Where_math_log(bool isAsync) await base.Where_math_log(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE (([od].[OrderID] = 11077) AND ([od].[Discount] > CAST(0 AS real))) AND (LOG([od].[Discount]) < 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE (([o].[OrderID] = 11077) AND ([o].[Discount] > CAST(0 AS real))) AND (LOG(CAST([o].[Discount] AS float)) < 0.0E0)"); } public override async Task Where_math_log_new_base(bool isAsync) @@ -710,9 +725,9 @@ public override async Task Where_math_log_new_base(bool isAsync) await base.Where_math_log_new_base(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE (([od].[OrderID] = 11077) AND ([od].[Discount] > CAST(0 AS real))) AND (LOG([od].[Discount], 7.0E0) < 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE (([o].[OrderID] = 11077) AND ([o].[Discount] > CAST(0 AS real))) AND (LOG(CAST([o].[Discount] AS float), 7.0E0) < 0.0E0)"); } public override async Task Where_math_sqrt(bool isAsync) @@ -720,9 +735,9 @@ public override async Task Where_math_sqrt(bool isAsync) await base.Where_math_sqrt(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (SQRT([od].[Discount]) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (SQRT(CAST([o].[Discount] AS float)) > 0.0E0)"); } public override async Task Where_math_acos(bool isAsync) @@ -730,9 +745,9 @@ public override async Task Where_math_acos(bool isAsync) await base.Where_math_acos(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (ACOS([od].[Discount]) > 1.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (ACOS(CAST([o].[Discount] AS float)) > 1.0E0)"); } public override async Task Where_math_asin(bool isAsync) @@ -740,9 +755,9 @@ public override async Task Where_math_asin(bool isAsync) await base.Where_math_asin(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (ASIN([od].[Discount]) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (ASIN(CAST([o].[Discount] AS float)) > 0.0E0)"); } public override async Task Where_math_atan(bool isAsync) @@ -750,9 +765,9 @@ public override async Task Where_math_atan(bool isAsync) await base.Where_math_atan(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (ATAN([od].[Discount]) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (ATAN(CAST([o].[Discount] AS float)) > 0.0E0)"); } public override async Task Where_math_atan2(bool isAsync) @@ -760,9 +775,9 @@ public override async Task Where_math_atan2(bool isAsync) await base.Where_math_atan2(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (ATN2([od].[Discount], 1.0E0) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (ATN2(CAST([o].[Discount] AS float), 1.0E0) > 0.0E0)"); } public override async Task Where_math_cos(bool isAsync) @@ -770,9 +785,9 @@ public override async Task Where_math_cos(bool isAsync) await base.Where_math_cos(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (COS([od].[Discount]) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (COS(CAST([o].[Discount] AS float)) > 0.0E0)"); } public override async Task Where_math_sin(bool isAsync) @@ -780,9 +795,9 @@ public override async Task Where_math_sin(bool isAsync) await base.Where_math_sin(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (SIN([od].[Discount]) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (SIN(CAST([o].[Discount] AS float)) > 0.0E0)"); } public override async Task Where_math_tan(bool isAsync) @@ -790,9 +805,9 @@ public override async Task Where_math_tan(bool isAsync) await base.Where_math_tan(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (TAN([od].[Discount]) > 0.0E0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (TAN(CAST([o].[Discount] AS float)) > 0.0E0)"); } public override async Task Where_math_sign(bool isAsync) @@ -800,9 +815,9 @@ public override async Task Where_math_sign(bool isAsync) await base.Where_math_sign(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE ([od].[OrderID] = 11077) AND (SIGN([od].[Discount]) > 0)"); + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE ([o].[OrderID] = 11077) AND (SIGN([o].[Discount]) > 0)"); } // TODO: Client Eval @@ -816,8 +831,8 @@ public override async Task Where_guid_newguid(bool isAsync) await base.Where_guid_newguid(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] WHERE NEWID() <> '00000000-0000-0000-0000-000000000000'"); } @@ -828,7 +843,7 @@ public override async Task Where_string_to_upper(bool isAsync) 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 UPPER([c].[CustomerID]) = N'ALFKI'"); +WHERE (UPPER([c].[CustomerID]) = N'ALFKI') AND UPPER([c].[CustomerID]) IS NOT NULL"); } public override async Task Where_string_to_lower(bool isAsync) @@ -838,7 +853,7 @@ public override async Task Where_string_to_lower(bool isAsync) 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 LOWER([c].[CustomerID]) = N'alfki'"); +WHERE (LOWER([c].[CustomerID]) = N'alfki') AND LOWER([c].[CustomerID]) IS NOT NULL"); } public override async Task Where_functions_nested(bool isAsync) @@ -848,45 +863,46 @@ public override async Task Where_functions_nested(bool isAsync) 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 POWER(CAST(LEN([c].[CustomerID]) AS int), 2.0E0) = 25.0E0"); +WHERE (POWER(CAST(CAST(LEN([c].[CustomerID]) AS int) AS float), 2.0E0) = 25.0E0) AND POWER(CAST(CAST(LEN([c].[CustomerID]) AS int) AS float), 2.0E0) IS NOT NULL"); } public override async Task Convert_ToByte(bool isAsync) { await base.Convert_ToByte(isAsync); + AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(float, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(float, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(smallint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(int, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(bigint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(tinyint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0)"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(tinyint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS tinyint))"); } public override async Task Convert_ToDecimal(bool isAsync) @@ -896,35 +912,35 @@ public override async Task Convert_ToDecimal(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(float, [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(float, [o].[OrderID] % 1)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(float, [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(int, [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(int, [o].[OrderID] % 1)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0)"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0)"); } public override async Task Convert_ToDouble(bool isAsync) @@ -934,35 +950,35 @@ public override async Task Convert_ToDouble(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(float, [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(float, [o].[OrderID] % 1)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(float, [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(int, [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(int, [o].[OrderID] % 1)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0E0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0E0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(float, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0E0)"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(float, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0E0)"); } public override async Task Convert_ToInt16(bool isAsync) @@ -972,35 +988,35 @@ public override async Task Convert_ToInt16(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(float, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(float, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(smallint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(int, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(bigint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS smallint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(smallint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0)"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(smallint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS smallint))"); } public override async Task Convert_ToInt32(bool isAsync) @@ -1010,35 +1026,35 @@ public override async Task Convert_ToInt32(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(float, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(float, [o].[OrderID] % 1)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(float, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(smallint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(smallint, [o].[OrderID] % 1)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(int, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(int, [o].[OrderID] % 1)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(bigint, [o].[OrderID] % 1)) >= 0)", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(bigint, [o].[OrderID] % 1)) >= 0)", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(int, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0)"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(int, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0)"); } public override async Task Convert_ToInt64(bool isAsync) @@ -1048,35 +1064,35 @@ public override async Task Convert_ToInt64(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS bigint))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(bigint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS bigint))"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(bigint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS bigint))"); } public override async Task Convert_ToString(bool isAsync) @@ -1086,39 +1102,39 @@ public override async Task Convert_ToString(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(tinyint, [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(tinyint, [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(float, [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(float, [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(float, [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(smallint, [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(smallint, [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(int, [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(int, [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(bigint, [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(bigint, [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND (CONVERT(nvarchar(max), CONVERT(nvarchar(max), [o].[OrderID] % 1)) <> N'10')", +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (CONVERT(nvarchar(max), CONVERT(nvarchar(max), [o].[OrderID] % 1)) <> N'10')", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'ALFKI') AND ((CHARINDEX(N'1997', CONVERT(nvarchar(max), [o].[OrderDate])) > 0) OR (CHARINDEX(N'1998', CONVERT(nvarchar(max), [o].[OrderDate])) > 0))"); +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) AND (((N'1997' = N'') OR (CHARINDEX(N'1997', CONVERT(nvarchar(max), [o].[OrderDate])) > 0)) OR ((N'1998' = N'') OR (CHARINDEX(N'1998', CONVERT(nvarchar(max), [o].[OrderDate])) > 0)))"); } public override async Task Indexof_with_emptystring(bool isAsync) @@ -1127,8 +1143,8 @@ public override async Task Indexof_with_emptystring(bool isAsync) AssertSql( @"SELECT CASE - WHEN N'' = N'' - THEN 0 ELSE CHARINDEX(N'', [c].[ContactName]) - 1 + WHEN N'' = N'' THEN 0 + ELSE CHARINDEX(N'', [c].[ContactName]) - 1 END FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI'"); @@ -1148,30 +1164,33 @@ public override async Task Substring_with_zero_startindex(bool isAsync) { await base.Substring_with_zero_startindex(isAsync); - AssertSql( - @"SELECT SUBSTRING([c].[ContactName], 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI'"); + // issue #15994 +// AssertSql( +// @"SELECT SUBSTRING([c].[ContactName], 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); - AssertSql( - @"SELECT SUBSTRING([c].[ContactName], 3, 0) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI'"); + // issue #15994 +// AssertSql( +// @"SELECT SUBSTRING([c].[ContactName], 3, 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); - AssertSql( - @"SELECT SUBSTRING([c].[ContactName], 2, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI'"); + // issue #15994 +// AssertSql( +// @"SELECT SUBSTRING([c].[ContactName], 2, 3) +//FROM [Customers] AS [c] +//WHERE [c].[CustomerID] = N'ALFKI'"); } public override async Task Substring_with_closure(bool isAsync) @@ -1191,7 +1210,10 @@ public override async Task Substring_with_Index_of(bool isAsync) await base.Substring_with_Index_of(isAsync); AssertSql( - @"SELECT [c].[ContactName] + @"SELECT SUBSTRING([c].[ContactName], CASE + WHEN N'a' = N'' THEN 0 + ELSE CHARINDEX(N'a', [c].[ContactName]) - 1 +END + 1, 3) FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI'"); } @@ -1203,7 +1225,7 @@ public override async Task IsNullOrEmpty_in_predicate(bool isAsync) 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].[Region] IS NULL OR ([c].[Region] = N'')"); +WHERE [c].[Region] IS NULL OR (([c].[Region] = N'') AND [c].[Region] IS NOT NULL)"); } public override void IsNullOrEmpty_in_projection() @@ -1212,8 +1234,8 @@ public override void IsNullOrEmpty_in_projection() AssertSql( @"SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[Region] IS NULL OR ([c].[Region] = N'') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[Region] IS NULL OR (([c].[Region] = N'') AND [c].[Region] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c]"); } @@ -1224,8 +1246,8 @@ public override void IsNullOrEmpty_negated_in_projection() AssertSql( @"SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[Region] IS NOT NULL AND ([c].[Region] <> N'') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[Region] IS NOT NULL AND (([c].[Region] <> N'') OR [c].[Region] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c]"); } @@ -1237,7 +1259,7 @@ public override async Task IsNullOrWhiteSpace_in_predicate(bool isAsync) 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].[Region] IS NULL OR (LTRIM(RTRIM([c].[Region])) = N'')"); +WHERE [c].[Region] IS NULL OR ((LTRIM(RTRIM([c].[Region])) = N'') AND LTRIM(RTRIM([c].[Region])) IS NOT NULL)"); } public override async Task TrimStart_without_arguments_in_predicate(bool isAsync) @@ -1247,7 +1269,7 @@ public override async Task TrimStart_without_arguments_in_predicate(bool isAsync 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 LTRIM([c].[ContactTitle]) = N'Owner'"); +WHERE (LTRIM([c].[ContactTitle]) = N'Owner') AND LTRIM([c].[ContactTitle]) IS NOT NULL"); } // TODO: Client Eval @@ -1263,7 +1285,7 @@ public override async Task TrimEnd_without_arguments_in_predicate(bool isAsync) 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 RTRIM([c].[ContactTitle]) = N'Owner'"); +WHERE (RTRIM([c].[ContactTitle]) = N'Owner') AND RTRIM([c].[ContactTitle]) IS NOT NULL"); } // TODO: Client Eval @@ -1279,7 +1301,7 @@ public override async Task Trim_without_argument_in_predicate(bool isAsync) 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 LTRIM(RTRIM([c].[ContactTitle])) = N'Owner'"); +WHERE (LTRIM(RTRIM([c].[ContactTitle])) = N'Owner') AND LTRIM(RTRIM([c].[ContactTitle])) IS NOT NULL"); } // TODO: Client Eval @@ -1321,11 +1343,11 @@ public override async Task Static_equals_nullable_datetime_compared_to_non_nulla await base.Static_equals_nullable_datetime_compared_to_non_nullable(isAsync); AssertSql( - @"@__arg_0='1996-07-04T00:00:00' (DbType = DateTime) + @"@__arg_0='1996-07-04T00:00:00' SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE [o].[OrderDate] = @__arg_0"); +WHERE (([o].[OrderDate] = @__arg_0) AND ([o].[OrderDate] IS NOT NULL AND @__arg_0 IS NOT NULL)) OR ([o].[OrderDate] IS NULL AND @__arg_0 IS NULL)"); } public override async Task Static_equals_int_compared_to_long(bool isAsync) @@ -1335,40 +1357,43 @@ public override async Task Static_equals_int_compared_to_long(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool isAsync) { await base.Projecting_Math_Truncate_and_ordering_by_it_twice(isAsync); - AssertSql( - @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -ORDER BY [A]"); + // issue #16038 +// AssertSql( +// @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] +//FROM [Orders] AS [o] +//WHERE [o].[OrderID] < 10250 +//ORDER BY [A]"); } public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool isAsync) { await base.Projecting_Math_Truncate_and_ordering_by_it_twice2(isAsync); - AssertSql( - @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -ORDER BY [A] DESC"); + // issue #16038 +// AssertSql( +// @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] +//FROM [Orders] AS [o] +//WHERE [o].[OrderID] < 10250 +//ORDER BY [A] DESC"); } public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool isAsync) { await base.Projecting_Math_Truncate_and_ordering_by_it_twice3(isAsync); - AssertSql( - @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -ORDER BY [A] DESC"); + // issue #16038 +// AssertSql( +// @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] +//FROM [Orders] AS [o] +//WHERE [o].[OrderID] < 10250 +//ORDER BY [A] DESC"); } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs index 0da4c599a4c..cbcf94ddb20 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs @@ -92,16 +92,14 @@ public override async Task Join_customers_orders_with_subquery(bool isAsync) { await base.Join_customers_orders_with_subquery(isAsync); - AssertContainsSql( + AssertSql( @"SELECT [c].[ContactName], [t].[OrderID] FROM [Customers] AS [c] INNER JOIN ( - SELECT [o2].* - FROM [Orders] AS [o2] - ORDER BY [o2].[OrderID] - OFFSET 0 ROWS + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + FROM [Orders] AS [o] ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] -WHERE [t].[CustomerID] = N'ALFKI'"); +WHERE ([t].[CustomerID] = N'ALFKI') AND [t].[CustomerID] IS NOT NULL"); } public override async Task Join_customers_orders_with_subquery_with_take(bool isAsync) @@ -114,11 +112,11 @@ public override async Task Join_customers_orders_with_subquery_with_take(bool is SELECT [c].[ContactName], [t].[OrderID] FROM [Customers] AS [c] INNER JOIN ( - SELECT TOP(@__p_0) [o2].* - FROM [Orders] AS [o2] - ORDER BY [o2].[OrderID] + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + FROM [Orders] AS [o] + ORDER BY [o].[OrderID] ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] -WHERE [t].[CustomerID] = N'ALFKI'"); +WHERE ([t].[CustomerID] = N'ALFKI') AND [t].[CustomerID] IS NOT NULL"); } public override async Task Join_customers_orders_with_subquery_anonymous_property_method(bool isAsync) @@ -160,17 +158,15 @@ public override async Task Join_customers_orders_with_subquery_predicate(bool is { await base.Join_customers_orders_with_subquery_predicate(isAsync); - AssertContainsSql( + AssertSql( @"SELECT [c].[ContactName], [t].[OrderID] FROM [Customers] AS [c] INNER JOIN ( - SELECT [o2].* - FROM [Orders] AS [o2] - WHERE [o2].[OrderID] > 0 - ORDER BY [o2].[OrderID] - OFFSET 0 ROWS + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + FROM [Orders] AS [o] + WHERE [o].[OrderID] > 0 ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] -WHERE [t].[CustomerID] = N'ALFKI'"); +WHERE ([t].[CustomerID] = N'ALFKI') AND [t].[CustomerID] IS NOT NULL"); } public override async Task Join_customers_orders_with_subquery_predicate_with_take(bool isAsync) @@ -183,12 +179,12 @@ public override async Task Join_customers_orders_with_subquery_predicate_with_ta SELECT [c].[ContactName], [t].[OrderID] FROM [Customers] AS [c] INNER JOIN ( - SELECT TOP(@__p_0) [o2].* - FROM [Orders] AS [o2] - WHERE [o2].[OrderID] > 0 - ORDER BY [o2].[OrderID] + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + FROM [Orders] AS [o] + WHERE [o].[OrderID] > 0 + ORDER BY [o].[OrderID] ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] -WHERE [t].[CustomerID] = N'ALFKI'"); +WHERE ([t].[CustomerID] = N'ALFKI') AND [t].[CustomerID] IS NOT NULL"); } public override async Task Join_composite_key(bool isAsync) @@ -198,7 +194,7 @@ public override async Task Join_composite_key(bool isAsync) AssertSql( @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Customers] AS [c] -INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID]"); +INNER JOIN [Orders] AS [o] ON (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AND (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL)"); } public override async Task Join_complex_condition(bool isAsync) @@ -209,10 +205,10 @@ public override async Task Join_complex_condition(bool isAsync) @"SELECT [c].[CustomerID] FROM [Customers] AS [c] INNER JOIN ( - SELECT [o].* + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderID] < 10250 -) AS [t] ON 1 = 1 +) AS [t] ON CAST(1 AS bit) = CAST(1 AS bit) WHERE [c].[CustomerID] = N'ALFKI'"); } @@ -233,10 +229,10 @@ public override async Task Join_same_collection_multiple(bool isAsync) await base.Join_same_collection_multiple(isAsync); AssertSql( - @"SELECT [i0].[CustomerID], [i0].[Address], [i0].[City], [i0].[CompanyName], [i0].[ContactName], [i0].[ContactTitle], [i0].[Country], [i0].[Fax], [i0].[Phone], [i0].[PostalCode], [i0].[Region] -FROM [Customers] AS [o] -INNER JOIN [Customers] AS [i] ON [o].[CustomerID] = [i].[CustomerID] -INNER JOIN [Customers] AS [i0] ON [o].[CustomerID] = [i0].[CustomerID]"); + @"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 [c0] +INNER JOIN [Customers] AS [c1] ON [c0].[CustomerID] = [c1].[CustomerID] +INNER JOIN [Customers] AS [c] ON [c0].[CustomerID] = [c].[CustomerID]"); } public override async Task Join_same_collection_force_alias_uniquefication(bool isAsync) @@ -244,9 +240,9 @@ public override async Task Join_same_collection_force_alias_uniquefication(bool await base.Join_same_collection_force_alias_uniquefication(isAsync); AssertSql( - @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [i].[OrderID], [i].[CustomerID], [i].[EmployeeID], [i].[OrderDate] + @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM [Orders] AS [o] -INNER JOIN [Orders] AS [i] ON [o].[CustomerID] = [i].[CustomerID]"); +INNER JOIN [Orders] AS [o0] ON [o].[CustomerID] = [o0].[CustomerID]"); } public override async Task GroupJoin_customers_orders_count(bool isAsync) @@ -372,10 +368,10 @@ public override async Task GroupJoin_DefaultIfEmpty_multiple(bool isAsync) await base.GroupJoin_DefaultIfEmpty_multiple(isAsync); AssertSql( - @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o1].[OrderID], [o1].[CustomerID], [o1].[EmployeeID], [o1].[OrderDate], [o2].[OrderID], [o2].[CustomerID], [o2].[EmployeeID], [o2].[OrderDate] + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM [Customers] AS [c] -LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] -LEFT JOIN [Orders] AS [o2] ON [c].[CustomerID] = [o2].[CustomerID]"); +LEFT JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] +LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID]"); } public override async Task GroupJoin_DefaultIfEmpty2(bool isAsync) @@ -392,16 +388,17 @@ public override async Task GroupJoin_DefaultIfEmpty3(bool isAsync) { await base.GroupJoin_DefaultIfEmpty3(isAsync); - AssertSql( - @"@__p_0='1' + // issue #15994 +// AssertSql( +// @"@__p_0='1' -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM ( - SELECT TOP(@__p_0) [c].* - FROM [Customers] AS [c] - ORDER BY [c].[CustomerID] -) AS [t] -LEFT JOIN [Orders] AS [o] ON [t].[CustomerID] = [o].[CustomerID]"); +//SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +//FROM ( +// SELECT TOP(@__p_0) [c].* +// FROM [Customers] AS [c] +// ORDER BY [c].[CustomerID] +//) AS [t] +//LEFT JOIN [Orders] AS [o] ON [t].[CustomerID] = [o].[CustomerID]"); } public override async Task GroupJoin_Where(bool isAsync) @@ -412,7 +409,7 @@ public override async Task GroupJoin_Where(bool isAsync) @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Customers] AS [c] INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] -WHERE [o].[CustomerID] = N'ALFKI'"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL"); } public override async Task GroupJoin_Where_OrderBy(bool isAsync) @@ -423,7 +420,7 @@ public override async Task GroupJoin_Where_OrderBy(bool isAsync) @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Customers] AS [c] INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] -WHERE ([o].[CustomerID] = N'ALFKI') OR ([c].[CustomerID] = N'ANATR') +WHERE (([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL) OR ([c].[CustomerID] = N'ANATR') ORDER BY [c].[City]"); } @@ -500,7 +497,7 @@ public override async Task GroupJoin_SelectMany_subquery_with_filter(bool isAsyn @"SELECT [c].[ContactName], [t].[OrderID] FROM [Customers] AS [c] INNER JOIN ( - SELECT [o].* + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderID] > 5 ) AS [t] ON [c].[CustomerID] = [t].[CustomerID]"); @@ -522,7 +519,7 @@ public override async Task GroupJoin_SelectMany_subquery_with_filter_and_Default await base.GroupJoin_SelectMany_subquery_with_filter_and_DefaultIfEmpty(isAsync); AssertSql( - @"SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [c].[ContactName] + @"SELECT [c].[ContactName], [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate] FROM [Customers] AS [c] LEFT JOIN ( SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.QueryTypes.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.QueryTypes.cs index 256d73c5e33..932d2980226 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.QueryTypes.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.QueryTypes.cs @@ -23,7 +23,7 @@ public override async Task QueryType_where_simple(bool isAsync) AssertSql( @"SELECT [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle] FROM [Customers] AS [c] -WHERE [c].[City] = N'London'"); +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL"); } public override void Query_backed_by_database_view() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs index cfaf6f62a98..e537ea100cb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs @@ -35,8 +35,8 @@ public override void Select_All() WHEN NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE ([o].[CustomerID] <> N'ALFKI') OR [o].[CustomerID] IS NULL) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE ([o].[CustomerID] <> N'ALFKI') OR [o].[CustomerID] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -81,8 +81,8 @@ public override async Task Sum_with_division_on_decimal(bool isAsync) await base.Sum_with_division_on_decimal(isAsync); AssertSql( - @"SELECT SUM([od].[Quantity] / 2.09) -FROM [Order Details] AS [od]"); + @"SELECT SUM(CAST([o].[Quantity] AS decimal(18,2)) / 2.09) +FROM [Order Details] AS [o]"); } public override async Task Sum_with_division_on_decimal_no_significant_digits(bool isAsync) @@ -90,8 +90,8 @@ public override async Task Sum_with_division_on_decimal_no_significant_digits(bo await base.Sum_with_division_on_decimal_no_significant_digits(isAsync); AssertSql( - @"SELECT SUM([od].[Quantity] / 2.0) -FROM [Order Details] AS [od]"); + @"SELECT SUM(CAST([o].[Quantity] AS decimal(18,2)) / 2.0) +FROM [Order Details] AS [o]"); } public override async Task Sum_with_coalesce(bool isAsync) @@ -138,9 +138,9 @@ public override async Task Sum_on_float_column(bool isAsync) await base.Sum_on_float_column(isAsync); AssertSql( - @"SELECT CAST(SUM([od].[Discount]) AS real) -FROM [Order Details] AS [od] -WHERE [od].[ProductID] = 1"); + @"SELECT CAST(SUM([o].[Discount]) AS real) +FROM [Order Details] AS [o] +WHERE [o].[ProductID] = 1"); } public override async Task Sum_on_float_column_in_subquery(bool isAsync) @@ -149,10 +149,9 @@ public override async Task Sum_on_float_column_in_subquery(bool isAsync) AssertSql( @"SELECT [o].[OrderID], ( - SELECT CAST(SUM([od].[Discount]) AS real) - FROM [Order Details] AS [od] - WHERE [o].[OrderID] = [od].[OrderID] -) AS [Sum] + SELECT CAST(SUM([o0].[Discount]) AS real) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] FROM [Orders] AS [o] WHERE [o].[OrderID] < 10300"); } @@ -171,7 +170,7 @@ public override async Task Average_with_binary_expression(bool isAsync) await base.Average_with_binary_expression(isAsync); AssertSql( - @"SELECT AVG(CAST([o].[OrderID] * 2 AS float)) + @"SELECT AVG(CAST(([o].[OrderID] * 2) AS float)) FROM [Orders] AS [o]"); } @@ -189,7 +188,7 @@ public override async Task Average_with_arg_expression(bool isAsync) await base.Average_with_arg_expression(isAsync); AssertSql( - @"SELECT AVG(CAST([o].[OrderID] + [o].[OrderID] AS float)) + @"SELECT AVG(CAST(([o].[OrderID] + [o].[OrderID]) AS float)) FROM [Orders] AS [o]"); } @@ -198,8 +197,8 @@ public override async Task Average_with_division_on_decimal(bool isAsync) await base.Average_with_division_on_decimal(isAsync); AssertSql( - @"SELECT AVG([od].[Quantity] / 2.09) -FROM [Order Details] AS [od]"); + @"SELECT AVG(CAST([o].[Quantity] AS decimal(18,2)) / 2.09) +FROM [Order Details] AS [o]"); } public override async Task Average_with_division_on_decimal_no_significant_digits(bool isAsync) @@ -207,8 +206,8 @@ public override async Task Average_with_division_on_decimal_no_significant_digit await base.Average_with_division_on_decimal_no_significant_digits(isAsync); AssertSql( - @"SELECT AVG([od].[Quantity] / 2.0) -FROM [Order Details] AS [od]"); + @"SELECT AVG(CAST([o].[Quantity] AS decimal(18,2)) / 2.0) +FROM [Order Details] AS [o]"); } public override async Task Average_with_coalesce(bool isAsync) @@ -261,9 +260,9 @@ public override async Task Average_on_float_column(bool isAsync) await base.Average_on_float_column(isAsync); AssertSql( - @"SELECT CAST(AVG([od].[Discount]) AS real) -FROM [Order Details] AS [od] -WHERE [od].[ProductID] = 1"); + @"SELECT CAST(AVG([o].[Discount]) AS real) +FROM [Order Details] AS [o] +WHERE [o].[ProductID] = 1"); } public override async Task Average_on_float_column_in_subquery(bool isAsync) @@ -292,10 +291,9 @@ public override async Task Average_on_float_column_in_subquery_with_cast(bool is AssertSql( @"SELECT [o].[OrderID], ( - SELECT CAST(AVG([od].[Discount]) AS real) - FROM [Order Details] AS [od] - WHERE [o].[OrderID] = [od].[OrderID] -) AS [Sum] + SELECT CAST(AVG([o0].[Discount]) AS real) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] FROM [Orders] AS [o] WHERE [o].[OrderID] < 10300"); } @@ -437,7 +435,7 @@ public override async Task Count_with_predicate(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI'"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL"); } public override async Task Where_OrderBy_Count(bool isAsync) @@ -447,7 +445,7 @@ public override async Task Where_OrderBy_Count(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI'"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL"); } public override async Task OrderBy_Where_Count(bool isAsync) @@ -457,7 +455,7 @@ public override async Task OrderBy_Where_Count(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI'"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL"); } public override async Task OrderBy_Count_with_predicate(bool isAsync) @@ -467,7 +465,7 @@ public override async Task OrderBy_Count_with_predicate(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI'"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL"); } public override async Task OrderBy_Where_Count_with_predicate(bool isAsync) @@ -640,7 +638,7 @@ public override async Task Distinct_Count(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM ( - SELECT DISTINCT [c].* + SELECT DISTINCT [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] ) AS [t]"); } @@ -671,14 +669,15 @@ public override async Task FirstOrDefault_inside_subquery_gets_server_evaluated( { await base.FirstOrDefault_inside_subquery_gets_server_evaluated(isAsync); - 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')"); + // 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')"); } public override async Task Multiple_collection_navigation_with_FirstOrDefault_chained(bool isAsync) @@ -719,20 +718,21 @@ public override async Task Multiple_collection_navigation_with_FirstOrDefault_ch { await base.Multiple_collection_navigation_with_FirstOrDefault_chained_projecting_scalar(isAsync); - 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]"); + // 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]"); } public override async Task First_inside_subquery_gets_client_evaluated(bool isAsync) @@ -778,7 +778,7 @@ public override async Task Last_Predicate(bool isAsync) AssertSql( @"SELECT TOP(1) [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].[City] = N'London' +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL ORDER BY [c].[ContactName] DESC"); } @@ -789,7 +789,7 @@ public override async Task Where_Last(bool isAsync) AssertSql( @"SELECT TOP(1) [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].[City] = N'London' +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL ORDER BY [c].[ContactName] DESC"); } @@ -810,7 +810,7 @@ public override async Task LastOrDefault_Predicate(bool isAsync) AssertSql( @"SELECT TOP(1) [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].[City] = N'London' +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL ORDER BY [c].[ContactName] DESC"); } @@ -821,7 +821,7 @@ public override async Task Where_LastOrDefault(bool isAsync) AssertSql( @"SELECT TOP(1) [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].[City] = N'London' +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL ORDER BY [c].[ContactName] DESC"); } @@ -861,15 +861,15 @@ public override async Task Contains_with_subquery_and_local_array_closure(bool i FROM [Customers] AS [c] WHERE EXISTS ( SELECT 1 - FROM [Customers] AS [c1] - WHERE [c1].[City] IN (N'London', N'Buenos Aires') AND ([c1].[CustomerID] = [c].[CustomerID]))", + FROM [Customers] AS [c0] + WHERE [c0].[City] IN (N'London', N'Buenos Aires') AND ([c0].[CustomerID] = [c].[CustomerID]))", // @"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 EXISTS ( SELECT 1 - FROM [Customers] AS [c1] - WHERE [c1].[City] IN (N'London') AND ([c1].[CustomerID] = [c].[CustomerID]))"); + FROM [Customers] AS [c0] + WHERE [c0].[City] IN (N'London') AND ([c0].[CustomerID] = [c].[CustomerID]))"); } public override async Task Contains_with_local_int_array_closure(bool isAsync) @@ -982,10 +982,11 @@ public override async Task Contains_with_local_collection_false(bool isAsync) { await base.Contains_with_local_collection_false(isAsync); - 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')"); + // 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')"); } public override async Task Contains_with_local_collection_complex_predicate_and(bool isAsync) @@ -995,37 +996,40 @@ public override async Task Contains_with_local_collection_complex_predicate_and( 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') AND [c].[CustomerID] IN (N'ABCDE', N'ALFKI')"); +WHERE (([c].[CustomerID] = N'ALFKI') OR ([c].[CustomerID] = N'ABCDE')) AND [c].[CustomerID] IN (N'ABCDE', N'ALFKI')"); } public override async Task Contains_with_local_collection_complex_predicate_or(bool isAsync) { await base.Contains_with_local_collection_complex_predicate_or(isAsync); - 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 #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')"); } 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); - 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 #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')"); } 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); - 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 #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')"); } public override async Task Contains_with_local_collection_sql_injection(bool isAsync) @@ -1035,7 +1039,7 @@ public override async Task Contains_with_local_collection_sql_injection(bool isA 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'ABC'')); GO; DROP TABLE Orders; GO; --', N'ALFKI', N'ABCDE')"); +WHERE [c].[CustomerID] IN (N'ALFKI', N'ABC'')); GO; DROP TABLE Orders; GO; --') OR (([c].[CustomerID] = N'ALFKI') OR ([c].[CustomerID] = N'ABCDE'))"); } public override async Task Contains_with_local_collection_empty_closure(bool isAsync) @@ -1045,32 +1049,34 @@ public override async Task Contains_with_local_collection_empty_closure(bool isA 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 0 = 1"); +WHERE CAST(1 AS bit) = CAST(0 AS bit)"); } public override async Task Contains_with_local_collection_empty_inline(bool isAsync) { await base.Contains_with_local_collection_empty_inline(isAsync); - 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]"); + // issue #16037 +// 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]"); } public override async Task Contains_top_level(bool isAsync) { await base.Contains_top_level(isAsync); - AssertSql( - @"@__p_0='ALFKI' (Size = 4000) + // 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"); +//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_tuple_array_closure(bool isAsync) @@ -1126,7 +1132,7 @@ public override async Task Average_with_non_matching_types_in_projection_doesnt_ AssertSql( @"SELECT AVG(CAST(CAST([o].[OrderID] AS bigint) AS float)) FROM [Orders] AS [o] -WHERE [o].[CustomerID] LIKE N'A%'"); +WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')"); } public override async Task Max_with_non_matching_types_in_projection_introduces_explicit_cast(bool isAsync) @@ -1136,7 +1142,7 @@ public override async Task Max_with_non_matching_types_in_projection_introduces_ AssertSql( @"SELECT MAX(CAST([o].[OrderID] AS bigint)) FROM [Orders] AS [o] -WHERE [o].[CustomerID] LIKE N'A%'"); +WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')"); } public override async Task Min_with_non_matching_types_in_projection_introduces_explicit_cast(bool isAsync) @@ -1146,7 +1152,7 @@ public override async Task Min_with_non_matching_types_in_projection_introduces_ AssertSql( @"SELECT MIN(CAST([o].[OrderID] AS bigint)) FROM [Orders] AS [o] -WHERE [o].[CustomerID] LIKE N'A%'"); +WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')"); } public override async Task OrderBy_Take_Last_gives_correct_result(bool isAsync) @@ -1156,7 +1162,7 @@ public override async Task OrderBy_Take_Last_gives_correct_result(bool isAsync) AssertSql( @"@__p_0='20' -SELECT TOP(1) [t].* +SELECT TOP(1) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( SELECT TOP(@__p_0) [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] @@ -1172,7 +1178,7 @@ public override async Task OrderBy_Skip_Last_gives_correct_result(bool isAsync) AssertSql( @"@__p_0='20' -SELECT TOP(1) [t].* +SELECT TOP(1) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( 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] @@ -1275,17 +1281,22 @@ public override async Task Where_subquery_where_any(bool isAsync) 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].[City] = N'México D.F.') AND [c].[CustomerID] IN (N'ABCDE', N'ALFKI', N'ANATR')"); +WHERE (([c].[City] = N'México D.F.') AND [c].[City] IS NOT NULL) AND [c].[CustomerID] IN (N'ABCDE', N'ALFKI', N'ANATR')", + // + @"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].[City] = N'México D.F.') AND [c].[City] IS NOT NULL) AND [c].[CustomerID] IN (N'ABCDE', N'ALFKI', N'ANATR')"); } public override async Task Where_subquery_all_not_equals_operator(bool isAsync) { await base.Where_subquery_all_not_equals_operator(isAsync); - 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', N'ANATR')"); + // issue #16037 +// 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', N'ANATR')"); } public override async Task Where_subquery_all_not_equals(bool isAsync) @@ -1295,27 +1306,29 @@ public override async Task Where_subquery_all_not_equals(bool isAsync) 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', N'ANATR')"); +WHERE NOT ([c].[CustomerID] IN (N'ABCDE', N'ALFKI', N'ANATR'))"); } public override async Task Where_subquery_all_not_equals_static(bool isAsync) { await base.Where_subquery_all_not_equals_static(isAsync); - 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', N'ANATR')"); + // issue #16037 +// 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', N'ANATR')"); } public override async Task Where_subquery_where_all(bool isAsync) { await base.Where_subquery_where_all(isAsync); - 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].[City] = N'México D.F.') AND [c].[CustomerID] NOT IN (N'ABCDE', N'ALFKI', N'ANATR')"); + // 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].[City] = N'México D.F.') AND [c].[CustomerID] NOT IN (N'ABCDE', N'ALFKI', N'ANATR')"); } public override async Task Cast_to_same_Type_Count_works(bool isAsync) @@ -1335,8 +1348,7 @@ public override async Task Cast_before_aggregate_is_preserved(bool isAsync) @"SELECT ( SELECT AVG(CAST([o].[OrderID] AS float)) FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] -) + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) FROM [Customers] AS [c]"); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs index b069a602d5f..0a64d741457 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs @@ -21,7 +21,7 @@ public override async Task Projection_when_arithmetic_expressions(bool isAsync) await base.Projection_when_arithmetic_expressions(isAsync); AssertSql( - @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + @"SELECT [o].[OrderID], [o].[OrderID] * 2 AS [Double], [o].[OrderID] + 23 AS [Add], 100000 - [o].[OrderID] AS [Sub], [o].[OrderID] / ([o].[OrderID] / 2) AS [Divide], 42 AS [Literal], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o]"); } @@ -32,17 +32,18 @@ public override async Task Projection_when_arithmetic_mixed(bool isAsync) AssertSql( @"@__p_0='10' -SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [t0].[EmployeeID], [t0].[City], [t0].[Country], [t0].[FirstName], [t0].[ReportsTo], [t0].[Title] +SELECT CAST([t].[EmployeeID] AS bigint) + CAST([t0].[OrderID] AS bigint) AS [Add], [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate], 42 AS [Literal], [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] FROM ( SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ORDER BY [o].[OrderID] -) AS [t] +) AS [t0] CROSS JOIN ( SELECT TOP(5) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] ORDER BY [e].[EmployeeID] -) AS [t0]"); +) AS [t] +ORDER BY [t0].[OrderID]"); } public override async Task Projection_when_arithmetic_mixed_subqueries(bool isAsync) @@ -180,7 +181,7 @@ public override async Task Select_anonymous_bool_constant_true(bool isAsync) await base.Select_anonymous_bool_constant_true(isAsync); AssertSql( - @"SELECT [c].[CustomerID] + @"SELECT [c].[CustomerID], CAST(1 AS bit) AS [ConstantTrue] FROM [Customers] AS [c]"); } @@ -199,8 +200,8 @@ public override async Task Select_anonymous_conditional_expression(bool isAsync) AssertSql( @"SELECT [p].[ProductID], CASE - WHEN [p].[UnitsInStock] > CAST(0 AS smallint) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [p].[UnitsInStock] > CAST(0 AS smallint) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [IsAvailable] FROM [Products] AS [p]"); } @@ -210,7 +211,7 @@ public override async Task Select_constant_int(bool isAsync) await base.Select_constant_int(isAsync); AssertSql( - @"SELECT 1 + @"SELECT 0 FROM [Customers] AS [c]"); } @@ -219,7 +220,7 @@ public override async Task Select_constant_null_string(bool isAsync) await base.Select_constant_null_string(isAsync); AssertSql( - @"SELECT 1 + @"SELECT NULL FROM [Customers] AS [c]"); } @@ -252,7 +253,7 @@ public override async Task Select_project_filter(bool isAsync) AssertSql( @"SELECT [c].[CompanyName] FROM [Customers] AS [c] -WHERE [c].[City] = N'London'"); +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL"); } public override async Task Select_project_filter2(bool isAsync) @@ -262,7 +263,7 @@ public override async Task Select_project_filter2(bool isAsync) AssertSql( @"SELECT [c].[City] FROM [Customers] AS [c] -WHERE [c].[City] = N'London'"); +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL"); } public override async Task Select_nested_collection(bool isAsync) @@ -360,8 +361,7 @@ public override void Select_nested_collection_multi_level2() @"SELECT ( SELECT TOP(1) [o].[OrderDate] FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] < 10500) -) AS [OrderDates] + WHERE (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AND ([o].[OrderID] < 10500)) AS [OrderDates] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -374,8 +374,7 @@ public override void Select_nested_collection_multi_level3() @"SELECT ( SELECT TOP(1) [o].[OrderDate] FROM [Orders] AS [o] - WHERE ([o].[OrderID] < 10500) AND ([c].[CustomerID] = [o].[CustomerID]) -) AS [OrderDates] + WHERE ([o].[OrderID] < 10500) AND (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL)) AS [OrderDates] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -385,15 +384,13 @@ public override void Select_nested_collection_multi_level4() base.Select_nested_collection_multi_level4(); AssertSql( - @"SELECT COALESCE(( + @"SELECT ( SELECT TOP(1) ( SELECT COUNT(*) - FROM [Order Details] AS [od] - WHERE ([o].[OrderID] = [od].[OrderID]) AND ([od].[OrderID] > 10) - ) - FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] < 10500) -), 0) AS [Order] + FROM [Order Details] AS [o] + WHERE ([o0].[OrderID] = [o].[OrderID]) AND ([o].[OrderID] > 10)) + FROM [Orders] AS [o0] + WHERE (([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) AND ([o0].[OrderID] < 10500)) AS [Order] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -403,19 +400,19 @@ public override void Select_nested_collection_multi_level5() base.Select_nested_collection_multi_level5(); AssertSql( - @"SELECT COALESCE(( + @"SELECT ( SELECT TOP(1) ( - SELECT TOP(1) [od].[ProductID] - FROM [Order Details] AS [od] - WHERE ([o].[OrderID] = [od].[OrderID]) AND ([od].[OrderID] <> ( + SELECT TOP(1) [o].[ProductID] + FROM [Order Details] AS [o] + WHERE ([o0].[OrderID] = [o].[OrderID]) AND (([o].[OrderID] <> ( SELECT COUNT(*) - FROM [Orders] AS [o0] - WHERE [c].[CustomerID] = [o0].[CustomerID] - )) - ) - FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] < 10500) -), 0) AS [Order] + FROM [Orders] AS [o1] + WHERE ([c].[CustomerID] = [o1].[CustomerID]) AND [o1].[CustomerID] IS NOT NULL)) OR ( + SELECT COUNT(*) + FROM [Orders] AS [o1] + WHERE ([c].[CustomerID] = [o1].[CustomerID]) AND [o1].[CustomerID] IS NOT NULL) IS NULL)) + FROM [Orders] AS [o0] + WHERE (([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) AND ([o0].[OrderID] < 10500)) AS [Order] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -425,15 +422,13 @@ public override void Select_nested_collection_multi_level6() base.Select_nested_collection_multi_level6(); AssertSql( - @"SELECT COALESCE(( + @"SELECT ( SELECT TOP(1) ( - SELECT TOP(1) [od].[ProductID] - FROM [Order Details] AS [od] - WHERE ([o].[OrderID] = [od].[OrderID]) AND ([od].[OrderID] <> CAST(LEN([c].[CustomerID]) AS int)) - ) - FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] < 10500) -), 0) AS [Order] + SELECT TOP(1) [o].[ProductID] + FROM [Order Details] AS [o] + WHERE ([o0].[OrderID] = [o].[OrderID]) AND ([o].[OrderID] <> CAST(LEN([c].[CustomerID]) AS int))) + FROM [Orders] AS [o0] + WHERE (([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) AND ([o0].[OrderID] < 10500)) AS [Order] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -446,8 +441,7 @@ public override async Task Select_nested_collection_count_using_anonymous_type(b @"SELECT ( SELECT COUNT(*) FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] -) AS [Count] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AS [Count] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -469,7 +463,7 @@ public override async Task Select_non_matching_value_types_int_to_long_introduce AssertSql( @"SELECT CAST([o].[OrderID] AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -480,7 +474,7 @@ public override async Task Select_non_matching_value_types_nullable_int_to_long_ AssertSql( @"SELECT CAST([o].[EmployeeID] AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -489,9 +483,9 @@ public override async Task Select_non_matching_value_types_nullable_int_to_int_d await base.Select_non_matching_value_types_nullable_int_to_int_doesnt_introduce_explicit_cast(isAsync); AssertSql( - @"SELECT [o].[EmployeeID] + @"SELECT CAST([o].[EmployeeID] AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -502,7 +496,7 @@ public override async Task Select_non_matching_value_types_int_to_nullable_int_d AssertSql( @"SELECT [o].[OrderID] FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -511,9 +505,9 @@ public override async Task Select_non_matching_value_types_from_binary_expressio await base.Select_non_matching_value_types_from_binary_expression_introduces_explicit_cast(isAsync); AssertSql( - @"SELECT CAST([o].[OrderID] + [o].[OrderID] AS bigint) + @"SELECT CAST(([o].[OrderID] + [o].[OrderID]) AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -523,9 +517,9 @@ public override async Task Select_non_matching_value_types_from_binary_expressio await base.Select_non_matching_value_types_from_binary_expression_nested_introduces_top_level_explicit_cast(isAsync); AssertSql( - @"SELECT CAST([o].[OrderID] + [o].[OrderID] AS smallint) + @"SELECT CAST((CAST([o].[OrderID] AS bigint) + CAST([o].[OrderID] AS bigint)) AS smallint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -536,7 +530,7 @@ public override async Task Select_non_matching_value_types_from_unary_expression AssertSql( @"SELECT CAST(-[o].[OrderID] AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -547,7 +541,7 @@ public override async Task Select_non_matching_value_types_from_unary_expression AssertSql( @"SELECT -CAST([o].[OrderID] AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -558,7 +552,7 @@ public override async Task Select_non_matching_value_types_from_length_introduce AssertSql( @"SELECT CAST(CAST(LEN([o].[CustomerID]) AS int) AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -569,7 +563,7 @@ public override async Task Select_non_matching_value_types_from_method_call_intr AssertSql( @"SELECT CAST(ABS([o].[OrderID]) AS bigint) FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID]"); } @@ -580,8 +574,8 @@ public override async Task Select_non_matching_value_types_from_anonymous_type_i AssertSql( @"SELECT CAST([o].[OrderID] AS bigint) AS [LongOrder], CAST([o].[OrderID] AS smallint) AS [ShortOrder], [o].[OrderID] AS [Order] FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' -ORDER BY [Order]"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL +ORDER BY [o].[OrderID]"); } public override async Task Select_conditional_with_null_comparison_in_test(bool isAsync) @@ -590,11 +584,14 @@ public override async Task Select_conditional_with_null_comparison_in_test(bool AssertSql( @"SELECT CASE - WHEN [o].[CustomerID] IS NULL OR ([o].[CustomerID] IS NOT NULL AND ([o].[OrderID] < 100)) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [o].[CustomerID] IS NULL THEN CAST(1 AS bit) + ELSE CASE + WHEN [o].[OrderID] < 100 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END END FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI'"); +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL"); } public override async Task Projection_in_a_subquery_should_be_liftable(bool isAsync) @@ -727,11 +724,10 @@ SELECT TOP(1) [t].[CustomerID] FROM ( SELECT TOP(2) [o].[CustomerID], [o].[OrderID], [o].[OrderDate] FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[OrderID], [o].[OrderDate] DESC ) AS [t] - ORDER BY [t].[OrderID], [t].[OrderDate] DESC -) + ORDER BY [t].[OrderID], [t].[OrderDate] DESC) FROM [Customers] AS [c]"); } @@ -757,11 +753,10 @@ SELECT TOP(1) [t].[CustomerID] FROM ( SELECT TOP(2) [o].[CustomerID], [o].[OrderDate] FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL ORDER BY [o].[CustomerID], [o].[OrderDate] DESC ) AS [t] - ORDER BY [t].[CustomerID], [t].[OrderDate] DESC -) + ORDER BY [t].[CustomerID], [t].[OrderDate] DESC) FROM [Customers] AS [c]"); } @@ -898,8 +893,8 @@ public override async Task Select_byte_constant(bool isAsync) AssertSql( @"SELECT CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS tinyint) ELSE CAST(2 AS tinyint) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS tinyint) + ELSE CAST(2 AS tinyint) END FROM [Customers] AS [c]"); } @@ -910,8 +905,8 @@ public override async Task Select_short_constant(bool isAsync) AssertSql( @"SELECT CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS smallint) ELSE CAST(2 AS smallint) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS smallint) + ELSE CAST(2 AS smallint) END FROM [Customers] AS [c]"); } @@ -922,8 +917,8 @@ public override async Task Select_bool_constant(bool isAsync) AssertSql( @"SELECT CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END FROM [Customers] AS [c]"); } @@ -933,7 +928,7 @@ public override async Task Anonymous_projection_AsNoTracking_Selector(bool isAsy await base.Anonymous_projection_AsNoTracking_Selector(isAsync); AssertSql( - @"SELECT [o].[CustomerID] AS [A], [o].[OrderDate] AS [B] + @"SELECT [o].[OrderDate] FROM [Orders] AS [o]"); } @@ -942,9 +937,9 @@ public override async Task Anonymous_projection_with_repeated_property_being_ord await base.Anonymous_projection_with_repeated_property_being_ordered(isAsync); AssertSql( - @"SELECT [c].[CustomerID] AS [B] + @"SELECT [c].[CustomerID] AS [A] FROM [Customers] AS [c] -ORDER BY [B]"); +ORDER BY [c].[CustomerID]"); } public override async Task Anonymous_projection_with_repeated_property_being_ordered_2(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs index 216f8158115..18e4174afd1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs @@ -14,7 +14,7 @@ public override async Task Where_simple(bool isAsync) 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].[City] = N'London'"); +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL"); } public override async Task Where_as_queryable_expression(bool isAsync) @@ -43,7 +43,7 @@ public override async Task Where_simple_closure(bool isAsync) 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].[City] = @__city_0"); +WHERE (([c].[City] = @__city_0) AND ([c].[City] IS NOT NULL AND @__city_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_0 IS NULL)"); } public override async Task Where_indexer_closure(bool isAsync) @@ -55,7 +55,7 @@ public override async Task Where_indexer_closure(bool isAsync) 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].[City] = @__p_0"); +WHERE (([c].[City] = @__p_0) AND ([c].[City] IS NOT NULL AND @__p_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__p_0 IS NULL)"); } public override async Task Where_dictionary_key_access_closure(bool isAsync) @@ -67,7 +67,7 @@ public override async Task Where_dictionary_key_access_closure(bool isAsync) 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].[City] = @__get_Item_0"); +WHERE (([c].[City] = @__get_Item_0) AND ([c].[City] IS NOT NULL AND @__get_Item_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__get_Item_0 IS NULL)"); } public override async Task Where_tuple_item_closure(bool isAsync) @@ -79,7 +79,7 @@ public override async Task Where_tuple_item_closure(bool isAsync) 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].[City] = @__predicateTuple_Item2_0"); +WHERE (([c].[City] = @__predicateTuple_Item2_0) AND ([c].[City] IS NOT NULL AND @__predicateTuple_Item2_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__predicateTuple_Item2_0 IS NULL)"); } public override async Task Where_named_tuple_item_closure(bool isAsync) @@ -91,7 +91,7 @@ public override async Task Where_named_tuple_item_closure(bool isAsync) 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].[City] = @__predicateTuple_Item2_0"); +WHERE (([c].[City] = @__predicateTuple_Item2_0) AND ([c].[City] IS NOT NULL AND @__predicateTuple_Item2_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__predicateTuple_Item2_0 IS NULL)"); } public override async Task Where_simple_closure_constant(bool isAsync) @@ -115,13 +115,13 @@ public override async Task Where_simple_closure_via_query_cache(bool isAsync) 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].[City] = @__city_0", +WHERE (([c].[City] = @__city_0) AND ([c].[City] IS NOT NULL AND @__city_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_0 IS NULL)", // @"@__city_0='Seattle' (Size = 4000) 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].[City] = @__city_0"); +WHERE (([c].[City] = @__city_0) AND ([c].[City] IS NOT NULL AND @__city_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_0 IS NULL)"); } public override async Task Where_method_call_nullable_type_closure_via_query_cache(bool isAsync) @@ -133,13 +133,13 @@ public override async Task Where_method_call_nullable_type_closure_via_query_cac SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__p_0", +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)", // @"@__p_0='5' (Nullable = true) SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__p_0"); +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)"); } public override async Task Where_method_call_nullable_type_reverse_closure_via_query_cache(bool isAsync) @@ -151,13 +151,13 @@ public override async Task Where_method_call_nullable_type_reverse_closure_via_q SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[EmployeeID] > @__p_0", +WHERE CAST([e].[EmployeeID] AS bigint) > @__p_0", // @"@__p_0='5' (Nullable = true) SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[EmployeeID] > @__p_0"); +WHERE CAST([e].[EmployeeID] AS bigint) > @__p_0"); } public override async Task Where_method_call_closure_via_query_cache(bool isAsync) @@ -169,13 +169,13 @@ public override async Task Where_method_call_closure_via_query_cache(bool isAsyn 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].[City] = @__GetCity_0", +WHERE (([c].[City] = @__GetCity_0) AND ([c].[City] IS NOT NULL AND @__GetCity_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__GetCity_0 IS NULL)", // @"@__GetCity_0='Seattle' (Size = 4000) 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].[City] = @__GetCity_0"); +WHERE (([c].[City] = @__GetCity_0) AND ([c].[City] IS NOT NULL AND @__GetCity_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__GetCity_0 IS NULL)"); } public override async Task Where_field_access_closure_via_query_cache(bool isAsync) @@ -187,13 +187,13 @@ public override async Task Where_field_access_closure_via_query_cache(bool isAsy 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].[City] = @__city_InstanceFieldValue_0", +WHERE (([c].[City] = @__city_InstanceFieldValue_0) AND ([c].[City] IS NOT NULL AND @__city_InstanceFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_InstanceFieldValue_0 IS NULL)", // @"@__city_InstanceFieldValue_0='Seattle' (Size = 4000) 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].[City] = @__city_InstanceFieldValue_0"); +WHERE (([c].[City] = @__city_InstanceFieldValue_0) AND ([c].[City] IS NOT NULL AND @__city_InstanceFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_InstanceFieldValue_0 IS NULL)"); } public override async Task Where_property_access_closure_via_query_cache(bool isAsync) @@ -205,13 +205,13 @@ public override async Task Where_property_access_closure_via_query_cache(bool is 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].[City] = @__city_InstancePropertyValue_0", +WHERE (([c].[City] = @__city_InstancePropertyValue_0) AND ([c].[City] IS NOT NULL AND @__city_InstancePropertyValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_InstancePropertyValue_0 IS NULL)", // @"@__city_InstancePropertyValue_0='Seattle' (Size = 4000) 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].[City] = @__city_InstancePropertyValue_0"); +WHERE (([c].[City] = @__city_InstancePropertyValue_0) AND ([c].[City] IS NOT NULL AND @__city_InstancePropertyValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_InstancePropertyValue_0 IS NULL)"); } public override async Task Where_static_field_access_closure_via_query_cache(bool isAsync) @@ -223,13 +223,13 @@ public override async Task Where_static_field_access_closure_via_query_cache(boo 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].[City] = @__StaticFieldValue_0", +WHERE (([c].[City] = @__StaticFieldValue_0) AND ([c].[City] IS NOT NULL AND @__StaticFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__StaticFieldValue_0 IS NULL)", // @"@__StaticFieldValue_0='Seattle' (Size = 4000) 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].[City] = @__StaticFieldValue_0"); +WHERE (([c].[City] = @__StaticFieldValue_0) AND ([c].[City] IS NOT NULL AND @__StaticFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__StaticFieldValue_0 IS NULL)"); } public override async Task Where_static_property_access_closure_via_query_cache(bool isAsync) @@ -241,13 +241,13 @@ public override async Task Where_static_property_access_closure_via_query_cache( 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].[City] = @__StaticPropertyValue_0", +WHERE (([c].[City] = @__StaticPropertyValue_0) AND ([c].[City] IS NOT NULL AND @__StaticPropertyValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__StaticPropertyValue_0 IS NULL)", // @"@__StaticPropertyValue_0='Seattle' (Size = 4000) 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].[City] = @__StaticPropertyValue_0"); +WHERE (([c].[City] = @__StaticPropertyValue_0) AND ([c].[City] IS NOT NULL AND @__StaticPropertyValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__StaticPropertyValue_0 IS NULL)"); } public override async Task Where_nested_field_access_closure_via_query_cache(bool isAsync) @@ -259,13 +259,13 @@ public override async Task Where_nested_field_access_closure_via_query_cache(boo 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].[City] = @__city_Nested_InstanceFieldValue_0", +WHERE (([c].[City] = @__city_Nested_InstanceFieldValue_0) AND ([c].[City] IS NOT NULL AND @__city_Nested_InstanceFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_Nested_InstanceFieldValue_0 IS NULL)", // @"@__city_Nested_InstanceFieldValue_0='Seattle' (Size = 4000) 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].[City] = @__city_Nested_InstanceFieldValue_0"); +WHERE (([c].[City] = @__city_Nested_InstanceFieldValue_0) AND ([c].[City] IS NOT NULL AND @__city_Nested_InstanceFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_Nested_InstanceFieldValue_0 IS NULL)"); } public override async Task Where_nested_property_access_closure_via_query_cache(bool isAsync) @@ -277,13 +277,13 @@ public override async Task Where_nested_property_access_closure_via_query_cache( 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].[City] = @__city_Nested_InstancePropertyValue_0", +WHERE (([c].[City] = @__city_Nested_InstancePropertyValue_0) AND ([c].[City] IS NOT NULL AND @__city_Nested_InstancePropertyValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_Nested_InstancePropertyValue_0 IS NULL)", // @"@__city_Nested_InstancePropertyValue_0='Seattle' (Size = 4000) 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].[City] = @__city_Nested_InstancePropertyValue_0"); +WHERE (([c].[City] = @__city_Nested_InstancePropertyValue_0) AND ([c].[City] IS NOT NULL AND @__city_Nested_InstancePropertyValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__city_Nested_InstancePropertyValue_0 IS NULL)"); } public override async Task Where_new_instance_field_access_query_cache(bool isAsync) @@ -293,11 +293,11 @@ public override async Task Where_new_instance_field_access_query_cache(bool isAs 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].[City] = N'London'", +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL", // @"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].[City] = N'Seattle'"); +WHERE ([c].[City] = N'Seattle') AND [c].[City] IS NOT NULL"); } public override async Task Where_new_instance_field_access_closure_via_query_cache(bool isAsync) @@ -309,13 +309,13 @@ public override async Task Where_new_instance_field_access_closure_via_query_cac 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].[City] = @__InstanceFieldValue_0", +WHERE (([c].[City] = @__InstanceFieldValue_0) AND ([c].[City] IS NOT NULL AND @__InstanceFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__InstanceFieldValue_0 IS NULL)", // @"@__InstanceFieldValue_0='Seattle' (Size = 4000) 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].[City] = @__InstanceFieldValue_0"); +WHERE (([c].[City] = @__InstanceFieldValue_0) AND ([c].[City] IS NOT NULL AND @__InstanceFieldValue_0 IS NOT NULL)) OR ([c].[City] IS NULL AND @__InstanceFieldValue_0 IS NULL)"); } public override async Task Where_simple_closure_via_query_cache_nullable_type(bool isAsync) @@ -327,17 +327,19 @@ public override async Task Where_simple_closure_via_query_cache_nullable_type(bo SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__p_0", +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)", // @"@__p_0='5' (Nullable = true) SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__p_0", +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)", // - @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + @"@__p_0='' (DbType = Int64) + +SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] IS NULL"); +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)"); } public override async Task Where_simple_closure_via_query_cache_nullable_type_reverse(bool isAsync) @@ -345,21 +347,23 @@ public override async Task Where_simple_closure_via_query_cache_nullable_type_re await base.Where_simple_closure_via_query_cache_nullable_type_reverse(isAsync); AssertSql( - @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + @"@__p_0='' (DbType = Int64) + +SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] IS NULL", +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)", // @"@__p_0='5' (Nullable = true) SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__p_0", +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)", // @"@__p_0='2' (Nullable = true) SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__p_0"); +WHERE ((CAST([e].[ReportsTo] AS bigint) = @__p_0) AND (CAST([e].[ReportsTo] AS bigint) IS NOT NULL AND @__p_0 IS NOT NULL)) OR (CAST([e].[ReportsTo] AS bigint) IS NULL AND @__p_0 IS NULL)"); } public override void Where_subquery_closure_via_query_cache() @@ -374,7 +378,7 @@ FROM [Customers] AS [c] WHERE EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE ([o].[CustomerID] = @__customerID_0) AND ([o].[CustomerID] = [c].[CustomerID]))", + WHERE ((([o].[CustomerID] = @__customerID_0) AND ([o].[CustomerID] IS NOT NULL AND @__customerID_0 IS NOT NULL)) OR ([o].[CustomerID] IS NULL AND @__customerID_0 IS NULL)) AND (([o].[CustomerID] = [c].[CustomerID]) AND [o].[CustomerID] IS NOT NULL))", // @"@__customerID_0='ANATR' (Size = 5) @@ -383,7 +387,7 @@ FROM [Customers] AS [c] WHERE EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE ([o].[CustomerID] = @__customerID_0) AND ([o].[CustomerID] = [c].[CustomerID]))"); + WHERE ((([o].[CustomerID] = @__customerID_0) AND ([o].[CustomerID] IS NOT NULL AND @__customerID_0 IS NOT NULL)) OR ([o].[CustomerID] IS NULL AND @__customerID_0 IS NULL)) AND (([o].[CustomerID] = [c].[CustomerID]) AND [o].[CustomerID] IS NOT NULL))"); } public override async Task Where_bitwise_or(bool isAsync) @@ -394,11 +398,11 @@ public override async Task Where_bitwise_or(bool isAsync) @"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 CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END | CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) = CAST(1 AS bit)"); } @@ -410,11 +414,11 @@ public override async Task Where_bitwise_and(bool isAsync) @"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 CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END & CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) = CAST(1 AS bit)"); } @@ -434,7 +438,7 @@ public override async Task Where_simple_shadow(bool isAsync) AssertSql( @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[Title] = N'Sales Representative'"); +WHERE ([e].[Title] = N'Sales Representative') AND [e].[Title] IS NOT NULL"); } public override async Task Where_simple_shadow_projection(bool isAsync) @@ -444,21 +448,22 @@ public override async Task Where_simple_shadow_projection(bool isAsync) AssertSql( @"SELECT [e].[Title] FROM [Employees] AS [e] -WHERE [e].[Title] = N'Sales Representative'"); +WHERE ([e].[Title] = N'Sales Representative') AND [e].[Title] IS NOT NULL"); } public override async Task Where_shadow_subquery_FirstOrDefault(bool isAsync) { await base.Where_shadow_subquery_FirstOrDefault(isAsync); - 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] -)"); + // 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] +//)"); } public override async Task Where_client(bool isAsync) @@ -475,12 +480,12 @@ public override async Task Where_subquery_correlated(bool isAsync) await base.Where_subquery_correlated(isAsync); AssertSql( - @"SELECT [c1].[CustomerID], [c1].[Address], [c1].[City], [c1].[CompanyName], [c1].[ContactName], [c1].[ContactTitle], [c1].[Country], [c1].[Fax], [c1].[Phone], [c1].[PostalCode], [c1].[Region] -FROM [Customers] AS [c1] + @"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 EXISTS ( SELECT 1 - FROM [Customers] AS [c2] - WHERE [c1].[CustomerID] = [c2].[CustomerID])"); + FROM [Customers] AS [c0] + WHERE [c].[CustomerID] = [c0].[CustomerID])"); } public override async Task Where_subquery_correlated_client_eval(bool isAsync) @@ -573,7 +578,7 @@ public override async Task Where_equals_method_string(bool isAsync) 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].[City] = N'London'"); +WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL"); } public override async Task Where_equals_method_int(bool isAsync) @@ -593,7 +598,7 @@ public override async Task Where_equals_using_object_overload_on_mismatched_type AssertSql( @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); //Assert.Contains( // RelationalStrings.LogPossibleUnintendedUseOfEquals.GenerateMessage( @@ -609,7 +614,7 @@ public override async Task Where_equals_using_int_overload_on_mismatched_types(b SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[EmployeeID] = @__p_0"); +WHERE ([e].[EmployeeID] = @__p_0) AND @__p_0 IS NOT NULL"); } public override async Task Where_equals_on_mismatched_types_nullable_int_long(bool isAsync) @@ -619,11 +624,11 @@ public override async Task Where_equals_on_mismatched_types_nullable_int_long(bo AssertSql( @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE 0 = 1", +WHERE CAST(0 AS bit) = CAST(1 AS bit)", // @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); //Assert.Contains( // RelationalStrings.LogPossibleUnintendedUseOfEquals.GenerateMessage( @@ -641,11 +646,11 @@ public override async Task Where_equals_on_mismatched_types_nullable_long_nullab AssertSql( @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE 0 = 1", +WHERE CAST(0 AS bit) = CAST(1 AS bit)", // @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); //Assert.Contains( // RelationalStrings.LogPossibleUnintendedUseOfEquals.GenerateMessage( @@ -667,13 +672,13 @@ public override async Task Where_equals_on_mismatched_types_int_nullable_int(boo SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__intPrm_0", +WHERE (([e].[ReportsTo] = @__intPrm_0) AND ([e].[ReportsTo] IS NOT NULL AND @__intPrm_0 IS NOT NULL)) OR ([e].[ReportsTo] IS NULL AND @__intPrm_0 IS NULL)", // @"@__intPrm_0='2' SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE @__intPrm_0 = [e].[ReportsTo]"); +WHERE ((@__intPrm_0 = [e].[ReportsTo]) AND (@__intPrm_0 IS NOT NULL AND [e].[ReportsTo] IS NOT NULL)) OR (@__intPrm_0 IS NULL AND [e].[ReportsTo] IS NULL)"); } public override async Task Where_equals_on_matched_nullable_int_types(bool isAsync) @@ -685,13 +690,13 @@ public override async Task Where_equals_on_matched_nullable_int_types(bool isAsy SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE @__nullableIntPrm_0 = [e].[ReportsTo]", +WHERE ((@__nullableIntPrm_0 = [e].[ReportsTo]) AND (@__nullableIntPrm_0 IS NOT NULL AND [e].[ReportsTo] IS NOT NULL)) OR (@__nullableIntPrm_0 IS NULL AND [e].[ReportsTo] IS NULL)", // @"@__nullableIntPrm_0='2' (Nullable = true) SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = @__nullableIntPrm_0"); +WHERE (([e].[ReportsTo] = @__nullableIntPrm_0) AND ([e].[ReportsTo] IS NOT NULL AND @__nullableIntPrm_0 IS NOT NULL)) OR ([e].[ReportsTo] IS NULL AND @__nullableIntPrm_0 IS NULL)"); } public override async Task Where_equals_on_null_nullable_int_types(bool isAsync) @@ -699,13 +704,17 @@ public override async Task Where_equals_on_null_nullable_int_types(bool isAsync) await base.Where_equals_on_null_nullable_int_types(isAsync); AssertSql( - @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + @"@__nullableIntPrm_0='' (DbType = Int32) + +SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] IS NULL", +WHERE ((@__nullableIntPrm_0 = [e].[ReportsTo]) AND (@__nullableIntPrm_0 IS NOT NULL AND [e].[ReportsTo] IS NOT NULL)) OR (@__nullableIntPrm_0 IS NULL AND [e].[ReportsTo] IS NULL)", // - @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + @"@__nullableIntPrm_0='' (DbType = Int64) + +SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] IS NULL"); +WHERE (([e].[ReportsTo] = @__nullableIntPrm_0) AND ([e].[ReportsTo] IS NOT NULL AND @__nullableIntPrm_0 IS NOT NULL)) OR ([e].[ReportsTo] IS NULL AND @__nullableIntPrm_0 IS NULL)"); } public override async Task Where_comparison_nullable_type_not_null(bool isAsync) @@ -715,7 +724,7 @@ public override async Task Where_comparison_nullable_type_not_null(bool isAsync) AssertSql( @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE [e].[ReportsTo] = 2"); +WHERE ([e].[ReportsTo] = 2) AND [e].[ReportsTo] IS NOT NULL"); } public override async Task Where_comparison_nullable_type_null(bool isAsync) @@ -735,7 +744,7 @@ public override async Task Where_string_length(bool isAsync) 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 CAST(LEN([c].[City]) AS int) = 6"); +WHERE (CAST(LEN([c].[City]) AS int) = 6) AND CAST(LEN([c].[City]) AS int) IS NOT NULL"); } public override async Task Where_string_indexof(bool isAsync) @@ -755,7 +764,7 @@ public override async Task Where_string_replace(bool isAsync) 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 REPLACE([c].[City], N'Sea', N'Rea') = N'Reattle'"); +WHERE (REPLACE([c].[City], N'Sea', N'Rea') = N'Reattle') AND REPLACE([c].[City], N'Sea', N'Rea') IS NOT NULL"); } public override async Task Where_string_substring(bool isAsync) @@ -765,31 +774,33 @@ public override async Task Where_string_substring(bool isAsync) 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 SUBSTRING([c].[City], 2, 2) = N'ea'"); +WHERE (SUBSTRING([c].[City], 1 + 1, 2) = N'ea') AND SUBSTRING([c].[City], 1 + 1, 2) IS NOT NULL"); } public override async Task Where_datetime_now(bool isAsync) { await base.Where_datetime_now(isAsync); - AssertSql( - @"@__myDatetime_0='2015-04-10T00:00:00' + // issue #15994 +// 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"); } public override async Task Where_datetime_utcnow(bool isAsync) { await base.Where_datetime_utcnow(isAsync); - AssertSql( - @"@__myDatetime_0='2015-04-10T00:00:00' + // issue #15994 +// 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"); } public override async Task Where_datetime_today(bool isAsync) @@ -799,7 +810,7 @@ public override async Task Where_datetime_today(bool isAsync) AssertSql( @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] -WHERE CONVERT(date, GETDATE()) = CONVERT(date, GETDATE())"); +WHERE ((CONVERT(date, GETDATE()) = CONVERT(date, GETDATE())) AND (CONVERT(date, GETDATE()) IS NOT NULL AND CONVERT(date, GETDATE()) IS NOT NULL)) OR (CONVERT(date, GETDATE()) IS NULL AND CONVERT(date, GETDATE()) IS NULL)"); } public override async Task Where_datetime_date_component(bool isAsync) @@ -811,7 +822,7 @@ public override async Task Where_datetime_date_component(bool isAsync) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE CONVERT(date, [o].[OrderDate]) = @__myDatetime_0"); +WHERE ((CONVERT(date, [o].[OrderDate]) = @__myDatetime_0) AND (CONVERT(date, [o].[OrderDate]) IS NOT NULL AND @__myDatetime_0 IS NOT NULL)) OR (CONVERT(date, [o].[OrderDate]) IS NULL AND @__myDatetime_0 IS NULL)"); } public override async Task Where_date_add_year_constant_component(bool isAsync) @@ -821,7 +832,7 @@ public override async Task Where_date_add_year_constant_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(year, DATEADD(year, -1, [o].[OrderDate])) = 1997"); +WHERE (DATEPART(year, DATEADD(year, CAST(-1 AS int), [o].[OrderDate])) = 1997) AND DATEPART(year, DATEADD(year, CAST(-1 AS int), [o].[OrderDate])) IS NOT NULL"); } public override async Task Where_datetime_year_component(bool isAsync) @@ -831,7 +842,7 @@ public override async Task Where_datetime_year_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(year, [o].[OrderDate]) = 1998"); +WHERE (DATEPART(year, [o].[OrderDate]) = 1998) AND DATEPART(year, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_month_component(bool isAsync) @@ -841,7 +852,7 @@ public override async Task Where_datetime_month_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(month, [o].[OrderDate]) = 4"); +WHERE (DATEPART(month, [o].[OrderDate]) = 4) AND DATEPART(month, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_dayOfYear_component(bool isAsync) @@ -851,7 +862,7 @@ public override async Task Where_datetime_dayOfYear_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(dayofyear, [o].[OrderDate]) = 68"); +WHERE (DATEPART(dayofyear, [o].[OrderDate]) = 68) AND DATEPART(dayofyear, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_day_component(bool isAsync) @@ -861,7 +872,7 @@ public override async Task Where_datetime_day_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(day, [o].[OrderDate]) = 4"); +WHERE (DATEPART(day, [o].[OrderDate]) = 4) AND DATEPART(day, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_hour_component(bool isAsync) @@ -871,7 +882,7 @@ public override async Task Where_datetime_hour_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(hour, [o].[OrderDate]) = 14"); +WHERE (DATEPART(hour, [o].[OrderDate]) = 14) AND DATEPART(hour, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_minute_component(bool isAsync) @@ -881,7 +892,7 @@ public override async Task Where_datetime_minute_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(minute, [o].[OrderDate]) = 23"); +WHERE (DATEPART(minute, [o].[OrderDate]) = 23) AND DATEPART(minute, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_second_component(bool isAsync) @@ -891,7 +902,7 @@ public override async Task Where_datetime_second_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(second, [o].[OrderDate]) = 44"); +WHERE (DATEPART(second, [o].[OrderDate]) = 44) AND DATEPART(second, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetime_millisecond_component(bool isAsync) @@ -901,25 +912,29 @@ public override async Task Where_datetime_millisecond_component(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE DATEPART(millisecond, [o].[OrderDate]) = 88"); +WHERE (DATEPART(millisecond, [o].[OrderDate]) = 88) AND DATEPART(millisecond, [o].[OrderDate]) IS NOT NULL"); } public override async Task Where_datetimeoffset_now_component(bool isAsync) { await base.Where_datetimeoffset_now_component(isAsync); - AssertSql( - @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] = SYSDATETIMEOFFSET()"); + + // issue #15994 +// AssertSql( +// @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +//FROM [Orders] AS [o] +//WHERE [o].[OrderDate] = SYSDATETIMEOFFSET()"); } public override async Task Where_datetimeoffset_utcnow_component(bool isAsync) { await base.Where_datetimeoffset_utcnow_component(isAsync); - AssertSql( - @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] = CAST(SYSUTCDATETIME() AS datetimeoffset)"); + + // issue #15994 +// AssertSql( +// @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +//FROM [Orders] AS [o] +//WHERE [o].[OrderDate] = CAST(SYSUTCDATETIME() AS datetimeoffset)"); } public override async Task Where_simple_reversed(bool isAsync) @@ -929,7 +944,7 @@ public override async Task Where_simple_reversed(bool isAsync) 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 N'London' = [c].[City]"); +WHERE (N'London' = [c].[City]) AND [c].[City] IS NOT NULL"); } public override async Task Where_is_null(bool isAsync) @@ -958,7 +973,7 @@ public override async Task Where_constant_is_null(bool isAsync) 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 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Where_is_not_null(bool isAsync) @@ -978,7 +993,7 @@ public override async Task Where_null_is_not_null(bool isAsync) 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 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Where_constant_is_not_null(bool isAsync) @@ -997,7 +1012,7 @@ public override async Task Where_identity_comparison(bool isAsync) 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].[City] = [c].[City]) OR [c].[City] IS NULL"); +WHERE (([c].[City] = [c].[City]) AND ([c].[City] IS NOT NULL AND [c].[City] IS NOT NULL)) OR ([c].[City] IS NULL AND [c].[City] IS NULL)"); } public override async Task Where_in_optimization_multiple(bool isAsync) @@ -1095,10 +1110,11 @@ public override async Task Where_bool_member_false(bool isAsync) { await base.Where_bool_member_false(isAsync); - 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)"); + // 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)"); } // public override async Task Where_bool_client_side_negated(bool isAsync) @@ -1138,7 +1154,7 @@ public override async Task Where_bool_member_false_shadow(bool isAsync) 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)"); +WHERE NOT ([p].[Discontinued] = CAST(1 AS bit))"); } public override async Task Where_bool_member_equals_constant(bool isAsync) @@ -1169,8 +1185,8 @@ public override async Task Where_bool_member_compared_to_binary_expression(bool @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] WHERE [p].[Discontinued] = CASE - WHEN [p].[ProductID] > 50 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [p].[ProductID] > 50 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1192,11 +1208,11 @@ public override async Task Where_negated_boolean_expression_compared_to_another_ @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] WHERE CASE - WHEN [p].[ProductID] > 50 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [p].[ProductID] > 50 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END = CASE - WHEN [p].[ProductID] > 20 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [p].[ProductID] > 20 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1208,8 +1224,8 @@ public override async Task Where_not_bool_member_compared_to_binary_expression(b @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] WHERE [p].[Discontinued] <> CASE - WHEN [p].[ProductID] > 50 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [p].[ProductID] > 50 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1234,10 +1250,10 @@ public override async Task Where_bool_parameter_compared_to_binary_expression(bo SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] -WHERE CASE - WHEN [p].[ProductID] > 50 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END <> @__prm_0"); +WHERE (CASE + WHEN [p].[ProductID] > 50 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END <> @__prm_0) OR @__prm_0 IS NULL"); } public override async Task Where_bool_member_and_parameter_compared_to_binary_expression_nested(bool isAsync) @@ -1250,11 +1266,11 @@ public override async Task Where_bool_member_and_parameter_compared_to_binary_ex SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] WHERE [p].[Discontinued] = CASE - WHEN CASE - WHEN [p].[ProductID] > 50 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END <> @__prm_0 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN (CASE + WHEN [p].[ProductID] > 50 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END <> @__prm_0) OR @__prm_0 IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1265,17 +1281,18 @@ public override async Task Where_de_morgan_or_optimizated(bool isAsync) 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)) AND ([p].[ProductID] >= 20)"); +WHERE NOT ([p].[Discontinued] = CAST(1 AS bit)) AND ([p].[ProductID] >= 20)"); } public override async Task Where_de_morgan_and_optimizated(bool isAsync) { await base.Where_de_morgan_and_optimizated(isAsync); - 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)) OR ([p].[ProductID] >= 20)"); + // issue #16037 +// 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)) OR ([p].[ProductID] >= 20)"); } public override async Task Where_complex_negated_expression_optimized(bool isAsync) @@ -1285,7 +1302,7 @@ public override async Task Where_complex_negated_expression_optimized(bool isAsy 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)) AND ([p].[ProductID] < 60)) AND ([p].[ProductID] > 30)"); +WHERE (NOT ([p].[Discontinued] = CAST(1 AS bit)) AND ([p].[ProductID] < 60)) AND ([p].[ProductID] > 30)"); } public override async Task Where_short_member_comparison(bool isAsync) @@ -1302,10 +1319,11 @@ public override async Task Where_comparison_to_nullable_bool(bool isAsync) { await base.Where_comparison_to_nullable_bool(isAsync); - 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'%KI'"); + // 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'%KI'"); } public override async Task Where_true(bool isAsync) @@ -1324,7 +1342,7 @@ public override async Task Where_false(bool isAsync) 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 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Where_default(bool isAsync) @@ -1356,7 +1374,7 @@ public override async Task Where_concat_string_int_comparison1(bool isAsync) SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE ([c].[CustomerID] + CAST(@__i_0 AS nvarchar(max))) = [c].[CompanyName]"); +WHERE ((([c].[CustomerID] + CAST(@__i_0 AS nchar(5))) = [c].[CompanyName]) AND ([c].[CustomerID] + CAST(@__i_0 AS nchar(5)) IS NOT NULL AND [c].[CompanyName] IS NOT NULL)) OR ([c].[CustomerID] + CAST(@__i_0 AS nchar(5)) IS NULL AND [c].[CompanyName] IS NULL)"); } public override async Task Where_concat_string_int_comparison2(bool isAsync) @@ -1368,7 +1386,7 @@ public override async Task Where_concat_string_int_comparison2(bool isAsync) SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE (CAST(@__i_0 AS nvarchar(max)) + [c].[CustomerID]) = [c].[CompanyName]"); +WHERE (((CAST(@__i_0 AS nchar(5)) + [c].[CustomerID]) = [c].[CompanyName]) AND (CAST(@__i_0 AS nchar(5)) + [c].[CustomerID] IS NOT NULL AND [c].[CompanyName] IS NOT NULL)) OR (CAST(@__i_0 AS nchar(5)) + [c].[CustomerID] IS NULL AND [c].[CompanyName] IS NULL)"); } public override async Task Where_concat_string_int_comparison3(bool isAsync) @@ -1381,28 +1399,41 @@ public override async Task Where_concat_string_int_comparison3(bool isAsync) SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE (((CAST(@__p_0 AS nvarchar(max)) + [c].[CustomerID]) + CAST(@__j_1 AS nvarchar(max))) + CAST(42 AS nvarchar(max))) = [c].[CompanyName]"); +WHERE (((((CAST(@__p_0 AS nchar(5)) + [c].[CustomerID]) + CAST(@__j_1 AS nchar(5))) + CAST(42 AS nchar(5))) = [c].[CompanyName]) AND (((CAST(@__p_0 AS nchar(5)) + [c].[CustomerID]) + CAST(@__j_1 AS nchar(5))) + CAST(42 AS nchar(5)) IS NOT NULL AND [c].[CompanyName] IS NOT NULL)) OR (((CAST(@__p_0 AS nchar(5)) + [c].[CustomerID]) + CAST(@__j_1 AS nchar(5))) + CAST(42 AS nchar(5)) IS NULL AND [c].[CompanyName] IS NULL)"); } public override async Task Where_concat_string_int_comparison4(bool isAsync) { await base.Where_concat_string_int_comparison4(isAsync); - AssertSql(" "); + AssertSql( + @"SELECT [o].[CustomerID] +FROM [Orders] AS [o] +WHERE (((CAST([o].[OrderID] AS nchar(5)) + [o].[CustomerID]) = [o].[CustomerID]) AND (CAST([o].[OrderID] AS nchar(5)) + [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] IS NOT NULL)) OR (CAST([o].[OrderID] AS nchar(5)) + [o].[CustomerID] IS NULL AND [o].[CustomerID] IS NULL)"); } public override async Task Where_concat_string_string_comparison(bool isAsync) { await base.Where_concat_string_string_comparison(isAsync); - AssertSql(" "); + AssertSql( + @"@__i_0='A' (Size = 5) + +SELECT [c].[CustomerID] +FROM [Customers] AS [c] +WHERE (((@__i_0 + [c].[CustomerID]) = [c].[CompanyName]) AND (@__i_0 + [c].[CustomerID] IS NOT NULL AND [c].[CompanyName] IS NOT NULL)) OR (@__i_0 + [c].[CustomerID] IS NULL AND [c].[CompanyName] IS NULL)"); } public override async Task Where_string_concat_method_comparison(bool isAsync) { await base.Where_string_concat_method_comparison(isAsync); - AssertSql(" "); + AssertSql( + @"@__i_0='A' (Size = 5) + +SELECT [c].[CustomerID] +FROM [Customers] AS [c] +WHERE (((@__i_0 + [c].[CustomerID]) = [c].[CompanyName]) AND (@__i_0 + [c].[CustomerID] IS NOT NULL AND [c].[CompanyName] IS NOT NULL)) OR (@__i_0 + [c].[CustomerID] IS NULL AND [c].[CompanyName] IS NULL)"); } public override async Task Where_ternary_boolean_condition_true(bool isAsync) @@ -1410,60 +1441,73 @@ public override async Task Where_ternary_boolean_condition_true(bool isAsync) await base.Where_ternary_boolean_condition_true(isAsync); AssertSql( - @"@__flag_0='True' + @"@__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))) OR ((@__flag_0 <> CAST(1 AS bit)) AND ([p].[UnitsInStock] < CAST(20 AS smallint)))"); +WHERE CASE + WHEN @__flag_0 = CAST(1 AS bit) THEN CASE + WHEN [p].[UnitsInStock] >= CAST(20 AS smallint) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END + ELSE CASE + WHEN [p].[UnitsInStock] < CAST(20 AS smallint) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END = CAST(1 AS bit)"); } public override async Task Where_ternary_boolean_condition_false(bool isAsync) { await base.Where_ternary_boolean_condition_false(isAsync); - AssertSql( - @"@__flag_0='False' + // 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)))"); +//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)))"); } public override async Task Where_ternary_boolean_condition_with_another_condition(bool isAsync) { await base.Where_ternary_boolean_condition_with_another_condition(isAsync); - AssertSql( - @"@__productId_0='15' -@__flag_1='True' + // issue #15994 +// AssertSql( +// @"@__productId_0='15' +//@__flag_1='True' -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 (((@__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))))"); } 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); - AssertSql( - @"@__flag_0='True' + // 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))"); +//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))"); } 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); - AssertSql( - @"@__flag_0='False' + // 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))"); +//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))"); } public override async Task Where_compare_constructed_equal(bool isAsync) @@ -1567,7 +1611,7 @@ public override async Task Where_compare_null(bool isAsync) 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].[City] IS NULL AND ([c].[Country] = N'UK')"); +WHERE [c].[City] IS NULL AND (([c].[Country] = N'UK') AND [c].[Country] IS NOT NULL)"); } public override async Task Where_Is_on_same_type(bool isAsync) @@ -1586,7 +1630,7 @@ public override async Task Where_chain(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[CustomerID] = N'QUICK') AND ([o].[OrderDate] > '1998-01-01T00:00:00.000')"); +WHERE (([o].[CustomerID] = N'QUICK') AND [o].[CustomerID] IS NOT NULL) AND ([o].[OrderDate] > '1998-01-01T00:00:00.000')"); } public override void Where_navigation_contains() @@ -1622,25 +1666,26 @@ public override async Task Where_array_index(bool isAsync) 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] = @__p_0"); +WHERE ([c].[CustomerID] = @__p_0) AND @__p_0 IS NOT NULL"); } public override async Task Where_multiple_contains_in_subquery_with_or(bool isAsync) { await base.Where_multiple_contains_in_subquery_with_or(isAsync); - 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] -)"); + // 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] +//)"); } public override async Task Where_multiple_contains_in_subquery_with_and(bool isAsync) @@ -1648,16 +1693,17 @@ public override async Task Where_multiple_contains_in_subquery_with_and(bool isA await base.Where_multiple_contains_in_subquery_with_and(isAsync); AssertSql( - @"SELECT [od].[OrderID], [od].[ProductID], [od].[Discount], [od].[Quantity], [od].[UnitPrice] -FROM [Order Details] AS [od] -WHERE [od].[ProductID] IN ( + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE [o].[ProductID] IN ( SELECT TOP(20) [p].[ProductID] FROM [Products] AS [p] ORDER BY [p].[ProductID] -) AND [od].[OrderID] IN ( - SELECT TOP(10) [o].[OrderID] - FROM [Orders] AS [o] - ORDER BY [o].[OrderID] +) + AND [o].[OrderID] IN ( + SELECT TOP(10) [o0].[OrderID] + FROM [Orders] AS [o0] + ORDER BY [o0].[OrderID] )"); } @@ -1712,8 +1758,8 @@ public override async Task Time_of_day_datetime(bool isAsync) await base.Time_of_day_datetime(isAsync); AssertSql( - @"SELECT CAST([c].[OrderDate] AS time) -FROM [Orders] AS [c]"); + @"SELECT CAST([o].[OrderDate] AS time) +FROM [Orders] AS [o]"); } public override async Task TypeBinary_short_circuit(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs index e1ef92e49eb..35b25943752 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs @@ -28,26 +28,27 @@ public override void Shaper_command_caching_when_parameter_names_different() AssertSql( @"SELECT COUNT(*) -FROM [Customers] AS [e] -WHERE [e].[CustomerID] = N'ALFKI'", +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'", // @"SELECT COUNT(*) -FROM [Customers] AS [e] -WHERE [e].[CustomerID] = N'ALFKI'"); +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'"); } public override void Can_convert_manually_build_expression_with_default() { base.Can_convert_manually_build_expression_with_default(); - 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"); + // 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"); } public override void Lifting_when_subquery_nested_order_by_anonymous() @@ -142,7 +143,7 @@ public override async Task Local_dictionary(bool isAsync) SELECT TOP(2) [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] = @__p_0"); +WHERE ([c].[CustomerID] = @__p_0) AND @__p_0 IS NOT NULL"); } public override void Method_with_constant_queryable_arg() @@ -213,7 +214,7 @@ public override async Task Entity_equality_null(bool isAsync) AssertSql( @"SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE [c].[CustomerID] IS NULL"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Entity_equality_null_composite_key(bool isAsync) @@ -221,7 +222,7 @@ public override async Task Entity_equality_null_composite_key(bool isAsync) await base.Entity_equality_null_composite_key(isAsync); AssertSql( - @"SELECT [o].[ProductID] + @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] FROM [Order Details] AS [o] WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } @@ -230,20 +231,22 @@ public override async Task Entity_equality_not_null(bool isAsync) { await base.Entity_equality_not_null(isAsync); - AssertSql( - @"SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] IS NOT NULL"); + // issue #15994 +// AssertSql( +// @"SELECT [c].[CustomerID] +//FROM [Customers] AS [c] +//WHERE [c].[CustomerID] IS NOT NULL"); } public override async Task Entity_equality_not_null_composite_key(bool isAsync) { await base.Entity_equality_not_null_composite_key(isAsync); - AssertSql( - @"SELECT [o].[ProductID] -FROM [Order Details] AS [o] -WHERE CAST(1 AS bit) = CAST(1 AS bit)"); + // issue #15994 +// AssertSql( +// @"SELECT [o].[ProductID] +//FROM [Order Details] AS [o] +//WHERE CAST(1 AS bit) = CAST(1 AS bit)"); } public override async Task Entity_equality_through_nested_anonymous_type_projection(bool isAsync) @@ -277,10 +280,7 @@ public override async Task Entity_equality_through_include(bool isAsync) AssertSql( @"SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE ( - SELECT TOP(1) [o].[OrderID] - FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) IS NOT NULL"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Queryable_reprojection(bool isAsync) @@ -378,14 +378,15 @@ public override async Task Where_query_composition(bool isAsync) { await base.Where_query_composition(isAsync); - 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] -)"); + // 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] +//)"); } public override async Task Where_query_composition_is_null(bool isAsync) @@ -578,38 +579,40 @@ public override async Task Where_query_composition2_FirstOrDefault(bool isAsync) { await base.Where_query_composition2_FirstOrDefault(isAsync); - AssertSql( - @"@__p_0='3' + // issue #15994 +// 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] +//)"); } public override async Task Where_query_composition2_FirstOrDefault_with_anonymous(bool isAsync) { await base.Where_query_composition2_FirstOrDefault_with_anonymous(isAsync); - AssertSql( - @"@__p_0='3' + // issue #15994 +// 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] +//)"); } public override void Select_Subquery_Single() @@ -681,13 +684,19 @@ public override void Select_Where_Subquery_Deep_First() SELECT TOP(@__p_0) [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] FROM [Order Details] AS [o] -WHERE ( +WHERE (( + SELECT TOP(1) ( + SELECT TOP(1) [c].[City] + FROM [Customers] AS [c] + WHERE ([o0].[CustomerID] = [c].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) + FROM [Orders] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) = N'Seattle') AND ( SELECT TOP(1) ( SELECT TOP(1) [c].[City] FROM [Customers] AS [c] - WHERE [o0].[CustomerID] = [c].[CustomerID]) + WHERE ([o0].[CustomerID] = [c].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) FROM [Orders] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) = N'Seattle'"); + WHERE [o].[OrderID] = [o0].[OrderID]) IS NOT NULL"); } public override void Select_Where_Subquery_Equality() @@ -796,11 +805,11 @@ public override async Task OrderBy_SelectMany(bool isAsync) @"SELECT [c].[ContactName], [t].[OrderID] FROM [Customers] AS [c] CROSS JOIN ( - SELECT TOP(3) [o].* + SELECT TOP(3) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ORDER BY [o].[OrderID] ) AS [t] -WHERE [c].[CustomerID] = [t].[CustomerID] +WHERE ([c].[CustomerID] = [t].[CustomerID]) AND [t].[CustomerID] IS NOT NULL ORDER BY [c].[CustomerID]"); } @@ -809,50 +818,16 @@ public override async Task Let_any_subquery_anonymous(bool isAsync) await base.Let_any_subquery_anonymous(isAsync); 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%' -ORDER BY [c].[CustomerID]", - // - @"@_outer_CustomerID='ALFKI' (Size = 5) - -SELECT CASE + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE WHEN EXISTS ( SELECT 1 - FROM [Orders] AS [o0] - WHERE [o0].[CustomerID] = @_outer_CustomerID) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END", - // - @"@_outer_CustomerID='ANATR' (Size = 5) - -SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Orders] AS [o0] - WHERE [o0].[CustomerID] = @_outer_CustomerID) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END", - // - @"@_outer_CustomerID='ANTON' (Size = 5) - -SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Orders] AS [o0] - WHERE [o0].[CustomerID] = @_outer_CustomerID) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END", - // - @"@_outer_CustomerID='AROUT' (Size = 5) - -SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Orders] AS [o0] - WHERE [o0].[CustomerID] = @_outer_CustomerID) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END"); + FROM [Orders] AS [o] + WHERE ([o].[CustomerID] = [c].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [hasOrders] +FROM [Customers] AS [c] +WHERE [c].[CustomerID] LIKE N'A%' +ORDER BY [c].[CustomerID]"); } public override async Task OrderBy_arithmetic(bool isAsync) @@ -873,8 +848,8 @@ public override async Task OrderBy_condition_comparison(bool isAsync) @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] ORDER BY CASE - WHEN [p].[UnitsInStock] > CAST(0 AS smallint) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [p].[UnitsInStock] > CAST(0 AS smallint) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END, [p].[ProductID]"); } @@ -882,13 +857,14 @@ public override async Task OrderBy_ternary_conditions(bool isAsync) { await base.OrderBy_ternary_conditions(isAsync); - 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 #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]"); } public override void OrderBy_any() @@ -896,17 +872,15 @@ public override void OrderBy_any() base.OrderBy_any(); AssertSql( - @"SELECT [p].[CustomerID], [p].[Address], [p].[City], [p].[CompanyName], [p].[ContactName], [p].[ContactTitle], [p].[Country], [p].[Fax], [p].[Phone], [p].[PostalCode], [p].[Region] -FROM [Customers] AS [p] -ORDER BY ( - SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Orders] AS [o] - WHERE ([p].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] > 11000)) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END -), [p].[CustomerID]"); + @"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] +ORDER BY CASE + WHEN EXISTS ( + SELECT 1 + FROM [Orders] AS [o] + WHERE (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AND ([o].[OrderID] > 11000)) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [c].[CustomerID]"); } [SqlServerCondition(SqlServerCondition.SupportsOffset)] @@ -1015,10 +989,10 @@ public override async Task Join_Customers_Orders_Orders_Skip_Take_Same_Propertie @"@__p_0='10' @__p_1='5' -SELECT [o].[OrderID], [ca].[CustomerID] AS [CustomerIDA], [cb].[CustomerID] AS [CustomerIDB], [ca].[ContactName] AS [ContactNameA], [cb].[ContactName] AS [ContactNameB] +SELECT [o].[OrderID], [c].[CustomerID] AS [CustomerIDA], [c0].[CustomerID] AS [CustomerIDB], [c].[ContactName] AS [ContactNameA], [c0].[ContactName] AS [ContactNameB] FROM [Orders] AS [o] -INNER JOIN [Customers] AS [ca] ON [o].[CustomerID] = [ca].[CustomerID] -INNER JOIN [Customers] AS [cb] ON [o].[CustomerID] = [cb].[CustomerID] +INNER JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] +INNER JOIN [Customers] AS [c0] ON [o].[CustomerID] = [c0].[CustomerID] ORDER BY [o].[OrderID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY"); } @@ -1032,7 +1006,7 @@ public override async Task Take_Skip(bool isAsync) @"@__p_0='10' @__p_1='5' -SELECT [t].* +SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( SELECT TOP(@__p_0) [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] @@ -1051,17 +1025,17 @@ public override async Task Take_Skip_Distinct(bool isAsync) @"@__p_0='10' @__p_1='5' -SELECT DISTINCT [t0].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT [t].* + SELECT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( SELECT TOP(@__p_0) [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] ORDER BY [c].[ContactName] - ) AS [t] - ORDER BY [t].[ContactName] + ) AS [t0] + ORDER BY [t0].[ContactName] OFFSET @__p_1 ROWS -) AS [t0]"); +) AS [t]"); } [SqlServerCondition(SqlServerCondition.SupportsOffset)] @@ -1073,32 +1047,32 @@ public override async Task Take_Skip_Distinct_Caching(bool isAsync) @"@__p_0='10' @__p_1='5' -SELECT DISTINCT [t0].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT [t].* + SELECT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( SELECT TOP(@__p_0) [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] ORDER BY [c].[ContactName] - ) AS [t] - ORDER BY [t].[ContactName] + ) AS [t0] + ORDER BY [t0].[ContactName] OFFSET @__p_1 ROWS -) AS [t0]", +) AS [t]", // @"@__p_0='15' @__p_1='10' -SELECT DISTINCT [t0].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT [t].* + SELECT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( SELECT TOP(@__p_0) [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] ORDER BY [c].[ContactName] - ) AS [t] - ORDER BY [t].[ContactName] + ) AS [t0] + ORDER BY [t0].[ContactName] OFFSET @__p_1 ROWS -) AS [t0]"); +) AS [t]"); } public override async Task Take_Distinct_Count(bool isAsync) @@ -1110,12 +1084,12 @@ public override async Task Take_Distinct_Count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT DISTINCT [t].* + SELECT DISTINCT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate] FROM ( - SELECT TOP(@__p_0) [o].* + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ) AS [t] -) AS [t0]"); +) AS [t]"); } public override async Task Take_Where_Distinct_Count(bool isAsync) @@ -1127,13 +1101,13 @@ public override async Task Take_Where_Distinct_Count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT DISTINCT [t].* + SELECT DISTINCT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate] FROM ( - SELECT TOP(@__p_0) [o].* + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] - WHERE [o].[CustomerID] = N'FRANK' + WHERE ([o].[CustomerID] = N'FRANK') AND [o].[CustomerID] IS NOT NULL ) AS [t] -) AS [t0]"); +) AS [t]"); } public override async Task Null_conditional_simple(bool isAsync) @@ -1153,7 +1127,7 @@ public override async Task Null_conditional_deep(bool isAsync) 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 CAST(LEN([c].[CustomerID]) AS int) = 5"); +WHERE (CAST(LEN([c].[CustomerID]) AS int) = 5) AND CAST(LEN([c].[CustomerID]) AS int) IS NOT NULL"); } public override async Task Queryable_simple(bool isAsync) @@ -1179,8 +1153,8 @@ public override async Task Queryable_nested_simple(bool isAsync) await base.Queryable_nested_simple(isAsync); AssertSql( - @"SELECT [c3].[CustomerID], [c3].[Address], [c3].[City], [c3].[CompanyName], [c3].[ContactName], [c3].[ContactTitle], [c3].[Country], [c3].[Fax], [c3].[Phone], [c3].[PostalCode], [c3].[Region] -FROM [Customers] AS [c3]"); + @"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]"); } public override async Task Queryable_simple_anonymous_projection_subquery(bool isAsync) @@ -1262,7 +1236,7 @@ public override async Task OrderBy_Take_Count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].* + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ORDER BY [o].[OrderID] ) AS [t]"); @@ -1277,7 +1251,7 @@ public override async Task Take_OrderBy_Count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].* + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ) AS [t]"); } @@ -1290,8 +1264,8 @@ public override async Task Any_simple(bool isAsync) @"SELECT CASE WHEN EXISTS ( SELECT 1 - FROM [Customers] AS [c]) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + FROM [Customers] AS [c]) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1304,8 +1278,8 @@ public override async Task Any_predicate(bool isAsync) WHEN EXISTS ( SELECT 1 FROM [Customers] AS [c] - WHERE [c].[ContactName] LIKE N'A%') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE [c].[ContactName] IS NOT NULL AND ([c].[ContactName] LIKE N'A%')) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1316,10 +1290,10 @@ public override async Task Any_nested_negated(bool isAsync) 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 NOT EXISTS ( +WHERE NOT (EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'A%')"); + WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')))"); } public override async Task Any_nested_negated2(bool isAsync) @@ -1329,10 +1303,10 @@ public override async Task Any_nested_negated2(bool isAsync) 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].[City] <> N'London') OR [c].[City] IS NULL) AND NOT EXISTS ( +WHERE (([c].[City] <> N'London') OR [c].[City] IS NULL) AND NOT (EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'A%')"); + WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')))"); } public override async Task Any_nested_negated3(bool isAsync) @@ -1342,10 +1316,10 @@ public override async Task Any_nested_negated3(bool isAsync) 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 NOT EXISTS ( +WHERE NOT (EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'A%') AND (([c].[City] <> N'London') OR [c].[City] IS NULL)"); + WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%'))) AND (([c].[City] <> N'London') OR [c].[City] IS NULL)"); } public override async Task Any_nested(bool isAsync) @@ -1358,7 +1332,7 @@ FROM [Customers] AS [c] WHERE EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'A%')"); + WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%'))"); } public override async Task Any_nested2(bool isAsync) @@ -1371,7 +1345,7 @@ FROM [Customers] AS [c] WHERE (([c].[City] <> N'London') OR [c].[City] IS NULL) AND EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'A%')"); + WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%'))"); } public override async Task Any_nested3(bool isAsync) @@ -1384,7 +1358,7 @@ FROM [Customers] AS [c] WHERE EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'A%') AND (([c].[City] <> N'London') OR [c].[City] IS NULL)"); + WHERE [o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')) AND (([c].[City] <> N'London') OR [c].[City] IS NULL)"); } public override void Any_with_multiple_conditions_still_uses_exists() @@ -1404,14 +1378,15 @@ public override async Task All_top_level(bool isAsync) { await base.All_top_level(isAsync); - 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"); + // 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"); } public override async Task All_top_level_column(bool isAsync) @@ -1423,8 +1398,8 @@ public override async Task All_top_level_column(bool isAsync) WHEN NOT EXISTS ( SELECT 1 FROM [Customers] AS [c] - WHERE (NOT ([c].[ContactName] LIKE [c].[ContactName] + N'%') OR (LEFT([c].[ContactName], LEN([c].[ContactName])) <> [c].[ContactName])) AND (([c].[ContactName] <> N'') OR [c].[ContactName] IS NULL)) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE (([c].[ContactName] <> N'') OR [c].[ContactName] IS NULL) AND ((([c].[ContactName] IS NULL AND ([c].[ContactName] IS NOT NULL AND (CAST(0 AS bit) = CAST(1 AS bit)))) OR ([c].[ContactName] IS NULL AND (CAST(1 AS bit) = CAST(1 AS bit)))) OR ((([c].[ContactName] IS NULL AND ([c].[ContactName] IS NOT NULL AND (CAST(0 AS bit) = CAST(1 AS bit)))) OR ([c].[ContactName] IS NULL AND (CAST(1 AS bit) = CAST(1 AS bit)))) OR (NOT ([c].[ContactName] LIKE [c].[ContactName] + N'%') OR (((LEFT([c].[ContactName], LEN([c].[ContactName])) <> [c].[ContactName]) OR (LEFT([c].[ContactName], LEN([c].[ContactName])) IS NULL OR [c].[ContactName] IS NULL)) AND (LEFT([c].[ContactName], LEN([c].[ContactName])) IS NOT NULL OR [c].[ContactName] IS NOT NULL)))))) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1436,20 +1411,15 @@ public override async Task All_top_level_subquery(bool isAsync) @"SELECT CASE WHEN NOT EXISTS ( SELECT 1 - FROM [Customers] AS [c1] - WHERE NOT (( - SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Customers] AS [c2] - WHERE EXISTS ( - SELECT 1 - FROM [Customers] AS [c3] - WHERE [c1].[CustomerID] = [c3].[CustomerID])) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END - ) = CAST(1 AS bit))) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + FROM [Customers] AS [c] + WHERE NOT (EXISTS ( + SELECT 1 + FROM [Customers] AS [c0] + WHERE EXISTS ( + SELECT 1 + FROM [Customers] AS [c1] + WHERE [c].[CustomerID] = [c1].[CustomerID])))) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1461,20 +1431,15 @@ public override async Task All_top_level_subquery_ef_property(bool isAsync) @"SELECT CASE WHEN NOT EXISTS ( SELECT 1 - FROM [Customers] AS [c1] - WHERE NOT (( - SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Customers] AS [c2] - WHERE EXISTS ( - SELECT 1 - FROM [Customers] AS [c3] - WHERE [c1].[CustomerID] = [c3].[CustomerID])) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END - ) = CAST(1 AS bit))) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + FROM [Customers] AS [c] + WHERE NOT (EXISTS ( + SELECT 1 + FROM [Customers] AS [c0] + WHERE EXISTS ( + SELECT 1 + FROM [Customers] AS [c1] + WHERE [c].[CustomerID] = [c1].[CustomerID])))) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1596,7 +1561,7 @@ public override async Task SelectMany_simple_subquery(bool isAsync) AssertSql( @"@__p_0='9' -SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title], [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] +SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [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] @@ -1609,7 +1574,7 @@ public override async Task SelectMany_simple1(bool isAsync) await base.SelectMany_simple1(isAsync); AssertSql( - @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title], [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] FROM [Employees] AS [e] CROSS JOIN [Customers] AS [c]"); } @@ -1619,10 +1584,10 @@ public override async Task SelectMany_simple2(bool isAsync) await base.SelectMany_simple2(isAsync); AssertSql( - @"SELECT [e1].[EmployeeID], [e1].[City], [e1].[Country], [e1].[FirstName], [e1].[ReportsTo], [e1].[Title], [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [e2].[FirstName] AS [FirstName0] -FROM [Employees] AS [e1] + @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title], [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [e0].[FirstName] +FROM [Employees] AS [e] CROSS JOIN [Customers] AS [c] -CROSS JOIN [Employees] AS [e2]"); +CROSS JOIN [Employees] AS [e0]"); } public override async Task SelectMany_entity_deep(bool isAsync) @@ -1630,11 +1595,11 @@ public override async Task SelectMany_entity_deep(bool isAsync) await base.SelectMany_entity_deep(isAsync); AssertSql( - @"SELECT [e1].[EmployeeID], [e1].[City], [e1].[Country], [e1].[FirstName], [e1].[ReportsTo], [e1].[Title], [e2].[EmployeeID], [e2].[City], [e2].[Country], [e2].[FirstName], [e2].[ReportsTo], [e2].[Title], [e3].[EmployeeID], [e3].[City], [e3].[Country], [e3].[FirstName], [e3].[ReportsTo], [e3].[Title], [e4].[EmployeeID], [e4].[City], [e4].[Country], [e4].[FirstName], [e4].[ReportsTo], [e4].[Title] + @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title], [e0].[EmployeeID], [e0].[City], [e0].[Country], [e0].[FirstName], [e0].[ReportsTo], [e0].[Title], [e1].[EmployeeID], [e1].[City], [e1].[Country], [e1].[FirstName], [e1].[ReportsTo], [e1].[Title], [e2].[EmployeeID], [e2].[City], [e2].[Country], [e2].[FirstName], [e2].[ReportsTo], [e2].[Title] FROM [Employees] AS [e1] -CROSS JOIN [Employees] AS [e2] -CROSS JOIN [Employees] AS [e3] -CROSS JOIN [Employees] AS [e4]"); +CROSS JOIN [Employees] AS [e] +CROSS JOIN [Employees] AS [e0] +CROSS JOIN [Employees] AS [e2]"); } public override async Task SelectMany_projection1(bool isAsync) @@ -1642,9 +1607,9 @@ public override async Task SelectMany_projection1(bool isAsync) await base.SelectMany_projection1(isAsync); AssertSql( - @"SELECT [e1].[City], [e2].[Country] -FROM [Employees] AS [e1] -CROSS JOIN [Employees] AS [e2]"); + @"SELECT [e].[City], [e0].[Country] +FROM [Employees] AS [e] +CROSS JOIN [Employees] AS [e0]"); } public override async Task SelectMany_projection2(bool isAsync) @@ -1652,10 +1617,10 @@ public override async Task SelectMany_projection2(bool isAsync) await base.SelectMany_projection2(isAsync); AssertSql( - @"SELECT [e1].[City], [e2].[Country], [e3].[FirstName] -FROM [Employees] AS [e1] -CROSS JOIN [Employees] AS [e2] -CROSS JOIN [Employees] AS [e3]"); + @"SELECT [e].[City], [e0].[Country], [e1].[FirstName] +FROM [Employees] AS [e] +CROSS JOIN [Employees] AS [e0] +CROSS JOIN [Employees] AS [e1]"); } public override async Task SelectMany_Count(bool isAsync) @@ -1687,8 +1652,8 @@ public override async Task SelectMany_OrderBy_ThenBy_Any(bool isAsync) WHEN EXISTS ( SELECT 1 FROM [Customers] AS [c] - CROSS JOIN [Orders] AS [o]) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + CROSS JOIN [Orders] AS [o]) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1788,9 +1753,9 @@ WHEN EXISTS ( SELECT 1 FROM [Customers] AS [c] INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] - INNER JOIN [Order Details] AS [od] ON [o].[OrderID] = [od].[OrderID] - WHERE [c].[City] = N'London') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + INNER JOIN [Order Details] AS [o0] ON [o].[OrderID] = [o0].[OrderID] + WHERE ([c].[City] = N'London') AND [c].[City] IS NOT NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -1825,7 +1790,7 @@ public override async Task Where_join_orderby_join_select(bool isAsync) @"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] INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] -INNER JOIN [Order Details] AS [od] ON [o].[OrderID] = [od].[OrderID] +INNER JOIN [Order Details] AS [o0] ON [o].[OrderID] = [o0].[OrderID] WHERE [c].[CustomerID] <> N'ALFKI' ORDER BY [c].[CustomerID]"); } @@ -1858,11 +1823,11 @@ public override async Task SelectMany_cartesian_product_with_ordering(bool isAsy await base.SelectMany_cartesian_product_with_ordering(isAsync); AssertSql( - @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [e].[City] AS [City0] + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [e].[City] FROM [Customers] AS [c] CROSS JOIN [Employees] AS [e] -WHERE ([c].[City] = [e].[City]) OR ([c].[City] IS NULL AND [e].[City] IS NULL) -ORDER BY [City0], [c].[CustomerID] DESC"); +WHERE (([c].[City] = [e].[City]) AND ([c].[City] IS NOT NULL AND [e].[City] IS NOT NULL)) OR ([c].[City] IS NULL AND [e].[City] IS NULL) +ORDER BY [e].[City], [c].[CustomerID] DESC"); } public override async Task SelectMany_Joined_DefaultIfEmpty(bool isAsync) @@ -1926,7 +1891,7 @@ public override async Task Take_with_single(bool isAsync) AssertSql( @"@__p_0='1' -SELECT TOP(2) [t].* +SELECT TOP(2) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( SELECT TOP(@__p_0) [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] @@ -1942,7 +1907,7 @@ public override async Task Take_with_single_select_many(bool isAsync) AssertSql( @"@__p_0='1' -SELECT TOP(2) [t].* +SELECT TOP(2) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [t].[OrderID], [t].[CustomerID0], [t].[EmployeeID], [t].[OrderDate] FROM ( SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[OrderID], [o].[CustomerID] AS [CustomerID0], [o].[EmployeeID], [o].[OrderDate] FROM [Customers] AS [c] @@ -1995,7 +1960,7 @@ public override async Task Skip_Distinct(bool isAsync) AssertSql( @"@__p_0='5' -SELECT DISTINCT [t].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( 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] @@ -2013,7 +1978,7 @@ public override async Task Skip_Take_Distinct(bool isAsync) @"@__p_0='5' @__p_1='10' -SELECT DISTINCT [t].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( 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] @@ -2036,8 +2001,8 @@ WHEN EXISTS ( SELECT 1 FROM [Customers] AS [c] ORDER BY [c].[ContactName] - OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2054,13 +2019,13 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM ( - SELECT [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] ORDER BY [c].[CustomerID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY ) AS [t] - WHERE NOT ([t].[CustomerID] LIKE N'B%')) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE ([t].[CustomerID] IS NULL AND (CAST(0 AS bit) = CAST(1 AS bit))) OR ((N'B' IS NULL AND (CAST(0 AS bit) = CAST(1 AS bit))) OR NOT ([t].[CustomerID] LIKE N'B%'))) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2076,12 +2041,12 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM ( - SELECT TOP(@__p_0) [c].* + SELECT TOP(@__p_0) [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] ORDER BY [c].[CustomerID] ) AS [t] - WHERE NOT ([t].[CustomerID] LIKE N'A%')) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE ([t].[CustomerID] IS NULL AND (CAST(0 AS bit) = CAST(1 AS bit))) OR ((N'A' IS NULL AND (CAST(0 AS bit) = CAST(1 AS bit))) OR NOT ([t].[CustomerID] LIKE N'A%'))) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2103,8 +2068,8 @@ FROM [Customers] AS [c] ORDER BY [c].[CustomerID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY ) AS [t] - WHERE [t].[CustomerID] LIKE N'C%') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE [t].[CustomerID] LIKE N'C%') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2124,8 +2089,8 @@ SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName FROM [Customers] AS [c] ORDER BY [c].[CustomerID] ) AS [t] - WHERE [t].[CustomerID] LIKE N'B%') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHERE [t].[CustomerID] LIKE N'B%') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2214,7 +2179,7 @@ public override async Task Take_Distinct(bool isAsync) AssertSql( @"@__p_0='5' -SELECT DISTINCT [t].* +SELECT DISTINCT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate] FROM ( SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] @@ -2246,7 +2211,7 @@ public override async Task Distinct_Take_Count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT DISTINCT TOP(@__p_0) [o].* + SELECT DISTINCT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ) AS [t]"); } @@ -2279,8 +2244,8 @@ public override async Task OrderBy_ThenBy_Any(bool isAsync) @"SELECT CASE WHEN EXISTS ( SELECT 1 - FROM [Customers] AS [c]) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + FROM [Customers] AS [c]) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2292,15 +2257,13 @@ public override async Task OrderBy_correlated_subquery1(bool isAsync) @"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%' -ORDER BY ( - SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Customers] AS [c2] - WHERE [c2].[CustomerID] = [c].[CustomerID]) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END -), [c].[CustomerID]"); +ORDER BY CASE + WHEN EXISTS ( + SELECT 1 + FROM [Customers] AS [c0] + WHERE [c0].[CustomerID] = [c].[CustomerID]) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [c].[CustomerID]"); } public override async Task OrderBy_correlated_subquery2(bool isAsync) @@ -2310,19 +2273,25 @@ public override async Task OrderBy_correlated_subquery2(bool isAsync) AssertSql( @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[OrderID] <= 10250) AND (( +WHERE ([o].[OrderID] <= 10250) AND ((( SELECT TOP(1) [c].[City] FROM [Customers] AS [c] - ORDER BY ( - SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [Customers] AS [c2] - WHERE [c2].[CustomerID] = N'ALFKI') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END - ) -) <> N'Nowhere')"); + ORDER BY CASE + WHEN EXISTS ( + SELECT 1 + FROM [Customers] AS [c0] + WHERE [c0].[CustomerID] = N'ALFKI') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END) <> N'Nowhere') OR ( + SELECT TOP(1) [c].[City] + FROM [Customers] AS [c] + ORDER BY CASE + WHEN EXISTS ( + SELECT 1 + FROM [Customers] AS [c0] + WHERE [c0].[CustomerID] = N'ALFKI') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END) IS NULL)"); } public override async Task Where_subquery_recursive_trivial(bool isAsync) @@ -2330,15 +2299,15 @@ public override async Task Where_subquery_recursive_trivial(bool isAsync) await base.Where_subquery_recursive_trivial(isAsync); AssertSql( - @"SELECT [e1].[EmployeeID], [e1].[City], [e1].[Country], [e1].[FirstName], [e1].[ReportsTo], [e1].[Title] -FROM [Employees] AS [e1] + @"SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] +FROM [Employees] AS [e] WHERE EXISTS ( SELECT 1 - FROM [Employees] AS [e2] + FROM [Employees] AS [e0] WHERE EXISTS ( SELECT 1 - FROM [Employees] AS [e3])) -ORDER BY [e1].[EmployeeID]"); + FROM [Employees] AS [e1])) +ORDER BY [e].[EmployeeID]"); } public override async Task Where_query_composition4(bool isAsync) @@ -2395,9 +2364,9 @@ public override void Select_DTO_constructor_distinct_with_navigation_translated_ base.Select_DTO_constructor_distinct_with_navigation_translated_to_server(); AssertSql( - @"SELECT DISTINCT [o.Customer].[City] + @"SELECT DISTINCT [c].[City] FROM [Orders] AS [o] -LEFT JOIN [Customers] AS [o.Customer] ON [o].[CustomerID] = [o.Customer].[CustomerID] +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] WHERE [o].[OrderID] < 10300"); } @@ -2419,8 +2388,7 @@ public override void Select_nested_collection_count_using_DTO() @"SELECT [c].[CustomerID] AS [Id], ( SELECT COUNT(*) FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] -) AS [Count] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AS [Count] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } @@ -2444,15 +2412,16 @@ 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(); - 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%'"); + // 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%'"); } public override async Task Select_correlated_subquery_projection(bool isAsync) @@ -2549,8 +2518,8 @@ public override async Task Where_subquery_on_bool(bool isAsync) @"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] FROM [Products] AS [p] WHERE N'Chai' IN ( - SELECT [p2].[ProductName] - FROM [Products] AS [p2] + SELECT [p0].[ProductName] + FROM [Products] AS [p0] )"); } @@ -2592,10 +2561,11 @@ public override async Task Select_null_coalesce_operator(bool isAsync) { await base.Select_null_coalesce_operator(isAsync); - AssertSql( - @"SELECT [c].[CustomerID], [c].[CompanyName], COALESCE([c].[Region], N'ZZ') AS [Region] -FROM [Customers] AS [c] -ORDER BY [Region], [c].[CustomerID]"); + // issue #16038 +// AssertSql( +// @"SELECT [c].[CustomerID], [c].[CompanyName], COALESCE([c].[Region], N'ZZ') AS [Region] +//FROM [Customers] AS [c] +//ORDER BY [Region], [c].[CustomerID]"); } public override async Task OrderBy_conditional_operator(bool isAsync) @@ -2606,8 +2576,8 @@ public override async Task OrderBy_conditional_operator(bool isAsync) @"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] ORDER BY CASE - WHEN [c].[Region] IS NULL - THEN N'ZZ' ELSE [c].[Region] + WHEN [c].[Region] IS NULL THEN N'ZZ' + ELSE [c].[Region] END, [c].[CustomerID]"); } @@ -2615,12 +2585,13 @@ public override async Task Null_Coalesce_Short_Circuit(bool isAsync) { await base.Null_Coalesce_Short_Circuit(isAsync); - AssertSql( - @"SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] -FROM ( - SELECT DISTINCT [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] -) AS [t]"); + // issue #15994 +// AssertSql( +// @"SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] +//FROM ( +// SELECT DISTINCT [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] +//) AS [t]"); } public override async Task OrderBy_conditional_operator_where_condition_false(bool isAsync) @@ -2633,8 +2604,8 @@ public override async Task OrderBy_conditional_operator_where_condition_false(bo 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] ORDER BY CASE - WHEN @__p_0 = CAST(1 AS bit) - THEN N'ZZ' ELSE [c].[City] + WHEN @__p_0 = CAST(1 AS bit) THEN N'ZZ' + ELSE [c].[City] END"); } @@ -2646,8 +2617,8 @@ public override async Task OrderBy_comparison_operator(bool isAsync) @"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] ORDER BY CASE - WHEN [c].[Region] = N'ASK' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN ([c].[Region] = N'ASK') AND [c].[Region] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END"); } @@ -2667,7 +2638,7 @@ public override async Task Filter_coalesce_operator(bool isAsync) 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 COALESCE([c].[CompanyName], [c].[ContactName]) = N'The Big Cheese'"); +WHERE (COALESCE([c].[CompanyName], [c].[ContactName]) = N'The Big Cheese') AND COALESCE([c].[CompanyName], [c].[ContactName]) IS NOT NULL"); } [SqlServerCondition(SqlServerCondition.SupportsOffset)] @@ -2679,29 +2650,30 @@ public override async Task Take_skip_null_coalesce_operator(bool isAsync) @"@__p_0='10' @__p_1='5' -SELECT DISTINCT [t0].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT [t].* + SELECT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region], [t0].[c] FROM ( SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], COALESCE([c].[Region], N'ZZ') AS [c] FROM [Customers] AS [c] - ORDER BY [c] - ) AS [t] - ORDER BY [t].[c] + ORDER BY COALESCE([c].[Region], N'ZZ') + ) AS [t0] + ORDER BY [t0].[c] OFFSET @__p_1 ROWS -) AS [t0]"); +) AS [t]"); } public override async Task Select_take_null_coalesce_operator(bool isAsync) { await base.Select_take_null_coalesce_operator(isAsync); - AssertSql( - @"@__p_0='5' + // issue #16038 +// AssertSql( +// @"@__p_0='5' -SELECT TOP(@__p_0) [c].[CustomerID], [c].[CompanyName], COALESCE([c].[Region], N'ZZ') AS [Region] -FROM [Customers] AS [c] -ORDER BY [Region]"); +//SELECT TOP(@__p_0) [c].[CustomerID], [c].[CompanyName], COALESCE([c].[Region], N'ZZ') AS [Region] +//FROM [Customers] AS [c] +//ORDER BY [Region]"); } [SqlServerCondition(SqlServerCondition.SupportsOffset)] @@ -2713,13 +2685,13 @@ public override async Task Select_take_skip_null_coalesce_operator(bool isAsync) @"@__p_0='10' @__p_1='5' -SELECT [t].* +SELECT [t].[CustomerID], [t].[CompanyName], [t].[c] AS [Region] FROM ( - SELECT TOP(@__p_0) [c].[CustomerID], [c].[CompanyName], COALESCE([c].[Region], N'ZZ') AS [Region] + SELECT TOP(@__p_0) [c].[CustomerID], [c].[CompanyName], COALESCE([c].[Region], N'ZZ') AS [c] FROM [Customers] AS [c] - ORDER BY [Region] + ORDER BY COALESCE([c].[Region], N'ZZ') ) AS [t] -ORDER BY [t].[Region] +ORDER BY [t].[c] OFFSET @__p_1 ROWS"); } @@ -2732,11 +2704,11 @@ public override async Task Select_take_skip_null_coalesce_operator2(bool isAsync @"@__p_0='10' @__p_1='5' -SELECT [t].* +SELECT [t].[CustomerID], [t].[CompanyName], [t].[Region] FROM ( SELECT TOP(@__p_0) [c].[CustomerID], [c].[CompanyName], [c].[Region], COALESCE([c].[Region], N'ZZ') AS [c] FROM [Customers] AS [c] - ORDER BY [c] + ORDER BY COALESCE([c].[Region], N'ZZ') ) AS [t] ORDER BY [t].[c] OFFSET @__p_1 ROWS"); @@ -2751,11 +2723,11 @@ public override async Task Select_take_skip_null_coalesce_operator3(bool isAsync @"@__p_0='10' @__p_1='5' -SELECT [t].* +SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], COALESCE([c].[Region], N'ZZ') AS [c] FROM [Customers] AS [c] - ORDER BY [c] + ORDER BY COALESCE([c].[Region], N'ZZ') ) AS [t] ORDER BY [t].[c] OFFSET @__p_1 ROWS"); @@ -2881,11 +2853,11 @@ public override async Task Environment_newline_is_funcletized(bool isAsync) AssertSql( @"@__NewLine_0=' -' (Size = 4000) +' (Size = 5) 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(@__NewLine_0, [c].[CustomerID]) > 0) OR (@__NewLine_0 = N'')"); +WHERE ((@__NewLine_0 = N'') AND @__NewLine_0 IS NOT NULL) OR (CHARINDEX(@__NewLine_0, [c].[CustomerID]) > 0)"); } public override async Task String_concat_with_navigation1(bool isAsync) @@ -2893,9 +2865,9 @@ public override async Task String_concat_with_navigation1(bool isAsync) await base.String_concat_with_navigation1(isAsync); AssertSql( - @"SELECT ([o].[CustomerID] + N' ') + [o.Customer].[City] + @"SELECT ([o].[CustomerID] + N' ') + [c].[City] FROM [Orders] AS [o] -LEFT JOIN [Customers] AS [o.Customer] ON [o].[CustomerID] = [o.Customer].[CustomerID]"); +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID]"); } public override async Task String_concat_with_navigation2(bool isAsync) @@ -2903,9 +2875,9 @@ public override async Task String_concat_with_navigation2(bool isAsync) await base.String_concat_with_navigation2(isAsync); AssertSql( - @"SELECT ([o.Customer].[City] + N' ') + [o.Customer].[City] + @"SELECT ([c].[City] + N' ') + [c].[City] FROM [Orders] AS [o] -LEFT JOIN [Customers] AS [o.Customer] ON [o].[CustomerID] = [o.Customer].[CustomerID]"); +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID]"); } public override void Select_bitwise_or() @@ -2914,11 +2886,11 @@ public override void Select_bitwise_or() AssertSql( @"SELECT [c].[CustomerID], CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END | CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); @@ -2930,14 +2902,14 @@ public override void Select_bitwise_or_multiple() AssertSql( @"SELECT [c].[CustomerID], (CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END | CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) | CASE - WHEN [c].[CustomerID] = N'ANTON' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANTON' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); @@ -2949,11 +2921,11 @@ public override void Select_bitwise_and() AssertSql( @"SELECT [c].[CustomerID], CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END & CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); @@ -2965,14 +2937,14 @@ public override void Select_bitwise_and_or() AssertSql( @"SELECT [c].[CustomerID], (CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END & CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) | CASE - WHEN [c].[CustomerID] = N'ANTON' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANTON' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); @@ -2986,11 +2958,11 @@ public override async Task Where_bitwise_or_with_logical_or(bool isAsync) @"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 CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END | CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) = CAST(1 AS bit)) OR ([c].[CustomerID] = N'ANTON')"); } @@ -3002,11 +2974,11 @@ public override async Task Where_bitwise_and_with_logical_and(bool isAsync) @"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 CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END & CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) = CAST(1 AS bit)) AND ([c].[CustomerID] = N'ANTON')"); } @@ -3018,12 +2990,12 @@ public override async Task Where_bitwise_or_with_logical_and(bool isAsync) @"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 CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END | CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END) = CAST(1 AS bit)) AND ([c].[Country] = N'Germany')"); + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END) = CAST(1 AS bit)) AND (([c].[Country] = N'Germany') AND [c].[Country] IS NOT NULL)"); } public override async Task Where_bitwise_and_with_logical_or(bool isAsync) @@ -3034,11 +3006,11 @@ public override async Task Where_bitwise_and_with_logical_or(bool isAsync) @"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 CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END & CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END) = CAST(1 AS bit)) OR ([c].[CustomerID] = N'ANTON')"); } @@ -3049,13 +3021,13 @@ public override void Select_bitwise_or_with_logical_or() AssertSql( @"SELECT [c].[CustomerID], CASE WHEN ((CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END | CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END) = CAST(1 AS bit)) OR ([c].[CustomerID] = N'ANTON') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END) = CAST(1 AS bit)) OR ([c].[CustomerID] = N'ANTON') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); @@ -3068,13 +3040,13 @@ public override void Select_bitwise_and_with_logical_and() AssertSql( @"SELECT [c].[CustomerID], CASE WHEN ((CASE - WHEN [c].[CustomerID] = N'ALFKI' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END & CASE - WHEN [c].[CustomerID] = N'ANATR' - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END) = CAST(1 AS bit)) AND ([c].[CustomerID] = N'ANTON') - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) + WHEN [c].[CustomerID] = N'ANATR' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END) = CAST(1 AS bit)) AND ([c].[CustomerID] = N'ANTON') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) END AS [Value] FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); @@ -3102,7 +3074,7 @@ public override async Task Parameter_extraction_short_circuits_1(bool isAsync) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[OrderID] < 10400) AND (([o].[OrderDate] IS NOT NULL AND (DATEPART(month, [o].[OrderDate]) = @__dateFilter_Value_Month_0)) AND (DATEPART(year, [o].[OrderDate]) = @__dateFilter_Value_Year_1))", +WHERE ([o].[OrderID] < 10400) AND (([o].[OrderDate] IS NOT NULL AND (((DATEPART(month, [o].[OrderDate]) = @__dateFilter_Value_Month_0) AND (DATEPART(month, [o].[OrderDate]) IS NOT NULL AND @__dateFilter_Value_Month_0 IS NOT NULL)) OR (DATEPART(month, [o].[OrderDate]) IS NULL AND @__dateFilter_Value_Month_0 IS NULL))) AND (((DATEPART(year, [o].[OrderDate]) = @__dateFilter_Value_Year_1) AND (DATEPART(year, [o].[OrderDate]) IS NOT NULL AND @__dateFilter_Value_Year_1 IS NOT NULL)) OR (DATEPART(year, [o].[OrderDate]) IS NULL AND @__dateFilter_Value_Year_1 IS NULL)))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] @@ -3119,11 +3091,11 @@ public override async Task Parameter_extraction_short_circuits_2(bool isAsync) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[OrderID] < 10400) AND (([o].[OrderDate] IS NOT NULL AND (DATEPART(month, [o].[OrderDate]) = @__dateFilter_Value_Month_0)) AND (DATEPART(year, [o].[OrderDate]) = @__dateFilter_Value_Year_1))", +WHERE ([o].[OrderID] < 10400) AND (([o].[OrderDate] IS NOT NULL AND (((DATEPART(month, [o].[OrderDate]) = @__dateFilter_Value_Month_0) AND (DATEPART(month, [o].[OrderDate]) IS NOT NULL AND @__dateFilter_Value_Month_0 IS NOT NULL)) OR (DATEPART(month, [o].[OrderDate]) IS NULL AND @__dateFilter_Value_Month_0 IS NULL))) AND (((DATEPART(year, [o].[OrderDate]) = @__dateFilter_Value_Year_1) AND (DATEPART(year, [o].[OrderDate]) IS NOT NULL AND @__dateFilter_Value_Year_1 IS NOT NULL)) OR (DATEPART(year, [o].[OrderDate]) IS NULL AND @__dateFilter_Value_Year_1 IS NULL)))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Parameter_extraction_short_circuits_3(bool isAsync) @@ -3136,7 +3108,7 @@ public override async Task Parameter_extraction_short_circuits_3(bool isAsync) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE ([o].[OrderID] < 10400) OR (([o].[OrderDate] IS NOT NULL AND (DATEPART(month, [o].[OrderDate]) = @__dateFilter_Value_Month_0)) AND (DATEPART(year, [o].[OrderDate]) = @__dateFilter_Value_Year_1))", +WHERE ([o].[OrderID] < 10400) OR (([o].[OrderDate] IS NOT NULL AND (((DATEPART(month, [o].[OrderDate]) = @__dateFilter_Value_Month_0) AND (DATEPART(month, [o].[OrderDate]) IS NOT NULL AND @__dateFilter_Value_Month_0 IS NOT NULL)) OR (DATEPART(month, [o].[OrderDate]) IS NULL AND @__dateFilter_Value_Month_0 IS NULL))) AND (((DATEPART(year, [o].[OrderDate]) = @__dateFilter_Value_Year_1) AND (DATEPART(year, [o].[OrderDate]) IS NOT NULL AND @__dateFilter_Value_Year_1 IS NOT NULL)) OR (DATEPART(year, [o].[OrderDate]) IS NULL AND @__dateFilter_Value_Year_1 IS NULL)))", // @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o]"); @@ -3251,7 +3223,7 @@ public override async Task Query_expression_with_to_string_and_contains(bool isA AssertSql( @"SELECT [o].[CustomerID] FROM [Orders] AS [o] -WHERE [o].[OrderDate] IS NOT NULL AND (CHARINDEX(N'10', CONVERT(VARCHAR(10), [o].[EmployeeID])) > 0)"); +WHERE [o].[OrderDate] IS NOT NULL AND ((N'10' = N'') OR (CHARINDEX(N'10', CONVERT(VARCHAR(10), [o].[EmployeeID])) > 0))"); } public override async Task Select_expression_long_to_string(bool isAsync) @@ -3259,7 +3231,7 @@ public override async Task Select_expression_long_to_string(bool isAsync) await base.Select_expression_long_to_string(isAsync); AssertSql( - @"SELECT CONVERT(VARCHAR(20), [o].[OrderID]) AS [ShipName] + @"SELECT CONVERT(VARCHAR(20), CAST([o].[OrderID] AS bigint)) AS [ShipName] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3303,7 +3275,7 @@ public override async Task Select_expression_date_add_year(bool isAsync) await base.Select_expression_date_add_year(isAsync); AssertSql( - @"SELECT DATEADD(year, 1, [o].[OrderDate]) AS [OrderDate] + @"SELECT CAST(DATEADD(year, CAST(1 AS int), [o].[OrderDate]) AS datetime2) AS [OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3313,7 +3285,7 @@ public override async Task Select_expression_datetime_add_month(bool isAsync) await base.Select_expression_datetime_add_month(isAsync); AssertSql( - @"SELECT DATEADD(month, 1, [o].[OrderDate]) AS [OrderDate] + @"SELECT CAST(DATEADD(month, CAST(1 AS int), [o].[OrderDate]) AS datetime2) AS [OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3323,7 +3295,7 @@ public override async Task Select_expression_datetime_add_hour(bool isAsync) await base.Select_expression_datetime_add_hour(isAsync); AssertSql( - @"SELECT DATEADD(hour, 1.0E0, [o].[OrderDate]) AS [OrderDate] + @"SELECT CAST(DATEADD(hour, CAST(1.0E0 AS int), [o].[OrderDate]) AS datetime2) AS [OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3333,7 +3305,7 @@ public override async Task Select_expression_datetime_add_minute(bool isAsync) await base.Select_expression_datetime_add_minute(isAsync); AssertSql( - @"SELECT DATEADD(minute, 1.0E0, [o].[OrderDate]) AS [OrderDate] + @"SELECT CAST(DATEADD(minute, CAST(1.0E0 AS int), [o].[OrderDate]) AS datetime2) AS [OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3343,7 +3315,7 @@ public override async Task Select_expression_datetime_add_second(bool isAsync) await base.Select_expression_datetime_add_second(isAsync); AssertSql( - @"SELECT DATEADD(second, 1.0E0, [o].[OrderDate]) AS [OrderDate] + @"SELECT CAST(DATEADD(second, CAST(1.0E0 AS int), [o].[OrderDate]) AS datetime2) AS [OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3375,7 +3347,7 @@ public override async Task Select_expression_date_add_milliseconds_large_number_ AssertSql( @"@__millisecondsPerDay_0='86400000' -SELECT DATEADD(millisecond, DATEPART(millisecond, [o].[OrderDate]) % @__millisecondsPerDay_0, DATEADD(day, DATEPART(millisecond, [o].[OrderDate]) / @__millisecondsPerDay_0, [o].[OrderDate])) AS [OrderDate] +SELECT CAST(DATEADD(millisecond, CAST(CAST((CAST(DATEPART(millisecond, [o].[OrderDate]) AS bigint) % @__millisecondsPerDay_0) AS float) AS int), DATEADD(day, CAST(CAST((CAST(DATEPART(millisecond, [o].[OrderDate]) AS bigint) / @__millisecondsPerDay_0) AS float) AS int), [o].[OrderDate])) AS datetime2) AS [OrderDate] FROM [Orders] AS [o] WHERE [o].[OrderDate] IS NOT NULL"); } @@ -3387,13 +3359,9 @@ public override async Task Select_expression_references_are_updated_correctly_wi AssertSql( @"@__nextYear_0='2017' -SELECT [t].[c] -FROM ( - SELECT DISTINCT DATEPART(year, [o].[OrderDate]) AS [c] - FROM [Orders] AS [o] - WHERE [o].[OrderDate] IS NOT NULL -) AS [t] -WHERE [t].[c] < @__nextYear_0"); +SELECT DISTINCT DATEPART(year, [o].[OrderDate]) +FROM [Orders] AS [o] +WHERE [o].[OrderDate] IS NOT NULL AND (DATEPART(year, [o].[OrderDate]) < @__nextYear_0)"); } public override void DefaultIfEmpty_without_group_join() @@ -3495,7 +3463,7 @@ public override async Task OrderBy_skip_skip_take(bool isAsync) @__p_1='8' @__p_2='3' -SELECT [t].* +SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( 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] @@ -3516,7 +3484,7 @@ public override async Task OrderBy_skip_take_take(bool isAsync) @__p_0='5' @__p_1='8' -SELECT TOP(@__p_2) [t].* +SELECT TOP(@__p_2) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( 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] @@ -3537,22 +3505,22 @@ public override async Task OrderBy_skip_take_take_take_take(bool isAsync) @__p_2='10' @__p_1='15' -SELECT TOP(@__p_0) [t1].* +SELECT TOP(@__p_0) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT TOP(@__p_3) [t0].* + SELECT TOP(@__p_3) [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( - SELECT TOP(@__p_2) [t].* + SELECT TOP(@__p_2) [t1].[CustomerID], [t1].[Address], [t1].[City], [t1].[CompanyName], [t1].[ContactName], [t1].[ContactTitle], [t1].[Country], [t1].[Fax], [t1].[Phone], [t1].[PostalCode], [t1].[Region] FROM ( 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] ORDER BY [c].[ContactTitle], [c].[ContactName] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY - ) AS [t] - ORDER BY [t].[ContactTitle], [t].[ContactName] + ) AS [t1] + ORDER BY [t1].[ContactTitle], [t1].[ContactName] ) AS [t0] ORDER BY [t0].[ContactTitle], [t0].[ContactName] -) AS [t1] -ORDER BY [t1].[ContactTitle], [t1].[ContactName]"); +) AS [t] +ORDER BY [t].[ContactTitle], [t].[ContactName]"); } [SqlServerCondition(SqlServerCondition.SupportsOffset)] @@ -3566,19 +3534,19 @@ public override async Task OrderBy_skip_take_skip_take_skip(bool isAsync) @__p_2='2' @__p_3='8' -SELECT [t0].* +SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT [t].* + SELECT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( 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] ORDER BY [c].[ContactTitle], [c].[ContactName] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY - ) AS [t] - ORDER BY [t].[ContactTitle], [t].[ContactName] + ) AS [t0] + ORDER BY [t0].[ContactTitle], [t0].[ContactName] OFFSET @__p_2 ROWS FETCH NEXT @__p_3 ROWS ONLY -) AS [t0] -ORDER BY [t0].[ContactTitle], [t0].[ContactName] +) AS [t] +ORDER BY [t].[ContactTitle], [t].[ContactName] OFFSET @__p_0 ROWS"); } @@ -3591,7 +3559,7 @@ public override async Task OrderBy_skip_take_distinct(bool isAsync) @"@__p_0='5' @__p_1='15' -SELECT DISTINCT [t].* +SELECT DISTINCT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( 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] @@ -3608,9 +3576,9 @@ public override async Task OrderBy_coalesce_take_distinct(bool isAsync) AssertSql( @"@__p_0='15' -SELECT DISTINCT [t].* +SELECT DISTINCT [t].[ProductID], [t].[Discontinued], [t].[ProductName], [t].[SupplierID], [t].[UnitPrice], [t].[UnitsInStock] FROM ( - SELECT TOP(@__p_0) [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] + SELECT TOP(@__p_0) [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock], COALESCE([p].[UnitPrice], 0.0) AS [c] FROM [Products] AS [p] ORDER BY COALESCE([p].[UnitPrice], 0.0) ) AS [t]"); @@ -3625,9 +3593,9 @@ public override async Task OrderBy_coalesce_skip_take_distinct(bool isAsync) @"@__p_0='5' @__p_1='15' -SELECT DISTINCT [t].* +SELECT DISTINCT [t].[ProductID], [t].[Discontinued], [t].[ProductName], [t].[SupplierID], [t].[UnitPrice], [t].[UnitsInStock] FROM ( - SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] + SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock], COALESCE([p].[UnitPrice], 0.0) AS [c] FROM [Products] AS [p] ORDER BY COALESCE([p].[UnitPrice], 0.0) OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY @@ -3643,9 +3611,9 @@ public override async Task OrderBy_coalesce_skip_take_distinct_take(bool isAsync @"@__p_0='5' @__p_1='15' -SELECT DISTINCT TOP(@__p_0) [t].* +SELECT DISTINCT TOP(@__p_0) [t].[ProductID], [t].[Discontinued], [t].[ProductName], [t].[SupplierID], [t].[UnitPrice], [t].[UnitsInStock] FROM ( - SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] + SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock], COALESCE([p].[UnitPrice], 0.0) AS [c] FROM [Products] AS [p] ORDER BY COALESCE([p].[UnitPrice], 0.0) OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY @@ -3662,17 +3630,17 @@ public override async Task OrderBy_skip_take_distinct_orderby_take(bool isAsync) @__p_0='5' @__p_1='15' -SELECT TOP(@__p_2) [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] +SELECT TOP(@__p_2) [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] FROM ( - SELECT DISTINCT [t].* + SELECT DISTINCT [t0].[CustomerID], [t0].[Address], [t0].[City], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Country], [t0].[Fax], [t0].[Phone], [t0].[PostalCode], [t0].[Region] FROM ( 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] ORDER BY [c].[ContactTitle], [c].[ContactName] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY - ) AS [t] -) AS [t0] -ORDER BY [t0].[ContactTitle]"); + ) AS [t0] +) AS [t] +ORDER BY [t].[ContactTitle]"); } public override async Task No_orderby_added_for_fully_translated_manually_constructed_LOJ(bool isAsync) @@ -3680,9 +3648,9 @@ public override async Task No_orderby_added_for_fully_translated_manually_constr await base.No_orderby_added_for_fully_translated_manually_constructed_LOJ(isAsync); AssertSql( - @"SELECT [e1].[City] AS [City1], [e2].[City] AS [City2] -FROM [Employees] AS [e1] -LEFT JOIN [Employees] AS [e2] ON [e1].[EmployeeID] = [e2].[ReportsTo]"); + @"SELECT [e].[City] AS [City1], [e0].[City] AS [City2] +FROM [Employees] AS [e] +LEFT JOIN [Employees] AS [e0] ON [e].[EmployeeID] = [e0].[ReportsTo]"); } public override async Task No_orderby_added_for_client_side_GroupJoin_dependent_to_principal_LOJ(bool isAsync) @@ -3733,13 +3701,13 @@ public override async Task Contains_with_DateTime_Date(bool isAsync) await base.Contains_with_DateTime_Date(isAsync); AssertSql( - @"SELECT [e].[OrderID], [e].[CustomerID], [e].[EmployeeID], [e].[OrderDate] -FROM [Orders] AS [e] -WHERE CONVERT(date, [e].[OrderDate]) IN ('1996-07-04T00:00:00.000', '1996-07-16T00:00:00.000')", + @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Orders] AS [o] +WHERE CONVERT(date, [o].[OrderDate]) IN ('1996-07-04T00:00:00.000', '1996-07-16T00:00:00.000')", // - @"SELECT [e].[OrderID], [e].[CustomerID], [e].[EmployeeID], [e].[OrderDate] -FROM [Orders] AS [e] -WHERE CONVERT(date, [e].[OrderDate]) IN ('1996-07-04T00:00:00.000')"); + @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Orders] AS [o] +WHERE CONVERT(date, [o].[OrderDate]) IN ('1996-07-04T00:00:00.000')"); } public override async Task Contains_with_subquery_involving_join_binds_to_correct_table(bool isAsync) @@ -3750,10 +3718,10 @@ public override async Task Contains_with_subquery_involving_join_binds_to_correc @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE ([o].[OrderID] > 11000) AND [o].[OrderID] IN ( - SELECT [od].[OrderID] - FROM [Order Details] AS [od] - INNER JOIN [Products] AS [od.Product] ON [od].[ProductID] = [od.Product].[ProductID] - WHERE [od.Product].[ProductName] = N'Chai' + SELECT [o0].[OrderID] + FROM [Order Details] AS [o0] + INNER JOIN [Products] AS [p] ON [o0].[ProductID] = [p].[ProductID] + WHERE ([p].[ProductName] = N'Chai') AND [p].[ProductName] IS NOT NULL )"); } @@ -3809,12 +3777,9 @@ public override async Task Anonymous_member_distinct_where(bool isAsync) await base.Anonymous_member_distinct_where(isAsync); AssertSql( - @"SELECT [t].[CustomerID] -FROM ( - SELECT DISTINCT [c].[CustomerID] - FROM [Customers] AS [c] -) AS [t] -WHERE [t].[CustomerID] = N'ALFKI'"); + @"SELECT DISTINCT [c].[CustomerID] +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'"); } public override async Task Anonymous_member_distinct_orderby(bool isAsync) @@ -3839,8 +3804,8 @@ public override async Task Anonymous_member_distinct_result(bool isAsync) FROM ( SELECT DISTINCT [c].[CustomerID] FROM [Customers] AS [c] -) AS [t] -WHERE [t].[CustomerID] LIKE N'A%'"); + WHERE [c].[CustomerID] LIKE N'A%' +) AS [t]"); } public override async Task Anonymous_complex_distinct_where(bool isAsync) @@ -3848,12 +3813,9 @@ public override async Task Anonymous_complex_distinct_where(bool isAsync) await base.Anonymous_complex_distinct_where(isAsync); AssertSql( - @"SELECT [t].[A] -FROM ( - SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [A] - FROM [Customers] AS [c] -) AS [t] -WHERE [t].[A] = N'ALFKIBerlin'"); + @"SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [A] +FROM [Customers] AS [c] +WHERE (([c].[CustomerID] + [c].[City]) = N'ALFKIBerlin') AND [c].[CustomerID] + [c].[City] IS NOT NULL"); } public override async Task Anonymous_complex_distinct_orderby(bool isAsync) @@ -3861,12 +3823,12 @@ public override async Task Anonymous_complex_distinct_orderby(bool isAsync) await base.Anonymous_complex_distinct_orderby(isAsync); AssertSql( - @"SELECT [t].[A] + @"SELECT [t].[c] AS [A] FROM ( - SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [A] + SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [c] FROM [Customers] AS [c] ) AS [t] -ORDER BY [t].[A]"); +ORDER BY [t].[c]"); } public override async Task Anonymous_complex_distinct_result(bool isAsync) @@ -3876,10 +3838,10 @@ public override async Task Anonymous_complex_distinct_result(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM ( - SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [A] + SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [c] FROM [Customers] AS [c] -) AS [t] -WHERE [t].[A] LIKE N'A%'"); + WHERE [c].[CustomerID] + [c].[City] IS NOT NULL AND ([c].[CustomerID] + [c].[City] LIKE N'A%') +) AS [t]"); } public override async Task Anonymous_complex_orderby(bool isAsync) @@ -3889,7 +3851,7 @@ public override async Task Anonymous_complex_orderby(bool isAsync) AssertSql( @"SELECT [c].[CustomerID] + [c].[City] AS [A] FROM [Customers] AS [c] -ORDER BY [A]"); +ORDER BY [c].[CustomerID] + [c].[City]"); } public override async Task Anonymous_subquery_orderby(bool isAsync) @@ -3922,12 +3884,9 @@ public override async Task DTO_member_distinct_where(bool isAsync) await base.DTO_member_distinct_where(isAsync); AssertSql( - @"SELECT [t].[Property] -FROM ( - SELECT DISTINCT [c].[CustomerID] AS [Property] - FROM [Customers] AS [c] -) AS [t] -WHERE [t].[Property] = N'ALFKI'"); + @"SELECT DISTINCT [c].[CustomerID] AS [Property] +FROM [Customers] AS [c] +WHERE [c].[CustomerID] = N'ALFKI'"); } public override async Task DTO_member_distinct_orderby(bool isAsync) @@ -3935,12 +3894,12 @@ public override async Task DTO_member_distinct_orderby(bool isAsync) await base.DTO_member_distinct_orderby(isAsync); AssertSql( - @"SELECT [t].[Property] + @"SELECT [t].[CustomerID] AS [Property] FROM ( - SELECT DISTINCT [c].[CustomerID] AS [Property] + SELECT DISTINCT [c].[CustomerID] FROM [Customers] AS [c] ) AS [t] -ORDER BY [t].[Property]"); +ORDER BY [t].[CustomerID]"); } public override async Task DTO_member_distinct_result(bool isAsync) @@ -3950,10 +3909,10 @@ public override async Task DTO_member_distinct_result(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM ( - SELECT DISTINCT [c].[CustomerID] AS [Property] + SELECT DISTINCT [c].[CustomerID] FROM [Customers] AS [c] -) AS [t] -WHERE [t].[Property] LIKE N'A%'"); + WHERE [c].[CustomerID] LIKE N'A%' +) AS [t]"); } public override async Task DTO_complex_distinct_where(bool isAsync) @@ -3961,12 +3920,9 @@ public override async Task DTO_complex_distinct_where(bool isAsync) await base.DTO_complex_distinct_where(isAsync); AssertSql( - @"SELECT [t].[Property] -FROM ( - SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [Property] - FROM [Customers] AS [c] -) AS [t] -WHERE [t].[Property] = N'ALFKIBerlin'"); + @"SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [Property] +FROM [Customers] AS [c] +WHERE (([c].[CustomerID] + [c].[City]) = N'ALFKIBerlin') AND [c].[CustomerID] + [c].[City] IS NOT NULL"); } public override async Task DTO_complex_distinct_orderby(bool isAsync) @@ -3974,12 +3930,12 @@ public override async Task DTO_complex_distinct_orderby(bool isAsync) await base.DTO_complex_distinct_orderby(isAsync); AssertSql( - @"SELECT [t].[Property] + @"SELECT [t].[c] AS [Property] FROM ( - SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [Property] + SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [c] FROM [Customers] AS [c] ) AS [t] -ORDER BY [t].[Property]"); +ORDER BY [t].[c]"); } public override async Task DTO_complex_distinct_result(bool isAsync) @@ -3989,20 +3945,21 @@ public override async Task DTO_complex_distinct_result(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM ( - SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [Property] + SELECT DISTINCT [c].[CustomerID] + [c].[City] AS [c] FROM [Customers] AS [c] -) AS [t] -WHERE [t].[Property] LIKE N'A%'"); + WHERE [c].[CustomerID] + [c].[City] IS NOT NULL AND ([c].[CustomerID] + [c].[City] LIKE N'A%') +) AS [t]"); } public override async Task DTO_complex_orderby(bool isAsync) { await base.DTO_complex_orderby(isAsync); - AssertSql( - @"SELECT [c].[CustomerID] + [c].[City] AS [Property] -FROM [Customers] AS [c] -ORDER BY [Property]"); + // issue #15994 +// AssertSql( +// @"SELECT [c].[CustomerID] + [c].[City] AS [Property] +//FROM [Customers] AS [c] +//ORDER BY [Property]"); } public override async Task DTO_subquery_orderby(bool isAsync) @@ -4011,23 +3968,20 @@ public override async Task DTO_subquery_orderby(bool isAsync) AssertSql( @"SELECT ( - SELECT TOP(1) [o1].[OrderDate] - FROM [Orders] AS [o1] - WHERE [c].[CustomerID] = [o1].[CustomerID] - ORDER BY [o1].[OrderID] DESC -) AS [Property] + SELECT TOP(1) [o].[OrderDate] + FROM [Orders] AS [o] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL + ORDER BY [o].[OrderID] DESC) AS [Property] FROM [Customers] AS [c] WHERE ( SELECT COUNT(*) - FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] -) > 1 -ORDER BY ( - SELECT TOP(1) [o0].[OrderDate] FROM [Orders] AS [o0] - WHERE [c].[CustomerID] = [o0].[CustomerID] - ORDER BY [o0].[OrderID] DESC -)"); + WHERE ([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) > 1 +ORDER BY ( + SELECT TOP(1) [o1].[OrderDate] + FROM [Orders] AS [o1] + WHERE ([c].[CustomerID] = [o1].[CustomerID]) AND [o1].[CustomerID] IS NOT NULL + ORDER BY [o1].[OrderID] DESC)"); } public override async Task Include_with_orderby_skip_preserves_ordering(bool isAsync) @@ -4079,9 +4033,8 @@ FROM [Customers] AS [c] WHERE ( SELECT TOP(1) [o].[CustomerID] FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] - ORDER BY [o].[OrderID] DESC -) IS NULL"); + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL + ORDER BY [o].[OrderID] DESC) IS NULL"); } public override async Task Subquery_is_not_null_translated_correctly(bool isAsync) @@ -4094,9 +4047,8 @@ FROM [Customers] AS [c] WHERE ( SELECT TOP(1) [o].[CustomerID] FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] - ORDER BY [o].[OrderID] DESC -) IS NOT NULL"); + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL + ORDER BY [o].[OrderID] DESC) IS NOT NULL"); } public override async Task Select_take_average(bool isAsync) @@ -4123,7 +4075,7 @@ public override async Task Select_take_count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [c].* + SELECT TOP(@__p_0) [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] ) AS [t]"); } @@ -4137,7 +4089,7 @@ public override async Task Select_orderBy_take_count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [c].* + SELECT TOP(@__p_0) [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] ORDER BY [c].[Country] ) AS [t]"); @@ -4242,7 +4194,7 @@ public override async Task Select_skip_count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT [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] ORDER BY (SELECT 1) OFFSET @__p_0 ROWS @@ -4258,7 +4210,7 @@ public override async Task Select_orderBy_skip_count(bool isAsync) SELECT COUNT(*) FROM ( - SELECT [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] ORDER BY [c].[Country] OFFSET @__p_0 ROWS @@ -4364,7 +4316,7 @@ public override async Task Select_distinct_count(bool isAsync) AssertSql( @"SELECT COUNT(*) FROM ( - SELECT DISTINCT [c].* + SELECT DISTINCT [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] ) AS [t]"); } @@ -4422,11 +4374,11 @@ public override async Task Comparing_to_fixed_string_parameter(bool isAsync) await base.Comparing_to_fixed_string_parameter(isAsync); AssertSql( - @"@__prefix_0='A' (Size = 5) + @"@__prefix_0='A' (Size = 4000) SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE ([c].[CustomerID] LIKE @__prefix_0 + N'%' AND (LEFT([c].[CustomerID], LEN(@__prefix_0)) = @__prefix_0)) OR (@__prefix_0 = N'')"); +WHERE ((@__prefix_0 = N'') AND @__prefix_0 IS NOT NULL) OR (@__prefix_0 IS NOT NULL AND (([c].[CustomerID] LIKE [c].[CustomerID] + N'%') AND (((LEFT([c].[CustomerID], LEN(@__prefix_0)) = @__prefix_0) AND (LEFT([c].[CustomerID], LEN(@__prefix_0)) IS NOT NULL AND @__prefix_0 IS NOT NULL)) OR (LEFT([c].[CustomerID], LEN(@__prefix_0)) IS NULL AND @__prefix_0 IS NULL))))"); } public override async Task Comparing_entities_using_Equals(bool isAsync) @@ -4434,11 +4386,11 @@ public override async Task Comparing_entities_using_Equals(bool isAsync) await base.Comparing_entities_using_Equals(isAsync); AssertSql( - @"SELECT [c1].[CustomerID] AS [Id1], [c2].[CustomerID] AS [Id2] -FROM [Customers] AS [c1] -CROSS JOIN [Customers] AS [c2] -WHERE [c1].[CustomerID] LIKE N'ALFKI%' AND ([c1].[CustomerID] = [c2].[CustomerID]) -ORDER BY [Id1]"); + @"SELECT [c].[CustomerID] AS [Id1], [c0].[CustomerID] AS [Id2] +FROM [Customers] AS [c] +CROSS JOIN [Customers] AS [c0] +WHERE ([c].[CustomerID] LIKE N'ALFKI%') AND ([c].[CustomerID] = [c0].[CustomerID]) +ORDER BY [c].[CustomerID]"); } public override async Task Comparing_different_entity_types_using_Equals(bool isAsync) @@ -4449,7 +4401,7 @@ public override async Task Comparing_different_entity_types_using_Equals(bool is @"SELECT [c].[CustomerID] FROM [Customers] AS [c] CROSS JOIN [Orders] AS [o] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Comparing_entity_to_null_using_Equals(bool isAsync) @@ -4459,7 +4411,7 @@ public override async Task Comparing_entity_to_null_using_Equals(bool isAsync) AssertSql( @"SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE [c].[CustomerID] LIKE N'A%' AND [c].[CustomerID] IS NOT NULL +WHERE ([c].[CustomerID] LIKE N'A%') AND ([c].[CustomerID] IS NOT NULL OR (CAST(1 AS bit) = CAST(1 AS bit))) ORDER BY [c].[CustomerID]"); } @@ -4468,11 +4420,13 @@ public override async Task Comparing_navigations_using_Equals(bool isAsync) await base.Comparing_navigations_using_Equals(isAsync); AssertSql( - @"SELECT [o1].[OrderID] AS [Id1], [o2].[OrderID] AS [Id2] -FROM [Orders] AS [o1] -CROSS JOIN [Orders] AS [o2] -WHERE [o1].[CustomerID] LIKE N'A%' AND (([o1].[CustomerID] = [o2].[CustomerID]) OR ([o1].[CustomerID] IS NULL AND [o2].[CustomerID] IS NULL)) -ORDER BY [Id1], [Id2]"); + @"SELECT [o].[OrderID] AS [Id1], [o0].[OrderID] AS [Id2] +FROM [Orders] AS [o] +CROSS JOIN [Orders] AS [o0] +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] +LEFT JOIN [Customers] AS [c0] ON [o0].[CustomerID] = [c0].[CustomerID] +WHERE ([o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')) AND ((([c].[CustomerID] = [c0].[CustomerID]) AND ([c].[CustomerID] IS NOT NULL AND [c0].[CustomerID] IS NOT NULL)) OR ([c].[CustomerID] IS NULL AND [c0].[CustomerID] IS NULL)) +ORDER BY [o].[OrderID], [o0].[OrderID]"); } public override async Task Comparing_navigations_using_static_Equals(bool isAsync) @@ -4480,11 +4434,13 @@ public override async Task Comparing_navigations_using_static_Equals(bool isAsyn await base.Comparing_navigations_using_static_Equals(isAsync); AssertSql( - @"SELECT [o1].[OrderID] AS [Id1], [o2].[OrderID] AS [Id2] -FROM [Orders] AS [o1] -CROSS JOIN [Orders] AS [o2] -WHERE [o1].[CustomerID] LIKE N'A%' AND (([o1].[CustomerID] = [o2].[CustomerID]) OR ([o1].[CustomerID] IS NULL AND [o2].[CustomerID] IS NULL)) -ORDER BY [Id1], [Id2]"); + @"SELECT [o].[OrderID] AS [Id1], [o0].[OrderID] AS [Id2] +FROM [Orders] AS [o] +CROSS JOIN [Orders] AS [o0] +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] +LEFT JOIN [Customers] AS [c0] ON [o0].[CustomerID] = [c0].[CustomerID] +WHERE ([o].[CustomerID] IS NOT NULL AND ([o].[CustomerID] LIKE N'A%')) AND ((([c].[CustomerID] = [c0].[CustomerID]) AND ([c].[CustomerID] IS NOT NULL AND [c0].[CustomerID] IS NOT NULL)) OR ([c].[CustomerID] IS NULL AND [c0].[CustomerID] IS NULL)) +ORDER BY [o].[OrderID], [o0].[OrderID]"); } public override async Task Comparing_non_matching_entities_using_Equals(bool isAsync) @@ -4495,7 +4451,7 @@ public override async Task Comparing_non_matching_entities_using_Equals(bool isA @"SELECT [c].[CustomerID] AS [Id1], [o].[OrderID] AS [Id2] FROM [Customers] AS [c] CROSS JOIN [Orders] AS [o] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Comparing_non_matching_collection_navigations_using_Equals(bool isAsync) @@ -4506,17 +4462,18 @@ public override async Task Comparing_non_matching_collection_navigations_using_E @"SELECT [c].[CustomerID] AS [Id1], [o].[OrderID] AS [Id2] FROM [Customers] AS [c] CROSS JOIN [Orders] AS [o] -WHERE 0 = 1"); +WHERE CAST(0 AS bit) = CAST(1 AS bit)"); } public override async Task Comparing_collection_navigation_to_null(bool isAsync) { await base.Comparing_collection_navigation_to_null(isAsync); - AssertSql( - @"SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] IS NULL"); + // issue #15994 +// AssertSql( +// @"SELECT [c].[CustomerID] +//FROM [Customers] AS [c] +//WHERE [c].[CustomerID] IS NULL"); } public override async Task Comparing_collection_navigation_to_null_complex(bool isAsync) @@ -4524,12 +4481,12 @@ public override async Task Comparing_collection_navigation_to_null_complex(bool await base.Comparing_collection_navigation_to_null_complex(isAsync); AssertSql( - @"SELECT [od].[ProductID], [od].[OrderID] -FROM [Order Details] AS [od] -INNER JOIN [Orders] AS [od.Order] ON [od].[OrderID] = [od.Order].[OrderID] -LEFT JOIN [Customers] AS [od.Order.Customer] ON [od.Order].[CustomerID] = [od.Order.Customer].[CustomerID] -WHERE ([od].[OrderID] < 10250) AND [od.Order.Customer].[CustomerID] IS NOT NULL -ORDER BY [od].[OrderID], [od].[ProductID]"); + @"SELECT [o].[ProductID], [o].[OrderID] +FROM [Order Details] AS [o] +INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID] +LEFT JOIN [Customers] AS [c] ON [o0].[CustomerID] = [c].[CustomerID] +WHERE ([o].[OrderID] < 10250) AND [c].[CustomerID] IS NOT NULL +ORDER BY [o].[OrderID], [o].[ProductID]"); } public override async Task Compare_collection_navigation_with_itself(bool isAsync) @@ -4539,7 +4496,7 @@ public override async Task Compare_collection_navigation_with_itself(bool isAsyn AssertSql( @"SELECT [c].[CustomerID] FROM [Customers] AS [c] -WHERE [c].[CustomerID] LIKE N'A%' AND ([c].[CustomerID] = [c].[CustomerID])"); +WHERE ([c].[CustomerID] LIKE N'A%') AND ([c].[CustomerID] = [c].[CustomerID])"); } public override async Task Compare_two_collection_navigations_with_different_query_sources(bool isAsync) @@ -4547,10 +4504,10 @@ public override async Task Compare_two_collection_navigations_with_different_que await base.Compare_two_collection_navigations_with_different_query_sources(isAsync); AssertSql( - @"SELECT [c1].[CustomerID] AS [Id1], [c2].[CustomerID] AS [Id2] -FROM [Customers] AS [c1] -CROSS JOIN [Customers] AS [c2] -WHERE (([c1].[CustomerID] = N'ALFKI') AND ([c2].[CustomerID] = N'ALFKI')) AND ([c1].[CustomerID] = [c2].[CustomerID])"); + @"SELECT [c].[CustomerID] AS [Id1], [c0].[CustomerID] AS [Id2] +FROM [Customers] AS [c] +CROSS JOIN [Customers] AS [c0] +WHERE (([c].[CustomerID] = N'ALFKI') AND ([c0].[CustomerID] = N'ALFKI')) AND ([c].[CustomerID] = [c0].[CustomerID])"); } public override async Task Compare_two_collection_navigations_using_equals(bool isAsync) @@ -4568,13 +4525,14 @@ public override async Task Compare_two_collection_navigations_with_different_pro { await base.Compare_two_collection_navigations_with_different_property_chains(isAsync); - 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]"); + // 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]"); } public override async Task OrderBy_ThenBy_same_column_different_direction(bool isAsync) @@ -4629,12 +4587,10 @@ public override async Task Complex_nested_query_properly_binds_to_grandparent_wh @"SELECT [c].[CustomerID], ( SELECT COUNT(*) FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND (( + WHERE (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AND (( SELECT COUNT(*) FROM [Orders] AS [o0] - WHERE [c].[CustomerID] = [o0].[CustomerID] - ) > 0) -) AS [OuterOrders] + WHERE ([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL) > 0)) AS [OuterOrders] FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI'"); } @@ -4649,7 +4605,7 @@ public override async Task OrderBy_Dto_projection_skip_take(bool isAsync) SELECT [c].[CustomerID] AS [Id] FROM [Customers] AS [c] -ORDER BY [Id] +ORDER BY [c].[CustomerID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY"); } @@ -4686,15 +4642,15 @@ public override async Task Join_take_count_works(bool isAsync) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].* + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] INNER JOIN ( - SELECT [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] WHERE [c].[CustomerID] = N'ALFKI' ) AS [t] ON [o].[CustomerID] = [t].[CustomerID] WHERE ([o].[OrderID] > 690) AND ([o].[OrderID] < 710) -) AS [t0]"); +) AS [t]"); } public override async Task OrderBy_empty_list_contains(bool isAsync) @@ -4720,12 +4676,9 @@ public override void Manual_expression_tree_typed_null_equality() base.Manual_expression_tree_typed_null_equality(); AssertSql( - @"SELECT CASE - WHEN [o.Customer].[CustomerID] IS NULL - THEN [o.Customer].[City] ELSE NULL -END + @"SELECT [c].[City] FROM [Orders] AS [o] -LEFT JOIN [Customers] AS [o.Customer] ON [o].[CustomerID] = [o.Customer].[CustomerID] +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] WHERE [o].[OrderID] < 10300"); } @@ -4736,14 +4689,13 @@ public override async Task Let_subquery_with_multiple_occurences(bool isAsync) AssertSql( @"SELECT ( SELECT COUNT(*) - FROM [Order Details] AS [od0] - WHERE ([o].[OrderID] = [od0].[OrderID]) AND ([od0].[Quantity] < CAST(10 AS smallint)) -) AS [Count] -FROM [Orders] AS [o] + FROM [Order Details] AS [o] + WHERE ([o0].[OrderID] = [o].[OrderID]) AND ([o].[Quantity] < CAST(10 AS smallint))) AS [Count] +FROM [Orders] AS [o0] WHERE EXISTS ( SELECT 1 - FROM [Order Details] AS [od] - WHERE ([o].[OrderID] = [od].[OrderID]) AND ([od].[Quantity] < CAST(10 AS smallint)))"); + FROM [Order Details] AS [o1] + WHERE ([o0].[OrderID] = [o1].[OrderID]) AND ([o1].[Quantity] < CAST(10 AS smallint)))"); } public override async Task Let_entity_equality_to_null(bool isAsync) @@ -4752,41 +4704,16 @@ public override async Task Let_entity_equality_to_null(bool isAsync) AssertSql( @"SELECT [c].[CustomerID], ( - SELECT TOP(1) [o0].[OrderDate] - FROM [Orders] AS [o0] - WHERE [c].[CustomerID] = [o0].[CustomerID] - ORDER BY [o0].[OrderDate] -) AS [OrderDate] + SELECT TOP(1) [o].[OrderDate] + FROM [Orders] AS [o] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL + ORDER BY [o].[OrderDate]) AS [OrderDate] FROM [Customers] AS [c] -WHERE [c].[CustomerID] LIKE N'A%'", - // - @"@_outer_CustomerID='ALFKI' (Size = 5) - -SELECT TOP(1) [e].[OrderID], [e].[CustomerID], [e].[EmployeeID], [e].[OrderDate] -FROM [Orders] AS [e] -WHERE @_outer_CustomerID = [e].[CustomerID] -ORDER BY [e].[OrderDate]", - // - @"@_outer_CustomerID='ANATR' (Size = 5) - -SELECT TOP(1) [e].[OrderID], [e].[CustomerID], [e].[EmployeeID], [e].[OrderDate] -FROM [Orders] AS [e] -WHERE @_outer_CustomerID = [e].[CustomerID] -ORDER BY [e].[OrderDate]", - // - @"@_outer_CustomerID='ANTON' (Size = 5) - -SELECT TOP(1) [e].[OrderID], [e].[CustomerID], [e].[EmployeeID], [e].[OrderDate] -FROM [Orders] AS [e] -WHERE @_outer_CustomerID = [e].[CustomerID] -ORDER BY [e].[OrderDate]", - // - @"@_outer_CustomerID='AROUT' (Size = 5) - -SELECT TOP(1) [e].[OrderID], [e].[CustomerID], [e].[EmployeeID], [e].[OrderDate] -FROM [Orders] AS [e] -WHERE @_outer_CustomerID = [e].[CustomerID] -ORDER BY [e].[OrderDate]"); +WHERE ([c].[CustomerID] LIKE N'A%') AND ( + SELECT TOP(1) [o0].[OrderID] + FROM [Orders] AS [o0] + WHERE ([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL + ORDER BY [o0].[OrderDate]) IS NOT NULL"); } public override async Task Let_entity_equality_to_other_entity(bool isAsync) @@ -4890,9 +4817,8 @@ FROM [Customers] AS [c] WHERE ( SELECT TOP(1) [o].[OrderID] FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] - ORDER BY [o].[OrderID] -) IS NULL"); + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL + ORDER BY [o].[OrderID]) IS NULL"); } public override async Task Dependent_to_principal_navigation_equal_to_null_for_subquery(bool isAsync) @@ -4915,20 +4841,21 @@ public override async Task Collection_navigation_equality_rewrite_for_subquery(b { await base.Collection_navigation_equality_rewrite_for_subquery(isAsync); - 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] -))"); + // 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] +//))"); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs index 5234a983c50..917c60028c4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs @@ -42,26 +42,28 @@ public override async Task Area(bool isAsync) await base.Area(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STArea() AS [Area] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STArea() AS [Area] +FROM [PolygonEntity] AS [p]"); } public override async Task AsBinary(bool isAsync) { await base.AsBinary(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] +//FROM [PointEntity] AS [e]"); } public override async Task AsText(bool isAsync) { await base.AsText(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] +//FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -74,9 +76,10 @@ public override async Task Buffer(bool isAsync) { await base.Buffer(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] -FROM [PolygonEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] +//FROM [PolygonEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -95,20 +98,22 @@ public override async Task Contains(bool isAsync) { await base.Contains(isAsync); - AssertSql( - @"@__point_0='0xE6100000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Binary) + // issue #15994 +// 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); - AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] -FROM [PolygonEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] +//FROM [PolygonEntity] AS [e]"); } public override async Task IGeometryCollection_Count(bool isAsync) @@ -116,8 +121,8 @@ public override async Task IGeometryCollection_Count(bool isAsync) await base.IGeometryCollection_Count(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STNumGeometries() AS [Count] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STNumGeometries() AS [Count] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task LineString_Count(bool isAsync) @@ -125,8 +130,8 @@ public override async Task LineString_Count(bool isAsync) await base.LineString_Count(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STNumPoints() AS [Count] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STNumPoints() AS [Count] +FROM [LineStringEntity] AS [l]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -151,11 +156,12 @@ public override async Task Difference(bool isAsync) { await base.Difference(isAsync); - AssertSql( - @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// 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) @@ -163,52 +169,56 @@ public override async Task Dimension(bool isAsync) await base.Dimension(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STDimension() AS [Dimension] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STDimension() AS [Dimension] +FROM [PointEntity] AS [p]"); } public override async Task Disjoint(bool isAsync) { await base.Disjoint(isAsync); - AssertSql( - @"@__point_0='0xE6100000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Binary) + // issue #15994 +// 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); - AssertSql( - @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // issue #15994 +// 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); - AssertSql( - @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // issue #15994 +// 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]"); } public override async Task Distance_concrete(bool isAsync) { await base.Distance_concrete(isAsync); - AssertSql( - @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) -SELECT [e].[Id], [e].[ConcretePoint].STDistance(@__point_0) AS [Distance] -FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], [e].[ConcretePoint].STDistance(@__point_0) AS [Distance] +//FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "Mixing SRIDs not supported")] @@ -221,9 +231,10 @@ public override async Task Distance_constant_srid_4326(bool isAsync) { await base.Distance_constant_srid_4326(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STDistance('POINT (1 1)') AS [Distance] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STDistance('POINT (1 1)') AS [Distance] +//FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "Mixing SRIDs not supported")] @@ -239,8 +250,8 @@ public override async Task Distance_on_converted_geometry_type(bool isAsync) AssertSql( @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Nullable = false) (Size = 22) (DbType = Binary) -SELECT [e].[Id], [e].[Location].STDistance(@__point_0) AS [Distance] -FROM [GeoPointEntity] AS [e]"); +SELECT [g].[Id], [g].[Location].STDistance(@__point_0) AS [Distance] +FROM [GeoPointEntity] AS [g]"); } [ConditionalTheory(Skip = "Mixing SRIDs not supported")] @@ -260,8 +271,8 @@ public override async Task EndPoint(bool isAsync) await base.EndPoint(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STEndPoint() AS [EndPoint] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STEndPoint() AS [EndPoint] +FROM [LineStringEntity] AS [l]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -274,11 +285,12 @@ public override async Task EqualsTopologically(bool isAsync) { await base.EqualsTopologically(isAsync); - AssertSql( - @"@__point_0='0xE6100000010C00000000000000000000000000000000' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0xE6100000010C00000000000000000000000000000000' (Size = 22) (DbType = Binary) -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) @@ -286,8 +298,8 @@ public override async Task ExteriorRing(bool isAsync) await base.ExteriorRing(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].RingN(1) AS [ExteriorRing] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].RingN(1) AS [ExteriorRing] +FROM [PolygonEntity] AS [p]"); } public override async Task GeometryType(bool isAsync) @@ -295,17 +307,18 @@ public override async Task GeometryType(bool isAsync) await base.GeometryType(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STGeometryType() AS [GeometryType] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STGeometryType() AS [GeometryType] +FROM [PointEntity] AS [p]"); } public override async Task GetGeometryN(bool isAsync) { await base.GetGeometryN(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] -FROM [MultiLineStringEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] +//FROM [MultiLineStringEntity] AS [e]"); } public override async Task GetInteriorRingN(bool isAsync) @@ -313,20 +326,21 @@ public override async Task GetInteriorRingN(bool isAsync) await base.GetInteriorRingN(isAsync); AssertSql( - @"SELECT [e].[Id], CASE - WHEN [e].[Polygon] IS NULL OR (([e].[Polygon].NumRings() - 1) = 0) - THEN NULL ELSE [e].[Polygon].RingN(0 + 2) + @"SELECT [p].[Id], CASE + WHEN [p].[Polygon] IS NULL OR ((([p].[Polygon].NumRings() - 1) = 0) AND [p].[Polygon].NumRings() - 1 IS NOT NULL) THEN NULL + ELSE [p].[Polygon].RingN(0 + 2) END AS [InteriorRing0] -FROM [PolygonEntity] AS [e]"); +FROM [PolygonEntity] AS [p]"); } public override async Task GetPointN(bool isAsync) { await base.GetPointN(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] -FROM [LineStringEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] +//FROM [LineStringEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -339,22 +353,24 @@ public override async Task Intersection(bool isAsync) { await base.Intersection(isAsync); - AssertSql( - @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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); - AssertSql( - @"@__lineString_0='0xE61000000114000000000000E0BF000000000000E03F000000000000E03F0000...' (Size = 38) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__lineString_0='0xE61000000114000000000000E0BF000000000000E03F000000000000E03F0000...' (Size = 38) (DbType = Binary) -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) @@ -362,8 +378,8 @@ public override async Task ICurve_IsClosed(bool isAsync) await base.ICurve_IsClosed(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STIsClosed() AS [IsClosed] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STIsClosed() AS [IsClosed] +FROM [LineStringEntity] AS [l]"); } public override async Task IMultiCurve_IsClosed(bool isAsync) @@ -371,8 +387,8 @@ public override async Task IMultiCurve_IsClosed(bool isAsync) await base.IMultiCurve_IsClosed(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STIsClosed() AS [IsClosed] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STIsClosed() AS [IsClosed] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task IsEmpty(bool isAsync) @@ -380,8 +396,8 @@ public override async Task IsEmpty(bool isAsync) await base.IsEmpty(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STIsEmpty() AS [IsEmpty] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STIsEmpty() AS [IsEmpty] +FROM [MultiLineStringEntity] AS [m]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -401,8 +417,8 @@ public override async Task IsValid(bool isAsync) await base.IsValid(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STIsValid() AS [IsValid] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STIsValid() AS [IsValid] +FROM [PointEntity] AS [p]"); } public override async Task IsWithinDistance(bool isAsync) @@ -412,20 +428,24 @@ public override async Task IsWithinDistance(bool isAsync) AssertSql( @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) -SELECT [e].[Id], CASE - WHEN [e].[Point].STDistance(@__point_0) <= 1.0E0 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) +SELECT [p].[Id], CASE + WHEN [p].[Point] IS NULL THEN NULL + ELSE CASE + WHEN [p].[Point].STDistance(@__point_0) <= 1.0E0 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END END AS [IsWithinDistance] -FROM [PointEntity] AS [e]"); +FROM [PointEntity] AS [p]"); } public override async Task Item(bool isAsync) { await base.Item(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] -FROM [MultiLineStringEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] +//FROM [MultiLineStringEntity] AS [e]"); } public override async Task Length(bool isAsync) @@ -433,8 +453,8 @@ public override async Task Length(bool isAsync) await base.Length(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STLength() AS [Length] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STLength() AS [Length] +FROM [LineStringEntity] AS [l]"); } public override async Task M(bool isAsync) @@ -442,8 +462,8 @@ public override async Task M(bool isAsync) await base.M(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].M AS [M] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].M AS [M] +FROM [PointEntity] AS [p]"); } public override async Task NumGeometries(bool isAsync) @@ -451,8 +471,8 @@ public override async Task NumGeometries(bool isAsync) await base.NumGeometries(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STNumGeometries() AS [NumGeometries] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STNumGeometries() AS [NumGeometries] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task NumInteriorRings(bool isAsync) @@ -460,8 +480,8 @@ public override async Task NumInteriorRings(bool isAsync) await base.NumInteriorRings(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].NumRings() - 1 AS [NumInteriorRings] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].NumRings() - 1 AS [NumInteriorRings] +FROM [PolygonEntity] AS [p]"); } public override async Task NumPoints(bool isAsync) @@ -469,8 +489,8 @@ public override async Task NumPoints(bool isAsync) await base.NumPoints(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STNumPoints() AS [NumPoints] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STNumPoints() AS [NumPoints] +FROM [LineStringEntity] AS [l]"); } public override async Task OgcGeometryType(bool isAsync) @@ -478,7 +498,7 @@ public override async Task OgcGeometryType(bool isAsync) await base.OgcGeometryType(isAsync); AssertSql( - @"SELECT [e].[Id], CASE [e].[Point].STGeometryType() + @"SELECT [p].[Id], CASE [p].[Point].STGeometryType() WHEN N'Point' THEN 1 WHEN N'LineString' THEN 2 WHEN N'Polygon' THEN 3 @@ -491,18 +511,19 @@ WHEN N'CompoundCurve' THEN 9 WHEN N'CurvePolygon' THEN 10 WHEN N'FullGlobe' THEN 126 END AS [OgcGeometryType] -FROM [PointEntity] AS [e]"); +FROM [PointEntity] AS [p]"); } public override async Task Overlaps(bool isAsync) { await base.Overlaps(isAsync); - AssertSql( - @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -528,8 +549,8 @@ public override async Task SRID(bool isAsync) await base.SRID(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STSrid AS [SRID] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STSrid AS [SRID] +FROM [PointEntity] AS [p]"); } public override async Task SRID_geometry(bool isAsync) @@ -537,8 +558,8 @@ public override async Task SRID_geometry(bool isAsync) await base.SRID_geometry(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Geometry].STSrid AS [SRID] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Geometry].STSrid AS [SRID] +FROM [PointEntity] AS [p]"); } public override async Task SRID_concrete(bool isAsync) @@ -546,8 +567,8 @@ public override async Task SRID_concrete(bool isAsync) await base.SRID_concrete(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[ConcretePoint].STSrid AS [SRID] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[ConcretePoint].STSrid AS [SRID] +FROM [PointEntity] AS [p]"); } public override async Task StartPoint(bool isAsync) @@ -555,37 +576,40 @@ public override async Task StartPoint(bool isAsync) await base.StartPoint(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STStartPoint() AS [StartPoint] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STStartPoint() AS [StartPoint] +FROM [LineStringEntity] AS [l]"); } public override async Task SymmetricDifference(bool isAsync) { await base.SymmetricDifference(isAsync); - AssertSql( - @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] +//FROM [PointEntity] AS [e]"); } public override async Task ToText(bool isAsync) { await base.ToText(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] +//FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -598,11 +622,12 @@ public override async Task Union(bool isAsync) { await base.Union(isAsync); - AssertSql( - @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -615,11 +640,12 @@ public override async Task Within(bool isAsync) { await base.Within(isAsync); - AssertSql( - @"@__polygon_0='0xE6100000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0xE6100000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Binary) -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) @@ -627,8 +653,8 @@ public override async Task X(bool isAsync) await base.X(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].Long AS [X] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].Long AS [X] +FROM [PointEntity] AS [p]"); } public override async Task Y(bool isAsync) @@ -636,8 +662,8 @@ public override async Task Y(bool isAsync) await base.Y(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].Lat AS [Y] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].Lat AS [Y] +FROM [PointEntity] AS [p]"); } public override async Task Z(bool isAsync) @@ -645,8 +671,8 @@ public override async Task Z(bool isAsync) await base.Z(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].Z AS [Z] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].Z AS [Z] +FROM [PointEntity] AS [p]"); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs index 5f2bde86803..ce04c556a6c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs @@ -43,26 +43,28 @@ public override async Task Area(bool isAsync) await base.Area(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STArea() AS [Area] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STArea() AS [Area] +FROM [PolygonEntity] AS [p]"); } public override async Task AsBinary(bool isAsync) { await base.AsBinary(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] +//FROM [PointEntity] AS [e]"); } public override async Task AsText(bool isAsync) { await base.AsText(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] +//FROM [PointEntity] AS [e]"); } public override async Task Boundary(bool isAsync) @@ -70,17 +72,18 @@ public override async Task Boundary(bool isAsync) await base.Boundary(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STBoundary() AS [Boundary] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STBoundary() AS [Boundary] +FROM [PolygonEntity] AS [p]"); } public override async Task Buffer(bool isAsync) { await base.Buffer(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] -FROM [PolygonEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] +//FROM [PolygonEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -94,28 +97,30 @@ public override async Task Centroid(bool isAsync) await base.Centroid(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STCentroid() AS [Centroid] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STCentroid() AS [Centroid] +FROM [PolygonEntity] AS [p]"); } public override async Task Contains(bool isAsync) { await base.Contains(isAsync); - AssertSql( - @"@__point_0='0x00000000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C000000000000D03F000000000000D03F' (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); - AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] -FROM [PolygonEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] +//FROM [PolygonEntity] AS [e]"); } public override async Task IGeometryCollection_Count(bool isAsync) @@ -123,8 +128,8 @@ public override async Task IGeometryCollection_Count(bool isAsync) await base.IGeometryCollection_Count(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STNumGeometries() AS [Count] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STNumGeometries() AS [Count] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task LineString_Count(bool isAsync) @@ -132,8 +137,8 @@ public override async Task LineString_Count(bool isAsync) await base.LineString_Count(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STNumPoints() AS [Count] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STNumPoints() AS [Count] +FROM [LineStringEntity] AS [l]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -152,33 +157,36 @@ public override async Task Crosses(bool isAsync) { await base.Crosses(isAsync); - AssertSql( - @"@__lineString_0='0x000000000114000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 38) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__lineString_0='0x000000000114000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 38) (DbType = Binary) -SELECT [e].[Id], [e].[LineString].STCrosses(@__lineString_0) AS [Crosses] -FROM [LineStringEntity] AS [e]"); +//SELECT [e].[Id], [e].[LineString].STCrosses(@__lineString_0) AS [Crosses] +//FROM [LineStringEntity] AS [e]"); } public override async Task Difference(bool isAsync) { await base.Difference(isAsync); - AssertSql( - @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (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 Distance_on_converted_geometry_type(bool isAsync) { await base.Distance_on_converted_geometry_type(isAsync); - AssertSql( - @"@__point_0='0x00000000010C000000000000F03F0000000000000000' (Nullable = false) (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C000000000000F03F0000000000000000' (Nullable = false) (Size = 22) (DbType = Binary) -SELECT [e].[Id], [e].[Location].STDistance(@__point_0) AS [Distance] -FROM [GeoPointEntity] AS [e]"); +//SELECT [e].[Id], [e].[Location].STDistance(@__point_0) AS [Distance] +//FROM [GeoPointEntity] AS [e]"); } public override async Task Distance_on_converted_geometry_type_constant(bool isAsync) @@ -186,8 +194,8 @@ public override async Task Distance_on_converted_geometry_type_constant(bool isA await base.Distance_on_converted_geometry_type_constant(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Location].STDistance(geometry::Parse('POINT (0 1)')) AS [Distance] -FROM [GeoPointEntity] AS [e]"); + @"SELECT [g].[Id], [g].[Location].STDistance(geometry::Parse('POINT (0 1)')) AS [Distance] +FROM [GeoPointEntity] AS [g]"); } public override async Task Distance_on_converted_geometry_type_constant_lhs(bool isAsync) @@ -195,17 +203,18 @@ public override async Task Distance_on_converted_geometry_type_constant_lhs(bool await base.Distance_on_converted_geometry_type_constant_lhs(isAsync); AssertSql( - @"SELECT [e].[Id], geometry::Parse('POINT (0 1)').STDistance([e].[Location]) AS [Distance] -FROM [GeoPointEntity] AS [e]"); + @"SELECT [g].[Id], geometry::Parse('POINT (0 1)').STDistance([g].[Location]) AS [Distance] +FROM [GeoPointEntity] AS [g]"); } public override async Task Distance_constant(bool isAsync) { await base.Distance_constant(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STDistance('POINT (0 1)') AS [Distance] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STDistance('POINT (0 1)') AS [Distance] +//FROM [PointEntity] AS [e]"); } public override async Task Distance_constant_srid_4326(bool isAsync) @@ -225,18 +234,20 @@ await AssertQuery( Assert.Null(a.Distance); }); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STDistance(geometry::STGeomFromText('POINT (1 1)', 4326)) AS [Distance] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STDistance(geometry::STGeomFromText('POINT (1 1)', 4326)) AS [Distance] +//FROM [PointEntity] AS [e]"); } public override async Task Distance_constant_lhs(bool isAsync) { await base.Distance_constant_lhs(isAsync); - AssertSql( - @"SELECT [e].[Id], geometry::Parse('POINT (0 1)').STDistance([e].[Point]) AS [Distance] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], geometry::Parse('POINT (0 1)').STDistance([e].[Point]) AS [Distance] +//FROM [PointEntity] AS [e]"); } public override async Task Dimension(bool isAsync) @@ -244,52 +255,56 @@ public override async Task Dimension(bool isAsync) await base.Dimension(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STDimension() AS [Dimension] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STDimension() AS [Dimension] +FROM [PointEntity] AS [p]"); } public override async Task Disjoint(bool isAsync) { await base.Disjoint(isAsync); - AssertSql( - @"@__point_0='0x00000000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C000000000000F03F000000000000F03F' (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); - AssertSql( - @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (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); - AssertSql( - @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (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]"); } public override async Task Distance_concrete(bool isAsync) { await base.Distance_concrete(isAsync); - AssertSql( - @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Binary) -SELECT [e].[Id], [e].[ConcretePoint].STDistance(@__point_0) AS [Distance] -FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], [e].[ConcretePoint].STDistance(@__point_0) AS [Distance] +//FROM [PointEntity] AS [e]"); } public override async Task EndPoint(bool isAsync) @@ -297,8 +312,8 @@ public override async Task EndPoint(bool isAsync) await base.EndPoint(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STEndPoint() AS [EndPoint] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STEndPoint() AS [EndPoint] +FROM [LineStringEntity] AS [l]"); } public override async Task Envelope(bool isAsync) @@ -306,19 +321,20 @@ public override async Task Envelope(bool isAsync) await base.Envelope(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STEnvelope() AS [Envelope] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STEnvelope() AS [Envelope] +FROM [PolygonEntity] AS [p]"); } public override async Task EqualsTopologically(bool isAsync) { await base.EqualsTopologically(isAsync); - AssertSql( - @"@__point_0='0x00000000010C00000000000000000000000000000000' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C00000000000000000000000000000000' (Size = 22) (DbType = Binary) -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) @@ -326,8 +342,8 @@ public override async Task ExteriorRing(bool isAsync) await base.ExteriorRing(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STExteriorRing() AS [ExteriorRing] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STExteriorRing() AS [ExteriorRing] +FROM [PolygonEntity] AS [p]"); } public override async Task GeometryType(bool isAsync) @@ -335,17 +351,18 @@ public override async Task GeometryType(bool isAsync) await base.GeometryType(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STGeometryType() AS [GeometryType] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STGeometryType() AS [GeometryType] +FROM [PointEntity] AS [p]"); } public override async Task GetGeometryN(bool isAsync) { await base.GetGeometryN(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] -FROM [MultiLineStringEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] +//FROM [MultiLineStringEntity] AS [e]"); } public override async Task GetInteriorRingN(bool isAsync) @@ -353,20 +370,21 @@ public override async Task GetInteriorRingN(bool isAsync) await base.GetInteriorRingN(isAsync); AssertSql( - @"SELECT [e].[Id], CASE - WHEN [e].[Polygon] IS NULL OR ([e].[Polygon].STNumInteriorRing() = 0) - THEN NULL ELSE [e].[Polygon].STInteriorRingN(0 + 1) + @"SELECT [p].[Id], CASE + WHEN [p].[Polygon] IS NULL OR (([p].[Polygon].STNumInteriorRing() = 0) AND [p].[Polygon].STNumInteriorRing() IS NOT NULL) THEN NULL + ELSE [p].[Polygon].STInteriorRingN(0 + 1) END AS [InteriorRing0] -FROM [PolygonEntity] AS [e]"); +FROM [PolygonEntity] AS [p]"); } public override async Task GetPointN(bool isAsync) { await base.GetPointN(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] -FROM [LineStringEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] +//FROM [LineStringEntity] AS [e]"); } public override async Task InteriorPoint(bool isAsync) @@ -374,30 +392,32 @@ public override async Task InteriorPoint(bool isAsync) await base.InteriorPoint(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STPointOnSurface() AS [InteriorPoint], [e].[Polygon] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STPointOnSurface() AS [InteriorPoint], [p].[Polygon] +FROM [PolygonEntity] AS [p]"); } public override async Task Intersection(bool isAsync) { await base.Intersection(isAsync); - AssertSql( - @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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); - AssertSql( - @"@__lineString_0='0x000000000114000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 38) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__lineString_0='0x000000000114000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 38) (DbType = Binary) -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) @@ -405,8 +425,8 @@ public override async Task ICurve_IsClosed(bool isAsync) await base.ICurve_IsClosed(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STIsClosed() AS [IsClosed] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STIsClosed() AS [IsClosed] +FROM [LineStringEntity] AS [l]"); } public override async Task IMultiCurve_IsClosed(bool isAsync) @@ -414,8 +434,8 @@ public override async Task IMultiCurve_IsClosed(bool isAsync) await base.IMultiCurve_IsClosed(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STIsClosed() AS [IsClosed] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STIsClosed() AS [IsClosed] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task IsEmpty(bool isAsync) @@ -423,8 +443,8 @@ public override async Task IsEmpty(bool isAsync) await base.IsEmpty(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STIsEmpty() AS [IsEmpty] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STIsEmpty() AS [IsEmpty] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task IsRing(bool isAsync) @@ -432,8 +452,8 @@ public override async Task IsRing(bool isAsync) await base.IsRing(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STIsRing() AS [IsRing] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STIsRing() AS [IsRing] +FROM [LineStringEntity] AS [l]"); } public override async Task IsSimple(bool isAsync) @@ -441,8 +461,8 @@ public override async Task IsSimple(bool isAsync) await base.IsSimple(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STIsSimple() AS [IsSimple] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STIsSimple() AS [IsSimple] +FROM [LineStringEntity] AS [l]"); } public override async Task IsValid(bool isAsync) @@ -450,31 +470,33 @@ public override async Task IsValid(bool isAsync) await base.IsValid(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STIsValid() AS [IsValid] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STIsValid() AS [IsValid] +FROM [PointEntity] AS [p]"); } public override async Task IsWithinDistance(bool isAsync) { await base.IsWithinDistance(isAsync); - AssertSql( - @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__point_0='0x00000000010C0000000000000000000000000000F03F' (Size = 22) (DbType = Binary) -SELECT [e].[Id], CASE - WHEN [e].[Point].STDistance(@__point_0) <= 1.0E0 - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END AS [IsWithinDistance] -FROM [PointEntity] AS [e]"); +//SELECT [e].[Id], CASE +// WHEN [e].[Point].STDistance(@__point_0) <= 1.0E0 +// THEN CAST(1 AS bit) ELSE CAST(0 AS bit) +//END AS [IsWithinDistance] +//FROM [PointEntity] AS [e]"); } public override async Task Item(bool isAsync) { await base.Item(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] -FROM [MultiLineStringEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] +//FROM [MultiLineStringEntity] AS [e]"); } public override async Task Length(bool isAsync) @@ -482,8 +504,8 @@ public override async Task Length(bool isAsync) await base.Length(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STLength() AS [Length] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STLength() AS [Length] +FROM [LineStringEntity] AS [l]"); } public override async Task M(bool isAsync) @@ -491,8 +513,8 @@ public override async Task M(bool isAsync) await base.M(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].M AS [M] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].M AS [M] +FROM [PointEntity] AS [p]"); } public override async Task NumGeometries(bool isAsync) @@ -500,8 +522,8 @@ public override async Task NumGeometries(bool isAsync) await base.NumGeometries(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[MultiLineString].STNumGeometries() AS [NumGeometries] -FROM [MultiLineStringEntity] AS [e]"); + @"SELECT [m].[Id], [m].[MultiLineString].STNumGeometries() AS [NumGeometries] +FROM [MultiLineStringEntity] AS [m]"); } public override async Task NumInteriorRings(bool isAsync) @@ -509,8 +531,8 @@ public override async Task NumInteriorRings(bool isAsync) await base.NumInteriorRings(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STNumInteriorRing() AS [NumInteriorRings] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STNumInteriorRing() AS [NumInteriorRings] +FROM [PolygonEntity] AS [p]"); } public override async Task NumPoints(bool isAsync) @@ -518,8 +540,8 @@ public override async Task NumPoints(bool isAsync) await base.NumPoints(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STNumPoints() AS [NumPoints] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STNumPoints() AS [NumPoints] +FROM [LineStringEntity] AS [l]"); } public override async Task OgcGeometryType(bool isAsync) @@ -527,7 +549,7 @@ public override async Task OgcGeometryType(bool isAsync) await base.OgcGeometryType(isAsync); AssertSql( - @"SELECT [e].[Id], CASE [e].[Point].STGeometryType() + @"SELECT [p].[Id], CASE [p].[Point].STGeometryType() WHEN N'Point' THEN 1 WHEN N'LineString' THEN 2 WHEN N'Polygon' THEN 3 @@ -539,18 +561,19 @@ WHEN N'CircularString' THEN 8 WHEN N'CompoundCurve' THEN 9 WHEN N'CurvePolygon' THEN 10 END AS [OgcGeometryType] -FROM [PointEntity] AS [e]"); +FROM [PointEntity] AS [p]"); } public override async Task Overlaps(bool isAsync) { await base.Overlaps(isAsync); - AssertSql( - @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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]"); } public override async Task PointOnSurface(bool isAsync) @@ -558,19 +581,20 @@ public override async Task PointOnSurface(bool isAsync) await base.PointOnSurface(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Polygon].STPointOnSurface() AS [PointOnSurface], [e].[Polygon] -FROM [PolygonEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Polygon].STPointOnSurface() AS [PointOnSurface], [p].[Polygon] +FROM [PolygonEntity] AS [p]"); } public override async Task Relate(bool isAsync) { await base.Relate(isAsync); - AssertSql( - @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -SELECT [e].[Id], [e].[Polygon].STRelate(@__polygon_0, N'212111212') AS [Relate] -FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STRelate(@__polygon_0, N'212111212') AS [Relate] +//FROM [PolygonEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -584,8 +608,8 @@ public override async Task SRID(bool isAsync) await base.SRID(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STSrid AS [SRID] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STSrid AS [SRID] +FROM [PointEntity] AS [p]"); } public override async Task SRID_geometry(bool isAsync) @@ -593,8 +617,8 @@ public override async Task SRID_geometry(bool isAsync) await base.SRID_geometry(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Geometry].STSrid AS [SRID] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Geometry].STSrid AS [SRID] +FROM [PointEntity] AS [p]"); } public override async Task SRID_concrete(bool isAsync) @@ -602,8 +626,8 @@ public override async Task SRID_concrete(bool isAsync) await base.SRID_concrete(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[ConcretePoint].STSrid AS [SRID] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[ConcretePoint].STSrid AS [SRID] +FROM [PointEntity] AS [p]"); } public override async Task StartPoint(bool isAsync) @@ -611,59 +635,64 @@ public override async Task StartPoint(bool isAsync) await base.StartPoint(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[LineString].STStartPoint() AS [StartPoint] -FROM [LineStringEntity] AS [e]"); + @"SELECT [l].[Id], [l].[LineString].STStartPoint() AS [StartPoint] +FROM [LineStringEntity] AS [l]"); } public override async Task SymmetricDifference(bool isAsync) { await base.SymmetricDifference(isAsync); - AssertSql( - @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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); - AssertSql( - @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] +//FROM [PointEntity] AS [e]"); } public override async Task ToText(bool isAsync) { await base.ToText(isAsync); - AssertSql( - @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] -FROM [PointEntity] AS [e]"); + // issue #15994 +// AssertSql( +// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] +//FROM [PointEntity] AS [e]"); } public override async Task Touches(bool isAsync) { await base.Touches(isAsync); - AssertSql( - @"@__polygon_0='0x000000000104040000000000000000000000000000000000F03F000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x000000000104040000000000000000000000000000000000F03F000000000000...' (Size = 96) (DbType = Binary) -SELECT [e].[Id], [e].[Polygon].STTouches(@__polygon_0) AS [Touches] -FROM [PolygonEntity] AS [e]"); +//SELECT [e].[Id], [e].[Polygon].STTouches(@__polygon_0) AS [Touches] +//FROM [PolygonEntity] AS [e]"); } public override async Task Union(bool isAsync) { await base.Union(isAsync); - AssertSql( - @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x0000000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -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]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -676,11 +705,12 @@ public override async Task Within(bool isAsync) { await base.Within(isAsync); - AssertSql( - @"@__polygon_0='0x00000000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Binary) + // issue #15994 +// AssertSql( +// @"@__polygon_0='0x00000000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Binary) -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) @@ -688,8 +718,8 @@ public override async Task X(bool isAsync) await base.X(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STX AS [X] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STX AS [X] +FROM [PointEntity] AS [p]"); } public override async Task Y(bool isAsync) @@ -697,8 +727,8 @@ public override async Task Y(bool isAsync) await base.Y(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].STY AS [Y] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].STY AS [Y] +FROM [PointEntity] AS [p]"); } public override async Task Z(bool isAsync) @@ -706,8 +736,8 @@ public override async Task Z(bool isAsync) await base.Z(isAsync); AssertSql( - @"SELECT [e].[Id], [e].[Point].Z AS [Z] -FROM [PointEntity] AS [e]"); + @"SELECT [p].[Id], [p].[Point].Z AS [Z] +FROM [PointEntity] AS [p]"); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs index 6caf0fab6e5..db1fb784bfa 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs @@ -29,10 +29,7 @@ public override void Scalar_Function_Extension_Method_Static() AssertSql( @"SELECT COUNT(*) FROM [Customers] AS [c] -WHERE CASE - WHEN IsDate([c].[FirstName]) = CAST(1 AS bit) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END = CAST(0 AS bit)"); +WHERE (IsDate([c].[FirstName]) = CAST(0 AS bit)) AND IsDate([c].[FirstName]) IS NOT NULL"); } public override void Scalar_Function_With_Translator_Translates_Static() @@ -44,7 +41,7 @@ public override void Scalar_Function_With_Translator_Translates_Static() SELECT TOP(2) len([c].[LastName]) FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } @@ -88,7 +85,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Parameter_Static() SELECT TOP(2) [c].[LastName], [dbo].[CustomerOrderCount](@__customerId_0) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } public override void Scalar_Function_Anonymous_Type_Select_Nested_Static() @@ -101,7 +98,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Nested_Static() SELECT TOP(2) [c].[LastName], [dbo].[StarValue](@__starCount_1, [dbo].[CustomerOrderCount](@__customerId_0)) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } public override void Scalar_Function_Where_Correlated_Static() @@ -123,7 +120,7 @@ public override void Scalar_Function_Where_Not_Correlated_Static() SELECT TOP(2) [c].[Id] FROM [Customers] AS [c] -WHERE [dbo].[GetCustomerWithMostOrdersAfterDate](@__startDate_0) = [c].[Id]"); +WHERE ([dbo].[GetCustomerWithMostOrdersAfterDate](@__startDate_0) = [c].[Id]) AND [dbo].[GetCustomerWithMostOrdersAfterDate](@__startDate_0) IS NOT NULL"); } public override void Scalar_Function_Where_Parameter_Static() @@ -135,7 +132,7 @@ public override void Scalar_Function_Where_Parameter_Static() SELECT TOP(2) [c].[Id] FROM [Customers] AS [c] -WHERE [c].[Id] = [dbo].[GetCustomerWithMostOrdersAfterDate]([dbo].[GetReportingPeriodStartDate](@__period_0))"); +WHERE ([c].[Id] = [dbo].[GetCustomerWithMostOrdersAfterDate]([dbo].[GetReportingPeriodStartDate](@__period_0))) AND [dbo].[GetCustomerWithMostOrdersAfterDate]([dbo].[GetReportingPeriodStartDate](@__period_0)) IS NOT NULL"); } public override void Scalar_Function_Where_Nested_Static() @@ -177,7 +174,7 @@ public override void Scalar_Function_Let_Not_Parameter_Static() SELECT TOP(2) [c].[LastName], [dbo].[CustomerOrderCount](@__customerId_0) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } public override void Scalar_Function_Let_Nested_Static() @@ -190,7 +187,7 @@ public override void Scalar_Function_Let_Nested_Static() SELECT TOP(2) [c].[LastName], [dbo].[StarValue](@__starCount_0, [dbo].[CustomerOrderCount](@__customerId_1)) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_1"); +WHERE ([c].[Id] = @__customerId_1) AND @__customerId_1 IS NOT NULL"); } [ConditionalFact(Skip = "Issue #14935. Cannot eval 'where (2 == AddOneStatic([c].Id))'")] @@ -375,10 +372,7 @@ public override void Scalar_Function_Extension_Method_Instance() AssertSql( @"SELECT COUNT(*) FROM [Customers] AS [c] -WHERE CASE - WHEN IsDate([c].[FirstName]) = CAST(1 AS bit) - THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END = CAST(0 AS bit)"); +WHERE (IsDate([c].[FirstName]) = CAST(0 AS bit)) AND IsDate([c].[FirstName]) IS NOT NULL"); } public override void Scalar_Function_With_Translator_Translates_Instance() @@ -390,7 +384,7 @@ public override void Scalar_Function_With_Translator_Translates_Instance() SELECT TOP(2) len([c].[LastName]) FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } public override void Scalar_Function_Constant_Parameter_Instance() @@ -433,7 +427,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Parameter_Instance() SELECT TOP(2) [c].[LastName], [dbo].[CustomerOrderCount](@__customerId_0) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } public override void Scalar_Function_Anonymous_Type_Select_Nested_Instance() @@ -446,7 +440,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Nested_Instance() SELECT TOP(2) [c].[LastName], [dbo].[StarValue](@__starCount_2, [dbo].[CustomerOrderCount](@__customerId_0)) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_0"); +WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } public override void Scalar_Function_Where_Correlated_Instance() @@ -468,7 +462,7 @@ public override void Scalar_Function_Where_Not_Correlated_Instance() SELECT TOP(2) [c].[Id] FROM [Customers] AS [c] -WHERE [dbo].[GetCustomerWithMostOrdersAfterDate](@__startDate_1) = [c].[Id]"); +WHERE ([dbo].[GetCustomerWithMostOrdersAfterDate](@__startDate_1) = [c].[Id]) AND [dbo].[GetCustomerWithMostOrdersAfterDate](@__startDate_1) IS NOT NULL"); } public override void Scalar_Function_Where_Parameter_Instance() @@ -480,7 +474,7 @@ public override void Scalar_Function_Where_Parameter_Instance() SELECT TOP(2) [c].[Id] FROM [Customers] AS [c] -WHERE [c].[Id] = [dbo].[GetCustomerWithMostOrdersAfterDate]([dbo].[GetReportingPeriodStartDate](@__period_1))"); +WHERE ([c].[Id] = [dbo].[GetCustomerWithMostOrdersAfterDate]([dbo].[GetReportingPeriodStartDate](@__period_1))) AND [dbo].[GetCustomerWithMostOrdersAfterDate]([dbo].[GetReportingPeriodStartDate](@__period_1)) IS NOT NULL"); } public override void Scalar_Function_Where_Nested_Instance() @@ -522,7 +516,7 @@ public override void Scalar_Function_Let_Not_Parameter_Instance() SELECT TOP(2) [c].[LastName], [dbo].[CustomerOrderCount](@__8__locals1_customerId_1) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__8__locals1_customerId_1"); +WHERE ([c].[Id] = @__8__locals1_customerId_1) AND @__8__locals1_customerId_1 IS NOT NULL"); } public override void Scalar_Function_Let_Nested_Instance() @@ -535,7 +529,7 @@ public override void Scalar_Function_Let_Nested_Instance() SELECT TOP(2) [c].[LastName], [dbo].[StarValue](@__starCount_1, [dbo].[CustomerOrderCount](@__customerId_2)) AS [OrderCount] FROM [Customers] AS [c] -WHERE [c].[Id] = @__customerId_2"); +WHERE ([c].[Id] = @__customerId_2) AND @__customerId_2 IS NOT NULL"); } [ConditionalFact(Skip = "Issue #14935. Cannot eval 'where (2 == __context_0.AddOneInstance([c].Id))'")] diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs index afe23eea160..b71b1aedea6 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs @@ -181,7 +181,7 @@ public override async Task Take_Skip(bool isAsync) @"@__p_0='10' (DbType = String) @__p_1='5' (DbType = String) -SELECT ""t"".* +SELECT ""t"".""CustomerID"", ""t"".""Address"", ""t"".""City"", ""t"".""CompanyName"", ""t"".""ContactName"", ""t"".""ContactTitle"", ""t"".""Country"", ""t"".""Fax"", ""t"".""Phone"", ""t"".""PostalCode"", ""t"".""Region"" FROM ( 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"" @@ -201,7 +201,7 @@ public override async Task Where_datetime_now(bool isAsync) 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 rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') <> @__myDatetime_0"); +WHERE ((rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') <> @__myDatetime_0) OR (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') IS NULL OR @__myDatetime_0 IS NULL)) AND (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') IS NOT NULL OR @__myDatetime_0 IS NOT NULL)"); } public override async Task Where_datetime_utcnow(bool isAsync) @@ -213,7 +213,7 @@ public override async Task Where_datetime_utcnow(bool isAsync) 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 rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') <> @__myDatetime_0"); +WHERE ((rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') <> @__myDatetime_0) OR (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') IS NULL OR @__myDatetime_0 IS NULL)) AND (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') IS NOT NULL OR @__myDatetime_0 IS NOT NULL)"); } public override async Task Where_datetime_today(bool isAsync) @@ -223,7 +223,7 @@ public override async Task Where_datetime_today(bool isAsync) AssertSql( @"SELECT ""e"".""EmployeeID"", ""e"".""City"", ""e"".""Country"", ""e"".""FirstName"", ""e"".""ReportsTo"", ""e"".""Title"" FROM ""Employees"" AS ""e"" -WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') = rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.')"); +WHERE ((rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') = rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.')) AND (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') IS NOT NULL AND rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') IS NOT NULL)) OR (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') IS NULL AND rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') IS NULL)"); } public override async Task Where_datetime_date_component(bool isAsync) @@ -235,7 +235,7 @@ public override async Task Where_datetime_date_component(bool isAsync) SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", 'start of day'), '0'), '.') = @__myDatetime_0"); +WHERE ((rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", 'start of day'), '0'), '.') = @__myDatetime_0) AND (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", 'start of day'), '0'), '.') IS NOT NULL AND @__myDatetime_0 IS NOT NULL)) OR (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", 'start of day'), '0'), '.') IS NULL AND @__myDatetime_0 IS NULL)"); } public override async Task Where_datetime_year_component(bool isAsync) @@ -245,7 +245,7 @@ public override async Task Where_datetime_year_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) = 1998"); +WHERE (CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) = 1998) AND CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } public override async Task Where_datetime_month_component(bool isAsync) @@ -255,7 +255,7 @@ public override async Task Where_datetime_month_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) = 4"); +WHERE (CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) = 4) AND CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } public override async Task Where_datetime_dayOfYear_component(bool isAsync) @@ -265,7 +265,7 @@ public override async Task Where_datetime_dayOfYear_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) = 68"); +WHERE (CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) = 68) AND CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } public override async Task Where_datetime_day_component(bool isAsync) @@ -275,7 +275,7 @@ public override async Task Where_datetime_day_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) = 4"); +WHERE (CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) = 4) AND CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } public override async Task Where_datetime_hour_component(bool isAsync) @@ -285,7 +285,7 @@ public override async Task Where_datetime_hour_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) = 14"); +WHERE (CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) = 14) AND CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } public override async Task Where_datetime_minute_component(bool isAsync) @@ -295,7 +295,7 @@ public override async Task Where_datetime_minute_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) = 23"); +WHERE (CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) = 23) AND CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } public override async Task Where_datetime_second_component(bool isAsync) @@ -305,7 +305,7 @@ public override async Task Where_datetime_second_component(bool isAsync) AssertSql( @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) = 44"); +WHERE (CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) = 44) AND CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) IS NOT NULL"); } [ConditionalTheory(Skip = "Issue#15586")] @@ -326,7 +326,7 @@ public override async Task String_StartsWith_Literal(bool isAsync) 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"".""ContactName"" LIKE 'M%'"); +WHERE ""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" LIKE 'M%')"); } public override async Task String_StartsWith_Identity(bool isAsync) @@ -336,7 +336,7 @@ public override async Task String_StartsWith_Identity(bool isAsync) 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"".""ContactName"" LIKE ""c"".""ContactName"" || '%' AND (substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) = ""c"".""ContactName"")) OR (""c"".""ContactName"" = '')"); +WHERE ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL) OR (""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" IS NOT NULL AND (((""c"".""ContactName"" LIKE ""c"".""ContactName"" || '%') AND (((substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) = ""c"".""ContactName"") AND (substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) IS NOT NULL AND ""c"".""ContactName"" IS NOT NULL)) OR (substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) IS NULL AND ""c"".""ContactName"" IS NULL))) OR ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL))))"); } public override async Task String_StartsWith_Column(bool isAsync) @@ -346,7 +346,7 @@ public override async Task String_StartsWith_Column(bool isAsync) 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"".""ContactName"" LIKE ""c"".""ContactName"" || '%' AND (substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) = ""c"".""ContactName"")) OR (""c"".""ContactName"" = '')"); +WHERE ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL) OR (""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" IS NOT NULL AND (((""c"".""ContactName"" LIKE ""c"".""ContactName"" || '%') AND (((substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) = ""c"".""ContactName"") AND (substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) IS NOT NULL AND ""c"".""ContactName"" IS NOT NULL)) OR (substr(""c"".""ContactName"", 1, length(""c"".""ContactName"")) IS NULL AND ""c"".""ContactName"" IS NULL))) OR ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL))))"); } public override async Task String_StartsWith_MethodCall(bool isAsync) @@ -356,7 +356,7 @@ public override async Task String_StartsWith_MethodCall(bool isAsync) 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"".""ContactName"" LIKE 'M%'"); +WHERE ""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" LIKE 'M%')"); } public override async Task String_EndsWith_Literal(bool isAsync) @@ -366,7 +366,7 @@ public override async Task String_EndsWith_Literal(bool isAsync) 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"".""ContactName"" LIKE '%b'"); +WHERE ""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" LIKE '%b')"); } public override async Task String_EndsWith_Identity(bool isAsync) @@ -376,7 +376,7 @@ public override async Task String_EndsWith_Identity(bool isAsync) 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 (substr(""c"".""ContactName"", -length(""c"".""ContactName"")) = ""c"".""ContactName"") OR (""c"".""ContactName"" = '')"); +WHERE ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL) OR (""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" IS NOT NULL AND ((((substr(""c"".""ContactName"", -length(""c"".""ContactName"")) = ""c"".""ContactName"") AND (substr(""c"".""ContactName"", -length(""c"".""ContactName"")) IS NOT NULL AND ""c"".""ContactName"" IS NOT NULL)) OR (substr(""c"".""ContactName"", -length(""c"".""ContactName"")) IS NULL AND ""c"".""ContactName"" IS NULL)) OR ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL))))"); } public override async Task String_EndsWith_Column(bool isAsync) @@ -386,7 +386,7 @@ public override async Task String_EndsWith_Column(bool isAsync) 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 (substr(""c"".""ContactName"", -length(""c"".""ContactName"")) = ""c"".""ContactName"") OR (""c"".""ContactName"" = '')"); +WHERE ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL) OR (""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" IS NOT NULL AND ((((substr(""c"".""ContactName"", -length(""c"".""ContactName"")) = ""c"".""ContactName"") AND (substr(""c"".""ContactName"", -length(""c"".""ContactName"")) IS NOT NULL AND ""c"".""ContactName"" IS NOT NULL)) OR (substr(""c"".""ContactName"", -length(""c"".""ContactName"")) IS NULL AND ""c"".""ContactName"" IS NULL)) OR ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL))))"); } public override async Task String_EndsWith_MethodCall(bool isAsync) @@ -396,7 +396,7 @@ public override async Task String_EndsWith_MethodCall(bool isAsync) 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"".""ContactName"" LIKE '%m'"); +WHERE ""c"".""ContactName"" IS NOT NULL AND (""c"".""ContactName"" LIKE '%m')"); } public override async Task String_Contains_Literal(bool isAsync) @@ -406,7 +406,7 @@ public override async Task String_Contains_Literal(bool isAsync) 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 instr(""c"".""ContactName"", 'M') > 0"); +WHERE ('M' = '') OR (instr(""c"".""ContactName"", 'M') > 0)"); } public override async Task String_Contains_Identity(bool isAsync) @@ -416,7 +416,7 @@ public override async Task String_Contains_Identity(bool isAsync) 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 (instr(""c"".""ContactName"", ""c"".""ContactName"") > 0) OR (""c"".""ContactName"" = '')"); +WHERE ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL) OR (instr(""c"".""ContactName"", ""c"".""ContactName"") > 0)"); } public override async Task String_Contains_Column(bool isAsync) @@ -426,7 +426,7 @@ public override async Task String_Contains_Column(bool isAsync) 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 (instr(""c"".""ContactName"", ""c"".""ContactName"") > 0) OR (""c"".""ContactName"" = '')"); +WHERE ((""c"".""ContactName"" = '') AND ""c"".""ContactName"" IS NOT NULL) OR (instr(""c"".""ContactName"", ""c"".""ContactName"") > 0)"); } public override async Task String_Contains_MethodCall(bool isAsync) @@ -436,7 +436,7 @@ public override async Task String_Contains_MethodCall(bool isAsync) 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 instr(""c"".""ContactName"", 'M') > 0"); +WHERE ('M' = '') OR (instr(""c"".""ContactName"", 'M') > 0)"); } public override async Task IsNullOrWhiteSpace_in_predicate(bool isAsync) @@ -446,7 +446,7 @@ public override async Task IsNullOrWhiteSpace_in_predicate(bool isAsync) 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"".""Region"" IS NULL OR (trim(""c"".""Region"") = '')"); +WHERE ""c"".""Region"" IS NULL OR ((trim(""c"".""Region"") = '') AND trim(""c"".""Region"") IS NOT NULL)"); } public override async Task Where_string_length(bool isAsync) @@ -456,7 +456,7 @@ public override async Task Where_string_length(bool isAsync) 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 length(""c"".""City"") = 6"); +WHERE (length(""c"".""City"") = 6) AND length(""c"".""City"") IS NOT NULL"); } public override async Task Where_string_indexof(bool isAsync) @@ -486,7 +486,7 @@ public override async Task Where_string_replace(bool isAsync) 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 replace(""c"".""City"", 'Sea', 'Rea') = 'Reattle'"); +WHERE (replace(""c"".""City"", 'Sea', 'Rea') = 'Reattle') AND replace(""c"".""City"", 'Sea', 'Rea') IS NOT NULL"); } public override async Task Replace_with_emptystring(bool isAsync) @@ -506,7 +506,7 @@ public override async Task Where_string_substring(bool isAsync) 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 substr(""c"".""City"", 2, 2) = 'ea'"); +WHERE (substr(""c"".""City"", 1 + 1, 2) = 'ea') AND substr(""c"".""City"", 1 + 1, 2) IS NOT NULL"); } public override async Task Substring_with_zero_startindex(bool isAsync) @@ -514,7 +514,7 @@ public override async Task Substring_with_zero_startindex(bool isAsync) await base.Substring_with_zero_startindex(isAsync); AssertSql( - @"SELECT substr(""c"".""ContactName"", 1, 3) + @"SELECT substr(""c"".""ContactName"", 0 + 1, 3) FROM ""Customers"" AS ""c"" WHERE ""c"".""CustomerID"" = 'ALFKI'"); } @@ -524,7 +524,7 @@ public override async Task Substring_with_constant(bool isAsync) await base.Substring_with_constant(isAsync); AssertSql( - @"SELECT substr(""c"".""ContactName"", 2, 3) + @"SELECT substr(""c"".""ContactName"", 1 + 1, 3) FROM ""Customers"" AS ""c"" WHERE ""c"".""CustomerID"" = 'ALFKI'"); } @@ -546,7 +546,7 @@ public override async Task Substring_with_Index_of(bool isAsync) await base.Substring_with_Index_of(isAsync); AssertSql( - @"SELECT ""c"".""ContactName"" + @"SELECT substr(""c"".""ContactName"", (instr(""c"".""ContactName"", 'a') - 1) + 1, 3) FROM ""Customers"" AS ""c"" WHERE ""c"".""CustomerID"" = 'ALFKI'"); } @@ -556,7 +556,7 @@ public override async Task Substring_with_zero_length(bool isAsync) await base.Substring_with_zero_length(isAsync); AssertSql( - @"SELECT substr(""c"".""ContactName"", 3, 0) + @"SELECT substr(""c"".""ContactName"", 2 + 1, 0) FROM ""Customers"" AS ""c"" WHERE ""c"".""CustomerID"" = 'ALFKI'"); } @@ -566,9 +566,9 @@ public override async Task Where_math_abs1(bool isAsync) await base.Where_math_abs1(isAsync); AssertSql( - @"SELECT ""od"".""OrderID"", ""od"".""ProductID"", ""od"".""Discount"", ""od"".""Quantity"", ""od"".""UnitPrice"" -FROM ""Order Details"" AS ""od"" -WHERE abs(""od"".""ProductID"") > 10"); + @"SELECT ""o"".""OrderID"", ""o"".""ProductID"", ""o"".""Discount"", ""o"".""Quantity"", ""o"".""UnitPrice"" +FROM ""Order Details"" AS ""o"" +WHERE abs(""o"".""ProductID"") > 10"); } public override async Task Where_math_abs2(bool isAsync) @@ -576,9 +576,9 @@ public override async Task Where_math_abs2(bool isAsync) await base.Where_math_abs2(isAsync); AssertSql( - @"SELECT ""od"".""OrderID"", ""od"".""ProductID"", ""od"".""Discount"", ""od"".""Quantity"", ""od"".""UnitPrice"" -FROM ""Order Details"" AS ""od"" -WHERE abs(""od"".""Quantity"") > 10"); + @"SELECT ""o"".""OrderID"", ""o"".""ProductID"", ""o"".""Discount"", ""o"".""Quantity"", ""o"".""UnitPrice"" +FROM ""Order Details"" AS ""o"" +WHERE abs(""o"".""Quantity"") > 10"); } public override async Task Where_math_abs_uncorrelated(bool isAsync) @@ -586,9 +586,9 @@ public override async Task Where_math_abs_uncorrelated(bool isAsync) await base.Where_math_abs_uncorrelated(isAsync); AssertSql( - @"SELECT ""od"".""OrderID"", ""od"".""ProductID"", ""od"".""Discount"", ""od"".""Quantity"", ""od"".""UnitPrice"" -FROM ""Order Details"" AS ""od"" -WHERE 10 < ""od"".""ProductID"""); + @"SELECT ""o"".""OrderID"", ""o"".""ProductID"", ""o"".""Discount"", ""o"".""Quantity"", ""o"".""UnitPrice"" +FROM ""Order Details"" AS ""o"" +WHERE 10 < ""o"".""ProductID"""); } public override async Task Select_math_round_int(bool isAsync) @@ -596,7 +596,7 @@ public override async Task Select_math_round_int(bool isAsync) await base.Select_math_round_int(isAsync); AssertSql( - @"SELECT round(""o"".""OrderID"") AS ""A"" + @"SELECT round(CAST(""o"".""OrderID"" AS REAL)) AS ""A"" FROM ""Orders"" AS ""o"" WHERE ""o"".""OrderID"" < 10250"); } @@ -606,9 +606,9 @@ public override async Task Where_math_min(bool isAsync) await base.Where_math_min(isAsync); AssertSql( - @"SELECT ""od"".""OrderID"", ""od"".""ProductID"", ""od"".""Discount"", ""od"".""Quantity"", ""od"".""UnitPrice"" -FROM ""Order Details"" AS ""od"" -WHERE (""od"".""OrderID"" = 11077) AND (min(""od"".""OrderID"", ""od"".""ProductID"") = ""od"".""ProductID"")"); + @"SELECT ""o"".""OrderID"", ""o"".""ProductID"", ""o"".""Discount"", ""o"".""Quantity"", ""o"".""UnitPrice"" +FROM ""Order Details"" AS ""o"" +WHERE (""o"".""OrderID"" = 11077) AND (min(""o"".""OrderID"", ""o"".""ProductID"") = ""o"".""ProductID"")"); } public override async Task Where_math_max(bool isAsync) @@ -616,9 +616,9 @@ public override async Task Where_math_max(bool isAsync) await base.Where_math_max(isAsync); AssertSql( - @"SELECT ""od"".""OrderID"", ""od"".""ProductID"", ""od"".""Discount"", ""od"".""Quantity"", ""od"".""UnitPrice"" -FROM ""Order Details"" AS ""od"" -WHERE (""od"".""OrderID"" = 11077) AND (max(""od"".""OrderID"", ""od"".""ProductID"") = ""od"".""OrderID"")"); + @"SELECT ""o"".""OrderID"", ""o"".""ProductID"", ""o"".""Discount"", ""o"".""Quantity"", ""o"".""UnitPrice"" +FROM ""Order Details"" AS ""o"" +WHERE (""o"".""OrderID"" = 11077) AND (max(""o"".""OrderID"", ""o"".""ProductID"") = ""o"".""OrderID"")"); } public override async Task Where_string_to_lower(bool isAsync) @@ -628,7 +628,7 @@ public override async Task Where_string_to_lower(bool isAsync) 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 lower(""c"".""CustomerID"") = 'alfki'"); +WHERE (lower(""c"".""CustomerID"") = 'alfki') AND lower(""c"".""CustomerID"") IS NOT NULL"); } public override async Task Where_string_to_upper(bool isAsync) @@ -638,7 +638,7 @@ public override async Task Where_string_to_upper(bool isAsync) 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 upper(""c"".""CustomerID"") = 'ALFKI'"); +WHERE (upper(""c"".""CustomerID"") = 'ALFKI') AND upper(""c"".""CustomerID"") IS NOT NULL"); } public override async Task TrimStart_without_arguments_in_predicate(bool isAsync) @@ -648,7 +648,7 @@ public override async Task TrimStart_without_arguments_in_predicate(bool isAsync 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 ltrim(""c"".""ContactTitle"") = 'Owner'"); +WHERE (ltrim(""c"".""ContactTitle"") = 'Owner') AND ltrim(""c"".""ContactTitle"") IS NOT NULL"); } public override async Task TrimStart_with_char_argument_in_predicate(bool isAsync) @@ -658,7 +658,7 @@ public override async Task TrimStart_with_char_argument_in_predicate(bool isAsyn 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 ltrim(""c"".""ContactTitle"", 'O') = 'wner'"); +WHERE (ltrim(""c"".""ContactTitle"", 'O') = 'wner') AND ltrim(""c"".""ContactTitle"", 'O') IS NOT NULL"); } public override async Task TrimStart_with_char_array_argument_in_predicate(bool isAsync) @@ -668,7 +668,7 @@ public override async Task TrimStart_with_char_array_argument_in_predicate(bool 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 ltrim(""c"".""ContactTitle"", 'Ow') = 'ner'"); +WHERE (ltrim(""c"".""ContactTitle"", 'Ow') = 'ner') AND ltrim(""c"".""ContactTitle"", 'Ow') IS NOT NULL"); } public override async Task TrimEnd_without_arguments_in_predicate(bool isAsync) @@ -678,7 +678,7 @@ public override async Task TrimEnd_without_arguments_in_predicate(bool isAsync) 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 rtrim(""c"".""ContactTitle"") = 'Owner'"); +WHERE (rtrim(""c"".""ContactTitle"") = 'Owner') AND rtrim(""c"".""ContactTitle"") IS NOT NULL"); } public override async Task TrimEnd_with_char_argument_in_predicate(bool isAsync) @@ -688,7 +688,7 @@ public override async Task TrimEnd_with_char_argument_in_predicate(bool isAsync) 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 rtrim(""c"".""ContactTitle"", 'r') = 'Owne'"); +WHERE (rtrim(""c"".""ContactTitle"", 'r') = 'Owne') AND rtrim(""c"".""ContactTitle"", 'r') IS NOT NULL"); } public override async Task TrimEnd_with_char_array_argument_in_predicate(bool isAsync) @@ -698,7 +698,7 @@ public override async Task TrimEnd_with_char_array_argument_in_predicate(bool is 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 rtrim(""c"".""ContactTitle"", 'er') = 'Own'"); +WHERE (rtrim(""c"".""ContactTitle"", 'er') = 'Own') AND rtrim(""c"".""ContactTitle"", 'er') IS NOT NULL"); } public override async Task Trim_without_argument_in_predicate(bool isAsync) @@ -708,7 +708,7 @@ public override async Task Trim_without_argument_in_predicate(bool isAsync) 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 trim(""c"".""ContactTitle"") = 'Owner'"); +WHERE (trim(""c"".""ContactTitle"") = 'Owner') AND trim(""c"".""ContactTitle"") IS NOT NULL"); } public override async Task Trim_with_char_argument_in_predicate(bool isAsync) @@ -718,7 +718,7 @@ public override async Task Trim_with_char_argument_in_predicate(bool isAsync) 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 trim(""c"".""ContactTitle"", 'O') = 'wner'"); +WHERE (trim(""c"".""ContactTitle"", 'O') = 'wner') AND trim(""c"".""ContactTitle"", 'O') IS NOT NULL"); } public override async Task Trim_with_char_array_argument_in_predicate(bool isAsync) @@ -728,7 +728,7 @@ public override async Task Trim_with_char_array_argument_in_predicate(bool isAsy 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 trim(""c"".""ContactTitle"", 'Or') = 'wne'"); +WHERE (trim(""c"".""ContactTitle"", 'Or') = 'wne') AND trim(""c"".""ContactTitle"", 'Or') IS NOT NULL"); } // Skip for SQLite. Issue #14935. Cannot eval 'Sum()' @@ -815,7 +815,7 @@ public override async Task Select_datetime_millisecond_component(bool isAsync) await base.Select_datetime_millisecond_component(isAsync); AssertSql( - @"SELECT (CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000) % 1000 + @"SELECT (CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0 FROM ""Orders"" AS ""o"""); } @@ -959,7 +959,7 @@ public override async Task Select_expression_date_add_milliseconds_large_number_ AssertSql( @"@__millisecondsPerDay_0='86400000' (DbType = String) -SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000) % 1000) / @__millisecondsPerDay_0 AS TEXT) || ' days', CAST((((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000) % 1000) % @__millisecondsPerDay_0) / 1000 AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" +SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(CAST((CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0) AS INTEGER) / @__millisecondsPerDay_0) AS REAL) AS TEXT) || ' days', CAST((CAST((CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0) AS INTEGER) % @__millisecondsPerDay_0) AS REAL) / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" FROM ""Orders"" AS ""o"" WHERE ""o"".""OrderDate"" IS NOT NULL"); } @@ -968,7 +968,10 @@ public override async Task Decimal_cast_to_double_works(bool isAsync) { await base.Decimal_cast_to_double_works(isAsync); - AssertSql(@" "); + AssertSql( + @"SELECT ""p"".""ProductID"", ""p"".""Discontinued"", ""p"".""ProductName"", ""p"".""SupplierID"", ""p"".""UnitPrice"", ""p"".""UnitsInStock"" +FROM ""Products"" AS ""p"" +WHERE CAST(""p"".""UnitPrice"" AS REAL) > 100.0"); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs index e370143f8db..90043986fc3 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs @@ -33,8 +33,8 @@ public override async Task Distance_on_converted_geometry_type(bool isAsync) AssertSql( @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Nullable = false) (Size = 60) (DbType = String) -SELECT ""e"".""Id"", Distance(""e"".""Location"", @__point_0) AS ""Distance"" -FROM ""GeoPointEntity"" AS ""e"""); +SELECT ""g"".""Id"", Distance(""g"".""Location"", @__point_0) AS ""Distance"" +FROM ""GeoPointEntity"" AS ""g"""); } public override async Task Distance_on_converted_geometry_type_constant(bool isAsync) @@ -42,8 +42,8 @@ public override async Task Distance_on_converted_geometry_type_constant(bool isA await base.Distance_on_converted_geometry_type_constant(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Distance(""e"".""Location"", GeomFromText('POINT (0 1)')) AS ""Distance"" -FROM ""GeoPointEntity"" AS ""e"""); + @"SELECT ""g"".""Id"", Distance(""g"".""Location"", GeomFromText('POINT (0 1)')) AS ""Distance"" +FROM ""GeoPointEntity"" AS ""g"""); } public override async Task Distance_on_converted_geometry_type_constant_lhs(bool isAsync) @@ -51,8 +51,8 @@ public override async Task Distance_on_converted_geometry_type_constant_lhs(bool await base.Distance_on_converted_geometry_type_constant_lhs(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Distance(GeomFromText('POINT (0 1)'), ""e"".""Location"") AS ""Distance"" -FROM ""GeoPointEntity"" AS ""e"""); + @"SELECT ""g"".""Id"", Distance(GeomFromText('POINT (0 1)'), ""g"".""Location"") AS ""Distance"" +FROM ""GeoPointEntity"" AS ""g"""); } public override async Task WithConversion(bool isAsync) @@ -69,26 +69,28 @@ public override async Task Area(bool isAsync) await base.Area(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Area(""e"".""Polygon"") AS ""Area"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Area(""p"".""Polygon"") AS ""Area"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task AsBinary(bool isAsync) { await base.AsBinary(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", AsBinary(""e"".""Point"") AS ""Binary"" -FROM ""PointEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", AsBinary(""e"".""Point"") AS ""Binary"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task AsText(bool isAsync) { await base.AsText(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", AsText(""e"".""Point"") AS ""Text"" -FROM ""PointEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", AsText(""e"".""Point"") AS ""Text"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Boundary(bool isAsync) @@ -96,26 +98,28 @@ public override async Task Boundary(bool isAsync) await base.Boundary(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Boundary(""e"".""Polygon"") AS ""Boundary"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Boundary(""p"".""Polygon"") AS ""Boundary"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task Buffer(bool isAsync) { await base.Buffer(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", Buffer(""e"".""Polygon"", 1.0) AS ""Buffer"" -FROM ""PolygonEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", Buffer(""e"".""Polygon"", 1.0) AS ""Buffer"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Buffer_quadrantSegments(bool isAsync) { await base.Buffer_quadrantSegments(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", Buffer(""e"".""Polygon"", 1.0, 8) AS ""Buffer"" -FROM ""PolygonEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", Buffer(""e"".""Polygon"", 1.0, 8) AS ""Buffer"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Centroid(bool isAsync) @@ -123,30 +127,32 @@ public override async Task Centroid(bool isAsync) await base.Centroid(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Centroid(""e"".""Polygon"") AS ""Centroid"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Centroid(""p"".""Polygon"") AS ""Centroid"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task Contains(bool isAsync) { await base.Contains(isAsync); - AssertSql( - @"@__point_0='0x000100000000000000000000D03F000000000000D03F000000000000D03F0000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x000100000000000000000000D03F000000000000D03F000000000000D03F0000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NOT NULL THEN Contains(""e"".""Polygon"", @__point_0) -END AS ""Contains"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NOT NULL THEN Contains(""e"".""Polygon"", @__point_0) +//END AS ""Contains"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task ConvexHull(bool isAsync) { await base.ConvexHull(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", ConvexHull(""e"".""Polygon"") AS ""ConvexHull"" -FROM ""PolygonEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", ConvexHull(""e"".""Polygon"") AS ""ConvexHull"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task IGeometryCollection_Count(bool isAsync) @@ -154,8 +160,8 @@ public override async Task IGeometryCollection_Count(bool isAsync) await base.IGeometryCollection_Count(isAsync); AssertSql( - @"SELECT ""e"".""Id"", NumGeometries(""e"".""MultiLineString"") AS ""Count"" -FROM ""MultiLineStringEntity"" AS ""e"""); + @"SELECT ""m"".""Id"", NumGeometries(""m"".""MultiLineString"") AS ""Count"" +FROM ""MultiLineStringEntity"" AS ""m"""); } public override async Task LineString_Count(bool isAsync) @@ -163,58 +169,62 @@ public override async Task LineString_Count(bool isAsync) await base.LineString_Count(isAsync); AssertSql( - @"SELECT ""e"".""Id"", NumPoints(""e"".""LineString"") AS ""Count"" -FROM ""LineStringEntity"" AS ""e"""); + @"SELECT ""l"".""Id"", NumPoints(""l"".""LineString"") AS ""Count"" +FROM ""LineStringEntity"" AS ""l"""); } public override async Task CoveredBy(bool isAsync) { await base.CoveredBy(isAsync); - AssertSql( - @"@__polygon_0='0x000100000000000000000000F0BF000000000000F0BF00000000000000400000...' (Size = 132) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x000100000000000000000000F0BF000000000000F0BF00000000000000400000...' (Size = 132) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Point"" IS NOT NULL THEN CoveredBy(""e"".""Point"", @__polygon_0) -END AS ""CoveredBy"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Point"" IS NOT NULL THEN CoveredBy(""e"".""Point"", @__polygon_0) +//END AS ""CoveredBy"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Covers(bool isAsync) { await base.Covers(isAsync); - AssertSql( - @"@__point_0='0x000100000000000000000000D03F000000000000D03F000000000000D03F0000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x000100000000000000000000D03F000000000000D03F000000000000D03F0000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NOT NULL THEN Covers(""e"".""Polygon"", @__point_0) -END AS ""Covers"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NOT NULL THEN Covers(""e"".""Polygon"", @__point_0) +//END AS ""Covers"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Crosses(bool isAsync) { await base.Crosses(isAsync); - AssertSql( - @"@__lineString_0='0x000100000000000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 80) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__lineString_0='0x000100000000000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 80) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""LineString"" IS NOT NULL THEN Crosses(""e"".""LineString"", @__lineString_0) -END AS ""Crosses"" -FROM ""LineStringEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""LineString"" IS NOT NULL THEN Crosses(""e"".""LineString"", @__lineString_0) +//END AS ""Crosses"" +//FROM ""LineStringEntity"" AS ""e"""); } public override async Task Difference(bool isAsync) { await base.Difference(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", Difference(""e"".""Polygon"", @__polygon_0) AS ""Difference"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", Difference(""e"".""Polygon"", @__polygon_0) AS ""Difference"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Dimension(bool isAsync) @@ -222,81 +232,88 @@ public override async Task Dimension(bool isAsync) await base.Dimension(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Dimension(""e"".""Point"") AS ""Dimension"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Dimension(""p"".""Point"") AS ""Dimension"" +FROM ""PointEntity"" AS ""p"""); } public override async Task Disjoint(bool isAsync) { await base.Disjoint(isAsync); - AssertSql( - @"@__point_0='0x000100000000000000000000F03F000000000000F03F000000000000F03F0000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x000100000000000000000000F03F000000000000F03F000000000000F03F0000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NOT NULL THEN Disjoint(""e"".""Polygon"", @__point_0) -END AS ""Disjoint"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NOT NULL THEN Disjoint(""e"".""Polygon"", @__point_0) +//END AS ""Disjoint"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Distance(bool isAsync) { await base.Distance(isAsync); - AssertSql( - @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", Distance(""e"".""Point"", @__point_0) AS ""Distance"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", Distance(""e"".""Point"", @__point_0) AS ""Distance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Distance_geometry(bool isAsync) { await base.Distance_geometry(isAsync); - AssertSql( - @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", Distance(""e"".""Geometry"", @__point_0) AS ""Distance"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", Distance(""e"".""Geometry"", @__point_0) AS ""Distance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Distance_concrete(bool isAsync) { await base.Distance_concrete(isAsync); - AssertSql( - @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", Distance(""e"".""ConcretePoint"", @__point_0) AS ""Distance"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", Distance(""e"".""ConcretePoint"", @__point_0) AS ""Distance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Distance_constant(bool isAsync) { await base.Distance_constant(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", Distance(""e"".""Point"", GeomFromText('POINT (0 1)')) AS ""Distance"" -FROM ""PointEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", Distance(""e"".""Point"", GeomFromText('POINT (0 1)')) AS ""Distance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Distance_constant_srid_4326(bool isAsync) { await base.Distance_constant_srid_4326(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", Distance(""e"".""Point"", GeomFromText('POINT (1 1)', 4326)) AS ""Distance"" -FROM ""PointEntity"" AS ""e"""); + // isse #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", Distance(""e"".""Point"", GeomFromText('POINT (1 1)', 4326)) AS ""Distance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Distance_constant_lhs(bool isAsync) { await base.Distance_constant_lhs(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", Distance(GeomFromText('POINT (0 1)'), ""e"".""Point"") AS ""Distance"" -FROM ""PointEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", Distance(GeomFromText('POINT (0 1)'), ""e"".""Point"") AS ""Distance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task EndPoint(bool isAsync) @@ -304,8 +321,8 @@ public override async Task EndPoint(bool isAsync) await base.EndPoint(isAsync); AssertSql( - @"SELECT ""e"".""Id"", EndPoint(""e"".""LineString"") AS ""EndPoint"" -FROM ""LineStringEntity"" AS ""e"""); + @"SELECT ""l"".""Id"", EndPoint(""l"".""LineString"") AS ""EndPoint"" +FROM ""LineStringEntity"" AS ""l"""); } public override async Task Envelope(bool isAsync) @@ -313,21 +330,22 @@ public override async Task Envelope(bool isAsync) await base.Envelope(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Envelope(""e"".""Polygon"") AS ""Envelope"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Envelope(""p"".""Polygon"") AS ""Envelope"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task EqualsTopologically(bool isAsync) { await base.EqualsTopologically(isAsync); - AssertSql( - @"@__point_0='0x0001000000000000000000000000000000000000000000000000000000000000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x0001000000000000000000000000000000000000000000000000000000000000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Point"" IS NOT NULL THEN Equals(""e"".""Point"", @__point_0) -END AS ""EqualsTopologically"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Point"" IS NOT NULL THEN Equals(""e"".""Point"", @__point_0) +//END AS ""EqualsTopologically"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task ExteriorRing(bool isAsync) @@ -335,8 +353,8 @@ public override async Task ExteriorRing(bool isAsync) await base.ExteriorRing(isAsync); AssertSql( - @"SELECT ""e"".""Id"", ExteriorRing(""e"".""Polygon"") AS ""ExteriorRing"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", ExteriorRing(""p"".""Polygon"") AS ""ExteriorRing"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task GeometryType(bool isAsync) @@ -344,7 +362,7 @@ public override async Task GeometryType(bool isAsync) await base.GeometryType(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE rtrim(GeometryType(""e"".""Point""), ' ZM') + @"SELECT ""p"".""Id"", CASE rtrim(GeometryType(""p"".""Point""), ' ZM') WHEN 'POINT' THEN 'Point' WHEN 'LINESTRING' THEN 'LineString' WHEN 'POLYGON' THEN 'Polygon' @@ -353,37 +371,40 @@ public override async Task GeometryType(bool isAsync) WHEN 'MULTIPOLYGON' THEN 'MultiPolygon' WHEN 'GEOMETRYCOLLECTION' THEN 'GeometryCollection' END AS ""GeometryType"" -FROM ""PointEntity"" AS ""e"""); +FROM ""PointEntity"" AS ""p"""); } public override async Task GetGeometryN(bool isAsync) { await base.GetGeometryN(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", GeometryN(""e"".""MultiLineString"", 0 + 1) AS ""Geometry0"" -FROM ""MultiLineStringEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", GeometryN(""e"".""MultiLineString"", 0 + 1) AS ""Geometry0"" +//FROM ""MultiLineStringEntity"" AS ""e"""); } public override async Task GetInteriorRingN(bool isAsync) { await base.GetInteriorRingN(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NULL OR (NumInteriorRing(""e"".""Polygon"") = 0) - THEN NULL ELSE InteriorRingN(""e"".""Polygon"", 0 + 1) -END AS ""InteriorRing0"" -FROM ""PolygonEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NULL OR (NumInteriorRing(""e"".""Polygon"") = 0) +// THEN NULL ELSE InteriorRingN(""e"".""Polygon"", 0 + 1) +//END AS ""InteriorRing0"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task GetPointN(bool isAsync) { await base.GetPointN(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", PointN(""e"".""LineString"", 0 + 1) AS ""Point0"" -FROM ""LineStringEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", PointN(""e"".""LineString"", 0 + 1) AS ""Point0"" +//FROM ""LineStringEntity"" AS ""e"""); } public override async Task InteriorPoint(bool isAsync) @@ -391,32 +412,34 @@ public override async Task InteriorPoint(bool isAsync) await base.InteriorPoint(isAsync); AssertSql( - @"SELECT ""e"".""Id"", PointOnSurface(""e"".""Polygon"") AS ""InteriorPoint"", ""e"".""Polygon"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", PointOnSurface(""p"".""Polygon"") AS ""InteriorPoint"", ""p"".""Polygon"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task Intersection(bool isAsync) { await base.Intersection(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", Intersection(""e"".""Polygon"", @__polygon_0) AS ""Intersection"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", Intersection(""e"".""Polygon"", @__polygon_0) AS ""Intersection"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Intersects(bool isAsync) { await base.Intersects(isAsync); - AssertSql( - @"@__lineString_0='0x000100000000000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 80) (DbType = String) + // issue 16050 +// AssertSql( +// @"@__lineString_0='0x000100000000000000000000E03F000000000000E0BF000000000000E03F0000...' (Size = 80) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""LineString"" IS NOT NULL THEN Intersects(""e"".""LineString"", @__lineString_0) -END AS ""Intersects"" -FROM ""LineStringEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""LineString"" IS NOT NULL THEN Intersects(""e"".""LineString"", @__lineString_0) +//END AS ""Intersects"" +//FROM ""LineStringEntity"" AS ""e"""); } public override async Task ICurve_IsClosed(bool isAsync) @@ -424,10 +447,10 @@ public override async Task ICurve_IsClosed(bool isAsync) await base.ICurve_IsClosed(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""LineString"" IS NOT NULL THEN IsClosed(""e"".""LineString"") + @"SELECT ""l"".""Id"", CASE + WHEN ""l"".""LineString"" IS NOT NULL THEN IsClosed(""l"".""LineString"") END AS ""IsClosed"" -FROM ""LineStringEntity"" AS ""e"""); +FROM ""LineStringEntity"" AS ""l"""); } public override async Task IMultiCurve_IsClosed(bool isAsync) @@ -435,10 +458,10 @@ public override async Task IMultiCurve_IsClosed(bool isAsync) await base.IMultiCurve_IsClosed(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""MultiLineString"" IS NOT NULL THEN IsClosed(""e"".""MultiLineString"") + @"SELECT ""m"".""Id"", CASE + WHEN ""m"".""MultiLineString"" IS NOT NULL THEN IsClosed(""m"".""MultiLineString"") END AS ""IsClosed"" -FROM ""MultiLineStringEntity"" AS ""e"""); +FROM ""MultiLineStringEntity"" AS ""m"""); } public override async Task IsEmpty(bool isAsync) @@ -446,10 +469,10 @@ public override async Task IsEmpty(bool isAsync) await base.IsEmpty(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""MultiLineString"" IS NOT NULL THEN IsEmpty(""e"".""MultiLineString"") + @"SELECT ""m"".""Id"", CASE + WHEN ""m"".""MultiLineString"" IS NOT NULL THEN IsEmpty(""m"".""MultiLineString"") END AS ""IsEmpty"" -FROM ""MultiLineStringEntity"" AS ""e"""); +FROM ""MultiLineStringEntity"" AS ""m"""); } public override async Task IsRing(bool isAsync) @@ -457,10 +480,10 @@ public override async Task IsRing(bool isAsync) await base.IsRing(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""LineString"" IS NOT NULL THEN IsRing(""e"".""LineString"") + @"SELECT ""l"".""Id"", CASE + WHEN ""l"".""LineString"" IS NOT NULL THEN IsRing(""l"".""LineString"") END AS ""IsRing"" -FROM ""LineStringEntity"" AS ""e"""); +FROM ""LineStringEntity"" AS ""l"""); } public override async Task IsSimple(bool isAsync) @@ -468,10 +491,10 @@ public override async Task IsSimple(bool isAsync) await base.IsSimple(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""LineString"" IS NOT NULL THEN IsSimple(""e"".""LineString"") + @"SELECT ""l"".""Id"", CASE + WHEN ""l"".""LineString"" IS NOT NULL THEN IsSimple(""l"".""LineString"") END AS ""IsSimple"" -FROM ""LineStringEntity"" AS ""e"""); +FROM ""LineStringEntity"" AS ""l"""); } public override async Task IsValid(bool isAsync) @@ -479,33 +502,35 @@ public override async Task IsValid(bool isAsync) await base.IsValid(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE - WHEN ""e"".""Point"" IS NOT NULL THEN IsValid(""e"".""Point"") + @"SELECT ""p"".""Id"", CASE + WHEN ""p"".""Point"" IS NOT NULL THEN IsValid(""p"".""Point"") END AS ""IsValid"" -FROM ""PointEntity"" AS ""e"""); +FROM ""PointEntity"" AS ""p"""); } public override async Task IsWithinDistance(bool isAsync) { await base.IsWithinDistance(isAsync); - AssertSql( - @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__point_0='0x0001000000000000000000000000000000000000F03F00000000000000000000...' (Size = 60) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN Distance(""e"".""Point"", @__point_0) <= 1.0 - THEN 1 ELSE 0 -END AS ""IsWithinDistance"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN Distance(""e"".""Point"", @__point_0) <= 1.0 +// THEN 1 ELSE 0 +//END AS ""IsWithinDistance"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Item(bool isAsync) { await base.Item(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", GeometryN(""e"".""MultiLineString"", 0 + 1) AS ""Item0"" -FROM ""MultiLineStringEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", GeometryN(""e"".""MultiLineString"", 0 + 1) AS ""Item0"" +//FROM ""MultiLineStringEntity"" AS ""e"""); } public override async Task Length(bool isAsync) @@ -513,8 +538,8 @@ public override async Task Length(bool isAsync) await base.Length(isAsync); AssertSql( - @"SELECT ""e"".""Id"", GLength(""e"".""LineString"") AS ""Length"" -FROM ""LineStringEntity"" AS ""e"""); + @"SELECT ""l"".""Id"", GLength(""l"".""LineString"") AS ""Length"" +FROM ""LineStringEntity"" AS ""l"""); } public override async Task M(bool isAsync) @@ -522,8 +547,8 @@ public override async Task M(bool isAsync) await base.M(isAsync); AssertSql( - @"SELECT ""e"".""Id"", M(""e"".""Point"") AS ""M"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", M(""p"".""Point"") AS ""M"" +FROM ""PointEntity"" AS ""p"""); } public override async Task NumGeometries(bool isAsync) @@ -531,8 +556,8 @@ public override async Task NumGeometries(bool isAsync) await base.NumGeometries(isAsync); AssertSql( - @"SELECT ""e"".""Id"", NumGeometries(""e"".""MultiLineString"") AS ""NumGeometries"" -FROM ""MultiLineStringEntity"" AS ""e"""); + @"SELECT ""m"".""Id"", NumGeometries(""m"".""MultiLineString"") AS ""NumGeometries"" +FROM ""MultiLineStringEntity"" AS ""m"""); } public override async Task NumInteriorRings(bool isAsync) @@ -540,8 +565,8 @@ public override async Task NumInteriorRings(bool isAsync) await base.NumInteriorRings(isAsync); AssertSql( - @"SELECT ""e"".""Id"", NumInteriorRing(""e"".""Polygon"") AS ""NumInteriorRings"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", NumInteriorRing(""p"".""Polygon"") AS ""NumInteriorRings"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task NumPoints(bool isAsync) @@ -549,8 +574,8 @@ public override async Task NumPoints(bool isAsync) await base.NumPoints(isAsync); AssertSql( - @"SELECT ""e"".""Id"", NumPoints(""e"".""LineString"") AS ""NumPoints"" -FROM ""LineStringEntity"" AS ""e"""); + @"SELECT ""l"".""Id"", NumPoints(""l"".""LineString"") AS ""NumPoints"" +FROM ""LineStringEntity"" AS ""l"""); } public override async Task OgcGeometryType(bool isAsync) @@ -558,7 +583,7 @@ public override async Task OgcGeometryType(bool isAsync) await base.OgcGeometryType(isAsync); AssertSql( - @"SELECT ""e"".""Id"", CASE rtrim(GeometryType(""e"".""Point""), ' ZM') + @"SELECT ""p"".""Id"", CASE rtrim(GeometryType(""p"".""Point""), ' ZM') WHEN 'POINT' THEN 1 WHEN 'LINESTRING' THEN 2 WHEN 'POLYGON' THEN 3 @@ -567,20 +592,21 @@ public override async Task OgcGeometryType(bool isAsync) WHEN 'MULTIPOLYGON' THEN 6 WHEN 'GEOMETRYCOLLECTION' THEN 7 END AS ""OgcGeometryType"" -FROM ""PointEntity"" AS ""e"""); +FROM ""PointEntity"" AS ""p"""); } public override async Task Overlaps(bool isAsync) { await base.Overlaps(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NOT NULL THEN Overlaps(""e"".""Polygon"", @__polygon_0) -END AS ""Overlaps"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NOT NULL THEN Overlaps(""e"".""Polygon"", @__polygon_0) +//END AS ""Overlaps"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task PointOnSurface(bool isAsync) @@ -588,30 +614,32 @@ public override async Task PointOnSurface(bool isAsync) await base.PointOnSurface(isAsync); AssertSql( - @"SELECT ""e"".""Id"", PointOnSurface(""e"".""Polygon"") AS ""PointOnSurface"", ""e"".""Polygon"" -FROM ""PolygonEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", PointOnSurface(""p"".""Polygon"") AS ""PointOnSurface"", ""p"".""Polygon"" +FROM ""PolygonEntity"" AS ""p"""); } public override async Task Relate(bool isAsync) { await base.Relate(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NOT NULL THEN Relate(""e"".""Polygon"", @__polygon_0, '212111212') -END AS ""Relate"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NOT NULL THEN Relate(""e"".""Polygon"", @__polygon_0, '212111212') +//END AS ""Relate"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Reverse(bool isAsync) { await base.Reverse(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", ST_Reverse(""e"".""LineString"") AS ""Reverse"" -FROM ""LineStringEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", ST_Reverse(""e"".""LineString"") AS ""Reverse"" +//FROM ""LineStringEntity"" AS ""e"""); } public override async Task SRID(bool isAsync) @@ -619,8 +647,8 @@ public override async Task SRID(bool isAsync) await base.SRID(isAsync); AssertSql( - @"SELECT ""e"".""Id"", SRID(""e"".""Point"") AS ""SRID"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", SRID(""p"".""Point"") AS ""SRID"" +FROM ""PointEntity"" AS ""p"""); } public override async Task SRID_geometry(bool isAsync) @@ -628,8 +656,8 @@ public override async Task SRID_geometry(bool isAsync) await base.SRID_geometry(isAsync); AssertSql( - @"SELECT ""e"".""Id"", SRID(""e"".""Geometry"") AS ""SRID"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", SRID(""p"".""Geometry"") AS ""SRID"" +FROM ""PointEntity"" AS ""p"""); } public override async Task SRID_concrete(bool isAsync) @@ -637,8 +665,8 @@ public override async Task SRID_concrete(bool isAsync) await base.SRID_concrete(isAsync); AssertSql( - @"SELECT ""e"".""Id"", SRID(""e"".""ConcretePoint"") AS ""SRID"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", SRID(""p"".""ConcretePoint"") AS ""SRID"" +FROM ""PointEntity"" AS ""p"""); } public override async Task StartPoint(bool isAsync) @@ -646,83 +674,90 @@ public override async Task StartPoint(bool isAsync) await base.StartPoint(isAsync); AssertSql( - @"SELECT ""e"".""Id"", StartPoint(""e"".""LineString"") AS ""StartPoint"" -FROM ""LineStringEntity"" AS ""e"""); + @"SELECT ""l"".""Id"", StartPoint(""l"".""LineString"") AS ""StartPoint"" +FROM ""LineStringEntity"" AS ""l"""); } public override async Task SymmetricDifference(bool isAsync) { await base.SymmetricDifference(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", SymDifference(""e"".""Polygon"", @__polygon_0) AS ""SymmetricDifference"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", SymDifference(""e"".""Polygon"", @__polygon_0) AS ""SymmetricDifference"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task ToBinary(bool isAsync) { await base.ToBinary(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", AsBinary(""e"".""Point"") AS ""Binary"" -FROM ""PointEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", AsBinary(""e"".""Point"") AS ""Binary"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task ToText(bool isAsync) { await base.ToText(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", AsText(""e"".""Point"") AS ""Text"" -FROM ""PointEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", AsText(""e"".""Point"") AS ""Text"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task Touches(bool isAsync) { await base.Touches(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Polygon"" IS NOT NULL THEN Touches(""e"".""Polygon"", @__polygon_0) -END AS ""Touches"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Polygon"" IS NOT NULL THEN Touches(""e"".""Polygon"", @__polygon_0) +//END AS ""Touches"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Union(bool isAsync) { await base.Union(isAsync); - AssertSql( - @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x00010000000000000000000000000000000000000000000000000000F03F0000...' (Size = 116) (DbType = String) -SELECT ""e"".""Id"", GUnion(""e"".""Polygon"", @__polygon_0) AS ""Union"" -FROM ""PolygonEntity"" AS ""e"""); +//SELECT ""e"".""Id"", GUnion(""e"".""Polygon"", @__polygon_0) AS ""Union"" +//FROM ""PolygonEntity"" AS ""e"""); } public override async Task Union_void(bool isAsync) { await base.Union_void(isAsync); - AssertSql( - @"SELECT ""e"".""Id"", UnaryUnion(""e"".""MultiLineString"") AS ""Union"" -FROM ""MultiLineStringEntity"" AS ""e"""); + // issue #16050 +// AssertSql( +// @"SELECT ""e"".""Id"", UnaryUnion(""e"".""MultiLineString"") AS ""Union"" +//FROM ""MultiLineStringEntity"" AS ""e"""); } public override async Task Within(bool isAsync) { await base.Within(isAsync); - AssertSql( - @"@__polygon_0='0x000100000000000000000000F0BF000000000000F0BF00000000000000400000...' (Size = 132) (DbType = String) + // issue #16050 +// AssertSql( +// @"@__polygon_0='0x000100000000000000000000F0BF000000000000F0BF00000000000000400000...' (Size = 132) (DbType = String) -SELECT ""e"".""Id"", CASE - WHEN ""e"".""Point"" IS NOT NULL THEN Within(""e"".""Point"", @__polygon_0) -END AS ""Within"" -FROM ""PointEntity"" AS ""e"""); +//SELECT ""e"".""Id"", CASE +// WHEN ""e"".""Point"" IS NOT NULL THEN Within(""e"".""Point"", @__polygon_0) +//END AS ""Within"" +//FROM ""PointEntity"" AS ""e"""); } public override async Task X(bool isAsync) @@ -730,8 +765,8 @@ public override async Task X(bool isAsync) await base.X(isAsync); AssertSql( - @"SELECT ""e"".""Id"", X(""e"".""Point"") AS ""X"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", X(""p"".""Point"") AS ""X"" +FROM ""PointEntity"" AS ""p"""); } public override async Task Y(bool isAsync) @@ -739,8 +774,8 @@ public override async Task Y(bool isAsync) await base.Y(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Y(""e"".""Point"") AS ""Y"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Y(""p"".""Point"") AS ""Y"" +FROM ""PointEntity"" AS ""p"""); } public override async Task Z(bool isAsync) @@ -748,8 +783,8 @@ public override async Task Z(bool isAsync) await base.Z(isAsync); AssertSql( - @"SELECT ""e"".""Id"", Z(""e"".""Point"") AS ""Z"" -FROM ""PointEntity"" AS ""e"""); + @"SELECT ""p"".""Id"", Z(""p"".""Point"") AS ""Z"" +FROM ""PointEntity"" AS ""p"""); } private void AssertSql(params string[] expected)