diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs index 9c512a44cbc..a39f6759a22 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs @@ -1049,6 +1049,9 @@ await AssertQueryScalar( e => (e.BoolA ? e.NullableBoolA != e.NullableBoolB : e.BoolC) != e.BoolB ? e.BoolA : e.NullableBoolB == e.NullableBoolC).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Select(e => (e.BoolA ? e.NullableIntA : e.IntB) > e.IntC)); } [ConditionalTheory] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index cecc6e20f4d..723439c6bf5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -1745,6 +1745,17 @@ ELSE CASE ELSE CAST(0 AS bit) END END = CAST(1 AS bit) +""", + // + """ +SELECT CASE + WHEN CASE + WHEN [e].[BoolA] = CAST(1 AS bit) THEN [e].[NullableIntA] + ELSE [e].[IntB] + END > [e].[IntC] THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Entities1] AS [e] """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs index 12b90479a50..959aacf861b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs @@ -17,6 +17,53 @@ public NullSemanticsQuerySqliteTest(NullSemanticsQuerySqliteFixture fixture, ITe //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + public override async Task Null_semantics_conditional(bool async) + { + await base.Null_semantics_conditional(async); + + AssertSql( + """ +SELECT "e"."Id" +FROM "Entities1" AS "e" +WHERE "e"."BoolA" = CASE + WHEN "e"."BoolB" THEN "e"."NullableBoolB" + ELSE "e"."NullableBoolC" +END +""", + // + """ +SELECT "e"."Id" +FROM "Entities1" AS "e" +WHERE CASE + WHEN ("e"."NullableBoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolA" IS NULL OR "e"."NullableBoolB" IS NULL) AND ("e"."NullableBoolA" IS NOT NULL OR "e"."NullableBoolB" IS NOT NULL) THEN "e"."BoolB" + ELSE "e"."BoolC" +END = "e"."BoolA" +""", + // + """ +SELECT "e"."Id" +FROM "Entities1" AS "e" +WHERE CASE + WHEN CASE + WHEN "e"."BoolA" THEN ("e"."NullableBoolA" <> "e"."NullableBoolB" OR "e"."NullableBoolA" IS NULL OR "e"."NullableBoolB" IS NULL) AND ("e"."NullableBoolA" IS NOT NULL OR "e"."NullableBoolB" IS NOT NULL) + ELSE "e"."BoolC" + END <> "e"."BoolB" THEN "e"."BoolA" + ELSE ("e"."NullableBoolB" = "e"."NullableBoolC" AND "e"."NullableBoolB" IS NOT NULL AND "e"."NullableBoolC" IS NOT NULL) OR ("e"."NullableBoolB" IS NULL AND "e"."NullableBoolC" IS NULL) +END +""", + // + """ +SELECT CASE + WHEN CASE + WHEN "e"."BoolA" THEN "e"."NullableIntA" + ELSE "e"."IntB" + END > "e"."IntC" THEN 1 + ELSE 0 +END +FROM "Entities1" AS "e" +"""); + } + public override async Task Null_semantics_contains_non_nullable_item_with_non_nullable_subquery(bool async) { await base.Null_semantics_contains_non_nullable_item_with_non_nullable_subquery(async);