From 4a9993ecc04bff133746c6a2090e8e0a45e099aa Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Mon, 29 Jul 2024 22:03:49 +0200 Subject: [PATCH] Update baselines --- .../Query/SqlNullabilityProcessor.cs | 2 +- .../AdHocMiscellaneousQuerySqlServerTest.cs | 5 +- .../AdHocNavigationsQuerySqlServerTest.cs | 5 +- .../AdHocQueryFiltersQuerySqlServerTest.cs | 20 +- ...avigationsCollectionsQuerySqlServerTest.cs | 130 ++++-- ...CollectionsSharedTypeQuerySqlServerTest.cs | 120 ++++- ...tionsCollectionsSplitQuerySqlServerTest.cs | 215 +++++++-- .../ComplexNavigationsQuerySqlServerTest.cs | 180 +++++--- ...NavigationsSharedTypeQuerySqlServerTest.cs | 263 ++++++----- .../Query/ComplexTypeQuerySqlServerTest.cs | 10 +- .../Query/Ef6GroupBySqlServerTest.cs | 10 +- .../Query/FunkyDataQuerySqlServerTest.cs | 9 +- .../Query/GearsOfWarQuerySqlServerTest.cs | 288 +++++++++--- ...eritanceRelationshipsQuerySqlServerTest.cs | 130 ++++-- .../Query/JsonQuerySqlServerTest.cs | 170 +++++-- ...indAggregateOperatorsQuerySqlServerTest.cs | 15 +- ...NorthwindAsNoTrackingQuerySqlServerTest.cs | 5 +- ...windEFPropertyIncludeQuerySqlServerTest.cs | 5 +- .../NorthwindFunctionsQuerySqlServerTest.cs | 20 +- .../NorthwindGroupByQuerySqlServerTest.cs | 5 +- ...windIncludeNoTrackingQuerySqlServerTest.cs | 5 +- .../NorthwindIncludeQuerySqlServerTest.cs | 5 +- ...orthwindMiscellaneousQuerySqlServerTest.cs | 91 ++-- .../NorthwindNavigationsQuerySqlServerTest.cs | 30 +- .../NorthwindSelectQuerySqlServerTest.cs | 28 +- ...plitIncludeNoTrackingQuerySqlServerTest.cs | 10 +- ...NorthwindSplitIncludeQuerySqlServerTest.cs | 10 +- ...orthwindStringIncludeQuerySqlServerTest.cs | 5 +- .../Query/NorthwindWhereQuerySqlServerTest.cs | 18 +- .../Query/NullSemanticsQuerySqlServerTest.cs | 426 ++++++++++++------ .../Query/OwnedQuerySqlServerTest.cs | 20 +- .../Query/TPCGearsOfWarQuerySqlServerTest.cs | 288 +++++++++--- .../TPCRelationshipsQuerySqlServerTest.cs | 130 ++++-- .../Query/TPTGearsOfWarQuerySqlServerTest.cs | 288 +++++++++--- .../TPTRelationshipsQuerySqlServerTest.cs | 130 ++++-- ...avigationsCollectionsQuerySqlServerTest.cs | 130 ++++-- ...CollectionsSharedTypeQuerySqlServerTest.cs | 105 ++++- .../TemporalGearsOfWarQuerySqlServerTest.cs | 288 +++++++++--- .../Query/TemporalOwnedQuerySqlServerTest.cs | 20 +- .../Query/ComplexTypeQuerySqliteTest.cs | 10 +- .../Query/GearsOfWarQuerySqliteTest.cs | 291 +++++++++--- .../Query/NorthwindWhereQuerySqliteTest.cs | 5 +- .../Query/NullSemanticsQuerySqliteTest.cs | 290 +++++++++--- 43 files changed, 3201 insertions(+), 1029 deletions(-) diff --git a/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs b/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs index b27b8efa39b..6f3ac65ba28 100644 --- a/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs +++ b/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs @@ -1825,7 +1825,7 @@ private SqlExpression RewriteNullSemantics( // - a == b || (a == null) // - a == b || (b == null) // as these expressions can use indexes on a and/or on b. - if (leftNullable && rightNullable || originallyNotEqual == bodyNotEqual) + if (leftNullable && rightNullable || (optimize && originallyNotEqual == bodyNotEqual)) { // (a == b && (a != null && b != null)) || (a == null && b == null) body = _sqlExpressionFactory.OrElse( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs index b37228e5028..7bca660df3d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs @@ -2246,7 +2246,10 @@ SELECT MIN([o0].[HourlyRate]) FROM [Order] AS [o0] WHERE [o0].[CustomerId] = [o].[CustomerId]) AS [CustomerMinHourlyRate], MIN([o].[HourlyRate]) AS [HourlyRate], COUNT(*) AS [Count] FROM [Order] AS [o] -WHERE [o].[Number] <> N'A1' OR [o].[Number] IS NULL +WHERE CASE + WHEN [o].[Number] = N'A1' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) GROUP BY [o].[CustomerId], [o].[Number] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs index b265e957cf7..02d51103238 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs @@ -368,7 +368,10 @@ FROM [Employees] AS [e] LEFT JOIN ( SELECT [d].[Id], [d].[Device], [d].[EmployeeId] FROM [Devices] AS [d] - WHERE [d].[Device] <> N'foo' OR [d].[Device] IS NULL + WHERE CASE + WHEN [d].[Device] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [d0] ON [e].[Id] = [d0].[EmployeeId] ORDER BY [e].[Id] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs index 53d5e14fbe9..7c26d4ab321 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs @@ -214,7 +214,10 @@ public override async Task Self_reference_in_query_filter_works() FROM [EntitiesWithQueryFilterSelfReference] AS [e] WHERE EXISTS ( SELECT 1 - FROM [EntitiesWithQueryFilterSelfReference] AS [e0]) AND ([e].[Name] <> N'Foo' OR [e].[Name] IS NULL) + FROM [EntitiesWithQueryFilterSelfReference] AS [e0]) AND CASE + WHEN [e].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -225,7 +228,10 @@ SELECT 1 FROM [EntitiesWithQueryFilterSelfReference] AS [e0] WHERE EXISTS ( SELECT 1 - FROM [EntitiesWithQueryFilterSelfReference] AS [e1])) AND ([e].[Name] <> N'Foo' OR [e].[Name] IS NULL) + FROM [EntitiesWithQueryFilterSelfReference] AS [e1])) AND CASE + WHEN [e].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -239,7 +245,10 @@ public override async Task Invoke_inside_query_filter_gets_correctly_evaluated_d SELECT [e].[Id], [e].[Name], [e].[TenantId] FROM [Entities] AS [e] -WHERE ([e].[Name] <> N'Foo' OR [e].[Name] IS NULL) AND [e].[TenantId] = @__ef_filter__p_0 +WHERE CASE + WHEN [e].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [e].[TenantId] = @__ef_filter__p_0 """, // """ @@ -247,7 +256,10 @@ FROM [Entities] AS [e] SELECT [e].[Id], [e].[Name], [e].[TenantId] FROM [Entities] AS [e] -WHERE ([e].[Name] <> N'Foo' OR [e].[Name] IS NULL) AND [e].[TenantId] = @__ef_filter__p_0 +WHERE CASE + WHEN [e].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [e].[TenantId] = @__ef_filter__p_0 """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs index 6ada8222c2e..fa0f878749f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs @@ -194,7 +194,10 @@ LEFT JOIN ( FROM [LevelThree] AS [l1] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] ) AS [s] ON [l0].[Id] = [s].[OneToMany_Required_Inverse3Id] -WHERE [l0].[Name] <> N'L2 09' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'L2 09' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id], [s].[Id] """); } @@ -283,7 +286,10 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l3] ON [l].[Id] = [l3].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] LEFT JOIN [LevelThree] AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] -WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id] """); } @@ -531,7 +537,10 @@ LEFT JOIN ( FROM [LevelTwo] AS [l15] WHERE [l15].[Id] <> 42 ) AS [l16] ON [s].[Id2] = [l16].[OneToMany_Optional_Self_Inverse2Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """); } @@ -602,7 +611,10 @@ FROM [LevelOne] 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] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] WHERE [l].[Id] < 3 ORDER BY [l].[Id] @@ -797,7 +809,10 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte SELECT [l].[Name] FROM [LevelOne] AS [l] GROUP BY [l].[Name] - HAVING [l].[Name] <> N'Foo' OR [l].[Name] IS NULL + HAVING CASE + WHEN [l].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] LEFT JOIN ( SELECT [l3].[Id], [l3].[Date], [l3].[Name], [l3].[OneToMany_Optional_Self_Inverse1Id], [l3].[OneToMany_Required_Self_Inverse1Id], [l3].[OneToOne_Optional_Self1Id] @@ -1164,7 +1179,10 @@ FROM [LevelTwo] AS [l2] SELECT COUNT(*) FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -1457,7 +1475,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] @@ -1479,7 +1500,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] @@ -1500,7 +1524,10 @@ LEFT JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -1509,7 +1536,10 @@ LEFT JOIN ( FROM ( SELECT [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], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Name] DESC) AS [row] FROM [LevelTwo] AS [l1] - WHERE [l1].[Name] <> N'Bar' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE 1 < [l4].[row] ) AS [l5] ON [l].[Id] = [l5].[OneToMany_Required_Inverse2Id] @@ -1530,7 +1560,10 @@ OUTER APPLY ( FROM ( SELECT TOP(3) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Name] ) AS [l2] LEFT JOIN ( @@ -1538,7 +1571,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Bar' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] ) AS [l4] ON [l2].[Id] = [l4].[OneToMany_Required_Inverse3Id] @@ -1560,7 +1596,10 @@ LEFT JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 2 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1581,7 +1620,10 @@ OUTER APPLY ( FROM ( SELECT TOP(2) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -1606,7 +1648,10 @@ OUTER APPLY ( FROM ( SELECT TOP(2) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -1629,7 +1674,10 @@ LEFT JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1650,7 +1698,10 @@ LEFT JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1671,7 +1722,10 @@ OUTER APPLY ( FROM ( SELECT TOP(1) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] @@ -1701,7 +1755,10 @@ OUTER APPLY ( FROM ( SELECT TOP(1) [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] FROM [LevelThree] AS [l1] - WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL) + WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l1].[Id] ) AS [l4] LEFT JOIN [LevelFour] AS [l2] ON [l4].[Id] = [l2].[OneToMany_Optional_Inverse4Id] @@ -1728,7 +1785,10 @@ OUTER APPLY ( FROM ( SELECT TOP(1) [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] FROM [LevelThree] AS [l1] - WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL) + WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l1].[Id] ) AS [l4] LEFT JOIN [LevelFour] AS [l2] ON [l4].[Id] = [l2].[OneToMany_Optional_Inverse4Id] @@ -1754,7 +1814,10 @@ LEFT JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> @__prm_0 OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1853,7 +1916,10 @@ LEFT JOIN ( FROM ( SELECT 1 AS [c], [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE [l3].[row] <= 1 ) AS [l4] ON [l].[Id] = [l4].[OneToMany_Optional_Inverse2Id] @@ -1903,7 +1969,10 @@ LEFT JOIN ( FROM [LevelTwo] AS [l15] WHERE [l15].[Id] <> 42 ) AS [l16] ON [s].[Id2] = [l16].[OneToMany_Optional_Self_Inverse2Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """); } @@ -2665,7 +2734,10 @@ FROM [LevelOne] AS [l] OUTER APPLY ( SELECT TOP(1) 1 AS [c], [l0].[Id] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] OUTER APPLY ( SELECT [l1].[Name], [l1].[Id] @@ -2801,7 +2873,10 @@ FROM [LevelTwo] AS [l2] SELECT COUNT(*) FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -2870,7 +2945,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs index 8e6aa9a6b77..c752d9bab9f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs @@ -39,7 +39,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Level2_Name] <> N'Foo' OR [l2].[Level2_Name] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] OUTER APPLY ( SELECT [l3].[Name], [l3].[Id] @@ -213,7 +216,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 2 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -329,7 +335,10 @@ WHERE [l10].[Level2_Required_Id] IS NOT NULL AND [l10].[OneToMany_Required_Inver ) AS [l11] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END = [l11].[OneToMany_Optional_Inverse3Id] -WHERE [l3].[Level3_Name] <> N'Foo' OR [l3].[Level3_Name] IS NULL +WHERE CASE + WHEN [l3].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l1].[Id], [l3].[Id], [l5].[Id], [l7].[Id], [l9].[Id] """); } @@ -381,7 +390,10 @@ OUTER APPLY ( FROM ( SELECT TOP(3) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Level2_Name] ) AS [l2] LEFT JOIN ( @@ -389,7 +401,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Level3_Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Level3_Name] DESC) AS [row] FROM [Level1] AS [l1] - WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l1].[Level3_Name] <> N'Bar' OR [l1].[Level3_Name] IS NULL) + WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l1].[Level3_Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] ) AS [l4] ON CASE @@ -411,7 +426,10 @@ FROM [Level1] AS [l] LEFT JOIN ( SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] WHERE [l].[Id] < 3 ORDER BY [l].[Id] @@ -457,7 +475,10 @@ LEFT JOIN ( FROM ( SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l2].[OneToMany_Optional_Inverse3Id] ORDER BY [l2].[Level3_Name]) AS [row] FROM [Level1] AS [l2] - WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL) + WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] AND [l3].[row] <= 4 ) AS [l4] ON CASE @@ -514,7 +535,10 @@ WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse ) AS [s] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END = [s].[OneToMany_Required_Inverse3Id] -WHERE [l1].[Level2_Name] <> N'L2 09' OR [l1].[Level2_Name] IS NULL +WHERE CASE + WHEN [l1].[Level2_Name] = N'L2 09' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l1].[Id], [s].[Id] """); } @@ -822,7 +846,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -984,7 +1011,10 @@ SELECT TOP(1) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END @@ -1329,7 +1359,10 @@ LEFT JOIN ( FROM ( SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l2].[OneToMany_Optional_Inverse3Id] ORDER BY [l2].[Level3_Name]) AS [row] FROM [Level1] AS [l2] - WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL) + WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] AND [l3].[row] <= 4 ) AS [l4] ON CASE @@ -1471,7 +1504,10 @@ LEFT JOIN ( FROM ( SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Level2_Name]) AS [row] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -1480,7 +1516,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Level2_Name] DESC) AS [row] FROM [Level1] AS [l1] - WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l1].[Level2_Name] <> N'Bar' OR [l1].[Level2_Name] IS NULL) + WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l1].[Level2_Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE 1 < [l4].[row] ) AS [l5] ON [l].[Id] = [l5].[OneToMany_Required_Inverse2Id] @@ -1840,7 +1879,10 @@ END IS NOT NULL AND (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l1].[OneToMany_Optional_Inverse3Id] OR (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] - END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND ([l1].[Level3_Name] <> N'Foo' OR [l1].[Level3_Name] IS NULL) + END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND CASE + WHEN [l1].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l1].[Id] END @@ -2101,7 +2143,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -2178,7 +2223,10 @@ LEFT JOIN ( FROM ( SELECT 1 AS [c], [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Required_Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE [l3].[row] <= 1 ) AS [l4] ON [l].[Id] = [l4].[OneToMany_Optional_Inverse2Id] @@ -2399,7 +2447,10 @@ SELECT TOP(2) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END @@ -2434,7 +2485,10 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte SELECT [l].[Name] FROM [Level1] AS [l] GROUP BY [l].[Name] - HAVING [l].[Name] <> N'Foo' OR [l].[Name] IS NULL + HAVING CASE + WHEN [l].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] LEFT JOIN ( SELECT [l3].[Id], [l3].[Date], [l3].[Name] @@ -2472,7 +2526,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> @__prm_0 OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -2521,7 +2578,10 @@ SELECT TOP(2) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END @@ -2818,7 +2878,10 @@ WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse ) AS [l2] ON CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l2].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL)) > 0 + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -3190,7 +3253,10 @@ END IS NOT NULL AND (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l1].[OneToMany_Optional_Inverse3Id] OR (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] - END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND ([l1].[Level3_Name] <> N'Foo' OR [l1].[Level3_Name] IS NULL) + END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND CASE + WHEN [l1].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l1].[Id] END @@ -3632,7 +3698,10 @@ WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse ) AS [l2] ON CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l2].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL)) > 0 + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -3710,7 +3779,10 @@ LEFT JOIN ( FROM ( SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l2].[OneToMany_Optional_Inverse3Id] ORDER BY [l2].[Level3_Name]) AS [row] FROM [Level1] AS [l2] - WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL) + WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] AND [l3].[row] <= 4 ) AS [l4] ON CASE diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs index fac384c0bcd..b16df106010 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs @@ -268,7 +268,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] @@ -297,7 +300,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] @@ -324,7 +330,10 @@ INNER JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -339,7 +348,10 @@ INNER JOIN ( FROM ( SELECT [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], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Name] DESC) AS [row] FROM [LevelTwo] AS [l1] - WHERE [l1].[Name] <> N'Bar' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE 1 < [l4].[row] ) AS [l5] ON [l].[Id] = [l5].[OneToMany_Required_Inverse2Id] @@ -366,7 +378,10 @@ INNER JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -381,7 +396,10 @@ INNER JOIN ( FROM ( SELECT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -390,7 +408,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Bar' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE 1 < [l4].[row] ) AS [l5] ON [l3].[Id] = [l5].[OneToMany_Required_Inverse3Id] @@ -417,7 +438,10 @@ INNER JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 2 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -444,7 +468,10 @@ CROSS APPLY ( FROM ( SELECT TOP(2) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -460,7 +487,10 @@ CROSS APPLY ( FROM ( SELECT TOP(2) [l0].[Id] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -491,7 +521,10 @@ CROSS APPLY ( FROM ( SELECT TOP(2) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -507,7 +540,10 @@ CROSS APPLY ( FROM ( SELECT TOP(2) [l0].[Id] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -536,7 +572,10 @@ INNER JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -563,7 +602,10 @@ INNER JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -590,7 +632,10 @@ CROSS APPLY ( FROM ( SELECT TOP(1) [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] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] @@ -606,7 +651,10 @@ CROSS APPLY ( FROM ( SELECT TOP(1) [l0].[Id] FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] AS [l1] ON [l2].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] @@ -647,7 +695,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE [l4].[row] <= 1 ) AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] @@ -663,7 +714,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE [l4].[row] <= 1 ) AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] @@ -680,7 +734,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE [l4].[row] <= 1 ) AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] @@ -716,7 +773,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE [l4].[row] <= 1 ) AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] @@ -732,7 +792,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE [l4].[row] <= 1 ) AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] @@ -749,7 +812,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE [l4].[row] <= 1 ) AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] @@ -779,7 +845,10 @@ INNER JOIN ( FROM ( 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], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> @__prm_0 OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -943,7 +1012,10 @@ FROM [LevelFour] AS [l7] LEFT JOIN [LevelThree] AS [l12] ON [s].[Id2] = [l12].[Level2_Optional_Id] LEFT JOIN [LevelTwo] AS [l13] ON [s0].[Level2_Optional_Id0] = [l13].[Id] LEFT JOIN [LevelThree] AS [l14] ON [l13].[Id] = [l14].[Level2_Required_Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """, // @@ -976,7 +1048,10 @@ INNER JOIN ( FROM [LevelTwo] AS [l17] WHERE [l17].[Id] <> 42 ) AS [l18] ON [s].[Id2] = [l18].[OneToMany_Optional_Self_Inverse2Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """); } @@ -1109,7 +1184,10 @@ FROM [LevelOne] AS [l] INNER JOIN ( SELECT [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 [LevelTwo] AS [l2] - WHERE [l2].[Name] <> N'Foo' OR [l2].[Name] IS NULL + WHERE CASE + WHEN [l2].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] WHERE [l].[Id] < 3 ORDER BY [l].[Id] @@ -1478,7 +1556,10 @@ FROM [LevelOne] AS [l] OUTER APPLY ( SELECT TOP(1) 1 AS [c], [l0].[Id] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] ORDER BY [l].[Id], [l1].[Id] """, @@ -1489,7 +1570,10 @@ FROM [LevelOne] AS [l] OUTER APPLY ( SELECT TOP(1) [l21].[Id] FROM [LevelTwo] AS [l21] - WHERE [l21].[Name] <> N'Foo' OR [l21].[Name] IS NULL + WHERE CASE + WHEN [l21].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l28] CROSS APPLY ( SELECT [l26].[Name] @@ -1516,7 +1600,10 @@ LEFT JOIN ( FROM ( SELECT 1 AS [c], [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 1 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1531,7 +1618,10 @@ LEFT JOIN ( FROM ( SELECT [l14].[Id], [l14].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l14].[OneToMany_Optional_Inverse2Id] ORDER BY [l14].[Id]) AS [row] FROM [LevelTwo] AS [l14] - WHERE [l14].[Name] <> N'Foo' OR [l14].[Name] IS NULL + WHERE CASE + WHEN [l14].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l21] WHERE [l21].[row] <= 1 ) AS [l22] ON [l].[Id] = [l22].[OneToMany_Optional_Inverse2Id] @@ -1576,7 +1666,10 @@ FROM [LevelFour] AS [l7] LEFT JOIN [LevelThree] AS [l12] ON [s].[Id2] = [l12].[Level2_Optional_Id] LEFT JOIN [LevelTwo] AS [l13] ON [s0].[Level2_Optional_Id0] = [l13].[Id] LEFT JOIN [LevelThree] AS [l14] ON [l13].[Id] = [l14].[Level2_Required_Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """, // @@ -1609,7 +1702,10 @@ INNER JOIN ( FROM [LevelTwo] AS [l17] WHERE [l17].[Id] <> 42 ) AS [l18] ON [s].[Id2] = [l18].[OneToMany_Optional_Self_Inverse2Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """); } @@ -1960,7 +2056,10 @@ public override async Task Include_nested_with_optional_navigation(bool async) SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[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] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -WHERE [l0].[Name] <> N'L2 09' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'L2 09' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id] """, // @@ -1973,7 +2072,10 @@ INNER JOIN ( FROM [LevelThree] AS [l1] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] ) AS [s] ON [l0].[Id] = [s].[OneToMany_Required_Inverse3Id] -WHERE [l0].[Name] <> N'L2 09' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'L2 09' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id] """); } @@ -2139,7 +2241,10 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[Level2_Optional_Id] LEFT JOIN [LevelTwo] AS [l3] ON [l].[Id] = [l3].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] -WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id] """, // @@ -2152,7 +2257,10 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l3] ON [l].[Id] = [l3].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] INNER JOIN [LevelThree] AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] -WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id] """); } @@ -2711,7 +2819,10 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte SELECT [l].[Name] FROM [LevelOne] AS [l] GROUP BY [l].[Name] - HAVING [l].[Name] <> N'Foo' OR [l].[Name] IS NULL + HAVING CASE + WHEN [l].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] LEFT JOIN ( SELECT [l2].[Id], [l2].[Date], [l2].[Name], [l2].[OneToMany_Optional_Self_Inverse1Id], [l2].[OneToMany_Required_Self_Inverse1Id], [l2].[OneToOne_Optional_Self1Id] @@ -2730,7 +2841,10 @@ FROM [LevelOne] AS [l0] SELECT [l].[Name] FROM [LevelOne] AS [l] GROUP BY [l].[Name] - HAVING [l].[Name] <> N'Foo' OR [l].[Name] IS NULL + HAVING CASE + WHEN [l].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l7] LEFT JOIN ( SELECT [l8].[Id], [l8].[Name] @@ -3138,7 +3252,10 @@ FROM [LevelOne] AS [l] SELECT COUNT(*) FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id] """, // @@ -3155,7 +3272,10 @@ FROM [LevelTwo] AS [l2] SELECT COUNT(*) FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id] """); } @@ -4153,7 +4273,10 @@ FROM [LevelOne] AS [l] SELECT COUNT(*) FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id] """, // @@ -4170,7 +4293,10 @@ FROM [LevelTwo] AS [l2] SELECT COUNT(*) FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id] """); } @@ -4264,7 +4390,10 @@ INNER JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 9a04d360e86..e35c8d6bcea 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -739,7 +739,10 @@ public override async Task Where_nav_prop_reference_optional2(bool async) SELECT [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -WHERE [l0].[Name] = N'L2 05' OR [l0].[Name] <> N'L2 42' OR [l0].[Name] IS NULL +WHERE [l0].[Name] = N'L2 05' OR CASE + WHEN [l0].[Name] = N'L2 42' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -753,7 +756,10 @@ SELECT [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] -WHERE [l0].[Name] = N'L2 05' OR [l1].[Name] <> N'L2 42' OR [l1].[Name] IS NULL +WHERE [l0].[Name] = N'L2 05' OR CASE + WHEN [l1].[Name] = N'L2 42' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -780,7 +786,10 @@ public override async Task Where_multiple_nav_prop_reference_optional_member_com FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] -WHERE [l1].[Name] <> N'L3 05' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'L3 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -918,7 +927,10 @@ public override async Task Where_multiple_nav_prop_optional_required(bool async) FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -WHERE [l1].[Name] <> N'L3 05' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'L3 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -974,7 +986,10 @@ FROM [LevelOne] AS [l] CROSS JOIN [LevelTwo] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] INNER JOIN [LevelOne] AS [l2] ON [l0].[Level1_Required_Id] = [l2].[Id] -WHERE [l1].[Name] = N'L2 01' OR [l2].[Name] <> N'Bar' OR [l2].[Name] IS NULL +WHERE [l1].[Name] = N'L2 01' OR CASE + WHEN [l2].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -988,7 +1003,10 @@ SELECT [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -WHERE [l1].[Name] = N'L3 05' OR [l0].[Name] <> N'L2 05' OR [l0].[Name] IS NULL +WHERE [l1].[Name] = N'L3 05' OR CASE + WHEN [l0].[Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1003,7 +1021,10 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [l1].[Id] = [l2].[Level2_Optional_Id] -WHERE [l0].[Name] <> N'L2 05' OR [l0].[Name] IS NULL OR [l2].[Name] = N'L3 05' +WHERE CASE + WHEN [l0].[Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) OR [l2].[Name] = N'L3 05' """); } @@ -1018,7 +1039,10 @@ FROM [LevelThree] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Level2_Optional_Id] = [l0].[Id] INNER JOIN [LevelTwo] AS [l1] ON [l].[Level2_Required_Id] = [l1].[Id] LEFT JOIN [LevelOne] AS [l2] ON [l1].[Level1_Optional_Id] = [l2].[Id] -WHERE [l0].[Name] <> N'L2 05' OR [l0].[Name] IS NULL OR [l2].[Name] = N'L1 05' +WHERE CASE + WHEN [l0].[Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) OR [l2].[Name] = N'L1 05' """); } @@ -1033,7 +1057,10 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[Level2_Optional_Id] -WHERE ([l1].[Id] = [l2].[Id] OR ([l1].[Id] IS NULL AND [l2].[Id] IS NULL)) AND ([l2].[Id] <> 7 OR [l2].[Id] IS NULL) +WHERE ([l1].[Id] = [l2].[Id] OR ([l1].[Id] IS NULL AND [l2].[Id] IS NULL)) AND CASE + WHEN [l2].[Id] = 7 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1048,7 +1075,13 @@ FROM [LevelThree] AS [l] INNER JOIN [LevelTwo] AS [l0] ON [l].[Level2_Required_Id] = [l0].[Id] INNER JOIN [LevelOne] AS [l1] ON [l0].[Level1_Required_Id] = [l1].[Id] LEFT JOIN [LevelOne] AS [l2] ON [l0].[Level1_Optional_Id] = [l2].[Id] -WHERE ([l1].[Id] <> [l2].[Id] OR [l2].[Id] IS NULL) AND ([l2].[Id] <> 7 OR [l2].[Id] IS NULL) +WHERE CASE + WHEN [l1].[Id] = [l2].[Id] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l2].[Id] = 7 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1189,7 +1222,10 @@ public override async Task Include_with_optional_navigation(bool async) SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[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] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -WHERE [l0].[Name] <> N'L2 05' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2138,7 +2174,10 @@ SELECT [l1].[Name] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelOne] AS [l1] ON [l0].[Level1_Required_Id] = [l1].[Id] -WHERE [l1].[Name] <> N'L3 02' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'L3 02' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2530,7 +2569,10 @@ public override async Task Optional_navigation_in_subquery_with_unrelated_projec SELECT TOP(@__p_0) [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id] """); } @@ -2546,7 +2588,10 @@ public override async Task Explicit_GroupJoin_in_subquery_with_unrelated_project SELECT TOP(@__p_0) [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id] """); } @@ -2562,7 +2607,10 @@ SELECT [s].[Id] 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] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] """); } @@ -2576,7 +2624,10 @@ public override async Task Explicit_GroupJoin_in_subquery_with_unrelated_project SELECT DISTINCT [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2593,7 +2644,10 @@ SELECT TOP(@__p_0) [s].[Id] SELECT DISTINCT [l].[Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ORDER BY [s].[Id] """); @@ -2705,7 +2759,10 @@ public override async Task Navigation_with_same_navigation_compared_to_null(bool SELECT [l].[Id] FROM [LevelTwo] AS [l] INNER JOIN [LevelOne] AS [l0] ON [l].[OneToMany_Required_Inverse2Id] = [l0].[Id] -WHERE [l0].[Name] <> N'L1 07' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'L1 07' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2733,7 +2790,10 @@ SELECT [l].[Id] FROM [LevelThree] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[OneToMany_Optional_Inverse3Id] = [l0].[Id] LEFT JOIN [LevelOne] AS [l1] ON [l0].[Level1_Required_Id] = [l1].[Id] -WHERE ([l1].[Name] <> N'L1 07' OR [l1].[Name] IS NULL) AND [l1].[Id] IS NOT NULL +WHERE CASE + WHEN [l1].[Name] = N'L1 07' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [l1].[Id] IS NOT NULL """); } @@ -2857,11 +2917,7 @@ SELECT CASE SELECT TOP(1) [l1].[Name] FROM [LevelTwo] AS [l0] INNER JOIN [LevelOne] AS [l1] ON [l0].[Level1_Required_Id] = [l1].[Id] - ORDER BY [l0].[Id]) = N'L1 02' AND ( - SELECT TOP(1) [l1].[Name] - FROM [LevelTwo] AS [l0] - INNER JOIN [LevelOne] AS [l1] ON [l0].[Level1_Required_Id] = [l1].[Id] - ORDER BY [l0].[Id]) IS NOT NULL THEN CAST(1 AS bit) + ORDER BY [l0].[Id]) = N'L1 02' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [LevelTwo] AS [l] @@ -3251,7 +3307,10 @@ public override async Task Include8(bool async) 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], [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] FROM [LevelTwo] AS [l] LEFT JOIN [LevelOne] AS [l0] ON [l].[Level1_Optional_Id] = [l0].[Id] -WHERE [l0].[Name] <> N'Fubar' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'Fubar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3264,7 +3323,10 @@ public override async Task Include9(bool async) 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], [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] FROM [LevelTwo] AS [l] LEFT JOIN [LevelOne] AS [l0] ON [l].[Level1_Optional_Id] = [l0].[Id] -WHERE [l0].[Name] <> N'Fubar' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'Fubar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3395,7 +3457,10 @@ public override async Task Include18_2(bool async) 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] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] LEFT JOIN [LevelTwo] AS [l1] ON [s].[Id] = [l1].[Level1_Optional_Id] """); @@ -3584,31 +3649,22 @@ public override async Task Member_pushdown_chain_3_levels_deep(bool async) """ SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] FROM [LevelOne] AS [l] -WHERE ( - SELECT TOP(1) ( - SELECT TOP(1) ( - SELECT TOP(1) [l2].[Name] - FROM [LevelFour] AS [l2] - WHERE [l2].[Level3_Required_Id] = [l1].[Id] - ORDER BY [l2].[Id]) - FROM [LevelThree] AS [l1] - WHERE [l1].[Level2_Required_Id] = [l0].[Id] - ORDER BY [l1].[Id]) - FROM [LevelTwo] AS [l0] - WHERE [l0].[Level1_Optional_Id] = [l].[Id] - ORDER BY [l0].[Id]) <> N'Foo' OR ( - SELECT TOP(1) ( +WHERE CASE + WHEN ( SELECT TOP(1) ( - SELECT TOP(1) [l2].[Name] - FROM [LevelFour] AS [l2] - WHERE [l2].[Level3_Required_Id] = [l1].[Id] - ORDER BY [l2].[Id]) - FROM [LevelThree] AS [l1] - WHERE [l1].[Level2_Required_Id] = [l0].[Id] - ORDER BY [l1].[Id]) - FROM [LevelTwo] AS [l0] - WHERE [l0].[Level1_Optional_Id] = [l].[Id] - ORDER BY [l0].[Id]) IS NULL + SELECT TOP(1) ( + SELECT TOP(1) [l2].[Name] + FROM [LevelFour] AS [l2] + WHERE [l2].[Level3_Required_Id] = [l1].[Id] + ORDER BY [l2].[Id]) + FROM [LevelThree] AS [l1] + WHERE [l1].[Level2_Required_Id] = [l0].[Id] + ORDER BY [l1].[Id]) + FROM [LevelTwo] AS [l0] + WHERE [l0].[Level1_Optional_Id] = [l].[Id] + ORDER BY [l0].[Id]) = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id] """); } @@ -4000,7 +4056,10 @@ public override async Task GroupBy_aggregate_where_required_relationship(bool as FROM [LevelTwo] AS [l] INNER JOIN [LevelOne] AS [l0] ON [l].[OneToMany_Required_Inverse2Id] = [l0].[Id] GROUP BY [l0].[Id] -HAVING MAX([l].[Id]) <> 2 OR MAX([l].[Id]) IS NULL +HAVING CASE + WHEN MAX([l].[Id]) = 2 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4051,12 +4110,12 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] WHERE CASE - WHEN [l0].[Id] IS NULL THEN NULL - ELSE [l1].[Name] -END <> N'L' OR CASE - WHEN [l0].[Id] IS NULL THEN NULL - ELSE [l1].[Name] -END IS NULL + WHEN CASE + WHEN [l0].[Id] IS NULL THEN NULL + ELSE [l1].[Name] + END = N'L' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4856,7 +4915,10 @@ public override async Task Multiple_select_many_in_projection(bool async) SELECT COUNT(*) FROM [LevelTwo] AS [l3] INNER JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse3Id] - WHERE [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] AND ([l4].[Name] <> N'' OR [l4].[Name] IS NULL)) + WHERE [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l4].[Name] = N'' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) FROM [LevelOne] AS [l] OUTER APPLY ( SELECT [s].[Id0] AS [Id], [l2].[Id] AS [RefId], [s].[Id] AS [Id0] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs index c07c15b88a0..20e1add8855 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs @@ -359,7 +359,10 @@ WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] END WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] - WHERE [s].[Level2_Name] <> N'Foo' OR [s].[Level2_Name] IS NULL + WHERE CASE + WHEN [s].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] """); } @@ -428,12 +431,12 @@ WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END = [l3].[Level2_Optional_Id] WHERE CASE - WHEN [l1].[OneToOne_Required_PK_Date] IS NULL OR [l1].[Level1_Required_Id] IS NULL OR [l1].[OneToMany_Required_Inverse2Id] IS NULL THEN NULL - ELSE [l3].[Level3_Name] -END <> N'L' OR CASE - WHEN [l1].[OneToOne_Required_PK_Date] IS NULL OR [l1].[Level1_Required_Id] IS NULL OR [l1].[OneToMany_Required_Inverse2Id] IS NULL THEN NULL - ELSE [l3].[Level3_Name] -END IS NULL + WHEN CASE + WHEN [l1].[OneToOne_Required_PK_Date] IS NULL OR [l1].[Level1_Required_Id] IS NULL OR [l1].[OneToMany_Required_Inverse2Id] IS NULL THEN NULL + ELSE [l3].[Level3_Name] + END = N'L' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1210,47 +1213,30 @@ WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] LEFT JOIN [Level1] AS [l2] ON [l1].[OneToMany_Required_Inverse2Id] = [l2].[Id] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL GROUP BY [l2].[Id] -HAVING ( - SELECT MAX(CASE - WHEN [l8].[OneToOne_Required_PK_Date] IS NOT NULL AND [l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l8].[Id] - END) - FROM [Level1] AS [l3] - LEFT JOIN ( - SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] - FROM [Level1] AS [l5] - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL - ) AS [l4] ON [l3].[Id] = CASE - WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l4].[Id] - END - LEFT JOIN [Level1] AS [l6] ON [l4].[OneToMany_Required_Inverse2Id] = [l6].[Id] - LEFT JOIN ( - SELECT [l7].[Id], [l7].[OneToOne_Required_PK_Date], [l7].[Level1_Required_Id], [l7].[OneToMany_Required_Inverse2Id] - FROM [Level1] AS [l7] - WHERE [l7].[OneToOne_Required_PK_Date] IS NOT NULL AND [l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL - ) AS [l8] ON [l3].[Id] = CASE - WHEN [l8].[OneToOne_Required_PK_Date] IS NOT NULL AND [l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l8].[Id] - END - WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] = [l6].[Id] OR ([l2].[Id] IS NULL AND [l6].[Id] IS NULL))) <> 2 OR ( - SELECT MAX(CASE - WHEN [l8].[OneToOne_Required_PK_Date] IS NOT NULL AND [l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l8].[Id] - END) - FROM [Level1] AS [l3] - LEFT JOIN ( - SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] - FROM [Level1] AS [l5] - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL - ) AS [l4] ON [l3].[Id] = CASE - WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l4].[Id] - END - LEFT JOIN [Level1] AS [l6] ON [l4].[OneToMany_Required_Inverse2Id] = [l6].[Id] - LEFT JOIN ( - SELECT [l7].[Id], [l7].[OneToOne_Required_PK_Date], [l7].[Level1_Required_Id], [l7].[OneToMany_Required_Inverse2Id] - FROM [Level1] AS [l7] - WHERE [l7].[OneToOne_Required_PK_Date] IS NOT NULL AND [l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL - ) AS [l8] ON [l3].[Id] = CASE - WHEN [l8].[OneToOne_Required_PK_Date] IS NOT NULL AND [l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l8].[Id] - END - WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] = [l6].[Id] OR ([l2].[Id] IS NULL AND [l6].[Id] IS NULL))) IS NULL +HAVING CASE + WHEN ( + SELECT MAX(CASE + WHEN [l8].[OneToOne_Required_PK_Date] IS NOT NULL AND [l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l8].[Id] + END) + FROM [Level1] AS [l3] + LEFT JOIN ( + SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] + FROM [Level1] AS [l5] + WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL + ) AS [l4] ON [l3].[Id] = CASE + WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l4].[Id] + END + LEFT JOIN [Level1] AS [l6] ON [l4].[OneToMany_Required_Inverse2Id] = [l6].[Id] + LEFT JOIN ( + SELECT [l7].[Id], [l7].[OneToOne_Required_PK_Date], [l7].[Level1_Required_Id], [l7].[OneToMany_Required_Inverse2Id] + FROM [Level1] AS [l7] + WHERE [l7].[OneToOne_Required_PK_Date] IS NOT NULL AND [l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL + ) AS [l8] ON [l3].[Id] = CASE + WHEN [l8].[OneToOne_Required_PK_Date] IS NOT NULL AND [l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l8].[Id] + END + WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] = [l6].[Id] OR ([l2].[Id] IS NULL AND [l6].[Id] IS NULL))) = 2 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2331,7 +2317,10 @@ WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] LEFT JOIN [Level1] AS [l3] ON [s].[Level1_Required_Id] = [l3].[Id] -WHERE [l3].[Name] <> N'L3 02' OR [l3].[Name] IS NULL +WHERE CASE + WHEN [l3].[Name] = N'L3 02' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2760,7 +2749,10 @@ WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse ) AS [l3] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END = [l3].[Level2_Required_Id] -WHERE [l3].[Level3_Name] <> N'L3 05' OR [l3].[Level3_Name] IS NULL +WHERE CASE + WHEN [l3].[Level3_Name] = N'L3 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3167,7 +3159,10 @@ FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [l4] ON [l].[Id] = [l4].[Level1_Optional_Id] LEFT JOIN [Level1] AS [l5] ON [s].[Level1_Required_Id] = [l5].[Id] -WHERE [l4].[Level2_Name] = N'L2 01' OR [l5].[Name] <> N'Bar' OR [l5].[Name] IS NULL +WHERE [l4].[Level2_Name] = N'L2 01' OR CASE + WHEN [l5].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3327,7 +3322,10 @@ WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l5].[Id] END LEFT JOIN [Level1] AS [l6] ON [l5].[Level1_Required_Id] = [l6].[Id] -WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l6].[Name] <> N'L1 07' OR [l6].[Name] IS NULL) AND [l6].[Id] IS NOT NULL +WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l6].[Name] = N'L1 07' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [l6].[Id] IS NOT NULL """); } @@ -3418,7 +3416,10 @@ WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse ) AS [l5] ON CASE WHEN [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l3].[Id] END = [l5].[Level2_Optional_Id] -WHERE [l1].[Level2_Name] <> N'L2 05' OR [l1].[Level2_Name] IS NULL OR [l5].[Level3_Name] = N'L3 05' +WHERE CASE + WHEN [l1].[Level2_Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) OR [l5].[Level3_Name] = N'L3 05' """); } @@ -3640,7 +3641,10 @@ WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse ) AS [l3] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END = [l3].[Level2_Optional_Id] -WHERE [l3].[Level3_Name] <> N'L3 05' OR [l3].[Level3_Name] IS NULL +WHERE CASE + WHEN [l3].[Level3_Name] = N'L3 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3703,7 +3707,10 @@ WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] END WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] - WHERE [s].[Level2_Name] <> N'Foo' OR [s].[Level2_Name] IS NULL + WHERE CASE + WHEN [s].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ORDER BY [s0].[Id] """); @@ -3834,7 +3841,10 @@ WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] END WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] -WHERE [s].[Level2_Name] <> N'Foo' OR [s].[Level2_Name] IS NULL +WHERE CASE + WHEN [s].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4470,10 +4480,11 @@ FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] WHERE CASE - WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] -END <> 6 OR CASE - WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] -END IS NULL + WHEN CASE + WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] + END = 6 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4562,7 +4573,10 @@ WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse ) AS [l3] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END = [l3].[Level2_Required_Id] -WHERE [l3].[Level3_Name] = N'L3 05' OR [l1].[Level2_Name] <> N'L2 05' OR [l1].[Level2_Name] IS NULL +WHERE [l3].[Level3_Name] = N'L3 05' OR CASE + WHEN [l1].[Level2_Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4803,11 +4817,12 @@ END OR (CASE WHEN [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l3].[Id] END IS NULL AND CASE WHEN [l5].[Level2_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l5].[Id] -END IS NULL)) AND (CASE - WHEN [l5].[Level2_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l5].[Id] -END <> 7 OR CASE - WHEN [l5].[Level2_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l5].[Id] -END IS NULL) +END IS NULL)) AND CASE + WHEN CASE + WHEN [l5].[Level2_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l5].[Id] + END = 7 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4920,7 +4935,10 @@ LEFT JOIN ( FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [l1] ON [l].[Id] = [l1].[Level1_Required_Id] - WHERE [l1].[Level2_Name] <> N'Foo' OR [l1].[Level2_Name] IS NULL + WHERE CASE + WHEN [l1].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] LEFT JOIN ( SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] @@ -4959,7 +4977,10 @@ LEFT JOIN ( FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] -WHERE [l1].[Level2_Name] <> N'L2 05' OR [l1].[Level2_Name] IS NULL +WHERE CASE + WHEN [l1].[Level2_Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -5781,7 +5802,10 @@ LEFT JOIN ( FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] -WHERE [l1].[Level2_Name] = N'L2 05' OR [l1].[Level2_Name] <> N'L2 42' OR [l1].[Level2_Name] IS NULL +WHERE [l1].[Level2_Name] = N'L2 05' OR CASE + WHEN [l1].[Level2_Name] = N'L2 42' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6092,7 +6116,10 @@ WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] END WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [s0] ON [l].[Id] = [s0].[Level1_Optional_Id] -WHERE [s].[Level2_Name] = N'L2 05' OR [s0].[Level2_Name] <> N'L2 42' OR [s0].[Level2_Name] IS NULL +WHERE [s].[Level2_Name] = N'L2 05' OR CASE + WHEN [s0].[Level2_Name] = N'L2 42' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6510,7 +6537,10 @@ WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] END LEFT JOIN [Level1] AS [l6] ON [l5].[Level1_Required_Id] = [l6].[Id] LEFT JOIN [Level1] AS [l7] ON [l5].[Level1_Optional_Id] = [l7].[Id] -WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l6].[Id] <> [l7].[Id] OR [l6].[Id] IS NULL OR [l7].[Id] IS NULL) AND ([l6].[Id] IS NOT NULL OR [l7].[Id] IS NOT NULL) AND ([l7].[Id] <> 7 OR [l7].[Id] IS NULL) +WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l6].[Id] <> [l7].[Id] OR [l6].[Id] IS NULL OR [l7].[Id] IS NULL) AND ([l6].[Id] IS NOT NULL OR [l7].[Id] IS NOT NULL) AND CASE + WHEN [l7].[Id] = 7 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6776,7 +6806,10 @@ LEFT JOIN ( FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] -WHERE [l1].[Level2_Name] <> N'Foo' OR [l1].[Level2_Name] IS NULL +WHERE CASE + WHEN [l1].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id] """); } @@ -6824,21 +6857,7 @@ WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL ORDER BY CASE WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l4].[Id] - END) = N'L1 02' AND ( - SELECT TOP(1) [l5].[Name] - FROM [Level1] AS [l2] - LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] - FROM [Level1] AS [l3] - WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL - ) AS [l4] ON [l2].[Id] = CASE - WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l4].[Id] - END - LEFT JOIN [Level1] AS [l5] ON [l4].[Level1_Required_Id] = [l5].[Id] - WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL - ORDER BY CASE - WHEN [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l4].[Id] - END) IS NOT NULL THEN CAST(1 AS bit) + END) = N'L1 02' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Level1] AS [l] @@ -7163,7 +7182,10 @@ WHERE [l6].[OneToOne_Required_PK_Date] IS NOT NULL AND [l6].[Level1_Required_Id] WHEN [l7].[OneToOne_Required_PK_Date] IS NOT NULL AND [l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l7].[Id] END LEFT JOIN [Level1] AS [l8] ON [l7].[Level1_Optional_Id] = [l8].[Id] -WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l5].[Level2_Name] <> N'L2 05' OR [l5].[Level2_Name] IS NULL OR [l8].[Name] = N'L1 05') +WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3Id] IS NOT NULL AND (CASE + WHEN [l5].[Level2_Name] = N'L2 05' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) OR [l8].[Name] = N'L1 05') """); } @@ -7341,7 +7363,10 @@ WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id] END LEFT JOIN [Level1] AS [l2] ON [l1].[OneToMany_Required_Inverse2Id] = [l2].[Id] -WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Name] <> N'L1 07' OR [l2].[Name] IS NULL) AND [l2].[Id] IS NOT NULL +WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Name] = N'L1 07' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [l2].[Id] IS NOT NULL """); } @@ -7367,7 +7392,10 @@ WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] END WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] -WHERE [s].[Level2_Name] <> N'Foo' OR [s].[Level2_Name] IS NULL +WHERE CASE + WHEN [s].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id] """); } @@ -8046,7 +8074,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] <> @__prm_0 OR [l2].[Id] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Id] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] """); } @@ -8073,7 +8104,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] <> @__prm_0 OR [l2].[Id] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Id] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] """); } @@ -8103,7 +8137,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] <> @__prm1_0 OR [l2].[Id] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Id] = @__prm1_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] LEFT JOIN ( SELECT [l7].[Id] AS [Id1], [l7].[Level2_Optional_Id], [l7].[Level2_Required_Id], [l7].[OneToMany_Required_Inverse3Id] @@ -8124,7 +8161,10 @@ WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] END = CASE WHEN [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l7].[Id] END - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l7].[Id] <> @__prm2_1 OR [l7].[Id] IS NULL) + WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l7].[Id] = @__prm2_1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON CASE WHEN [s].[OneToOne_Required_PK_Date] IS NOT NULL AND [s].[Level1_Required_Id] IS NOT NULL AND [s].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [s].[Id0] END = [s0].[Level2_Optional_Id] @@ -8156,7 +8196,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] <> @__prm1_0 OR [l2].[Id] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Id] = @__prm1_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] INNER JOIN ( SELECT [l7].[Id] AS [Id1], [l7].[Level2_Optional_Id], [l7].[Level2_Required_Id], [l7].[OneToMany_Required_Inverse3Id] @@ -8177,7 +8220,10 @@ WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] END = CASE WHEN [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l7].[Id] END - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l7].[Id] <> @__prm2_1 OR [l7].[Id] IS NULL) + WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l7].[Id] = @__prm2_1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON CASE WHEN [s].[OneToOne_Required_PK_Date] IS NOT NULL AND [s].[Level1_Required_Id] IS NOT NULL AND [s].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [s].[Id0] END = [s0].[Level2_Optional_Id] @@ -8208,7 +8254,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] <> @__prm_0 OR [l2].[Id] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Id] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] LEFT JOIN ( SELECT [l7].[Id] AS [Id1], [l7].[Level2_Optional_Id], [l7].[Level2_Required_Id], [l7].[OneToMany_Required_Inverse3Id] @@ -8229,7 +8278,10 @@ WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] END = CASE WHEN [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l7].[Id] END - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l7].[Id] <> @__prm_0 OR [l7].[Id] IS NULL) + WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l7].[Id] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON CASE WHEN [s].[OneToOne_Required_PK_Date] IS NOT NULL AND [s].[Level1_Required_Id] IS NOT NULL AND [s].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [s].[Id0] END = [s0].[Level2_Optional_Id] @@ -8260,7 +8312,10 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] ) AS [l2] ON [l0].[Id] = CASE WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END - WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l2].[Id] <> @__prm_0 OR [l2].[Id] IS NULL) + WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l2].[Id] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s] ON [l].[Id] = [s].[Level1_Optional_Id] INNER JOIN ( SELECT [l7].[Id] AS [Id1], [l7].[Level2_Optional_Id], [l7].[Level2_Required_Id], [l7].[OneToMany_Required_Inverse3Id] @@ -8281,7 +8336,10 @@ WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] END = CASE WHEN [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l7].[Id] END - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l7].[Id] <> @__prm_0 OR [l7].[Id] IS NULL) + WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l7].[Id] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON CASE WHEN [s].[OneToOne_Required_PK_Date] IS NOT NULL AND [s].[Level1_Required_Id] IS NOT NULL AND [s].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [s].[Id0] END = [s0].[Level2_Optional_Id] @@ -8439,7 +8497,10 @@ WHERE [l6].[Level2_Required_Id] IS NOT NULL AND [l6].[OneToMany_Required_Inverse ) AS [l7] ON CASE WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l5].[Id] END = [l7].[OneToMany_Optional_Inverse3Id] - WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l5].[OneToMany_Optional_Inverse2Id] AND ([l7].[Level3_Name] <> N'' OR [l7].[Level3_Name] IS NULL)) + WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l5].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l7].[Level3_Name] = N'' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) FROM [Level1] AS [l] OUTER APPLY ( SELECT CASE diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs index b62c0570bf0..ba4ca001e4a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs @@ -89,7 +89,10 @@ public override async Task Filter_on_required_property_inside_required_complex_t FROM [CustomerGroup] AS [c] LEFT JOIN [Customer] AS [c0] ON [c].[OptionalCustomerId] = [c0].[Id] INNER JOIN [Customer] AS [c1] ON [c].[RequiredCustomerId] = [c1].[Id] -WHERE [c0].[ShippingAddress_ZipCode] <> 7728 OR [c0].[ShippingAddress_ZipCode] IS NULL +WHERE CASE + WHEN [c0].[ShippingAddress_ZipCode] = 7728 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -458,7 +461,10 @@ public override async Task Filter_on_required_property_inside_required_struct_co FROM [ValuedCustomerGroup] AS [v] LEFT JOIN [ValuedCustomer] AS [v0] ON [v].[OptionalCustomerId] = [v0].[Id] INNER JOIN [ValuedCustomer] AS [v1] ON [v].[RequiredCustomerId] = [v1].[Id] -WHERE [v0].[ShippingAddress_ZipCode] <> 7728 OR [v0].[ShippingAddress_ZipCode] IS NULL +WHERE CASE + WHEN [v0].[ShippingAddress_ZipCode] = 7728 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs index 018d20fb4b7..6d1983955c7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs @@ -770,11 +770,17 @@ FROM [Person] AS [p1] LEFT JOIN [Feet] AS [f0] ON [p1].[Id] = [f0].[Id] LEFT JOIN [Person] AS [p2] ON [f0].[Id] = [p2].[Id] LEFT JOIN [Feet] AS [f1] ON [p1].[Id] = [f1].[Id] - WHERE [f0].[Size] = @__size_0 AND [p1].[MiddleInitial] IS NOT NULL AND ([f0].[Id] <> 1 OR [f0].[Id] IS NULL) AND ([f].[Size] = [f0].[Size] OR ([f].[Size] IS NULL AND [f0].[Size] IS NULL)) AND ([p0].[LastName] = [p2].[LastName] OR ([p0].[LastName] IS NULL AND [p2].[LastName] IS NULL))) AS [Min] + WHERE [f0].[Size] = @__size_0 AND [p1].[MiddleInitial] IS NOT NULL AND CASE + WHEN [f0].[Id] = 1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND ([f].[Size] = [f0].[Size] OR ([f].[Size] IS NULL AND [f0].[Size] IS NULL)) AND ([p0].[LastName] = [p2].[LastName] OR ([p0].[LastName] IS NULL AND [p2].[LastName] IS NULL))) AS [Min] FROM [Person] AS [p] LEFT JOIN [Feet] AS [f] ON [p].[Id] = [f].[Id] LEFT JOIN [Person] AS [p0] ON [f].[Id] = [p0].[Id] -WHERE [f].[Size] = @__size_0 AND [p].[MiddleInitial] IS NOT NULL AND ([f].[Id] <> 1 OR [f].[Id] IS NULL) +WHERE [f].[Size] = @__size_0 AND [p].[MiddleInitial] IS NOT NULL AND CASE + WHEN [f].[Id] = 1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) GROUP BY [f].[Size], [p0].[LastName] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs index 45af4624f1e..277b4185e71 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs @@ -562,9 +562,12 @@ public override async Task String_ends_with_not_equals_nullable_column(bool asyn FROM [FunkyCustomers] AS [f] CROSS JOIN [FunkyCustomers] AS [f0] WHERE CASE - WHEN [f].[FirstName] IS NOT NULL AND [f0].[LastName] IS NOT NULL AND RIGHT([f].[FirstName], LEN([f0].[LastName])) = [f0].[LastName] THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END <> [f].[NullableBool] OR [f].[NullableBool] IS NULL + WHEN CASE + WHEN [f].[FirstName] IS NOT NULL AND [f0].[LastName] IS NOT NULL AND RIGHT([f].[FirstName], LEN([f0].[LastName])) = [f0].[LastName] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END = [f].[NullableBool] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index ee1bf84c519..027781061fe 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -360,7 +360,10 @@ public override async Task Include_with_nested_navigation_in_order_by(bool async FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -WHERE [g].[Nickname] <> N'Paduk' OR [g].[Nickname] IS NULL +WHERE CASE + WHEN [g].[Nickname] = N'Paduk' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Name], [w].[Id] """); } @@ -784,7 +787,7 @@ public override async Task Select_comparison_with_null(bool async) @__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @__ammunitionType_0 AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[AmmunitionType] = @__ammunitionType_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Cartridge] FROM [Weapons] AS [w] @@ -909,7 +912,10 @@ public override async Task Select_multiple_conditions(bool async) AssertSql( """ SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND CASE + WHEN [w].[SynergyWithId] = 1 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) END AS [IsCartridge] FROM [Weapons] AS [w] @@ -1358,7 +1364,10 @@ public override async Task Select_Singleton_Navigation_With_Member_Access(bool a SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) +WHERE [g].[Nickname] = N'Marcus' AND CASE + WHEN [g].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1913,7 +1922,10 @@ public override async Task Singleton_Navigation_With_Member_Access(bool async) SELECT [g].[CityOfBirthName] AS [B] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) +WHERE [g].[Nickname] = N'Marcus' AND CASE + WHEN [g].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2271,7 +2283,10 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -2282,7 +2297,10 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + WHEN CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Tags] AS [t] @@ -2299,7 +2317,10 @@ public override async Task Optional_navigation_type_compensation_works_with_pred SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[HasSoulPatch] = CAST(1 AS bit) """); } @@ -2414,7 +2435,10 @@ public override async Task Optional_navigation_type_compensation_works_with_proj SELECT [g].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2427,7 +2451,10 @@ public override async Task Optional_navigation_type_compensation_works_with_proj SELECT [g].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2440,7 +2467,10 @@ public override async Task Optional_navigation_type_compensation_works_with_DTOs SELECT [g].[SquadId] AS [Id] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2453,7 +2483,10 @@ public override async Task Optional_navigation_type_compensation_works_with_list SELECT [g].[SquadId], [g].[SquadId] + 1 FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [t].[Note] """); } @@ -2467,7 +2500,10 @@ public override async Task Optional_navigation_type_compensation_works_with_arra SELECT [g].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2480,7 +2516,10 @@ public override async Task Optional_navigation_type_compensation_works_with_orde SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[SquadId] """); } @@ -2496,7 +2535,10 @@ WHEN NOT EXISTS ( SELECT 1 FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) + WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND [g].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -2511,7 +2553,10 @@ public override async Task Optional_navigation_type_compensation_works_with_nega SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[HasSoulPatch] = CAST(0 AS bit) """); } @@ -2524,7 +2569,10 @@ public override async Task Optional_navigation_type_compensation_works_with_cont SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[SquadId] IN ( +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[SquadId] IN ( SELECT [g0].[SquadId] FROM [Gears] AS [g0] ) @@ -2557,7 +2605,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Lancer' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [c].[Name] IN (N'Ephyra', N'Hanover') ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] @@ -2987,7 +3038,10 @@ public override async Task Distinct_with_optional_navigation_is_translated_to_sq SELECT DISTINCT [g].[HasSoulPatch] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3000,7 +3054,10 @@ public override async Task Sum_with_optional_navigation_is_translated_to_sql(boo SELECT COALESCE(SUM([g].[SquadId]), 0) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3013,7 +3070,10 @@ public override async Task Count_with_optional_navigation_is_translated_to_sql(b SELECT COUNT(*) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3197,7 +3257,10 @@ SELECT [g].[Nickname] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +WHERE CASE + WHEN [t].[GearNickName] = N'Cole Train' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [t0].[Id] """); } @@ -4133,7 +4196,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4151,7 +4217,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4169,7 +4238,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4187,7 +4259,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC @@ -4223,7 +4298,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4241,7 +4319,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4259,7 +4340,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4382,7 +4466,10 @@ FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] @@ -4565,7 +4652,10 @@ FROM [Weapons] AS [w] LEFT JOIN [Squads] AS [s] ON [g3].[SquadId] = [s].[Id] LEFT JOIN [Weapons] AS [w0] ON [g3].[FullName] = [w0].[OwnerFullName] LEFT JOIN [Gears] AS [g4] ON [s].[Id] = [g4].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON [g2].[FullName] = [s0].[OwnerFullName] WHERE [g2].[FullName] <> N'Foo' ) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] @@ -4632,7 +4722,10 @@ FROM [Gears] AS [g0] OUTER APPLY ( SELECT [w].[Name], [g0].[Nickname], [w].[Id] FROM [Weapons] AS [w] - WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + WHERE [g0].[FullName] = [w].[OwnerFullName] AND CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] @@ -4655,7 +4748,10 @@ FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' ) AS [s] @@ -4676,7 +4772,10 @@ CROSS JOIN [Squads] AS [s] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] @@ -5021,7 +5120,10 @@ INNER JOIN ( FROM [Factions] AS [f] WHERE [f].[Name] = N'Swarm' ) AS [f0] ON [l].[Name] = [f0].[CommanderName] -WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL +WHERE CASE + WHEN [f0].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -5038,7 +5140,10 @@ LEFT JOIN ( FROM [Factions] AS [f] WHERE [f].[Name] = N'Swarm' ) AS [f0] ON [l].[Name] = [f0].[CommanderName] -WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL +WHERE CASE + WHEN [f0].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6018,7 +6123,7 @@ public override async Task Double_order_by_on_string_compare(bool async) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [w].[Id] """); @@ -6046,7 +6151,7 @@ public override async Task String_compare_with_null_conditional_argument(bool as FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w0].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -6062,7 +6167,7 @@ public override async Task String_compare_with_null_conditional_argument2(bool a FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN N'Marcus'' Lancer' = [w0].[Name] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -6506,7 +6611,13 @@ public override async Task OfTypeNav1(bool async) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[Discriminator] = N'Officer' AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6520,7 +6631,13 @@ public override async Task OfTypeNav2(bool async) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[Discriminator] = N'Officer' AND CASE + WHEN [c].[Location] = 'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6535,7 +6652,13 @@ FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[Discriminator] = N'Officer' AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6567,7 +6690,10 @@ LEFT JOIN ( FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6585,7 +6711,13 @@ SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l0].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6603,7 +6735,13 @@ SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l0].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6980,7 +7118,7 @@ public override async Task Navigation_based_on_complex_expression6(bool async) AssertSql( """ SELECT CASE - WHEN [l2].[Name] = N'Queen Myrrah' AND [l2].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [l2].[Name] = N'Queen Myrrah' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] FROM [Factions] AS [f] @@ -7047,7 +7185,7 @@ public override async Task Nullable_bool_comparison_is_translated_to_server(bool AssertSql( """ SELECT CASE - WHEN [f].[Eradicated] = CAST(1 AS bit) AND [f].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) + WHEN [f].[Eradicated] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsEradicated] FROM [Factions] AS [f] @@ -7533,7 +7671,10 @@ FROM [Weapons] AS [w] SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @__prm_0 <> 0 OR [w].[AmmunitionType] IS NULL +WHERE CASE + WHEN [w].[AmmunitionType] & @__prm_0 = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -7591,10 +7732,11 @@ SELECT CASE FROM [LocustLeaders] AS [l] INNER JOIN [Factions] AS [f] ON [l].[Name] = [f].[CommanderName] WHERE CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL + WHEN CASE + WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) + END = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8224,7 +8366,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_con """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +INNER JOIN [Weapons] AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [w].[Id] """); } @@ -8237,7 +8382,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_Def """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [w].[Id] """); } @@ -8255,7 +8403,10 @@ LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +) AS [s] ON CASE + WHEN [g].[FullName] = [s].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [s].[Id] """); } @@ -8268,7 +8419,10 @@ public override async Task SelectMany_without_result_selector_and_non_equality_c """ SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8322,7 +8476,10 @@ FROM [Gears] AS [g] CROSS APPLY ( SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL + WHERE CASE + WHEN [w].[OwnerFullName] = [g].[FullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [w].[Id] ) AS [w0] ORDER BY [g].[Nickname], [w0].[Id] @@ -8371,13 +8528,19 @@ public override async Task Accessing_derived_property_using_hard_and_soft_cast(b """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) +WHERE [l].[Discriminator] = N'LocustCommander' AND CASE + WHEN [l].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) +WHERE [l].[Discriminator] = N'LocustCommander' AND CASE + WHEN [l].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8692,7 +8855,7 @@ public override async Task Projecting_property_converted_to_nullable_with_condit AssertSql( """ SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[Note] <> N'K.I.A.' THEN CASE WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] END ELSE -1 @@ -8822,7 +8985,10 @@ public override async Task Projecting_property_converted_to_nullable_into_member SELECT [g].[Nickname] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +WHERE CASE + WHEN DATEPART(month, [t].[IssueDate]) = 5 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs index e33e06fcbae..642a77f81c3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs @@ -101,7 +101,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseReferencesOnBase] AS [b0] ON [b].[Id] = [b0].[BaseParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId] """); } @@ -117,7 +120,10 @@ FROM [BaseReferencesOnBase] AS [b] LEFT JOIN [BaseEntities] AS [b0] ON [b].[BaseParentId] = [b0].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b0].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b0].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId] """); } @@ -163,7 +169,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [ReferencesOnBase] AS [r] ON [b].[Id] = [r].[ParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [r].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId] """); } @@ -179,7 +188,10 @@ FROM [ReferencesOnBase] AS [r] LEFT JOIN [BaseEntities] AS [b] ON [r].[ParentId] = [b].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] -WHERE [r].[Name] <> N'Bar' OR [r].[Name] IS NULL +WHERE CASE + WHEN [r].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [r].[Id], [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId] """); } @@ -225,7 +237,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] LEFT JOIN [BaseCollectionsOnBase] AS [b2] ON [b].[Id] = [b2].[BaseParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id] """); } @@ -241,7 +256,10 @@ FROM [BaseCollectionsOnBase] AS [b] LEFT JOIN [BaseEntities] AS [b0] ON [b].[BaseParentId] = [b0].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b0].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b0].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId] """); } @@ -287,7 +305,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] LEFT JOIN [CollectionsOnBase] AS [c] ON [b].[Id] = [c].[ParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id] """); } @@ -303,7 +324,10 @@ FROM [CollectionsOnBase] AS [c] LEFT JOIN [BaseEntities] AS [b] ON [c].[ParentId] = [b].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId] """); } @@ -390,7 +414,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseReferencesOnBase] AS [b0] ON [b].[Id] = [b0].[BaseParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' AND ([b].[Name] <> N'Bar' OR [b].[Name] IS NULL) +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' AND CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId] """); } @@ -406,7 +433,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseReferencesOnDerived] AS [b0] ON [b].[Id] = [b0].[BaseParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' AND ([b].[Name] <> N'Bar' OR [b].[Name] IS NULL) +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' AND CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId] """); } @@ -426,7 +456,10 @@ FROM [BaseReferencesOnDerived] AS [b0] ) AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b2] ON [b].[Id] = [b2].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b3] ON [b].[Id] = [b3].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' AND ([b].[Name] <> N'Bar' OR [b].[Name] IS NULL) +WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' AND CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b1].[Id], [b2].[BaseInheritanceRelationshipEntityId], [b2].[Id], [b3].[DerivedInheritanceRelationshipEntityId] """); } @@ -446,7 +479,10 @@ FROM [BaseEntities] AS [b0] ) AS [b1] ON [b].[BaseParentId] = [b1].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b2] ON [b1].[Id] = [b2].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b3] ON [b1].[Id] = [b3].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b1].[Id], [b2].[BaseInheritanceRelationshipEntityId], [b2].[Id], [b3].[DerivedInheritanceRelationshipEntityId] """); } @@ -861,7 +897,10 @@ public override async Task Include_collection_with_inheritance_with_filter_split """ SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [b].[OwnedReferenceOnDerived_Id], [b].[OwnedReferenceOnDerived_Name] FROM [BaseEntities] AS [b] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -869,7 +908,10 @@ ORDER BY [b].[Id] SELECT [b2].[BaseInheritanceRelationshipEntityId], [b2].[Id], [b2].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b2] ON [b].[Id] = [b2].[BaseInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -877,7 +919,10 @@ ORDER BY [b].[Id] SELECT [b3].[DerivedInheritanceRelationshipEntityId], [b3].[Id], [b3].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b3] ON [b].[Id] = [b3].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -885,7 +930,10 @@ ORDER BY [b].[Id] SELECT [b4].[Id], [b4].[BaseParentId], [b4].[Discriminator], [b4].[Name], [b4].[DerivedProperty], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseCollectionsOnBase] AS [b4] ON [b].[Id] = [b4].[BaseParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """); } @@ -899,7 +947,10 @@ public override async Task Include_collection_with_inheritance_with_filter_rever SELECT [b].[Id], [b].[BaseParentId], [b].[Discriminator], [b].[Name], [b].[DerivedProperty], [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[BaseId], [b0].[OwnedReferenceOnBase_Id], [b0].[OwnedReferenceOnBase_Name], [b0].[OwnedReferenceOnDerived_Id], [b0].[OwnedReferenceOnDerived_Name] FROM [BaseCollectionsOnBase] AS [b] LEFT JOIN [BaseEntities] AS [b0] ON [b].[BaseParentId] = [b0].[Id] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id] """, // @@ -908,7 +959,10 @@ WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL FROM [BaseCollectionsOnBase] AS [b] LEFT JOIN [BaseEntities] AS [b0] ON [b].[BaseParentId] = [b0].[Id] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b3] ON [b0].[Id] = [b3].[BaseInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id] """, // @@ -917,7 +971,10 @@ WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL FROM [BaseCollectionsOnBase] AS [b] LEFT JOIN [BaseEntities] AS [b0] ON [b].[BaseParentId] = [b0].[Id] INNER JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b4] ON [b0].[Id] = [b4].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[Id] """); } @@ -992,7 +1049,10 @@ public override async Task Include_collection_without_inheritance_with_filter_sp """ SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [b].[OwnedReferenceOnDerived_Id], [b].[OwnedReferenceOnDerived_Name] FROM [BaseEntities] AS [b] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1000,7 +1060,10 @@ ORDER BY [b].[Id] SELECT [b2].[BaseInheritanceRelationshipEntityId], [b2].[Id], [b2].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b2] ON [b].[Id] = [b2].[BaseInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1008,7 +1071,10 @@ ORDER BY [b].[Id] SELECT [b3].[DerivedInheritanceRelationshipEntityId], [b3].[Id], [b3].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b3] ON [b].[Id] = [b3].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1016,7 +1082,10 @@ ORDER BY [b].[Id] SELECT [c].[Id], [c].[Name], [c].[ParentId], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [CollectionsOnBase] AS [c] ON [b].[Id] = [c].[ParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """); } @@ -1030,7 +1099,10 @@ public override async Task Include_collection_without_inheritance_with_filter_re SELECT [c].[Id], [c].[Name], [c].[ParentId], [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [b].[OwnedReferenceOnDerived_Id], [b].[OwnedReferenceOnDerived_Name] FROM [CollectionsOnBase] AS [c] LEFT JOIN [BaseEntities] AS [b] ON [c].[ParentId] = [b].[Id] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [b].[Id] """, // @@ -1039,7 +1111,10 @@ WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL FROM [CollectionsOnBase] AS [c] LEFT JOIN [BaseEntities] AS [b] ON [c].[ParentId] = [b].[Id] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b2] ON [b].[Id] = [b2].[BaseInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [b].[Id] """, // @@ -1048,7 +1123,10 @@ WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL FROM [CollectionsOnBase] AS [c] LEFT JOIN [BaseEntities] AS [b] ON [c].[ParentId] = [b].[Id] INNER JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b3] ON [b].[Id] = [b3].[DerivedInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [b].[Id] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs index 22f2644faff..ec982334c60 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs @@ -1003,7 +1003,10 @@ public override async Task Json_collection_index_in_predicate_using_constant(boo """ SELECT [j].[Id] FROM [JsonEntitiesBasic] AS [j] -WHERE JSON_VALUE([j].[OwnedCollectionRoot], '$[0].Name') <> N'Foo' OR JSON_VALUE([j].[OwnedCollectionRoot], '$[0].Name') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[OwnedCollectionRoot], '$[0].Name') = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1018,7 +1021,10 @@ public override async Task Json_collection_index_in_predicate_using_variable(boo SELECT [j].[Id] FROM [JsonEntitiesBasic] AS [j] -WHERE JSON_VALUE([j].[OwnedCollectionRoot], '$[' + CAST(@__prm_0 AS nvarchar(max)) + '].Name') <> N'Foo' OR JSON_VALUE([j].[OwnedCollectionRoot], '$[' + CAST(@__prm_0 AS nvarchar(max)) + '].Name') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[OwnedCollectionRoot], '$[' + CAST(@__prm_0 AS nvarchar(max)) + '].Name') = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1074,7 +1080,10 @@ public override async Task Json_collection_ElementAt_in_predicate(bool async) """ SELECT [j].[Id] FROM [JsonEntitiesBasic] AS [j] -WHERE JSON_VALUE([j].[OwnedCollectionRoot], '$[1].Name') <> N'Foo' OR JSON_VALUE([j].[OwnedCollectionRoot], '$[1].Name') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[OwnedCollectionRoot], '$[1].Name') = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1299,7 +1308,10 @@ FROM [JsonEntitiesBasic] AS [j] OUTER APPLY ( SELECT [j].[Id], JSON_VALUE([o].[value], '$.Name') AS [Name], JSON_QUERY([o].[value], '$.Names') AS [Names], CAST(JSON_VALUE([o].[value], '$.Number') AS int) AS [Number], JSON_QUERY([o].[value], '$.Numbers') AS [Numbers], JSON_QUERY([o].[value], '$.OwnedCollectionBranch') AS [c], JSON_QUERY([o].[value], '$.OwnedReferenceBranch') AS [c0], [o].[key], CAST([o].[key] AS int) AS [c1] FROM OPENJSON([j].[OwnedCollectionRoot], '$') AS [o] - WHERE JSON_VALUE([o].[value], '$.Name') <> N'Foo' OR JSON_VALUE([o].[value], '$.Name') IS NULL + WHERE CASE + WHEN JSON_VALUE([o].[value], '$.Name') = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [o0] ORDER BY [j].[Id], [o0].[c1] """); @@ -1438,7 +1450,10 @@ FROM [JsonEntitiesBasic] AS [j] OUTER APPLY ( SELECT [j].[Id], JSON_VALUE([o].[value], '$.SomethingSomething') AS [SomethingSomething], [o].[key], CAST([o].[key] AS int) AS [c] FROM OPENJSON([j].[OwnedReferenceRoot], '$.OwnedReferenceBranch.OwnedCollectionLeaf') AS [o] - WHERE JSON_VALUE([o].[value], '$.SomethingSomething') <> N'Baz' OR JSON_VALUE([o].[value], '$.SomethingSomething') IS NULL + WHERE CASE + WHEN JSON_VALUE([o].[value], '$.SomethingSomething') = N'Baz' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [o0] ORDER BY [j].[Id], [o0].[c] """); @@ -1455,7 +1470,10 @@ FROM [JsonEntitiesBasic] AS [j] OUTER APPLY ( SELECT [j].[Id], JSON_VALUE([o].[value], '$.SomethingSomething') AS [SomethingSomething], [o].[key], CAST([o].[key] AS int) AS [c] FROM OPENJSON([j].[OwnedReferenceRoot], '$.OwnedReferenceBranch.OwnedCollectionLeaf') AS [o] - WHERE JSON_VALUE([o].[value], '$.SomethingSomething') <> N'Baz' OR JSON_VALUE([o].[value], '$.SomethingSomething') IS NULL + WHERE CASE + WHEN JSON_VALUE([o].[value], '$.SomethingSomething') = N'Baz' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [o4] OUTER APPLY ( SELECT DISTINCT [j].[Id], [o0].[Name], [o0].[Names], [o0].[Number], [o0].[Numbers], [o0].[OwnedCollectionBranch] AS [c], [o0].[OwnedReferenceBranch] AS [c0] @@ -1942,7 +1960,10 @@ public override async Task Json_scalar_required_null_semantics(bool async) """ SELECT [j].[Name] FROM [JsonEntitiesBasic] AS [j] -WHERE CAST(JSON_VALUE([j].[OwnedReferenceRoot], '$.Number') AS int) <> CAST(LEN(JSON_VALUE([j].[OwnedReferenceRoot], '$.Name')) AS int) OR JSON_VALUE([j].[OwnedReferenceRoot], '$.Name') IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[OwnedReferenceRoot], '$.Number') AS int) = CAST(LEN(JSON_VALUE([j].[OwnedReferenceRoot], '$.Name')) AS int) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2357,7 +2378,10 @@ public override async Task Json_predicate_on_default_string(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE JSON_VALUE([j].[Reference], '$.TestDefaultString') <> N'MyDefaultStringInReference1' OR JSON_VALUE([j].[Reference], '$.TestDefaultString') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[Reference], '$.TestDefaultString') = N'MyDefaultStringInReference1' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2369,7 +2393,10 @@ public override async Task Json_predicate_on_max_length_string(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE JSON_VALUE([j].[Reference], '$.TestMaxLengthString') <> N'Foo' OR JSON_VALUE([j].[Reference], '$.TestMaxLengthString') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[Reference], '$.TestMaxLengthString') = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2396,7 +2423,10 @@ public override async Task Json_predicate_on_byte(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestByte') AS tinyint) <> CAST(3 AS tinyint) OR CAST(JSON_VALUE([j].[Reference], '$.TestByte') AS tinyint) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestByte') AS tinyint) = CAST(3 AS tinyint) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2409,7 +2439,10 @@ public override async Task Json_predicate_on_byte_array(bool async) SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] OUTER APPLY OPENJSON([j].[Reference]) WITH ([TestByteArray] varbinary(max) '$.TestByteArray') AS [t] -WHERE [t].[TestByteArray] <> 0x010203 OR [t].[TestByteArray] IS NULL +WHERE CASE + WHEN [t].[TestByteArray] = 0x010203 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2421,7 +2454,10 @@ public override async Task Json_predicate_on_character(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE JSON_VALUE([j].[Reference], '$.TestCharacter') <> N'z' OR JSON_VALUE([j].[Reference], '$.TestCharacter') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[Reference], '$.TestCharacter') = N'z' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2433,7 +2469,10 @@ public override async Task Json_predicate_on_datetime(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestDateTime') AS datetime2) <> '2000-01-03T00:00:00.0000000' OR CAST(JSON_VALUE([j].[Reference], '$.TestDateTime') AS datetime2) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestDateTime') AS datetime2) = '2000-01-03T00:00:00.0000000' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2445,7 +2484,10 @@ public override async Task Json_predicate_on_datetimeoffset(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestDateTimeOffset') AS datetimeoffset) <> '2000-01-04T00:00:00.0000000+03:02' OR CAST(JSON_VALUE([j].[Reference], '$.TestDateTimeOffset') AS datetimeoffset) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestDateTimeOffset') AS datetimeoffset) = '2000-01-04T00:00:00.0000000+03:02' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2457,7 +2499,10 @@ public override async Task Json_predicate_on_decimal(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestDecimal') AS decimal(18,3)) <> 1.35 OR CAST(JSON_VALUE([j].[Reference], '$.TestDecimal') AS decimal(18,3)) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestDecimal') AS decimal(18,3)) = 1.35 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2469,7 +2514,10 @@ public override async Task Json_predicate_on_double(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestDouble') AS float) <> 33.25E0 OR CAST(JSON_VALUE([j].[Reference], '$.TestDouble') AS float) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestDouble') AS float) = 33.25E0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2481,7 +2529,10 @@ public override async Task Json_predicate_on_enum(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestEnum') AS int) <> 2 OR CAST(JSON_VALUE([j].[Reference], '$.TestEnum') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestEnum') AS int) = 2 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2493,7 +2544,10 @@ public override async Task Json_predicate_on_enumwithintconverter(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestEnumWithIntConverter') AS int) <> -3 OR CAST(JSON_VALUE([j].[Reference], '$.TestEnumWithIntConverter') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestEnumWithIntConverter') AS int) = -3 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2505,7 +2559,10 @@ public override async Task Json_predicate_on_guid(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestGuid') AS uniqueidentifier) <> '00000000-0000-0000-0000-000000000000' OR CAST(JSON_VALUE([j].[Reference], '$.TestGuid') AS uniqueidentifier) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestGuid') AS uniqueidentifier) = '00000000-0000-0000-0000-000000000000' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2517,7 +2574,10 @@ public override async Task Json_predicate_on_int16(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestInt16') AS smallint) <> CAST(3 AS smallint) OR CAST(JSON_VALUE([j].[Reference], '$.TestInt16') AS smallint) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestInt16') AS smallint) = CAST(3 AS smallint) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2529,7 +2589,10 @@ public override async Task Json_predicate_on_int32(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestInt32') AS int) <> 33 OR CAST(JSON_VALUE([j].[Reference], '$.TestInt32') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestInt32') AS int) = 33 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2541,7 +2604,10 @@ public override async Task Json_predicate_on_int64(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestInt64') AS bigint) <> CAST(333 AS bigint) OR CAST(JSON_VALUE([j].[Reference], '$.TestInt64') AS bigint) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestInt64') AS bigint) = CAST(333 AS bigint) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2553,7 +2619,10 @@ public override async Task Json_predicate_on_nullableenum1(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestNullableEnum') AS int) <> -1 OR CAST(JSON_VALUE([j].[Reference], '$.TestNullableEnum') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestNullableEnum') AS int) = -1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2577,7 +2646,10 @@ public override async Task Json_predicate_on_nullableenumwithconverter1(bool asy """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestNullableEnumWithIntConverter') AS int) <> 2 OR CAST(JSON_VALUE([j].[Reference], '$.TestNullableEnumWithIntConverter') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestNullableEnumWithIntConverter') AS int) = 2 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2601,7 +2673,10 @@ public override async Task Json_predicate_on_nullableenumwithconverterthathandle """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE JSON_VALUE([j].[Reference], '$.TestNullableEnumWithConverterThatHandlesNulls') <> N'One' OR JSON_VALUE([j].[Reference], '$.TestNullableEnumWithConverterThatHandlesNulls') IS NULL +WHERE CASE + WHEN JSON_VALUE([j].[Reference], '$.TestNullableEnumWithConverterThatHandlesNulls') = N'One' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2623,7 +2698,10 @@ public override async Task Json_predicate_on_nullableint321(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestNullableInt32') AS int) <> 100 OR CAST(JSON_VALUE([j].[Reference], '$.TestNullableInt32') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestNullableInt32') AS int) = 100 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2647,7 +2725,10 @@ public override async Task Json_predicate_on_signedbyte(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestSignedByte') AS smallint) <> CAST(100 AS smallint) OR CAST(JSON_VALUE([j].[Reference], '$.TestSignedByte') AS smallint) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestSignedByte') AS smallint) = CAST(100 AS smallint) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2659,7 +2740,10 @@ public override async Task Json_predicate_on_single(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestSingle') AS real) <> CAST(10.4 AS real) OR CAST(JSON_VALUE([j].[Reference], '$.TestSingle') AS real) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestSingle') AS real) = CAST(10.4 AS real) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2671,7 +2755,10 @@ public override async Task Json_predicate_on_timespan(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestTimeSpan') AS time) <> '03:02:00' OR CAST(JSON_VALUE([j].[Reference], '$.TestTimeSpan') AS time) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestTimeSpan') AS time) = '03:02:00' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2683,7 +2770,10 @@ public override async Task Json_predicate_on_dateonly(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestDateOnly') AS date) <> '0003-02-01' OR CAST(JSON_VALUE([j].[Reference], '$.TestDateOnly') AS date) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestDateOnly') AS date) = '0003-02-01' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2695,7 +2785,10 @@ public override async Task Json_predicate_on_timeonly(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestTimeOnly') AS time) <> '03:02:00' OR CAST(JSON_VALUE([j].[Reference], '$.TestTimeOnly') AS time) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestTimeOnly') AS time) = '03:02:00' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2707,7 +2800,10 @@ public override async Task Json_predicate_on_unisgnedint16(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt16') AS int) <> 100 OR CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt16') AS int) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt16') AS int) = 100 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2719,7 +2815,10 @@ public override async Task Json_predicate_on_unsignedint32(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt32') AS bigint) <> CAST(1000 AS bigint) OR CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt32') AS bigint) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt32') AS bigint) = CAST(1000 AS bigint) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2731,7 +2830,10 @@ public override async Task Json_predicate_on_unsignedint64(bool async) """ SELECT [j].[Id], [j].[TestBooleanCollection], [j].[TestBooleanCollectionCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestCharacterCollectionCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDefaultStringCollectionCollection], [j].[TestDoubleCollection], [j].[TestDoubleCollectionCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt16CollectionCollection], [j].[TestInt32Collection], [j].[TestInt32CollectionCollection], [j].[TestInt64Collection], [j].[TestInt64CollectionCollection], [j].[TestMaxLengthStringCollection], [j].[TestMaxLengthStringCollectionCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumCollectionCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableEnumWithIntConverterCollectionCollection], [j].[TestNullableInt32Collection], [j].[TestNullableInt32CollectionCollection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestSingleCollectionCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] -WHERE CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt64') AS decimal(20,0)) <> 10000.0 OR CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt64') AS decimal(20,0)) IS NULL +WHERE CASE + WHEN CAST(JSON_VALUE([j].[Reference], '$.TestUnsignedInt64') AS decimal(20,0)) = 10000.0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index 4db5547df79..19b8a709f9a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -616,7 +616,10 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> N'ALFKI' OR [o].[CustomerID] IS NULL) THEN CAST(1 AS bit) + WHERE CASE + WHEN [o].[CustomerID] = N'ALFKI' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -1247,7 +1250,10 @@ public override async Task OrderBy_Where_Count_with_predicate(bool async) """ SELECT COUNT(*) FROM [Orders] AS [o] -WHERE [o].[OrderID] > 10 AND ([o].[CustomerID] <> N'ALFKI' OR [o].[CustomerID] IS NULL) +WHERE [o].[OrderID] > 10 AND CASE + WHEN [o].[CustomerID] = N'ALFKI' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2552,7 +2558,10 @@ ELSE CAST(0 AS bit) WHEN EXISTS ( SELECT 1 FROM [Orders] AS [o1] - WHERE ([o1].[CustomerID] <> N'VINET' OR [o1].[CustomerID] IS NULL) AND [o1].[EmployeeID] IS NULL) THEN CAST(1 AS bit) + WHERE CASE + WHEN [o1].[CustomerID] = N'VINET' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND [o1].[EmployeeID] IS NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs index 17cc4dd1b7b..64d09a3926a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs @@ -105,7 +105,10 @@ public override async Task Applied_after_navigation_expansion(bool async) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -WHERE [c].[City] <> N'London' OR [c].[City] IS NULL +WHERE CASE + WHEN [c].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs index da37c8b4f3c..0ecda7e2d48 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs @@ -1034,7 +1034,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index beb327c5ac4..7075cb92c3b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -41,7 +41,10 @@ FROM [Orders] AS [o] SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE [o].[OrderDate] <> @__myDatetime_0 OR [o].[OrderDate] IS NULL +WHERE CASE + WHEN [o].[OrderDate] = @__myDatetime_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -667,7 +670,10 @@ 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] -WHERE [c].[ContactTitle] = N'Owner' AND ([c].[Country] <> N'USA' OR [c].[Country] IS NULL) +WHERE [c].[ContactTitle] = N'Owner' AND CASE + WHEN [c].[Country] = N'USA' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -901,7 +907,10 @@ 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] -WHERE [c].[ContactTitle] = N'Owner' AND ([c].[Country] <> N'USA' OR [c].[Country] IS NULL) +WHERE [c].[ContactTitle] = N'Owner' AND CASE + WHEN [c].[Country] = N'USA' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -923,7 +932,10 @@ FROM [Orders] AS [o] SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE [o].[OrderDate] <> @__myDatetime_0 OR [o].[OrderDate] IS NULL +WHERE CASE + WHEN [o].[OrderDate] = @__myDatetime_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs index b0bd1c81497..da3f48f286b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs @@ -2050,7 +2050,10 @@ WHEN NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] GROUP BY [o].[CustomerID] - HAVING [o].[CustomerID] <> N'ALFKI' OR [o].[CustomerID] IS NULL) THEN CAST(1 AS bit) + HAVING CASE + WHEN [o].[CustomerID] = N'ALFKI' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs index 2481d8e6f9d..431166f8fe5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs @@ -1245,7 +1245,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index 7b7256de090..d5728abc940 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -758,7 +758,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index ef9132bcc54..f024b2c69c1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -671,7 +671,10 @@ FROM [Employees] AS [e] WHERE ( SELECT TOP(1) [e0].[EmployeeID] FROM [Employees] AS [e0] - WHERE [e0].[EmployeeID] <> [e].[ReportsTo] OR [e].[ReportsTo] IS NULL + WHERE CASE + WHEN [e0].[EmployeeID] = [e].[ReportsTo] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [e0].[EmployeeID]) = 1 """); } @@ -687,7 +690,10 @@ FROM [Employees] AS [e] WHERE ( SELECT TOP(1) [e0].[EmployeeID] FROM [Employees] AS [e0] - WHERE [e0].[EmployeeID] <> [e].[ReportsTo] OR [e].[ReportsTo] IS NULL) = 0 + WHERE CASE + WHEN [e0].[EmployeeID] = [e].[ReportsTo] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) = 0 """); } @@ -702,7 +708,10 @@ FROM [Employees] AS [e] WHERE ( SELECT TOP(1) [e0].[EmployeeID] FROM [Employees] AS [e0] - WHERE [e0].[EmployeeID] <> [e].[ReportsTo] OR [e].[ReportsTo] IS NULL) = 0 + WHERE CASE + WHEN [e0].[EmployeeID] = [e].[ReportsTo] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) = 0 """); } @@ -717,7 +726,10 @@ FROM [Employees] AS [e] WHERE ( SELECT TOP(1) [e0].[EmployeeID] FROM [Employees] AS [e0] - WHERE [e0].[EmployeeID] <> [e].[ReportsTo] OR [e].[ReportsTo] IS NULL) = 0 + WHERE CASE + WHEN [e0].[EmployeeID] = [e].[ReportsTo] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) = 0 """); } @@ -1521,7 +1533,10 @@ public override async Task Any_nested_negated2(bool async) """ SELECT [c].[CustomerID], [c].[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 CASE + WHEN [c].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] WHERE [o].[CustomerID] LIKE N'ABC%') @@ -1539,7 +1554,10 @@ FROM [Customers] AS [c] WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] LIKE N'ABC%') AND ([c].[City] <> N'London' OR [c].[City] IS NULL) + WHERE [o].[CustomerID] LIKE N'ABC%') AND CASE + WHEN [c].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1566,7 +1584,10 @@ public override async Task Any_nested2(bool async) """ SELECT [c].[CustomerID], [c].[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 EXISTS ( +WHERE CASE + WHEN [c].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND EXISTS ( SELECT 1 FROM [Orders] AS [o] WHERE [o].[CustomerID] LIKE N'A%') @@ -1584,7 +1605,10 @@ 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] LIKE N'A%') AND CASE + WHEN [c].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2491,25 +2515,19 @@ public override async Task OrderBy_correlated_subquery2(bool async) """ SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE [o].[OrderID] <= 10250 AND (( - 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) <> 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) +WHERE [o].[OrderID] <= 10250 AND CASE + WHEN ( + 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) = N'Nowhere' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2844,7 +2862,7 @@ public override async Task OrderBy_comparison_operator(bool async) SELECT [c].[CustomerID], [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' AND [c].[Region] IS NOT NULL THEN CAST(1 AS bit) + WHEN [c].[Region] = N'ASK' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -5131,15 +5149,14 @@ FROM [Orders] AS [o0] WHERE [c].[CustomerID] = [o0].[CustomerID] ORDER BY [o0].[OrderDate]) AS [A] FROM [Customers] AS [c] -WHERE [c].[CustomerID] LIKE N'A%' AND (( - SELECT TOP(1) [o].[OrderID] - FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] - ORDER BY [o].[OrderDate]) <> 0 OR ( - SELECT TOP(1) [o].[OrderID] - FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] - ORDER BY [o].[OrderDate]) IS NULL) +WHERE [c].[CustomerID] LIKE N'A%' AND CASE + WHEN ( + SELECT TOP(1) [o].[OrderID] + FROM [Orders] AS [o] + WHERE [c].[CustomerID] = [o].[CustomerID] + ORDER BY [o].[OrderDate]) = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs index 6fab28fb8c7..9dc0edc2f89 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs @@ -293,7 +293,10 @@ public override async Task Select_Where_Navigation_Multiple_Access(bool async) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -WHERE [c].[City] = N'Seattle' AND ([c].[Phone] <> N'555 555 5555' OR [c].[Phone] IS NULL) +WHERE [c].[City] = N'Seattle' AND CASE + WHEN [c].[Phone] = N'555 555 5555' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -306,7 +309,10 @@ public override async Task Select_Navigations_Where_Navigations(bool async) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -WHERE [c].[City] = N'Seattle' AND ([c].[Phone] <> N'555 555 5555' OR [c].[Phone] IS NULL) +WHERE [c].[City] = N'Seattle' AND CASE + WHEN [c].[Phone] = N'555 555 5555' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -319,7 +325,10 @@ public override async Task Select_Singleton_Navigation_With_Member_Access(bool a SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -WHERE [c].[City] = N'Seattle' AND ([c].[Phone] <> N'555 555 5555' OR [c].[Phone] IS NULL) +WHERE [c].[City] = N'Seattle' AND CASE + WHEN [c].[Phone] = N'555 555 5555' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -349,7 +358,10 @@ public override async Task Singleton_Navigation_With_Member_Access(bool async) SELECT [c].[City] AS [B] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -WHERE [c].[City] = N'Seattle' AND ([c].[Phone] <> N'555 555 5555' OR [c].[Phone] IS NULL) +WHERE [c].[City] = N'Seattle' AND CASE + WHEN [c].[Phone] = N'555 555 5555' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -576,7 +588,10 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] AND ([o].[CustomerID] <> N'ALFKI' OR [o].[CustomerID] IS NULL)) THEN CAST(1 AS bit) + WHERE [c].[CustomerID] = [o].[CustomerID] AND CASE + WHEN [o].[CustomerID] = N'ALFKI' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [All] FROM [Customers] AS [c] @@ -594,7 +609,10 @@ FROM [Customers] AS [c] WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID] AND ([o].[CustomerID] <> N'ALFKI' OR [o].[CustomerID] IS NULL)) + WHERE [c].[CustomerID] = [o].[CustomerID] AND CASE + WHEN [o].[CustomerID] = N'ALFKI' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index 30732589058..a6df431bc53 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -422,13 +422,13 @@ SELECT COALESCE(( SELECT TOP(1) COALESCE(( SELECT TOP(1) [o0].[ProductID] FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID] AND ([o0].[OrderID] <> ( - SELECT COUNT(*) - FROM [Orders] AS [o1] - WHERE [c].[CustomerID] = [o1].[CustomerID]) OR ( - SELECT COUNT(*) - FROM [Orders] AS [o1] - WHERE [c].[CustomerID] = [o1].[CustomerID]) IS NULL) + WHERE [o].[OrderID] = [o0].[OrderID] AND CASE + WHEN [o0].[OrderID] = ( + SELECT COUNT(*) + FROM [Orders] AS [o1] + WHERE [c].[CustomerID] = [o1].[CustomerID]) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [o0].[OrderID], [o0].[ProductID]), 0) FROM [Orders] AS [o] WHERE [c].[CustomerID] = [o].[CustomerID] AND [o].[OrderID] < 10500 @@ -1175,7 +1175,7 @@ public override async Task Projecting_nullable_struct(bool async) AssertSql( """ SELECT [o].[CustomerID], CASE - WHEN [o].[CustomerID] = N'ALFKI' AND [o].[CustomerID] IS NOT NULL THEN CAST(1 AS bit) + WHEN [o].[CustomerID] = N'ALFKI' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [o].[OrderID], CAST(LEN([o].[CustomerID]) AS int) FROM [Orders] AS [o] @@ -1297,7 +1297,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT [c].[City] FROM [Orders] AS [o] - WHERE [c].[CustomerID] <> [o].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [c].[CustomerID] = [o].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [o0] """); } @@ -1313,7 +1316,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(2) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] - WHERE [c].[CustomerID] <> [o].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [c].[CustomerID] = [o].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[City], [o].[OrderID] ) AS [o0] """); @@ -1917,7 +1923,7 @@ public override async Task Projection_custom_type_in_both_sides_of_ternary(bool AssertSql( """ SELECT CASE - WHEN [c].[City] = N'Seattle' AND [c].[City] IS NOT NULL THEN CAST(1 AS bit) + WHEN [c].[City] = N'Seattle' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Customers] AS [c] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs index 9113c9c34ee..68160622533 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs @@ -2463,7 +2463,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] WHERE [c].[CustomerID] LIKE N'F%' @@ -2476,7 +2479,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] INNER JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs index 3c7f3cd592a..80805ad6918 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs @@ -1070,7 +1070,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] WHERE [c].[CustomerID] LIKE N'F%' @@ -1083,7 +1086,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] INNER JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs index 81178b22899..fc8fbca2bc1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs @@ -1034,7 +1034,10 @@ FROM [Customers] AS [c] OUTER APPLY ( SELECT TOP(5) [o].[OrderID] FROM [Orders] AS [o] - WHERE [o].[CustomerID] <> [c].[CustomerID] OR [o].[CustomerID] IS NULL + WHERE CASE + WHEN [o].[CustomerID] = [c].[CustomerID] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [c].[CustomerID] ) AS [o0] LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index c40a5fc7c4a..afa0f5a1ddd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -795,7 +795,10 @@ public override async Task Where_string_indexof(bool async) """ SELECT [c].[CustomerID], [c].[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'Sea', [c].[City]) - 1 <> -1 OR [c].[City] IS NULL +WHERE CASE + WHEN CHARINDEX(N'Sea', [c].[City]) - 1 = -1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1018,7 +1021,10 @@ public override async Task Where_datetimeoffset_utcnow_component(bool async) """ SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE CAST([o].[OrderDate] AS datetimeoffset) <> CAST(SYSUTCDATETIME() AS datetimeoffset) OR [o].[OrderDate] IS NULL +WHERE CASE + WHEN CAST([o].[OrderDate] AS datetimeoffset) = CAST(SYSUTCDATETIME() AS datetimeoffset) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1138,7 +1144,13 @@ public override async Task Where_not_in_optimization1(bool async) 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 [Customers] AS [c] CROSS JOIN [Employees] AS [e] -WHERE ([c].[City] <> N'London' OR [c].[City] IS NULL) AND ([e].[City] <> N'London' OR [e].[City] IS NULL) +WHERE CASE + WHEN [c].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [e].[City] = N'London' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index ea689bb61c3..99fa0ec41c6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -34,7 +34,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableIntA] = [e].[IntB] AND [e].[NullableIntA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableIntA] = [e].[IntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -48,7 +48,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[IntA] = [e].[NullableIntB] AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -87,8 +87,8 @@ WHERE [e].[IntA] <> [e].[IntB] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableIntA] <> [e].[IntB] OR [e].[NullableIntA] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableIntA] = [e].[IntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -96,13 +96,16 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] <> [e].[IntB] OR [e].[NullableIntA] IS NULL +WHERE CASE + WHEN [e].[NullableIntA] = [e].[IntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -110,7 +113,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[IntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL +WHERE CASE + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -140,8 +146,8 @@ WHERE [e].[IntA] <> [e].[IntB] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableIntA] <> [e].[IntB] OR [e].[NullableIntA] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableIntA] = [e].[IntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -149,13 +155,16 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] <> [e].[IntB] OR [e].[NullableIntA] IS NULL +WHERE CASE + WHEN [e].[NullableIntA] = [e].[IntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -163,7 +172,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[IntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL +WHERE CASE + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -193,7 +205,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableIntA] = [e].[IntB] AND [e].[NullableIntA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableIntA] = [e].[IntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -207,7 +219,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[IntA] = [e].[NullableIntB] AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -252,7 +264,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -277,7 +289,7 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -291,7 +303,7 @@ WHERE [e].[BoolA] <> [e].[NullableBoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -319,7 +331,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] <> [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] <> [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -358,7 +370,7 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -383,7 +395,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -397,7 +409,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] <> [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] <> [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -425,7 +437,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -464,8 +476,8 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -473,7 +485,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -489,8 +504,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -503,8 +518,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -512,7 +527,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -531,8 +549,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -570,8 +588,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -595,8 +613,8 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -604,13 +622,16 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -637,8 +658,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -646,7 +667,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -676,8 +700,8 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -685,7 +709,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -701,8 +728,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -715,8 +742,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -724,7 +751,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -743,8 +773,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -782,8 +812,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -807,8 +837,8 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -816,13 +846,16 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -849,8 +882,8 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [X] FROM [Entities1] AS [e] """, @@ -858,7 +891,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -888,7 +924,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -913,7 +949,7 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -927,7 +963,7 @@ WHERE [e].[BoolA] <> [e].[NullableBoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -955,7 +991,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] <> [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] <> [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -994,7 +1030,7 @@ WHERE [e].[BoolA] <> [e].[BoolB] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] <> [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] <> [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -1019,7 +1055,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[BoolA] = [e].[NullableBoolB] AND [e].[NullableBoolB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -1033,7 +1069,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] <> [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] <> [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -1061,7 +1097,7 @@ FROM [Entities1] AS [e] // """ SELECT [e].[Id], CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [X] FROM [Entities1] AS [e] @@ -1222,13 +1258,19 @@ WHERE [e].[BoolA] <> [e].[BoolB] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -1312,13 +1354,19 @@ WHERE [e].[BoolA] <> [e].[BoolB] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -1342,13 +1390,19 @@ WHERE [e].[BoolA] <> [e].[BoolB] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -1432,13 +1486,19 @@ WHERE [e].[BoolA] <> [e].[BoolB] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -1642,13 +1702,19 @@ WHERE [e].[BoolA] <> [e].[BoolB] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -1672,13 +1738,19 @@ WHERE [e].[BoolA] <> [e].[BoolB] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[BoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL +WHERE CASE + WHEN [e].[BoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableBoolA] <> [e].[BoolB] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -1703,10 +1775,10 @@ FROM [Entities1] AS [e] SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END = CASE - WHEN [e].[IntA] = [e].[NullableIntB] AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """, @@ -1739,10 +1811,10 @@ FROM [Entities1] AS [e] SELECT [e].[Id] FROM [Entities1] AS [e] WHERE CASE - WHEN [e].[NullableBoolA] = [e].[BoolB] AND [e].[NullableBoolA] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[NullableBoolA] = [e].[BoolB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END <> CASE - WHEN [e].[IntA] = [e].[NullableIntB] AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """, @@ -1775,10 +1847,10 @@ FROM [Entities1] AS [e] 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END = CASE - WHEN [e].[IntA] = [e].[NullableIntB] AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """, @@ -1811,10 +1883,10 @@ FROM [Entities1] AS [e] 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END <> CASE - WHEN [e].[IntA] = [e].[NullableIntB] AND [e].[NullableIntB] IS NOT NULL THEN CAST(1 AS bit) + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """, @@ -1847,11 +1919,11 @@ FROM [Entities1] AS [e] 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] THEN CAST(0 AS bit) + ELSE CAST(1 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END """, // @@ -1883,11 +1955,11 @@ FROM [Entities1] AS [e] 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] THEN CAST(0 AS bit) + ELSE CAST(1 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] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END """, // @@ -1912,7 +1984,10 @@ public override async Task Compare_simple_expression(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] + [e].[IntB] <> [e].[IntC] OR [e].[NullableIntA] IS NULL +WHERE CASE + WHEN [e].[NullableIntA] + [e].[IntB] = [e].[IntC] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1924,7 +1999,10 @@ public override async Task Compare_complex_expression_not_duplicated(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] + [e].[NullableIntB] <> [e].[IntC] OR [e].[NullableIntA] IS NULL OR [e].[NullableIntB] IS NULL +WHERE CASE + WHEN [e].[NullableIntA] + [e].[NullableIntB] = [e].[IntC] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2092,7 +2170,10 @@ public override async Task Where_multiple_ands_with_nullable_parameter_and_const SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableStringA] <> N'Foo' OR [e].[NullableStringA] IS NULL) AND [e].[NullableStringA] IS NOT NULL AND [e].[NullableStringA] <> @__prm3_2 +WHERE CASE + WHEN [e].[NullableStringA] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [e].[NullableStringA] IS NOT NULL AND [e].[NullableStringA] <> @__prm3_2 """); } @@ -2106,7 +2187,10 @@ public override async Task Where_multiple_ands_with_nullable_parameter_and_const 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] <> @__prm3_2 +WHERE [e].[NullableStringB] IS NOT NULL AND CASE + WHEN [e].[NullableStringA] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [e].[NullableStringA] IS NOT NULL AND [e].[NullableStringA] <> @__prm3_2 """); } @@ -2268,10 +2352,13 @@ public override async Task Where_equal_with_conditional_non_nullable(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringC] <> CASE - WHEN [e].[NullableStringA] = [e].[NullableStringB] OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[StringA] - ELSE [e].[StringB] -END OR [e].[NullableStringC] IS NULL +WHERE CASE + WHEN [e].[NullableStringC] = CASE + WHEN [e].[NullableStringA] = [e].[NullableStringB] OR ([e].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL) THEN [e].[StringA] + ELSE [e].[StringB] + END THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2294,8 +2381,8 @@ public override async Task Null_comparison_in_selector_with_relational_nulls(boo AssertSql( """ SELECT CASE - WHEN [e].[NullableStringA] <> N'Foo' OR [e].[NullableStringA] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableStringA] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END FROM [Entities1] AS [e] """); @@ -2310,11 +2397,11 @@ public override async Task Null_comparison_in_order_by_with_relational_nulls(boo 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' OR [e].[NullableStringA] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableStringA] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END, CASE - WHEN [e].[NullableIntB] <> 10 OR [e].[NullableIntB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableIntB] = 10 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END """); } @@ -2803,7 +2890,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE COALESCE([e].[NullableBoolB], [e].[BoolC]) <> [e].[NullableBoolA] OR [e].[NullableBoolA] IS NULL +WHERE CASE + WHEN COALESCE([e].[NullableBoolB], [e].[BoolC]) = [e].[NullableBoolA] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -3186,7 +3276,10 @@ WHERE [e].[IntA] IN (1, 2, [e].[NullableIntB]) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[IntA] NOT IN (1, 2) AND ([e].[IntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL) +WHERE [e].[IntA] NOT IN (1, 2) AND CASE + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3204,7 +3297,10 @@ WHERE [e].[IntA] IN (1, 2, [e].[NullableIntB]) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[IntA] NOT IN (1, 2) AND ([e].[IntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL) +WHERE [e].[IntA] NOT IN (1, 2) AND CASE + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3317,7 +3413,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[IntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL +WHERE CASE + WHEN [e].[IntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3335,7 +3434,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] <> 1 OR [e].[NullableIntA] IS NULL +WHERE CASE + WHEN [e].[NullableIntA] = 1 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -3473,7 +3575,10 @@ FROM [Entities1] AS [e] """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] IS NOT NULL AND ([e].[NullableIntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL) +WHERE [e].[NullableIntA] IS NOT NULL AND CASE + WHEN [e].[NullableIntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -3503,13 +3608,22 @@ public override async Task Null_semantics_with_null_check_complex(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] IS NOT NULL AND ([e].[NullableIntC] <> [e].[NullableIntA] OR [e].[NullableIntC] IS NULL OR ([e].[NullableIntB] IS NOT NULL AND [e].[NullableIntA] <> [e].[NullableIntB])) +WHERE [e].[NullableIntA] IS NOT NULL AND (CASE + WHEN [e].[NullableIntC] = [e].[NullableIntA] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) OR ([e].[NullableIntB] IS NOT NULL AND [e].[NullableIntA] <> [e].[NullableIntB])) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableIntA] IS NOT NULL AND ([e].[NullableIntC] <> [e].[NullableIntA] OR [e].[NullableIntC] IS NULL OR [e].[NullableIntA] <> [e].[NullableIntB] OR [e].[NullableIntB] IS NULL) +WHERE [e].[NullableIntA] IS NOT NULL AND (CASE + WHEN [e].[NullableIntC] = [e].[NullableIntA] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) OR CASE + WHEN [e].[NullableIntA] = [e].[NullableIntB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit)) """, // """ @@ -3527,13 +3641,25 @@ public override async Task Null_semantics_with_null_check_complex2(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL AND ([e].[NullableBoolB] <> [e].[NullableBoolA] OR [e].[NullableBoolC] IS NOT NULL) AND ([e].[NullableBoolC] <> [e].[NullableBoolB] OR [e].[NullableBoolC] IS NULL)) OR [e].[NullableBoolC] <> [e].[BoolB] OR [e].[NullableBoolC] IS NULL +WHERE ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL AND ([e].[NullableBoolB] <> [e].[NullableBoolA] OR [e].[NullableBoolC] IS NOT NULL) AND CASE + WHEN [e].[NullableBoolC] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit)) OR CASE + WHEN [e].[NullableBoolC] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL AND ([e].[NullableBoolB] <> [e].[NullableBoolA] OR [e].[NullableBoolC] IS NOT NULL) AND ([e].[NullableBoolC] <> [e].[NullableBoolB] OR [e].[NullableBoolC] IS NULL)) OR [e].[NullableBoolB] <> [e].[BoolB] OR [e].[NullableBoolB] IS NULL +WHERE ([e].[NullableBoolA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL AND ([e].[NullableBoolB] <> [e].[NullableBoolA] OR [e].[NullableBoolC] IS NOT NULL) AND CASE + WHEN [e].[NullableBoolC] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit)) OR CASE + WHEN [e].[NullableBoolB] = [e].[BoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3699,7 +3825,10 @@ public override async Task Nullable_column_info_propagates_inside_binary_OrElse_ """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE (([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL) OR [e].[NullableStringA] IS NOT NULL) AND ([e].[NullableStringA] <> [e].[NullableStringB] OR [e].[NullableStringB] IS NULL) +WHERE (([e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL) OR [e].[NullableStringA] IS NOT NULL) AND CASE + WHEN [e].[NullableStringA] = [e].[NullableStringB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -3736,8 +3865,8 @@ SELECT CASE WHEN [e].[NullableStringA] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Foo], CASE - WHEN [e].[NullableStringA] <> [e].[StringA] OR [e].[NullableStringA] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableStringA] = [e].[StringA] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [Bar] FROM [Entities1] AS [e] """); @@ -3764,7 +3893,10 @@ public override async Task Nullable_column_info_propagation_complex(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE [e].[NullableStringA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL AND [e].[NullableStringC] IS NOT NULL AND ([e].[NullableBoolB] <> [e].[NullableBoolC] OR [e].[NullableBoolC] IS NULL) +WHERE [e].[NullableStringA] IS NOT NULL AND [e].[NullableBoolB] IS NOT NULL AND [e].[NullableStringC] IS NOT NULL AND CASE + WHEN [e].[NullableBoolB] = [e].[NullableBoolC] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3918,11 +4050,7 @@ WHEN CASE WHEN [e].[StringA] = N'Foo' THEN 3 WHEN [e].[StringB] = N'Foo' THEN 2 WHEN [e].[StringC] = N'Foo' THEN 3 - END = 2 AND CASE - WHEN [e].[StringA] = N'Foo' THEN 3 - WHEN [e].[StringB] = N'Foo' THEN 2 - WHEN [e].[StringC] = N'Foo' THEN 3 - END IS NOT NULL THEN CAST(1 AS bit) + END = 2 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Entities1] AS [e] @@ -3941,11 +4069,7 @@ WHEN CASE WHEN [e].[StringA] = N'Foo' THEN 3 WHEN [e].[StringB] = N'Foo' THEN 2 WHEN [e].[StringC] = N'Foo' THEN 3 - END = 3 AND CASE - WHEN [e].[StringA] = N'Foo' THEN 3 - WHEN [e].[StringB] = N'Foo' THEN 2 - WHEN [e].[StringC] = N'Foo' THEN 3 - END IS NOT NULL THEN CAST(1 AS bit) + END = 3 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Entities1] AS [e] @@ -4331,7 +4455,10 @@ public override async Task Is_null_on_column_followed_by_OrElse_optimizes_nullab """ 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] -WHERE ([e].[NullableStringA] IS NULL AND ([e].[StringA] = N'Foo' OR [e].[NullableStringA] IS NULL OR [e].[NullableStringB] IS NULL)) OR [e].[NullableStringA] <> [e].[NullableStringB] OR [e].[NullableStringB] IS NULL +WHERE ([e].[NullableStringA] IS NULL AND ([e].[StringA] = N'Foo' OR [e].[NullableStringA] IS NULL OR [e].[NullableStringB] IS NULL)) OR CASE + WHEN [e].[NullableStringA] = [e].[NullableStringB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4405,11 +4532,11 @@ public override async Task Is_null_on_column_followed_by_OrElse_optimizes_nullab FROM [Entities1] AS [e] WHERE [e].[NullableBoolA] IS NULL OR CASE WHEN [e].[NullableBoolB] IS NULL THEN CASE - WHEN [e].[NullableBoolB] <> [e].[NullableBoolA] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableBoolB] = [e].[NullableBoolA] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END - WHEN [e].[NullableBoolA] <> [e].[NullableBoolB] OR [e].[NullableBoolB] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [e].[NullableBoolA] = [e].[NullableBoolB] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END = CAST(1 AS bit) """); } @@ -4442,8 +4569,8 @@ public override async Task Sum_function_is_always_considered_non_nullable(bool a AssertSql( """ SELECT [e].[NullableIntA] AS [Key], CASE - WHEN COALESCE(SUM([e].[IntA]), 0) <> [e].[NullableIntA] OR [e].[NullableIntA] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN COALESCE(SUM([e].[IntA]), 0) = [e].[NullableIntA] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) END AS [Sum] FROM [Entities1] AS [e] GROUP BY [e].[NullableIntA] @@ -4458,7 +4585,10 @@ public override async Task Nullability_is_computed_correctly_for_chained_coalesc """ 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] -WHERE COALESCE([e].[NullableIntA], [e].[NullableIntB], [e].[IntC]) <> [e].[NullableIntC] OR [e].[NullableIntC] IS NULL +WHERE CASE + WHEN COALESCE([e].[NullableIntA], [e].[NullableIntB], [e].[IntC]) = [e].[NullableIntC] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index df65d197ba4..4bc2d73ab6a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -350,7 +350,10 @@ LEFT JOIN ( FROM [Order] AS [o0] LEFT JOIN [OrderDetail] AS [o1] ON [o0].[ClientId] = [o1].[OrderClientId] AND [o0].[Id] = [o1].[OrderId] ) AS [s] ON [o].[Id] = [s].[ClientId] -WHERE [p].[Id] <> 42 OR [p].[Id] IS NULL +WHERE CASE + WHEN [p].[Id] = 42 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [o].[Id], [p].[Id], [s].[ClientId], [s].[Id], [s].[OrderClientId], [s].[OrderId] """); } @@ -385,7 +388,10 @@ FROM [Order] AS [o0] LEFT JOIN [OwnedPerson] AS [o1] ON [o0].[ClientId] = [o1].[Id] LEFT JOIN [Planet] AS [p0] ON [o1].[PersonAddress_Country_PlanetId] = [p0].[Id] LEFT JOIN [Star] AS [s] ON [p0].[StarId] = [s].[Id] - WHERE [o].[Id] = [o0].[ClientId] AND ([s].[Id] <> 42 OR [s].[Id] IS NULL)) AS [Count], [p].[Id], [p].[Name], [p].[StarId] + WHERE [o].[Id] = [o0].[ClientId] AND CASE + WHEN [s].[Id] = 42 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) AS [Count], [p].[Id], [p].[Name], [p].[StarId] FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] ORDER BY [o].[Id] @@ -406,7 +412,10 @@ LEFT JOIN ( FROM [Order] AS [o0] LEFT JOIN [OrderDetail] AS [o1] ON [o0].[ClientId] = [o1].[OrderClientId] AND [o0].[Id] = [o1].[OrderId] ) AS [s] ON [o].[Id] = [s].[ClientId] -WHERE [p].[Id] <> 7 OR [p].[Id] IS NULL +WHERE CASE + WHEN [p].[Id] = 7 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [o].[Id], [p].[Id], [s].[ClientId], [s].[Id], [s].[OrderClientId], [s].[OrderId] """); } @@ -1396,7 +1405,10 @@ public override async Task Projecting_collection_correlated_with_keyless_entity_ SELECT [b].[Throned_Value], [f].[Id], [b].[Id], [p].[Id], [p].[Name], [p].[StarId] FROM [Fink] AS [f] LEFT JOIN [Barton] AS [b] ON [f].[BartonId] = [b].[Id] -LEFT JOIN [Planet] AS [p] ON [b].[Throned_Value] <> [p].[Id] OR [b].[Throned_Value] IS NULL +LEFT JOIN [Planet] AS [p] ON CASE + WHEN [b].[Throned_Value] = [p].[Id] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [f].[Id], [b].[Id] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index 5f691f3504a..ded049d2215 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -512,7 +512,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] ON [w].[OwnerFullName] = [u].[FullName] LEFT JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -WHERE [u].[Nickname] <> N'Paduk' OR [u].[Nickname] IS NULL +WHERE CASE + WHEN [u].[Nickname] = N'Paduk' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Name], [w].[Id] """); } @@ -1152,7 +1155,7 @@ public override async Task Select_comparison_with_null(bool async) @__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @__ammunitionType_0 AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[AmmunitionType] = @__ammunitionType_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Cartridge] FROM [Weapons] AS [w] @@ -1277,7 +1280,10 @@ public override async Task Select_multiple_conditions(bool async) AssertSql( """ SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND CASE + WHEN [w].[SynergyWithId] = 1 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) END AS [IsCartridge] FROM [Weapons] AS [w] @@ -1942,7 +1948,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] = N'Marcus' AND ([u].[CityOfBirthName] <> N'Ephyra' OR [u].[CityOfBirthName] IS NULL) +WHERE [u].[Nickname] = N'Marcus' AND CASE + WHEN [u].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2703,7 +2712,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] = N'Marcus' AND ([u].[CityOfBirthName] <> N'Ephyra' OR [u].[CityOfBirthName] IS NULL) +WHERE [u].[Nickname] = N'Marcus' AND CASE + WHEN [u].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3205,7 +3217,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -3216,7 +3231,10 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + WHEN CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Tags] AS [t] @@ -3245,7 +3263,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [u].[HasSoulPatch] = CAST(1 AS bit) """); } @@ -3408,7 +3429,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3427,7 +3451,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3446,7 +3473,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3465,7 +3495,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [t].[Note] """); } @@ -3485,7 +3518,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3504,7 +3540,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[SquadId] """); } @@ -3526,7 +3565,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) + WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND [u].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -3547,7 +3589,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(0 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [u].[HasSoulPatch] = CAST(0 AS bit) """); } @@ -3566,7 +3611,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[SquadId] IN ( +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [u].[SquadId] IN ( SELECT [g0].[SquadId] FROM [Gears] AS [g0] UNION ALL @@ -3608,7 +3656,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Lancer' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [c].[Name] IN (N'Ephyra', N'Hanover') ORDER BY [u].[Nickname], [u].[SquadId], [c].[Name] @@ -4022,7 +4073,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4041,7 +4095,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4060,7 +4117,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4322,7 +4382,10 @@ FROM [Officers] AS [o] ) AS [u] INNER JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] INNER JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +WHERE CASE + WHEN [t].[GearNickName] = N'Cole Train' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Nickname], [t0].[Id] """); } @@ -5525,7 +5588,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId] @@ -5549,7 +5615,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId] @@ -5573,7 +5642,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId] @@ -5597,7 +5669,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId], [w0].[Name] DESC @@ -5648,7 +5723,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId] @@ -5672,7 +5750,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId] @@ -5696,7 +5777,10 @@ FROM [Officers] AS [o] LEFT JOIN ( SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] <> N'Marcus' ORDER BY [u].[Nickname], [u].[SquadId] @@ -5840,7 +5924,10 @@ FROM [Officers] AS [o0] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] WHERE [u0].[FullName] <> N'Foo' ) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] @@ -6141,7 +6228,10 @@ UNION ALL SELECT [o4].[Nickname], [o4].[SquadId], [o4].[HasSoulPatch] FROM [Officers] AS [o4] ) AS [u4] ON [s].[Id] = [u4].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON [u2].[FullName] = [s0].[OwnerFullName] WHERE [u2].[FullName] <> N'Foo' ) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] @@ -6245,7 +6335,10 @@ FROM [Officers] AS [o0] OUTER APPLY ( SELECT [w].[Name], [u0].[Nickname], [w].[Id] FROM [Weapons] AS [w] - WHERE [u0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + WHERE [u0].[FullName] = [w].[OwnerFullName] AND CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] WHERE [u0].[FullName] <> N'Foo' ) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] @@ -6276,7 +6369,10 @@ FROM [Officers] AS [o0] LEFT JOIN ( SELECT [w].[Name], [u].[Nickname], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u0].[FullName] <> N'Foo' ) AS [s] @@ -6302,7 +6398,10 @@ CROSS JOIN [Squads] AS [s] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] LEFT JOIN ( SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] @@ -6824,7 +6923,10 @@ INNER JOIN ( FROM [LocustHordes] AS [l1] WHERE [l1].[Name] = N'Swarm' ) AS [l2] ON [u].[Name] = [l2].[CommanderName] -WHERE [l2].[Eradicated] = CAST(0 AS bit) OR [l2].[Eradicated] IS NULL +WHERE CASE + WHEN [l2].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6847,7 +6949,10 @@ LEFT JOIN ( FROM [LocustHordes] AS [l1] WHERE [l1].[Name] = N'Swarm' ) AS [l2] ON [u].[Name] = [l2].[CommanderName] -WHERE [l2].[Eradicated] = CAST(0 AS bit) OR [l2].[Eradicated] IS NULL +WHERE CASE + WHEN [l2].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8185,7 +8290,7 @@ public override async Task Double_order_by_on_string_compare(bool async) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [w].[Id] """); @@ -8213,7 +8318,7 @@ public override async Task String_compare_with_null_conditional_argument(bool as FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w0].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -8229,7 +8334,7 @@ public override async Task String_compare_with_null_conditional_argument2(bool a FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN N'Marcus'' Lancer' = [w0].[Name] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -8783,7 +8888,13 @@ FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8800,7 +8911,13 @@ FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [c].[Location] = 'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8818,7 +8935,13 @@ FROM [Officers] AS [o] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8846,7 +8969,10 @@ public override async Task Nav_rewrite_with_convert1(bool async) FROM [LocustHordes] AS [l] LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8860,7 +8986,13 @@ public override async Task Nav_rewrite_with_convert2(bool async) FROM [LocustHordes] AS [l] LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l0].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8874,7 +9006,13 @@ public override async Task Nav_rewrite_with_convert3(bool async) FROM [LocustHordes] AS [l] LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l0].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -9301,7 +9439,7 @@ public override async Task Navigation_based_on_complex_expression6(bool async) AssertSql( """ SELECT CASE - WHEN [l1].[Name] = N'Queen Myrrah' AND [l1].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [l1].[Name] = N'Queen Myrrah' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM [LocustHordes] AS [l] @@ -9367,7 +9505,7 @@ public override async Task Nullable_bool_comparison_is_translated_to_server(bool AssertSql( """ SELECT CASE - WHEN [l].[Eradicated] = CAST(1 AS bit) AND [l].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) + WHEN [l].[Eradicated] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsEradicated] FROM [LocustHordes] AS [l] @@ -10060,7 +10198,10 @@ FROM [Weapons] AS [w] SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @__prm_0 <> 0 OR [w].[AmmunitionType] IS NULL +WHERE CASE + WHEN [w].[AmmunitionType] & @__prm_0 = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -10135,10 +10276,11 @@ FROM [LocustCommanders] AS [l0] ) AS [u] INNER JOIN [LocustHordes] AS [l1] ON [u].[Name] = [l1].[CommanderName] WHERE CASE - WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL + WHEN CASE + WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) + END = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -10957,7 +11099,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] -INNER JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +INNER JOIN [Weapons] AS [w] ON CASE + WHEN [u].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Nickname], [w].[Id] """); } @@ -10976,7 +11121,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] AS [w] ON CASE + WHEN [u].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Nickname], [w].[Id] """); } @@ -11000,7 +11148,10 @@ LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [u].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +) AS [s] ON CASE + WHEN [u].[FullName] = [s].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Nickname], [s].[Id] """); } @@ -11019,7 +11170,10 @@ UNION ALL SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] AS [w] ON CASE + WHEN [u].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -11097,7 +11251,10 @@ FROM [Officers] AS [o] CROSS APPLY ( SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] <> [u].[FullName] OR [w].[OwnerFullName] IS NULL + WHERE CASE + WHEN [w].[OwnerFullName] = [u].[FullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [w].[Id] ) AS [w0] ORDER BY [u].[Nickname], [w0].[Id] @@ -11166,7 +11323,10 @@ UNION ALL SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] FROM [LocustCommanders] AS [l0] ) AS [u] -WHERE [u].[Discriminator] = N'LocustCommander' AND ([u].[HighCommandId] <> 0 OR [u].[HighCommandId] IS NULL) +WHERE [u].[Discriminator] = N'LocustCommander' AND CASE + WHEN [u].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -11178,7 +11338,10 @@ UNION ALL SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] FROM [LocustCommanders] AS [l0] ) AS [u] -WHERE [u].[Discriminator] = N'LocustCommander' AND ([u].[HighCommandId] <> 0 OR [u].[HighCommandId] IS NULL) +WHERE [u].[Discriminator] = N'LocustCommander' AND CASE + WHEN [u].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -11444,7 +11607,7 @@ public override async Task Projecting_property_converted_to_nullable_with_condit AssertSql( """ SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[Note] <> N'K.I.A.' THEN CASE WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] END ELSE -1 @@ -11622,7 +11785,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +WHERE CASE + WHEN DATEPART(month, [t].[IssueDate]) = 5 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Nickname] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs index dbd27151be3..2224dd3f85c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs @@ -119,7 +119,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedCollections] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [u].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] LEFT JOIN [CollectionsOnBase] AS [c] ON [u].[Id] = [c].[ParentId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id] """); } @@ -143,7 +146,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [DerivedEntities] AS [d0] ON [u].[Id] = [d0].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [u].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -313,7 +319,10 @@ UNION ALL SELECT [d2].[Id], [d2].[BaseParentId], [d2].[Name], [d2].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d2] ) AS [u0] ON [u].[Id] = [u0].[BaseParentId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id] """); } @@ -343,7 +352,10 @@ FROM [DerivedEntities] AS [d0] LEFT JOIN [DerivedEntities] AS [d1] ON [u0].[Id] = [d1].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [u0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [u0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [u0].[Id], [o].[BaseInheritanceRelationshipEntityId], [d1].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId] """); } @@ -461,7 +473,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [DerivedEntities] AS [d0] ON [u].[Id] = [d0].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [u].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [r].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -485,7 +500,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [DerivedEntities] AS [d0] ON [u].[Id] = [d0].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [u].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [r].[Name] <> N'Bar' OR [r].[Name] IS NULL +WHERE CASE + WHEN [r].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [r].[Id], [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -619,7 +637,10 @@ FROM [DerivedReferencesOnBase] AS [d0] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [d].[Name] <> N'Bar' OR [d].[Name] IS NULL +WHERE CASE + WHEN [d].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [d].[Id], [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -642,7 +663,10 @@ FROM [DerivedReferencesOnDerived] AS [d0] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [d].[Name] <> N'Bar' OR [d].[Name] IS NULL +WHERE CASE + WHEN [d].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [d].[Id], [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -659,7 +683,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [d].[Name] <> N'Bar' OR [d].[Name] IS NULL +WHERE CASE + WHEN [d].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [d].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -682,7 +709,10 @@ FROM [DerivedReferencesOnDerived] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d0].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -741,7 +771,10 @@ FROM [DerivedReferencesOnBase] AS [d0] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [u].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [u0].[Id], [o].[BaseInheritanceRelationshipEntityId], [d1].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId] """); } @@ -771,7 +804,10 @@ FROM [DerivedEntities] AS [d0] LEFT JOIN [DerivedEntities] AS [d1] ON [u0].[Id] = [d1].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [u0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [u0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [u0].[Id], [o].[BaseInheritanceRelationshipEntityId], [d1].[Id], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId] """); } @@ -1404,7 +1440,10 @@ FROM [DerivedEntities] AS [d] ) AS [u] LEFT JOIN [OwnedReferences] AS [o] ON [u].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d0] ON [u].[Id] = [d0].[Id] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id] """, // @@ -1420,7 +1459,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [OwnedCollections] AS [o1] ON [u].[Id] = [o1].[BaseInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """, // @@ -1436,7 +1478,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [u].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """, // @@ -1458,7 +1503,10 @@ UNION ALL SELECT [d3].[Id], [d3].[BaseParentId], [d3].[Name], [d3].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d3] ) AS [u0] ON [u].[Id] = [u0].[BaseParentId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """); } @@ -1486,7 +1534,10 @@ FROM [DerivedEntities] AS [d0] ) AS [u0] ON [u].[BaseParentId] = [u0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [u0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u0].[Id] = [d1].[Id] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [u0].[Id], [o].[BaseInheritanceRelationshipEntityId], [d1].[Id] """, // @@ -1509,7 +1560,10 @@ FROM [DerivedEntities] AS [d0] LEFT JOIN [OwnedReferences] AS [o0] ON [u0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d2] ON [u0].[Id] = [d2].[Id] INNER JOIN [OwnedCollections] AS [o1] ON [u0].[Id] = [o1].[BaseInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [u0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d2].[Id] """, // @@ -1532,7 +1586,10 @@ FROM [DerivedEntities] AS [d0] LEFT JOIN [OwnedReferences] AS [o0] ON [u0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d2] ON [u0].[Id] = [d2].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [u0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [u0].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d2].[Id] """); } @@ -1671,7 +1728,10 @@ FROM [DerivedEntities] AS [d] ) AS [u] LEFT JOIN [OwnedReferences] AS [o] ON [u].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d0] ON [u].[Id] = [d0].[Id] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id] """, // @@ -1687,7 +1747,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [OwnedCollections] AS [o1] ON [u].[Id] = [o1].[BaseInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """, // @@ -1703,7 +1766,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [u].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """, // @@ -1719,7 +1785,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [CollectionsOnBase] AS [c] ON [u].[Id] = [c].[ParentId] -WHERE [u].[Name] <> N'Bar' OR [u].[Name] IS NULL +WHERE CASE + WHEN [u].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """); } @@ -1741,7 +1810,10 @@ FROM [DerivedEntities] AS [d] ) AS [u] ON [c].[ParentId] = [u].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [u].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d0] ON [u].[Id] = [d0].[Id] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [u].[Id], [o].[BaseInheritanceRelationshipEntityId], [d0].[Id] """, // @@ -1758,7 +1830,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [OwnedCollections] AS [o1] ON [u].[Id] = [o1].[BaseInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """, // @@ -1775,7 +1850,10 @@ FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o0] ON [u].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities] AS [d1] ON [u].[Id] = [d1].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [u].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [u].[Id], [o0].[BaseInheritanceRelationshipEntityId], [d1].[Id] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 060ffae67ed..4e6d31a0c01 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -497,7 +497,10 @@ FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] LEFT JOIN [Cities] AS [c] ON [s].[CityOfBirthName] = [c].[Name] -WHERE [s].[Nickname] <> N'Paduk' OR [s].[Nickname] IS NULL +WHERE CASE + WHEN [s].[Nickname] = N'Paduk' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Name], [w].[Id] """); } @@ -985,7 +988,7 @@ public override async Task Select_comparison_with_null(bool async) @__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @__ammunitionType_0 AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[AmmunitionType] = @__ammunitionType_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Cartridge] FROM [Weapons] AS [w] @@ -1110,7 +1113,10 @@ public override async Task Select_multiple_conditions(bool async) AssertSql( """ SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND CASE + WHEN [w].[SynergyWithId] = 1 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) END AS [IsCartridge] FROM [Weapons] AS [w] @@ -1613,7 +1619,10 @@ END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] = N'Marcus' AND ([s].[CityOfBirthName] <> N'Ephyra' OR [s].[CityOfBirthName] IS NULL) +WHERE [s].[Nickname] = N'Marcus' AND CASE + WHEN [s].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2247,7 +2256,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] = N'Marcus' AND ([s].[CityOfBirthName] <> N'Ephyra' OR [s].[CityOfBirthName] IS NULL) +WHERE [s].[Nickname] = N'Marcus' AND CASE + WHEN [s].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2695,7 +2707,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -2706,7 +2721,10 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + WHEN CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Tags] AS [t] @@ -2729,7 +2747,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(1 AS bit) """); } @@ -2868,7 +2889,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2884,7 +2908,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2900,7 +2927,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2916,7 +2946,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [t].[Note] """); } @@ -2933,7 +2966,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2949,7 +2985,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [s].[SquadId] """); } @@ -2968,7 +3007,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) + WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -2986,7 +3028,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(0 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(0 AS bit) """); } @@ -3002,7 +3047,10 @@ LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[SquadId] IN ( +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [s].[SquadId] IN ( SELECT [g0].[SquadId] FROM [Gears] AS [g0] ) @@ -3035,7 +3083,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Lancer' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [c].[Name] IN (N'Ephyra', N'Hanover') ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] @@ -3418,7 +3469,10 @@ public override async Task Distinct_with_optional_navigation_is_translated_to_sq SELECT DISTINCT [g].[HasSoulPatch] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3431,7 +3485,10 @@ public override async Task Sum_with_optional_navigation_is_translated_to_sql(boo SELECT COALESCE(SUM([g].[SquadId]), 0) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3444,7 +3501,10 @@ public override async Task Count_with_optional_navigation_is_translated_to_sql(b SELECT COUNT(*) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3637,7 +3697,10 @@ SELECT [g].[Nickname] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +WHERE CASE + WHEN [t].[GearNickName] = N'Cole Train' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [t0].[Id] """); } @@ -4773,7 +4836,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4791,7 +4857,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4809,7 +4878,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4827,7 +4899,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC @@ -4864,7 +4939,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4882,7 +4960,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4900,7 +4981,10 @@ FROM [Gears] AS [g] LEFT JOIN ( SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -5027,7 +5111,10 @@ FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] @@ -5246,7 +5333,10 @@ LEFT JOIN ( SELECT [g4].[Nickname], [g4].[HasSoulPatch], [g4].[SquadId] FROM [Gears] AS [g4] ) AS [s3] ON [s1].[Id] = [s3].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s4] ON [g2].[FullName] = [s4].[OwnerFullName] WHERE [g2].[FullName] <> N'Foo' ) AS [s5] ON [g].[Nickname] = [s5].[LeaderNickname] AND [g].[SquadId] = [s5].[LeaderSquadId] @@ -5319,7 +5409,10 @@ FROM [Gears] AS [g0] OUTER APPLY ( SELECT [w].[Name], [g0].[Nickname], [w].[Id] FROM [Weapons] AS [w] - WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + WHERE [g0].[FullName] = [w].[OwnerFullName] AND CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] @@ -5343,7 +5436,10 @@ FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' ) AS [s] @@ -5364,7 +5460,10 @@ CROSS JOIN [Squads] AS [s] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE @@ -5766,7 +5865,10 @@ FROM [Factions] AS [f] LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] WHERE [l0].[Id] IS NOT NULL AND [f].[Name] = N'Swarm' ) AS [s] ON [l].[Name] = [s].[CommanderName] -WHERE [s].[Eradicated] = CAST(0 AS bit) OR [s].[Eradicated] IS NULL +WHERE CASE + WHEN [s].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -5786,7 +5888,10 @@ FROM [Factions] AS [f] LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] WHERE [l0].[Id] IS NOT NULL AND [f].[Name] = N'Swarm' ) AS [s] ON [l].[Name] = [s].[CommanderName] -WHERE [s].[Eradicated] = CAST(0 AS bit) OR [s].[Eradicated] IS NULL +WHERE CASE + WHEN [s].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6864,7 +6969,7 @@ public override async Task Double_order_by_on_string_compare(bool async) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [w].[Id] """); @@ -6892,7 +6997,7 @@ public override async Task String_compare_with_null_conditional_argument(bool as FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w0].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -6908,7 +7013,7 @@ public override async Task String_compare_with_null_conditional_argument2(bool a FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN N'Marcus'' Lancer' = [w0].[Name] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -7382,7 +7487,13 @@ FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [o].[Nickname] IS NOT NULL AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7399,7 +7510,13 @@ FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [o].[Nickname] IS NOT NULL AND CASE + WHEN [c].[Location] = 'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7417,7 +7534,13 @@ FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [o].[Nickname] IS NOT NULL AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7450,7 +7573,10 @@ LEFT JOIN ( FROM [LocustLeaders] AS [l0] INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] ) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7471,7 +7597,13 @@ SELECT [l0].[Name] FROM [LocustLeaders] AS [l0] INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] ) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([s].[Name] <> N'Bar' OR [s].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [s].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7492,7 +7624,13 @@ SELECT [l0].[Name] FROM [LocustLeaders] AS [l0] INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] ) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([s].[Name] <> N'Bar' OR [s].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [s].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7913,7 +8051,7 @@ public override async Task Navigation_based_on_complex_expression6(bool async) AssertSql( """ SELECT CASE - WHEN [s0].[Name] = N'Queen Myrrah' AND [s0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [s0].[Name] = N'Queen Myrrah' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] FROM [Factions] AS [f] @@ -7989,7 +8127,7 @@ public override async Task Nullable_bool_comparison_is_translated_to_server(bool AssertSql( """ SELECT CASE - WHEN [l].[Eradicated] = CAST(1 AS bit) AND [l].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) + WHEN [l].[Eradicated] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsEradicated] FROM [Factions] AS [f] @@ -8531,7 +8669,10 @@ FROM [Weapons] AS [w] SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @__prm_0 <> 0 OR [w].[AmmunitionType] IS NULL +WHERE CASE + WHEN [w].[AmmunitionType] & @__prm_0 = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -8601,10 +8742,11 @@ FROM [Factions] AS [f] WHERE [l0].[Id] IS NOT NULL ) AS [s] ON [l].[Name] = [s].[CommanderName] WHERE CASE - WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL + WHEN CASE + WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) + END = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -9288,7 +9430,10 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +INNER JOIN [Weapons] AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [w].[Id] """); } @@ -9304,7 +9449,10 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [w].[Id] """); } @@ -9325,7 +9473,10 @@ LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +) AS [s] ON CASE + WHEN [g].[FullName] = [s].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [s].[Id] """); } @@ -9338,7 +9489,10 @@ public override async Task SelectMany_without_result_selector_and_non_equality_c """ SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -9395,7 +9549,10 @@ FROM [Gears] AS [g] CROSS APPLY ( SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL + WHERE CASE + WHEN [w].[OwnerFullName] = [g].[FullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [w].[Id] ) AS [w0] ORDER BY [g].[Nickname], [w0].[Id] @@ -9448,7 +9605,10 @@ WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' END AS [Discriminator] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL AND ([l0].[HighCommandId] <> 0 OR [l0].[HighCommandId] IS NULL) +WHERE [l0].[Name] IS NOT NULL AND CASE + WHEN [l0].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -9457,7 +9617,10 @@ WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' END AS [Discriminator] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL AND ([l0].[HighCommandId] <> 0 OR [l0].[HighCommandId] IS NULL) +WHERE [l0].[Name] IS NOT NULL AND CASE + WHEN [l0].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -9690,7 +9853,7 @@ public override async Task Projecting_property_converted_to_nullable_with_condit AssertSql( """ SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[Note] <> N'K.I.A.' THEN CASE WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] END ELSE -1 @@ -9841,7 +10004,10 @@ public override async Task Projecting_property_converted_to_nullable_into_member SELECT [g].[Nickname] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +WHERE CASE + WHEN DATEPART(month, [t].[IssueDate]) = 5 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs index 6e8c7d8e184..dbef0d80bcf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs @@ -101,7 +101,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [b].[Id] = [d0].[DerivedInheritanceRelationshipEntityId] LEFT JOIN [CollectionsOnBase] AS [c] ON [b].[Id] = [c].[ParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id] """); } @@ -123,7 +126,10 @@ FROM [BaseEntities] AS [b] ) AS [s] ON [c].[ParentId] = [s].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [s].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [s].[Id] = [d0].[DerivedInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [s].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [d0].[DerivedInheritanceRelationshipEntityId] """); } @@ -282,7 +288,10 @@ END AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b1] LEFT JOIN [DerivedCollectionsOnBase] AS [d1] ON [b1].[Id] = [d1].[Id] ) AS [s] ON [b].[Id] = [s].[BaseParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id] """); } @@ -307,7 +316,10 @@ FROM [BaseEntities] AS [b0] ) AS [s] ON [b].[BaseParentId] = [s].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [s].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [s].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -416,7 +428,10 @@ FROM [BaseEntities] AS [b] LEFT JOIN [ReferencesOnBase] AS [r] ON [b].[Id] = [r].[ParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [b].[Id] = [d0].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [r].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [d0].[DerivedInheritanceRelationshipEntityId] """); } @@ -438,7 +453,10 @@ FROM [BaseEntities] AS [b] ) AS [s] ON [r].[ParentId] = [s].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [s].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [s].[Id] = [d0].[DerivedInheritanceRelationshipEntityId] -WHERE [r].[Name] <> N'Bar' OR [r].[Name] IS NULL +WHERE CASE + WHEN [r].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [r].[Id], [s].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [d0].[DerivedInheritanceRelationshipEntityId] """); } @@ -571,7 +589,10 @@ FROM [BaseReferencesOnBase] AS [b0] ) AS [s] ON [b].[Id] = [s].[BaseParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [b].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -594,7 +615,10 @@ FROM [BaseReferencesOnDerived] AS [b0] ) AS [s] ON [b].[Id] = [s].[BaseParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [b].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -615,7 +639,10 @@ FROM [BaseReferencesOnDerived] AS [b0] ) AS [s] ON [b].[Id] = [s].[DerivedInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [b].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -638,7 +665,10 @@ FROM [BaseEntities] AS [b0] ) AS [s] ON [b].[BaseParentId] = [s].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [s].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [s].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -687,7 +717,10 @@ FROM [BaseReferencesOnBase] AS [b0] ) AS [s] ON [b].[Id] = [s].[BaseParentId] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [b].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -712,7 +745,10 @@ FROM [BaseEntities] AS [b0] ) AS [s] ON [b].[BaseParentId] = [s].[Id] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [s].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [s].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [d1].[DerivedInheritanceRelationshipEntityId] """); } @@ -1227,7 +1263,10 @@ WHEN [d].[Id] IS NOT NULL THEN N'DerivedInheritanceRelationshipEntity' END AS [Discriminator], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [d].[Id], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name] FROM [BaseEntities] AS [b] LEFT JOIN [DerivedEntities] AS [d] ON [b].[Id] = [d].[Id] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1235,7 +1274,10 @@ ORDER BY [b].[Id] SELECT [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b1].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1243,7 +1285,10 @@ ORDER BY [b].[Id] SELECT [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [b].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1257,7 +1302,10 @@ END AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b2] LEFT JOIN [DerivedCollectionsOnBase] AS [d2] ON [b2].[Id] = [d2].[Id] ) AS [s] ON [b].[Id] = [s].[BaseParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """); } @@ -1280,7 +1328,10 @@ WHEN [d0].[Id] IS NOT NULL THEN N'DerivedInheritanceRelationshipEntity' FROM [BaseEntities] AS [b0] LEFT JOIN [DerivedEntities] AS [d0] ON [b0].[Id] = [d0].[Id] ) AS [s] ON [b].[BaseParentId] = [s].[Id] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id] """, // @@ -1292,7 +1343,10 @@ SELECT [b0].[Id] FROM [BaseEntities] AS [b0] ) AS [s] ON [b].[BaseParentId] = [s].[Id] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b2] ON [s].[Id] = [b2].[BaseInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id] """, // @@ -1304,7 +1358,10 @@ SELECT [b0].[Id] FROM [BaseEntities] AS [b0] ) AS [s] ON [b].[BaseParentId] = [s].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [s].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id], [s].[Id] """); } @@ -1397,7 +1454,10 @@ WHEN [d].[Id] IS NOT NULL THEN N'DerivedInheritanceRelationshipEntity' END AS [Discriminator], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [d].[Id], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name] FROM [BaseEntities] AS [b] LEFT JOIN [DerivedEntities] AS [d] ON [b].[Id] = [d].[Id] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1405,7 +1465,10 @@ ORDER BY [b].[Id] SELECT [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b1].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1413,7 +1476,10 @@ ORDER BY [b].[Id] SELECT [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [b].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """, // @@ -1421,7 +1487,10 @@ ORDER BY [b].[Id] SELECT [c].[Id], [c].[Name], [c].[ParentId], [b].[Id] FROM [BaseEntities] AS [b] INNER JOIN [CollectionsOnBase] AS [c] ON [b].[Id] = [c].[ParentId] -WHERE [b].[Name] <> N'Bar' OR [b].[Name] IS NULL +WHERE CASE + WHEN [b].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [b].[Id] """); } @@ -1441,7 +1510,10 @@ WHEN [d].[Id] IS NOT NULL THEN N'DerivedInheritanceRelationshipEntity' FROM [BaseEntities] AS [b] LEFT JOIN [DerivedEntities] AS [d] ON [b].[Id] = [d].[Id] ) AS [s] ON [c].[ParentId] = [s].[Id] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [s].[Id] """, // @@ -1453,7 +1525,10 @@ SELECT [b].[Id] FROM [BaseEntities] AS [b] ) AS [s] ON [c].[ParentId] = [s].[Id] INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [s].[Id] = [b1].[BaseInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [s].[Id] """, // @@ -1465,7 +1540,10 @@ SELECT [b].[Id] FROM [BaseEntities] AS [b] ) AS [s] ON [c].[ParentId] = [s].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [s].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Id], [s].[Id] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsQuerySqlServerTest.cs index 7115c32d5ee..6c39d74ad10 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsQuerySqlServerTest.cs @@ -97,7 +97,10 @@ LEFT JOIN ( FROM ( 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], [l0].[PeriodEnd], [l0].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -136,7 +139,10 @@ LEFT JOIN ( SELECT COUNT(*) FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -155,7 +161,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] @@ -264,7 +273,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] @@ -285,7 +297,10 @@ LEFT JOIN ( FROM ( SELECT 1 AS [c], [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE [l3].[row] <= 1 ) AS [l4] ON [l].[Id] = [l4].[OneToMany_Optional_Inverse2Id] @@ -355,7 +370,10 @@ OUTER APPLY ( FROM ( SELECT TOP(2) [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], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -438,7 +456,10 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte SELECT [l].[Name] FROM [LevelOne] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] GROUP BY [l].[Name] - HAVING [l].[Name] <> N'Foo' OR [l].[Name] IS NULL + HAVING CASE + WHEN [l].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] LEFT JOIN ( SELECT [l3].[Id], [l3].[Date], [l3].[Name], [l3].[OneToMany_Optional_Self_Inverse1Id], [l3].[OneToMany_Required_Self_Inverse1Id], [l3].[OneToOne_Optional_Self1Id], [l3].[PeriodEnd], [l3].[PeriodStart] @@ -722,7 +743,10 @@ public override async Task Multiple_include_with_multiple_optional_navigations(b LEFT JOIN [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l3] ON [l].[Id] = [l3].[Level1_Optional_Id] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] -WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL +WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id] """); } @@ -865,7 +889,10 @@ LEFT JOIN ( FROM ( 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], [l0].[PeriodEnd], [l0].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> @__prm_0 OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -950,7 +977,10 @@ LEFT JOIN ( FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l15] WHERE [l15].[Id] <> 42 ) AS [l16] ON [s].[Id2] = [l16].[OneToMany_Optional_Self_Inverse2Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """); } @@ -969,7 +999,10 @@ LEFT JOIN ( FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] LEFT JOIN [LevelFour] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] ) AS [s] ON [l0].[Id] = [s].[OneToMany_Required_Inverse3Id] -WHERE [l0].[Name] <> N'L2 09' OR [l0].[Name] IS NULL +WHERE CASE + WHEN [l0].[Name] = N'L2 09' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l0].[Id], [s].[Id] """); } @@ -985,7 +1018,10 @@ public override async Task Project_collection_navigation_composed(bool async) 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], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] WHERE [l].[Id] < 3 ORDER BY [l].[Id] @@ -1168,7 +1204,10 @@ OUTER APPLY ( FROM ( SELECT TOP(3) [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], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Name] ) AS [l2] LEFT JOIN ( @@ -1176,7 +1215,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[Name] <> N'Bar' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] ) AS [l4] ON [l2].[Id] = [l4].[OneToMany_Required_Inverse3Id] @@ -1216,7 +1258,10 @@ public override async Task Complex_query_with_let_collection_projection_FirstOrD OUTER APPLY ( SELECT TOP(1) 1 AS [c], [l0].[Id] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] OUTER APPLY ( SELECT [l1].[Name], [l1].[Id] @@ -1438,7 +1483,10 @@ OUTER APPLY ( FROM ( SELECT TOP(1) [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], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] ON [l2].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] @@ -1502,7 +1550,10 @@ OUTER APPLY ( FROM ( SELECT TOP(1) [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l1].[PeriodEnd], [l1].[PeriodStart] FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL) + WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l1].[Id] ) AS [l4] LEFT JOIN [LevelFour] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l2] ON [l4].[Id] = [l2].[OneToMany_Optional_Inverse4Id] @@ -1848,7 +1899,10 @@ LEFT JOIN ( FROM ( 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], [l0].[PeriodEnd], [l0].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1892,7 +1946,10 @@ LEFT JOIN ( FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l15] WHERE [l15].[Id] <> 42 ) AS [l16] ON [s].[Id2] = [l16].[OneToMany_Optional_Self_Inverse2Id] -WHERE [l11].[Name] <> N'Foo' OR [l11].[Name] IS NULL +WHERE CASE + WHEN [l11].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [s].[Id], [s].[Id0], [s].[Id1], [s].[Id2], [s0].[Id], [s0].[Id0], [s0].[Id1], [s0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id] """); } @@ -2034,7 +2091,10 @@ LEFT JOIN ( FROM ( 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], [l0].[PeriodEnd], [l0].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 2 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -2226,7 +2286,10 @@ LEFT JOIN ( FROM ( 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], [l0].[PeriodEnd], [l0].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL + WHERE CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -2235,7 +2298,10 @@ LEFT JOIN ( FROM ( SELECT [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], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Name] DESC) AS [row] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[Name] <> N'Bar' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE 1 < [l4].[row] ) AS [l5] ON [l].[Id] = [l5].[OneToMany_Required_Inverse2Id] @@ -2529,7 +2595,10 @@ OUTER APPLY ( FROM ( SELECT TOP(2) [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], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Name] <> N'Foo' OR [l0].[Name] IS NULL) + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Id] ) AS [l2] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] ON [l2].[Id] = [l1].[Level2_Required_Id] @@ -2653,7 +2722,10 @@ OUTER APPLY ( FROM ( SELECT TOP(1) [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l1].[PeriodEnd], [l1].[PeriodStart] FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL) + WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l1].[Id] ) AS [l4] LEFT JOIN [LevelFour] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l2] ON [l4].[Id] = [l2].[OneToMany_Optional_Inverse4Id] @@ -2821,7 +2893,10 @@ LEFT JOIN ( SELECT COUNT(*) FROM [LevelTwo] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] LEFT JOIN [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL)) > 0 + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -2890,7 +2965,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] FROM [LevelThree] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[Name] <> N'Foo' OR [l1].[Name] IS NULL + WHERE CASE + WHEN [l1].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE 1 < [l2].[row] AND [l2].[row] <= 4 ) AS [l3] ON [l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs index f772b926c0f..a7c4d220a75 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs @@ -172,7 +172,10 @@ LEFT JOIN ( FROM ( SELECT 1 AS [c], [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Required_Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[PeriodEnd], [l0].[PeriodStart], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE [l3].[row] <= 1 ) AS [l4] ON [l].[Id] = [l4].[OneToMany_Optional_Inverse2Id] @@ -235,7 +238,10 @@ OUTER APPLY ( FROM ( SELECT TOP(3) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [l0].[Level2_Name] ) AS [l2] LEFT JOIN ( @@ -243,7 +249,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Level3_Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Level3_Name] DESC) AS [row] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l1].[Level3_Name] <> N'Bar' OR [l1].[Level3_Name] IS NULL) + WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l1].[Level3_Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] ) AS [l4] ON CASE @@ -267,7 +276,10 @@ LEFT JOIN ( FROM ( SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[PeriodEnd], [l0].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Level2_Name]) AS [row] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] WHERE [l2].[row] <= 3 ) AS [l3] ON [l].[Id] = [l3].[OneToMany_Optional_Inverse2Id] @@ -276,7 +288,10 @@ LEFT JOIN ( FROM ( SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[PeriodEnd], [l1].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Level2_Name] DESC) AS [row] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] - WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l1].[Level2_Name] <> N'Bar' OR [l1].[Level2_Name] IS NULL) + WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l1].[Level2_Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l4] WHERE 1 < [l4].[row] ) AS [l5] ON [l].[Id] = [l5].[OneToMany_Required_Inverse2Id] @@ -302,7 +317,10 @@ LEFT JOIN ( FROM ( SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[PeriodEnd], [l2].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l2].[OneToMany_Optional_Inverse3Id] ORDER BY [l2].[Level3_Name]) AS [row] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l2] - WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL) + WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] AND [l3].[row] <= 4 ) AS [l4] ON CASE @@ -327,7 +345,10 @@ SELECT TOP(1) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END @@ -368,7 +389,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -393,7 +417,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -505,7 +532,10 @@ END IS NOT NULL AND (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l1].[OneToMany_Optional_Inverse3Id] OR (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] - END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND ([l1].[Level3_Name] <> N'Foo' OR [l1].[Level3_Name] IS NULL) + END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND CASE + WHEN [l1].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l1].[Id] END @@ -555,7 +585,10 @@ END IS NOT NULL AND (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l1].[OneToMany_Optional_Inverse3Id] OR (CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] - END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND ([l1].[Level3_Name] <> N'Foo' OR [l1].[Level3_Name] IS NULL) + END IS NULL AND [l1].[OneToMany_Optional_Inverse3Id] IS NULL)) AND CASE + WHEN [l1].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [l1].[Id] END @@ -670,7 +703,10 @@ SELECT TOP(2) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END @@ -712,7 +748,10 @@ LEFT JOIN ( FROM ( SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[PeriodEnd], [l2].[PeriodStart], ROW_NUMBER() OVER(PARTITION BY [l2].[OneToMany_Optional_Inverse3Id] ORDER BY [l2].[Level3_Name]) AS [row] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l2] - WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL) + WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l3] WHERE 1 < [l3].[row] AND [l3].[row] <= 4 ) AS [l4] ON CASE @@ -841,7 +880,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> @__prm_0 OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = @__prm_0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 3 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -997,7 +1039,10 @@ WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] WHERE [l1].[row] <= 2 ) AS [l2] ON [l].[Id] = [l2].[OneToMany_Optional_Inverse2Id] @@ -1020,7 +1065,10 @@ SELECT TOP(2) [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END AS [c] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END @@ -1345,7 +1393,10 @@ WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse ) AS [l2] ON CASE WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id] END = [l2].[OneToOne_Optional_PK_Inverse3Id] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND ([l2].[Level3_Name] <> N'Foo' OR [l2].[Level3_Name] IS NULL)) > 0 + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] AND CASE + WHEN [l2].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) > 0 ORDER BY [l].[Id], [s].[Id], [s].[Id0] """); } @@ -1501,7 +1552,10 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte SELECT [l].[Name] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] GROUP BY [l].[Name] - HAVING [l].[Name] <> N'Foo' OR [l].[Name] IS NULL + HAVING CASE + WHEN [l].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l2] LEFT JOIN ( SELECT [l3].[Id], [l3].[Date], [l3].[Name], [l3].[PeriodEnd], [l3].[PeriodStart] @@ -1578,7 +1632,10 @@ WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse ) AS [s] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l1].[PeriodEnd] IS NOT NULL AND [l1].[PeriodStart] IS NOT NULL THEN [l1].[Id] END = [s].[OneToMany_Required_Inverse3Id] -WHERE [l1].[Level2_Name] <> N'L2 09' OR [l1].[Level2_Name] IS NULL +WHERE CASE + WHEN [l1].[Level2_Name] = N'L2 09' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l1].[Id], [s].[Id] """); } @@ -2039,7 +2096,10 @@ WHERE [l10].[Level2_Required_Id] IS NOT NULL AND [l10].[OneToMany_Required_Inver ) AS [l11] ON CASE WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [l1].[PeriodEnd] IS NOT NULL AND [l1].[PeriodStart] IS NOT NULL THEN [l1].[Id] END = [l11].[OneToMany_Optional_Inverse3Id] -WHERE [l3].[Level3_Name] <> N'Foo' OR [l3].[Level3_Name] IS NULL +WHERE CASE + WHEN [l3].[Level3_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [l].[Id], [l1].[Id], [l3].[Id], [l5].[Id], [l7].[Id], [l9].[Id] """); } @@ -2493,7 +2553,10 @@ public override async Task Project_collection_navigation_composed(bool async) LEFT JOIN ( SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level2_Name] <> N'Foo' OR [l0].[Level2_Name] IS NULL) + WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE + WHEN [l0].[Level2_Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] WHERE [l].[Id] < 3 ORDER BY [l].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index e9372707817..da15bdc820e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -555,13 +555,19 @@ public override async Task Accessing_derived_property_using_hard_and_soft_cast(b """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[PeriodEnd], [l].[PeriodStart], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) +WHERE [l].[Discriminator] = N'LocustCommander' AND CASE + WHEN [l].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[PeriodEnd], [l].[PeriodStart], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) +WHERE [l].[Discriminator] = N'LocustCommander' AND CASE + WHEN [l].[HighCommandId] = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -832,7 +838,13 @@ public override async Task OfTypeNav1(bool async) FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[Discriminator] = N'Officer' AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1216,7 +1228,7 @@ public override async Task Projecting_property_converted_to_nullable_with_condit AssertSql( """ SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[Note] <> N'K.I.A.' THEN CASE WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] END ELSE -1 @@ -1295,7 +1307,10 @@ WHEN NOT EXISTS ( SELECT 1 FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) + WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND [g].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -1345,7 +1360,10 @@ LEFT JOIN ( LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] @@ -1472,7 +1490,13 @@ SELECT [l].[Name] FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l0].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -1665,7 +1689,10 @@ OUTER APPLY ( LEFT JOIN ( SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' ) AS [s] @@ -1796,7 +1823,10 @@ public override async Task Optional_navigation_type_compensation_works_with_nega SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[HasSoulPatch] = CAST(0 AS bit) """); } @@ -1875,7 +1905,7 @@ public override async Task Navigation_based_on_complex_expression6(bool async) AssertSql( """ SELECT CASE - WHEN [l2].[Name] = N'Queen Myrrah' AND [l2].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [l2].[Name] = N'Queen Myrrah' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[PeriodEnd], [l2].[PeriodStart], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[PeriodEnd], [l0].[PeriodStart], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] FROM [Factions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] @@ -2064,7 +2094,10 @@ public override async Task Correlated_collections_basic_projection_explicit_to_l LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -2111,7 +2144,7 @@ public override async Task String_compare_with_null_conditional_argument2(bool a FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN N'Marcus'' Lancer' = [w0].[Name] THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -2260,7 +2293,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_wit CROSS APPLY ( SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL + WHERE CASE + WHEN [w].[OwnerFullName] = [g].[FullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ORDER BY [w].[Id] ) AS [w0] ORDER BY [g].[Nickname], [w0].[Id] @@ -2306,7 +2342,10 @@ public override async Task Optional_navigation_type_compensation_works_with_proj SELECT [g].[SquadId] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2323,7 +2362,10 @@ LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +) AS [s] ON CASE + WHEN [g].[FullName] = [s].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [s].[Id] """); } @@ -2531,7 +2573,10 @@ public override async Task Correlated_collections_basic_projecting_single_proper LEFT JOIN ( SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -2563,10 +2608,11 @@ SELECT CASE FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] INNER JOIN [Factions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] ON [l].[Name] = [f].[CommanderName] WHERE CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL + WHEN CASE + WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) + END = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2801,7 +2847,10 @@ public override async Task Distinct_with_optional_navigation_is_translated_to_sq SELECT DISTINCT [g].[HasSoulPatch] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -2960,7 +3009,10 @@ public override async Task Select_Singleton_Navigation_With_Member_Access(bool a SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) +WHERE [g].[Nickname] = N'Marcus' AND CASE + WHEN [g].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3125,7 +3177,10 @@ public override async Task Correlated_collections_basic_projecting_constant(bool LEFT JOIN ( SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -3236,7 +3291,10 @@ WHERE [w].[AmmunitionType] IS NULL SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] & @__prm_0 <> 0 OR [w].[AmmunitionType] IS NULL +WHERE CASE + WHEN [w].[AmmunitionType] & @__prm_0 = 0 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """, // """ @@ -3353,7 +3411,10 @@ public override async Task Select_multiple_conditions(bool async) AssertSql( """ SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND CASE + WHEN [w].[SynergyWithId] = 1 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) END AS [IsCartridge] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] @@ -3424,7 +3485,10 @@ LEFT JOIN ( LEFT JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [g3].[SquadId] = [s].[Id] LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] ON [g3].[FullName] = [w0].[OwnerFullName] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g4] ON [s].[Id] = [g4].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [s0] ON [g2].[FullName] = [s0].[OwnerFullName] WHERE [g2].[FullName] <> N'Foo' ) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] @@ -3488,7 +3552,7 @@ public override async Task Select_comparison_with_null(bool async) @__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @__ammunitionType_0 AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[AmmunitionType] = @__ammunitionType_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Cartridge] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] @@ -3528,7 +3592,13 @@ public override async Task OfTypeNav2(bool async) FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN [Cities] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[Discriminator] = N'Officer' AND CASE + WHEN [c].[Location] = 'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -3570,7 +3640,10 @@ public override async Task Optional_navigation_type_compensation_works_with_list SELECT [g].[SquadId], [g].[SquadId] + 1 FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [t].[Note] """); } @@ -3625,7 +3698,10 @@ public override async Task Correlated_collections_on_select_many(bool async) LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank] @@ -3926,7 +4002,10 @@ public override async Task Optional_navigation_type_compensation_works_with_orde SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[SquadId] """); } @@ -3954,7 +4033,10 @@ public override async Task Correlated_collections_basic_projecting_constant_bool LEFT JOIN ( SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4107,7 +4189,13 @@ SELECT [l].[Name] FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND CASE + WHEN [l0].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4201,7 +4289,7 @@ public override async Task String_compare_with_null_conditional_argument(bool as FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w0].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -4218,7 +4306,10 @@ public override async Task Correlated_collections_basic_projection_explicit_to_a LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -4294,7 +4385,7 @@ public override async Task Double_order_by_on_string_compare(bool async) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [w].[Name] = N'Marcus'' Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [w].[Id] """); @@ -4367,7 +4458,10 @@ public override async Task Include_with_nested_navigation_in_order_by(bool async FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Cities] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [c] ON [g].[CityOfBirthName] = [c].[Name] -WHERE [g].[Nickname] <> N'Paduk' OR [g].[Nickname] IS NULL +WHERE CASE + WHEN [g].[Nickname] = N'Paduk' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [c].[Name], [w].[Id] """); } @@ -4497,7 +4591,10 @@ INNER JOIN ( FROM [Factions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] WHERE [f].[Name] = N'Swarm' ) AS [f0] ON [l].[Name] = [f0].[CommanderName] -WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL +WHERE CASE + WHEN [f0].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -4688,7 +4785,10 @@ public override async Task Optional_navigation_type_compensation_works_with_pred SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[HasSoulPatch] = CAST(1 AS bit) """); } @@ -4699,7 +4799,7 @@ public override async Task Nullable_bool_comparison_is_translated_to_server(bool AssertSql( """ SELECT CASE - WHEN [f].[Eradicated] = CAST(1 AS bit) AND [f].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) + WHEN [f].[Eradicated] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsEradicated] FROM [Factions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] @@ -5162,7 +5262,10 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -5549,7 +5652,10 @@ public override async Task SelectMany_without_result_selector_and_non_equality_c """ SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -5616,7 +5722,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_Def """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [w].[Id] """); } @@ -5632,7 +5741,10 @@ public override async Task Correlated_collections_basic_projection(bool async) LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId] @@ -5706,7 +5818,10 @@ public override async Task Sum_with_optional_navigation_is_translated_to_sql(boo SELECT COALESCE(SUM([g].[SquadId]), 0) FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -5856,7 +5971,10 @@ public override async Task Projecting_property_converted_to_nullable_into_member SELECT [g].[Nickname] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +WHERE CASE + WHEN DATEPART(month, [t].[IssueDate]) = 5 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } @@ -5945,7 +6063,10 @@ public override async Task Count_with_optional_navigation_is_translated_to_sql(b SELECT COUNT(*) FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6156,7 +6277,13 @@ public override async Task OfTypeNav3(bool async) LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] INNER JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] = [w].[OwnerFullName] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE CASE + WHEN [t].[Note] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[Discriminator] = N'Officer' AND CASE + WHEN [t0].[Note] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6351,7 +6478,10 @@ public override async Task Optional_navigation_type_compensation_works_with_arra SELECT [g].[SquadId] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6446,7 +6576,10 @@ LEFT JOIN ( FROM [Factions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] WHERE [f].[Name] = N'Swarm' ) AS [f0] ON [l].[Name] = [f0].[CommanderName] -WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL +WHERE CASE + WHEN [f0].[Eradicated] = CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -6737,7 +6870,10 @@ public override async Task Optional_navigation_type_compensation_works_with_cont SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[SquadId] IN ( +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) AND [g].[SquadId] IN ( SELECT [g0].[SquadId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ) @@ -6753,7 +6889,10 @@ public override async Task Optional_navigation_type_compensation_works_with_DTOs SELECT [g].[SquadId] AS [Id] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7232,7 +7371,10 @@ SELECT [g].[Nickname] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] INNER JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] INNER JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t0] ON [g].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +WHERE CASE + WHEN [t].[GearNickName] = N'Cole Train' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [t0].[Id] """); } @@ -7299,7 +7441,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_con """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -INNER JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +INNER JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON CASE + WHEN [g].[FullName] = [w].[OwnerFullName] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [g].[Nickname], [w].[Id] """); } @@ -7318,7 +7463,10 @@ LEFT JOIN ( FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +WHERE CASE + WHEN [c].[Name] = N'Foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7348,7 +7496,10 @@ public override async Task Optional_navigation_type_compensation_works_with_proj SELECT [g].[SquadId] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -7715,7 +7866,10 @@ LEFT JOIN ( OUTER APPLY ( SELECT [w].[Name], [g0].[Nickname], [w].[Id] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + WHERE [g0].[FullName] = [w].[OwnerFullName] AND CASE + WHEN [w].[Name] = N'Bar' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] @@ -8129,7 +8283,10 @@ public override async Task Singleton_Navigation_With_Member_Access(bool async) SELECT [g].[CityOfBirthName] AS [B] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) +WHERE [g].[Nickname] = N'Marcus' AND CASE + WHEN [g].[CityOfBirthName] = N'Ephyra' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) """); } @@ -8552,7 +8709,10 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + WHEN CASE + WHEN [t].[Note] = N'K.I.A.' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] @@ -8881,7 +9041,10 @@ public override async Task Select_correlated_filtered_collection(bool async) LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL + WHERE CASE + WHEN [w].[Name] = N'Lancer' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [c].[Name] IN (N'Ephyra', N'Hanover') ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] @@ -9220,7 +9383,10 @@ public override async Task Correlated_collections_basic_projection_ordered(bool LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR CASE + WHEN [w].[Name] = N'foo' THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit) ) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs index 67aedc24e72..3c2b0823f68 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs @@ -355,7 +355,10 @@ LEFT JOIN ( FROM [Order] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o0] LEFT JOIN [OrderDetail] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o1] ON [o0].[ClientId] = [o1].[OrderClientId] AND [o0].[Id] = [o1].[OrderId] ) AS [s] ON [o].[Id] = [s].[ClientId] -WHERE [p].[Id] <> 42 OR [p].[Id] IS NULL +WHERE CASE + WHEN [p].[Id] = 42 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [o].[Id], [p].[Id], [s].[ClientId], [s].[Id], [s].[OrderClientId], [s].[OrderId] """); } @@ -390,7 +393,10 @@ SELECT COUNT(*) LEFT JOIN [OwnedPerson] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o1] ON [o0].[ClientId] = [o1].[Id] LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p0] ON [o1].[PersonAddress_Country_PlanetId] = [p0].[Id] LEFT JOIN [Star] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [p0].[StarId] = [s].[Id] - WHERE [o].[Id] = [o0].[ClientId] AND ([s].[Id] <> 42 OR [s].[Id] IS NULL)) AS [Count], [p].[Id], [p].[Name], [p].[PeriodEnd], [p].[PeriodStart], [p].[StarId] + WHERE [o].[Id] = [o0].[ClientId] AND CASE + WHEN [s].[Id] = 42 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) + END = CAST(1 AS bit)) AS [Count], [p].[Id], [p].[Name], [p].[PeriodEnd], [p].[PeriodStart], [p].[StarId] FROM [OwnedPerson] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o] LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] ORDER BY [o].[Id] @@ -411,7 +417,10 @@ LEFT JOIN ( FROM [Order] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o0] LEFT JOIN [OrderDetail] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o1] ON [o0].[ClientId] = [o1].[OrderClientId] AND [o0].[Id] = [o1].[OrderId] ) AS [s] ON [o].[Id] = [s].[ClientId] -WHERE [p].[Id] <> 7 OR [p].[Id] IS NULL +WHERE CASE + WHEN [p].[Id] = 7 THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [o].[Id], [p].[Id], [s].[ClientId], [s].[Id], [s].[OrderClientId], [s].[OrderId] """); } @@ -1374,7 +1383,10 @@ public override async Task Projecting_collection_correlated_with_keyless_entity_ SELECT [b].[Throned_Value], [f].[Id], [b].[Id], [p].[Id], [p].[Name], [p].[PeriodEnd], [p].[PeriodStart], [p].[StarId] FROM [Fink] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] LEFT JOIN [Barton] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [b] ON [f].[BartonId] = [b].[Id] -LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p] ON [b].[Throned_Value] <> [p].[Id] OR [b].[Throned_Value] IS NULL +LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p] ON CASE + WHEN [b].[Throned_Value] = [p].[Id] THEN CAST(0 AS bit) + ELSE CAST(1 AS bit) +END = CAST(1 AS bit) ORDER BY [f].[Id], [b].[Id] """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs index 066a3f2f22b..b339a6743d0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs @@ -89,7 +89,10 @@ public override async Task Filter_on_required_property_inside_required_complex_t FROM "CustomerGroup" AS "c" LEFT JOIN "Customer" AS "c0" ON "c"."OptionalCustomerId" = "c0"."Id" INNER JOIN "Customer" AS "c1" ON "c"."RequiredCustomerId" = "c1"."Id" -WHERE "c0"."ShippingAddress_ZipCode" <> 7728 OR "c0"."ShippingAddress_ZipCode" IS NULL +WHERE CASE + WHEN "c0"."ShippingAddress_ZipCode" = 7728 THEN 0 + ELSE 1 +END """); } @@ -458,7 +461,10 @@ public override async Task Filter_on_required_property_inside_required_struct_co FROM "ValuedCustomerGroup" AS "v" LEFT JOIN "ValuedCustomer" AS "v0" ON "v"."OptionalCustomerId" = "v0"."Id" INNER JOIN "ValuedCustomer" AS "v1" ON "v"."RequiredCustomerId" = "v1"."Id" -WHERE "v0"."ShippingAddress_ZipCode" <> 7728 OR "v0"."ShippingAddress_ZipCode" IS NULL +WHERE CASE + WHEN "v0"."ShippingAddress_ZipCode" = 7728 THEN 0 + ELSE 1 +END """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 0c822d8e003..050be6e9957 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -782,7 +782,10 @@ public override async Task Optional_navigation_type_compensation_works_with_DTOs SELECT "g"."SquadId" AS "Id" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END """); } @@ -949,7 +952,10 @@ public override async Task Correlated_collections_basic_projection_explicit_to_a LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId" @@ -1050,7 +1056,10 @@ public override async Task Nullable_bool_comparison_is_translated_to_server(bool AssertSql( """ -SELECT "f"."Eradicated" = 1 AND "f"."Eradicated" IS NOT NULL AS "IsEradicated" +SELECT CASE + WHEN "f"."Eradicated" = 1 THEN 1 + ELSE 0 +END AS "IsEradicated" FROM "Factions" AS "f" """); } @@ -1125,7 +1134,10 @@ public override async Task Correlated_collections_basic_projecting_constant_bool LEFT JOIN ( SELECT 1 AS "c", "w"."Id", "w"."OwnerFullName" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId" @@ -1383,7 +1395,13 @@ public override async Task OfTypeNav3(bool async) LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" INNER JOIN "Weapons" AS "w" ON "g"."FullName" = "w"."OwnerFullName" LEFT JOIN "Tags" AS "t0" ON "g"."Nickname" = "t0"."GearNickName" AND "g"."SquadId" = "t0"."GearSquadId" -WHERE ("t"."Note" <> 'Foo' OR "t"."Note" IS NULL) AND "g"."Discriminator" = 'Officer' AND ("t0"."Note" <> 'Bar' OR "t0"."Note" IS NULL) +WHERE CASE + WHEN "t"."Note" = 'Foo' THEN 0 + ELSE 1 +END AND "g"."Discriminator" = 'Officer' AND CASE + WHEN "t0"."Note" = 'Bar' THEN 0 + ELSE 1 +END """); } @@ -1420,7 +1438,10 @@ SELECT NOT EXISTS ( SELECT 1 FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" - WHERE ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND NOT ("g"."HasSoulPatch")) + WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 + END AND NOT ("g"."HasSoulPatch")) """); } @@ -1595,7 +1616,10 @@ public override async Task Correlated_collections_basic_projection_ordered(bool LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId", "w0"."Name" DESC @@ -1700,7 +1724,10 @@ public override async Task Select_Singleton_Navigation_With_Member_Access(bool a SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "g"."Nickname" = 'Marcus' AND ("g"."CityOfBirthName" <> 'Ephyra' OR "g"."CityOfBirthName" IS NULL) +WHERE "g"."Nickname" = 'Marcus' AND CASE + WHEN "g"."CityOfBirthName" = 'Ephyra' THEN 0 + ELSE 1 +END """); } @@ -1713,7 +1740,10 @@ public override async Task String_compare_with_null_conditional_argument2(bool a SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" FROM "Weapons" AS "w" LEFT JOIN "Weapons" AS "w0" ON "w"."SynergyWithId" = "w0"."Id" -ORDER BY 'Marcus'' Lancer' = "w0"."Name" AND "w0"."Name" IS NOT NULL +ORDER BY CASE + WHEN 'Marcus'' Lancer' = "w0"."Name" THEN 1 + ELSE 0 +END """); } @@ -1903,7 +1933,13 @@ public override async Task OfTypeNav1(bool async) FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" LEFT JOIN "Tags" AS "t0" ON "g"."Nickname" = "t0"."GearNickName" AND "g"."SquadId" = "t0"."GearSquadId" -WHERE ("t"."Note" <> 'Foo' OR "t"."Note" IS NULL) AND "g"."Discriminator" = 'Officer' AND ("t0"."Note" <> 'Bar' OR "t0"."Note" IS NULL) +WHERE CASE + WHEN "t"."Note" = 'Foo' THEN 0 + ELSE 1 +END AND "g"."Discriminator" = 'Officer' AND CASE + WHEN "t0"."Note" = 'Bar' THEN 0 + ELSE 1 +END """); } @@ -2002,7 +2038,10 @@ public override async Task Correlated_collections_basic_projecting_single_proper LEFT JOIN ( SELECT "w"."Name", "w"."Id", "w"."OwnerFullName" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId" @@ -2140,7 +2179,10 @@ public override async Task Select_multiple_conditions(bool async) AssertSql( """ -SELECT "w"."Id", NOT ("w"."IsAutomatic") AND "w"."SynergyWithId" = 1 AND "w"."SynergyWithId" IS NOT NULL AS "IsCartridge" +SELECT "w"."Id", NOT ("w"."IsAutomatic") AND CASE + WHEN "w"."SynergyWithId" = 1 THEN 1 + ELSE 0 +END AS "IsCartridge" FROM "Weapons" AS "w" """); } @@ -2202,7 +2244,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_Def """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Gears" AS "g" -LEFT JOIN "Weapons" AS "w" ON "g"."FullName" <> "w"."OwnerFullName" OR "w"."OwnerFullName" IS NULL +LEFT JOIN "Weapons" AS "w" ON CASE + WHEN "g"."FullName" = "w"."OwnerFullName" THEN 0 + ELSE 1 +END ORDER BY "g"."Nickname", "w"."Id" """); } @@ -2473,7 +2518,10 @@ public override async Task Optional_navigation_type_compensation_works_with_cont SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND "g"."SquadId" IN ( +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END AND "g"."SquadId" IN ( SELECT "g0"."SquadId" FROM "Gears" AS "g0" ) @@ -2524,7 +2572,10 @@ CROSS JOIN "Squads" AS "s" LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" LEFT JOIN ( SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank" @@ -2716,7 +2767,10 @@ public override async Task Subquery_containing_join_gets_lifted_clashing_names(b FROM "Gears" AS "g" INNER JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" INNER JOIN "Tags" AS "t0" ON "g"."Nickname" = "t0"."GearNickName" -WHERE "t"."GearNickName" <> 'Cole Train' OR "t"."GearNickName" IS NULL +WHERE CASE + WHEN "t"."GearNickName" = 'Cole Train' THEN 0 + ELSE 1 +END ORDER BY "g"."Nickname", "t0"."Id" """); } @@ -2873,10 +2927,11 @@ SELECT CASE FROM "LocustLeaders" AS "l" INNER JOIN "Factions" AS "f" ON "l"."Name" = "f"."CommanderName" WHERE CASE - WHEN "f"."Name" = 'Locust' THEN 1 -END = 0 OR CASE - WHEN "f"."Name" = 'Locust' THEN 1 -END IS NULL + WHEN CASE + WHEN "f"."Name" = 'Locust' THEN 1 + END = 1 THEN 0 + ELSE 1 +END """); } @@ -3046,7 +3101,10 @@ LEFT JOIN ( FROM "LocustLeaders" AS "l" WHERE "l"."Discriminator" = 'LocustCommander' ) AS "l0" ON "f"."CommanderName" = "l0"."Name" -WHERE "c"."Name" <> 'Foo' OR "c"."Name" IS NULL +WHERE CASE + WHEN "c"."Name" = 'Foo' THEN 0 + ELSE 1 +END """); } @@ -3059,7 +3117,10 @@ public override async Task Optional_navigation_type_compensation_works_with_orde SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END ORDER BY "g"."SquadId" """); } @@ -3141,7 +3202,10 @@ public override async Task Sum_with_optional_navigation_is_translated_to_sql(boo SELECT COALESCE(SUM("g"."SquadId"), 0) FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" -WHERE "t"."Note" <> 'Foo' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'Foo' THEN 0 + ELSE 1 +END """); } @@ -3243,7 +3307,10 @@ public override async Task Optional_navigation_type_compensation_works_with_nega SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND NOT ("g"."HasSoulPatch") +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END AND NOT ("g"."HasSoulPatch") """); } @@ -3801,7 +3868,10 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ -SELECT ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND COALESCE("g"."HasSoulPatch", 0) +SELECT CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END AND COALESCE("g"."HasSoulPatch", 0) FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" """); @@ -3912,7 +3982,10 @@ public override async Task SelectMany_without_result_selector_and_non_equality_c """ SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Gears" AS "g" -LEFT JOIN "Weapons" AS "w" ON "g"."FullName" <> "w"."OwnerFullName" OR "w"."OwnerFullName" IS NULL +LEFT JOIN "Weapons" AS "w" ON CASE + WHEN "g"."FullName" = "w"."OwnerFullName" THEN 0 + ELSE 1 +END """); } @@ -4051,7 +4124,13 @@ LEFT JOIN ( FROM "LocustLeaders" AS "l" WHERE "l"."Discriminator" = 'LocustCommander' ) AS "l0" ON "f"."CommanderName" = "l0"."Name" -WHERE ("c"."Name" <> 'Foo' OR "c"."Name" IS NULL) AND ("l0"."Name" <> 'Bar' OR "l0"."Name" IS NULL) +WHERE CASE + WHEN "c"."Name" = 'Foo' THEN 0 + ELSE 1 +END AND CASE + WHEN "l0"."Name" = 'Bar' THEN 0 + ELSE 1 +END """); } @@ -4118,7 +4197,10 @@ public override async Task Optional_navigation_type_compensation_works_with_arra SELECT "g"."SquadId" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END """); } @@ -4276,7 +4358,13 @@ LEFT JOIN ( FROM "LocustLeaders" AS "l" WHERE "l"."Discriminator" = 'LocustCommander' ) AS "l0" ON "f"."CommanderName" = "l0"."Name" -WHERE ("c"."Name" <> 'Foo' OR "c"."Name" IS NULL) AND ("l0"."Name" <> 'Bar' OR "l0"."Name" IS NULL) +WHERE CASE + WHEN "c"."Name" = 'Foo' THEN 0 + ELSE 1 +END AND CASE + WHEN "l0"."Name" = 'Bar' THEN 0 + ELSE 1 +END """); } @@ -4345,7 +4433,10 @@ LEFT JOIN ( SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" FROM "Weapons" AS "w" LEFT JOIN "Weapons" AS "w0" ON "w"."SynergyWithId" = "w0"."Id" -) AS "s" ON "g"."FullName" <> "s"."OwnerFullName" OR "s"."OwnerFullName" IS NULL +) AS "s" ON CASE + WHEN "g"."FullName" = "s"."OwnerFullName" THEN 0 + ELSE 1 +END ORDER BY "g"."Nickname", "s"."Id" """); } @@ -4666,7 +4757,10 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND COALESCE("g"."HasSoulPatch", 0) +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END AND COALESCE("g"."HasSoulPatch", 0) """); } @@ -4910,7 +5004,10 @@ public override async Task Singleton_Navigation_With_Member_Access(bool async) SELECT "g"."CityOfBirthName" AS "B" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "g"."Nickname" = 'Marcus' AND ("g"."CityOfBirthName" <> 'Ephyra' OR "g"."CityOfBirthName" IS NULL) +WHERE "g"."Nickname" = 'Marcus' AND CASE + WHEN "g"."CityOfBirthName" = 'Ephyra' THEN 0 + ELSE 1 +END """); } @@ -5016,7 +5113,10 @@ public override async Task Double_order_by_on_string_compare(bool async) """ SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" -ORDER BY "w"."Name" = 'Marcus'' Lancer' AND "w"."Name" IS NOT NULL, "w"."Id" +ORDER BY CASE + WHEN "w"."Name" = 'Marcus'' Lancer' THEN 1 + ELSE 0 +END, "w"."Id" """); } @@ -5163,7 +5263,10 @@ public override async Task Optional_navigation_type_compensation_works_with_proj SELECT "g"."SquadId" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END """); } @@ -5344,7 +5447,10 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_con """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Gears" AS "g" -INNER JOIN "Weapons" AS "w" ON "g"."FullName" <> "w"."OwnerFullName" OR "w"."OwnerFullName" IS NULL +INNER JOIN "Weapons" AS "w" ON CASE + WHEN "g"."FullName" = "w"."OwnerFullName" THEN 0 + ELSE 1 +END ORDER BY "g"."Nickname", "w"."Id" """); } @@ -5372,7 +5478,10 @@ public override async Task Optional_navigation_type_compensation_works_with_pred SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND "g"."HasSoulPatch" +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END AND "g"."HasSoulPatch" """); } @@ -5470,7 +5579,10 @@ LEFT JOIN ( FROM "Factions" AS "f" WHERE "f"."Name" = 'Swarm' ) AS "f0" ON "l"."Name" = "f0"."CommanderName" -WHERE "f0"."Eradicated" = 0 OR "f0"."Eradicated" IS NULL +WHERE CASE + WHEN "f0"."Eradicated" = 1 THEN 0 + ELSE 1 +END """); } @@ -5507,7 +5619,10 @@ public override async Task Include_with_nested_navigation_in_order_by(bool async FROM "Weapons" AS "w" LEFT JOIN "Gears" AS "g" ON "w"."OwnerFullName" = "g"."FullName" LEFT JOIN "Cities" AS "c" ON "g"."CityOfBirthName" = "c"."Name" -WHERE "g"."Nickname" <> 'Paduk' OR "g"."Nickname" IS NULL +WHERE CASE + WHEN "g"."Nickname" = 'Paduk' THEN 0 + ELSE 1 +END ORDER BY "c"."Name", "w"."Id" """); } @@ -5538,7 +5653,10 @@ INNER JOIN ( FROM "Factions" AS "f" WHERE "f"."Name" = 'Swarm' ) AS "f0" ON "l"."Name" = "f0"."CommanderName" -WHERE "f0"."Eradicated" = 0 OR "f0"."Eradicated" IS NULL +WHERE CASE + WHEN "f0"."Eradicated" = 1 THEN 0 + ELSE 1 +END """); } @@ -5644,7 +5762,10 @@ public override async Task String_compare_with_null_conditional_argument(bool as SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" FROM "Weapons" AS "w" LEFT JOIN "Weapons" AS "w0" ON "w"."SynergyWithId" = "w0"."Id" -ORDER BY "w0"."Name" = 'Marcus'' Lancer' AND "w0"."Name" IS NOT NULL +ORDER BY CASE + WHEN "w0"."Name" = 'Marcus'' Lancer' THEN 1 + ELSE 0 +END """); } @@ -5767,7 +5888,10 @@ public override async Task Distinct_with_optional_navigation_is_translated_to_sq SELECT DISTINCT "g"."HasSoulPatch" FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" -WHERE "t"."Note" <> 'Foo' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'Foo' THEN 0 + ELSE 1 +END """); } @@ -5897,13 +6021,19 @@ public override async Task Accessing_derived_property_using_hard_and_soft_cast(b """ SELECT "l"."Name", "l"."Discriminator", "l"."LocustHordeId", "l"."ThreatLevel", "l"."ThreatLevelByte", "l"."ThreatLevelNullableByte", "l"."DefeatedByNickname", "l"."DefeatedBySquadId", "l"."HighCommandId" FROM "LocustLeaders" AS "l" -WHERE "l"."Discriminator" = 'LocustCommander' AND ("l"."HighCommandId" <> 0 OR "l"."HighCommandId" IS NULL) +WHERE "l"."Discriminator" = 'LocustCommander' AND CASE + WHEN "l"."HighCommandId" = 0 THEN 0 + ELSE 1 +END """, // """ SELECT "l"."Name", "l"."Discriminator", "l"."LocustHordeId", "l"."ThreatLevel", "l"."ThreatLevelByte", "l"."ThreatLevelNullableByte", "l"."DefeatedByNickname", "l"."DefeatedBySquadId", "l"."HighCommandId" FROM "LocustLeaders" AS "l" -WHERE "l"."Discriminator" = 'LocustCommander' AND ("l"."HighCommandId" <> 0 OR "l"."HighCommandId" IS NULL) +WHERE "l"."Discriminator" = 'LocustCommander' AND CASE + WHEN "l"."HighCommandId" = 0 THEN 0 + ELSE 1 +END """); } @@ -6512,7 +6642,10 @@ public override async Task Correlated_collections_basic_projection_explicit_to_l LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId" @@ -6784,7 +6917,10 @@ public override async Task Select_correlated_filtered_collection(bool async) LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."Name" <> 'Lancer' OR "w"."Name" IS NULL + WHERE CASE + WHEN "w"."Name" = 'Lancer' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "c"."Name" IN ('Ephyra', 'Hanover') ORDER BY "g"."Nickname", "g"."SquadId", "c"."Name" @@ -7009,7 +7145,10 @@ LEFT JOIN ( LEFT JOIN "Squads" AS "s" ON "g3"."SquadId" = "s"."Id" LEFT JOIN "Weapons" AS "w0" ON "g3"."FullName" = "w0"."OwnerFullName" LEFT JOIN "Gears" AS "g4" ON "s"."Id" = "g4"."SquadId" - WHERE "w"."Name" <> 'Bar' OR "w"."Name" IS NULL + WHERE CASE + WHEN "w"."Name" = 'Bar' THEN 0 + ELSE 1 + END ) AS "s0" ON "g2"."FullName" = "s0"."OwnerFullName" WHERE "g2"."FullName" <> 'Foo' ) AS "s1" ON "g"."Nickname" = "s1"."LeaderNickname" AND "g"."SquadId" = "s1"."LeaderSquadId" @@ -7059,7 +7198,10 @@ public override async Task Bitwise_operation_with_null_arguments(bool async) SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" & @__prm_0 <> 0 OR "w"."AmmunitionType" IS NULL +WHERE CASE + WHEN "w"."AmmunitionType" & @__prm_0 = 0 THEN 0 + ELSE 1 +END """, // """ @@ -7600,7 +7742,10 @@ public override async Task Projecting_property_converted_to_nullable_into_member SELECT "g"."Nickname" FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" -WHERE CAST(strftime('%m', "t"."IssueDate") AS INTEGER) <> 5 OR "t"."IssueDate" IS NULL +WHERE CASE + WHEN CAST(strftime('%m', "t"."IssueDate") AS INTEGER) = 5 THEN 0 + ELSE 1 +END ORDER BY "g"."Nickname" """); } @@ -7825,7 +7970,10 @@ public override async Task Correlated_collections_basic_projecting_constant(bool LEFT JOIN ( SELECT 'BFG' AS "c", "w"."Id", "w"."OwnerFullName" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId" @@ -8256,7 +8404,10 @@ public override async Task Select_comparison_with_null(bool async) """ @__ammunitionType_0='1' (Nullable = true) -SELECT "w"."Id", "w"."AmmunitionType" = @__ammunitionType_0 AND "w"."AmmunitionType" IS NOT NULL AS "Cartridge" +SELECT "w"."Id", CASE + WHEN "w"."AmmunitionType" = @__ammunitionType_0 THEN 1 + ELSE 0 +END AS "Cartridge" FROM "Weapons" AS "w" WHERE "w"."AmmunitionType" = @__ammunitionType_0 """, @@ -8278,7 +8429,13 @@ public override async Task OfTypeNav2(bool async) FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" LEFT JOIN "Cities" AS "c" ON "g"."AssignedCityName" = "c"."Name" -WHERE ("t"."Note" <> 'Foo' OR "t"."Note" IS NULL) AND "g"."Discriminator" = 'Officer' AND ("c"."Location" <> 'Bar' OR "c"."Location" IS NULL) +WHERE CASE + WHEN "t"."Note" = 'Foo' THEN 0 + ELSE 1 +END AND "g"."Discriminator" = 'Officer' AND CASE + WHEN "c"."Location" = 'Bar' THEN 0 + ELSE 1 +END """); } @@ -8293,7 +8450,10 @@ public override async Task Correlated_collections_basic_projection(bool async) LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."IsAutomatic" OR "w"."Name" <> 'foo' OR "w"."Name" IS NULL + WHERE "w"."IsAutomatic" OR CASE + WHEN "w"."Name" = 'foo' THEN 0 + ELSE 1 + END ) AS "w0" ON "g"."FullName" = "w0"."OwnerFullName" WHERE "g"."Nickname" <> 'Marcus' ORDER BY "g"."Nickname", "g"."SquadId" @@ -8627,7 +8787,10 @@ LEFT JOIN ( LEFT JOIN ( SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Weapons" AS "w" - WHERE "w"."Name" <> 'Bar' OR "w"."Name" IS NULL + WHERE CASE + WHEN "w"."Name" = 'Bar' THEN 0 + ELSE 1 + END ) AS "w0" ON "g0"."FullName" = "w0"."OwnerFullName" WHERE "g0"."FullName" <> 'Foo' ) AS "s" ON "g"."Nickname" = "s"."LeaderNickname" AND "g"."SquadId" = "s"."LeaderSquadId" @@ -8809,7 +8972,10 @@ public override async Task Optional_navigation_type_compensation_works_with_proj SELECT "g"."SquadId" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END """); } @@ -8891,7 +9057,10 @@ public override async Task Optional_navigation_type_compensation_works_with_list SELECT "g"."SquadId", "g"."SquadId" + 1 FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" -WHERE "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'K.I.A.' THEN 0 + ELSE 1 +END ORDER BY "t"."Note" """); } @@ -8903,7 +9072,7 @@ public override async Task Projecting_property_converted_to_nullable_with_condit AssertSql( """ SELECT CASE - WHEN "t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL THEN CASE + WHEN "t"."Note" <> 'K.I.A.' THEN CASE WHEN "t"."GearNickName" IS NOT NULL THEN "g"."SquadId" END ELSE -1 @@ -8936,7 +9105,10 @@ public override async Task Count_with_optional_navigation_is_translated_to_sql(b SELECT COUNT(*) FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" -WHERE "t"."Note" <> 'Foo' OR "t"."Note" IS NULL +WHERE CASE + WHEN "t"."Note" = 'Foo' THEN 0 + ELSE 1 +END """); } @@ -9231,7 +9403,10 @@ public override async Task Navigation_based_on_complex_expression6(bool async) AssertSql( """ -SELECT "l2"."Name" = 'Queen Myrrah' AND "l2"."Name" IS NOT NULL, "l2"."Name", "l2"."Discriminator", "l2"."LocustHordeId", "l2"."ThreatLevel", "l2"."ThreatLevelByte", "l2"."ThreatLevelNullableByte", "l2"."DefeatedByNickname", "l2"."DefeatedBySquadId", "l2"."HighCommandId", "l0"."Name", "l0"."Discriminator", "l0"."LocustHordeId", "l0"."ThreatLevel", "l0"."ThreatLevelByte", "l0"."ThreatLevelNullableByte", "l0"."DefeatedByNickname", "l0"."DefeatedBySquadId", "l0"."HighCommandId" +SELECT CASE + WHEN "l2"."Name" = 'Queen Myrrah' THEN 1 + ELSE 0 +END, "l2"."Name", "l2"."Discriminator", "l2"."LocustHordeId", "l2"."ThreatLevel", "l2"."ThreatLevelByte", "l2"."ThreatLevelNullableByte", "l2"."DefeatedByNickname", "l2"."DefeatedBySquadId", "l2"."HighCommandId", "l0"."Name", "l0"."Discriminator", "l0"."LocustHordeId", "l0"."ThreatLevel", "l0"."ThreatLevelByte", "l0"."ThreatLevelNullableByte", "l0"."DefeatedByNickname", "l0"."DefeatedBySquadId", "l0"."HighCommandId" FROM "Factions" AS "f" CROSS JOIN ( SELECT "l"."Name", "l"."Discriminator", "l"."LocustHordeId", "l"."ThreatLevel", "l"."ThreatLevelByte", "l"."ThreatLevelNullableByte", "l"."DefeatedByNickname", "l"."DefeatedBySquadId", "l"."HighCommandId" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs index 31a2155adb1..265653ef358 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs @@ -230,7 +230,10 @@ public override async Task Where_string_indexof(bool async) """ SELECT "c"."CustomerID", "c"."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"."City", 'Sea') - 1 <> -1 OR "c"."City" IS NULL +WHERE CASE + WHEN instr("c"."City", 'Sea') - 1 = -1 THEN 0 + ELSE 1 +END """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs index 5018e8481a7..6b11db9f351 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs @@ -34,7 +34,10 @@ public override async Task Rewrite_compare_int_with_int(bool async) """, // """ -SELECT "e"."Id", "e"."NullableIntA" = "e"."IntB" AND "e"."NullableIntA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableIntA" = "e"."IntB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -45,7 +48,10 @@ public override async Task Rewrite_compare_int_with_int(bool async) """, // """ -SELECT "e"."Id", "e"."IntA" = "e"."NullableIntB" AND "e"."NullableIntB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."IntA" = "e"."NullableIntB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -78,25 +84,37 @@ public override async Task Rewrite_compare_int_with_int(bool async) """, // """ -SELECT "e"."Id", "e"."NullableIntA" <> "e"."IntB" OR "e"."NullableIntA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableIntA" = "e"."IntB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."NullableIntA" <> "e"."IntB" OR "e"."NullableIntA" IS NULL +WHERE CASE + WHEN "e"."NullableIntA" = "e"."IntB" THEN 0 + ELSE 1 +END """, // """ -SELECT "e"."Id", "e"."IntA" <> "e"."NullableIntB" OR "e"."NullableIntB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."IntA" = "e"."NullableIntB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."IntA" <> "e"."NullableIntB" OR "e"."NullableIntB" IS NULL +WHERE CASE + WHEN "e"."IntA" = "e"."NullableIntB" THEN 0 + ELSE 1 +END """, // """ @@ -122,25 +140,37 @@ public override async Task Rewrite_compare_int_with_int(bool async) """, // """ -SELECT "e"."Id", "e"."NullableIntA" <> "e"."IntB" OR "e"."NullableIntA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableIntA" = "e"."IntB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."NullableIntA" <> "e"."IntB" OR "e"."NullableIntA" IS NULL +WHERE CASE + WHEN "e"."NullableIntA" = "e"."IntB" THEN 0 + ELSE 1 +END """, // """ -SELECT "e"."Id", "e"."IntA" <> "e"."NullableIntB" OR "e"."NullableIntB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."IntA" = "e"."NullableIntB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."IntA" <> "e"."NullableIntB" OR "e"."NullableIntB" IS NULL +WHERE CASE + WHEN "e"."IntA" = "e"."NullableIntB" THEN 0 + ELSE 1 +END """, // """ @@ -166,7 +196,10 @@ public override async Task Rewrite_compare_int_with_int(bool async) """, // """ -SELECT "e"."Id", "e"."NullableIntA" = "e"."IntB" AND "e"."NullableIntA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableIntA" = "e"."IntB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -177,7 +210,10 @@ public override async Task Rewrite_compare_int_with_int(bool async) """, // """ -SELECT "e"."Id", "e"."IntA" = "e"."NullableIntB" AND "e"."NullableIntB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."IntA" = "e"."NullableIntB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -216,7 +252,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -238,7 +277,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -249,7 +291,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -271,7 +316,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -304,7 +352,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -326,7 +377,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -337,7 +391,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -359,7 +416,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -392,14 +452,20 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL +WHERE CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END """, // """ @@ -414,7 +480,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -425,14 +494,20 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL +WHERE CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END """, // """ @@ -447,7 +522,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -480,7 +558,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -502,18 +583,27 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL +WHERE CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -535,14 +625,20 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL +WHERE CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END """, // """ @@ -568,14 +664,20 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL +WHERE CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END """, // """ @@ -590,7 +692,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -601,14 +706,20 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL +WHERE CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END """, // """ @@ -623,7 +734,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -656,7 +770,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -678,18 +795,27 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."BoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolB" IS NULL +WHERE CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 0 + ELSE 1 +END """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // @@ -711,14 +837,20 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END AS "X" FROM "Entities1" AS "e" """, // """ SELECT "e"."Id" FROM "Entities1" AS "e" -WHERE "e"."NullableBoolA" <> "e"."BoolB" OR "e"."NullableBoolA" IS NULL +WHERE CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 0 + ELSE 1 +END """, // """ @@ -744,7 +876,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -766,7 +901,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -777,7 +915,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -799,7 +940,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -832,7 +976,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" <> "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" <> "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -854,7 +1001,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."BoolA" = "e"."NullableBoolB" AND "e"."NullableBoolB" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."BoolA" = "e"."NullableBoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -865,7 +1015,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" <> "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" <> "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -887,7 +1040,10 @@ public override async Task Rewrite_compare_bool_with_bool(bool async) """, // """ -SELECT "e"."Id", "e"."NullableBoolA" = "e"."BoolB" AND "e"."NullableBoolA" IS NOT NULL AS "X" +SELECT "e"."Id", CASE + WHEN "e"."NullableBoolA" = "e"."BoolB" THEN 1 + ELSE 0 +END AS "X" FROM "Entities1" AS "e" """, // @@ -1139,14 +1295,13 @@ public override async Task CaseWhen_equal_to_second_select(bool async) AssertSql( """ SELECT CASE - WHEN "e"."StringA" = 'Foo' THEN 3 - WHEN "e"."StringB" = 'Foo' THEN 2 - WHEN "e"."StringC" = 'Foo' THEN 3 -END = 2 AND CASE - WHEN "e"."StringA" = 'Foo' THEN 3 - WHEN "e"."StringB" = 'Foo' THEN 2 - WHEN "e"."StringC" = 'Foo' THEN 3 -END IS NOT NULL + WHEN CASE + WHEN "e"."StringA" = 'Foo' THEN 3 + WHEN "e"."StringB" = 'Foo' THEN 2 + WHEN "e"."StringC" = 'Foo' THEN 3 + END = 2 THEN 1 + ELSE 0 +END FROM "Entities1" AS "e" ORDER BY "e"."Id" """); @@ -1159,14 +1314,13 @@ public override async Task CaseWhen_equal_to_first_or_third_select(bool async) AssertSql( """ SELECT CASE - WHEN "e"."StringA" = 'Foo' THEN 3 - WHEN "e"."StringB" = 'Foo' THEN 2 - WHEN "e"."StringC" = 'Foo' THEN 3 -END = 3 AND CASE - WHEN "e"."StringA" = 'Foo' THEN 3 - WHEN "e"."StringB" = 'Foo' THEN 2 - WHEN "e"."StringC" = 'Foo' THEN 3 -END IS NOT NULL + WHEN CASE + WHEN "e"."StringA" = 'Foo' THEN 3 + WHEN "e"."StringB" = 'Foo' THEN 2 + WHEN "e"."StringC" = 'Foo' THEN 3 + END = 3 THEN 1 + ELSE 0 +END FROM "Entities1" AS "e" ORDER BY "e"."Id" """);