diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index 8b8e22874ca..f72eea8d982 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -1937,7 +1937,7 @@ public override Task Filter_coalesce_operator(bool async) """ SELECT c FROM root c -WHERE ((c["Discriminator"] = "Customer") AND (((c["CompanyName"] != null) ? c["CompanyName"] : c["ContactName"]) = "The Big Cheese")) +WHERE ((c["Discriminator"] = "Customer") AND (((c["ContactName"] != null) ? c["ContactName"] : c["CompanyName"]) = "Liz Nixon")) """); }); diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs index 5ecda262286..96a44ccf964 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs @@ -39,6 +39,7 @@ public abstract class GearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureB { case 1: case 2: + case 3: return "LocustHorde"; default: @@ -59,6 +60,7 @@ public abstract class GearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureB case "Queen Myrrah": case "Unknown": + case "Reyna Diaz": return "LocustCommander"; default: diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs index 146acd711fa..ceebfdb3126 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs @@ -565,7 +565,7 @@ public virtual Task Where_not_equal_with_coalesce(bool async) public virtual Task Where_equal_with_coalesce_both_sides(bool async) => AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) == (e.StringA ?? e.StringB)) + ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) == (e.NullableStringC ?? e.StringA)) .Select(e => e.Id)); [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index 50d9e1ee805..22ed658812d 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -84,7 +84,7 @@ public virtual Task ToString_boolean_property_non_nullable(bool async) async, ss => ss.Set().Select(w => w.IsAutomatic.ToString())); - [ConditionalTheory] + [ConditionalTheory(Skip = "Issue #33941 Nullable.ToString() does not match C#")] [MemberData(nameof(IsAsyncData))] public virtual Task ToString_boolean_property_nullable(bool async) => AssertQuery( @@ -1793,21 +1793,21 @@ from g2 in grouping.DefaultIfEmpty() public virtual Task Coalesce_operator_in_predicate(bool async) => AssertQuery( async, - ss => ss.Set().Where(w => (bool?)w.IsAutomatic ?? false)); + ss => ss.Set().Where(x => (bool?)x.Gear.HasSoulPatch ?? false)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Coalesce_operator_in_predicate_with_other_conditions(bool async) => AssertQuery( async, - ss => ss.Set().Where(w => w.AmmunitionType == AmmunitionType.Cartridge && ((bool?)w.IsAutomatic ?? false))); + ss => ss.Set().Where(x => x.Note != "K.I.A." && ((bool?)x.Gear.HasSoulPatch ?? false))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Coalesce_operator_in_projection_with_other_conditions(bool async) => AssertQueryScalar( async, - ss => ss.Set().Select(w => w.AmmunitionType == AmmunitionType.Cartridge && ((bool?)w.IsAutomatic ?? false))); + ss => ss.Set().Select(x => x.Note != "K.I.A." && ((bool?)x.Gear.HasSoulPatch ?? false))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -2704,7 +2704,7 @@ public virtual Task Property_access_on_derived_entity_using_cast(bool async) where f is LocustHorde let horde = (LocustHorde)f orderby f.Name - select new { Name = EF.Property(horde, "Name"), Eradicated = EF.Property((LocustHorde)f, "Eradicated") }, + select new { Name = EF.Property(horde, "Name"), Eradicated = EF.Property((LocustHorde)f, "Eradicated") }, assertOrder: true); [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index 2afa772e4e9..3592a8f744b 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -2698,7 +2698,7 @@ public virtual Task Filter_coalesce_operator(bool async) => AssertQuery( async, ss => ss.Set() - .Where(c => (c.CompanyName ?? c.ContactName) == "The Big Cheese")); + .Where(c => (c.ContactName ?? c.CompanyName) == "Liz Nixon")); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs index 391d267e46a..4e6b377e38a 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs @@ -415,6 +415,13 @@ public static IReadOnlyList CreateLocustLeaders() ThreatLevel = 0, ThreatLevelByte = 0, ThreatLevelNullableByte = null + }, + new LocustCommander + { + Name = "Reyna Diaz", + ThreatLevel = 4, + ThreatLevelByte = 4, + ThreatLevelNullableByte = 4 } }; @@ -435,6 +442,13 @@ public static IReadOnlyList CreateFactions() Name = "Swarm", Eradicated = false, CommanderName = "Unknown" + }, + new LocustHorde + { + Id = 3, + Name = "Future Locust", + Eradicated = null, + CommanderName = "Reyna Diaz" } }; @@ -588,17 +602,26 @@ public static void WireUp( ((LocustCommander)locustLeaders[3]).CommandingFaction = ((LocustHorde)factions[0]); ((LocustCommander)locustLeaders[5]).CommandingFaction = ((LocustHorde)factions[1]); + ((LocustCommander)locustLeaders[6]).CommandingFaction = ((LocustHorde)factions[2]); ((LocustHorde)factions[0]).Commander = ((LocustCommander)locustLeaders[3]); ((LocustHorde)factions[1]).Commander = ((LocustCommander)locustLeaders[5]); + ((LocustHorde)factions[2]).Commander = ((LocustCommander)locustLeaders[6]); - locustHighCommands[0].Commanders = [(LocustCommander)locustLeaders[3], (LocustCommander)locustLeaders[5]]; + locustHighCommands[0].Commanders = [ + (LocustCommander)locustLeaders[3], + (LocustCommander)locustLeaders[5], + (LocustCommander)locustLeaders[6], + ]; ((LocustCommander)locustLeaders[3]).HighCommand = locustHighCommands[0]; ((LocustCommander)locustLeaders[3]).HighCommandId = 1; ((LocustCommander)locustLeaders[5]).HighCommand = locustHighCommands[0]; ((LocustCommander)locustLeaders[5]).HighCommandId = 1; + + ((LocustCommander)locustLeaders[6]).HighCommand = locustHighCommands[0]; + ((LocustCommander)locustLeaders[6]).HighCommandId = 1; } public static void WireUp2( @@ -613,5 +636,6 @@ public static void WireUp2( locustLeaders[3] ]; ((LocustHorde)factions[1]).Leaders = [locustLeaders[4], locustLeaders[5]]; + ((LocustHorde)factions[2]).Leaders = [locustLeaders[6]]; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 5628030524c..f948f7fc776 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -2279,9 +2279,10 @@ public override async Task Coalesce_operator_in_predicate(bool async) AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +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 COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -2291,9 +2292,10 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = 1 AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +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) """); } @@ -2304,10 +2306,11 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN [w].[AmmunitionType] = 1 AND [w].[AmmunitionType] IS NOT NULL AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + 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) ELSE CAST(0 AS bit) END -FROM [Weapons] AS [w] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 0d50277c0b2..2893d0b69a6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -2861,7 +2861,7 @@ public override async Task Filter_coalesce_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] -WHERE COALESCE([c].[CompanyName], [c].[ContactName]) = N'The Big Cheese' +WHERE COALESCE([c].[ContactName], [c].[CompanyName]) = N'Liz Nixon' """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index 8bb7449f6e5..f6ffe26b610 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -1118,7 +1118,7 @@ public override async Task Where_equal_with_coalesce_both_sides(bool async) """ SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE COALESCE([e].[NullableStringA], [e].[NullableStringB]) = COALESCE([e].[StringA], [e].[StringB]) +WHERE COALESCE([e].[NullableStringA], [e].[NullableStringB]) = COALESCE([e].[NullableStringC], [e].[StringA]) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index 063eb74ec1e..22e58c54fc5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -3201,9 +3201,16 @@ public override async Task Coalesce_operator_in_predicate(bool async) AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + 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 COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -3213,9 +3220,16 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = 1 AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + 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) """); } @@ -3226,10 +3240,17 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN [w].[AmmunitionType] = 1 AND [w].[AmmunitionType] IS NOT NULL AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + 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) ELSE CAST(0 AS bit) END -FROM [Weapons] AS [w] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + 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] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 197eae2881e..cadd97ff667 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -2696,9 +2696,13 @@ public override async Task Coalesce_operator_in_predicate(bool async) AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +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 COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -2708,9 +2712,13 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = 1 AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +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) """); } @@ -2721,10 +2729,14 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN [w].[AmmunitionType] = 1 AND [w].[AmmunitionType] IS NOT NULL AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + 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) ELSE CAST(0 AS bit) END -FROM [Weapons] AS [w] +FROM [Tags] AS [t] +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] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index 863e77ba626..efe49c9bce9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -5199,9 +5199,10 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( AssertSql( """ -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] = 1 AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +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) """); } @@ -6343,9 +6344,10 @@ public override async Task Coalesce_operator_in_predicate(bool async) AssertSql( """ -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 COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) +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 COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } @@ -8595,10 +8597,11 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ SELECT CASE - WHEN [w].[AmmunitionType] = 1 AND [w].[AmmunitionType] IS NOT NULL AND COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + 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) ELSE CAST(0 AS bit) END -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] +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] """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 8c0d042d05e..a01b1bcc00d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -3819,8 +3819,9 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ -SELECT "w"."AmmunitionType" = 1 AND "w"."AmmunitionType" IS NOT NULL AND COALESCE("w"."IsAutomatic", 0) -FROM "Weapons" AS "w" +SELECT ("t"."Note" <> 'K.I.A.' OR "t"."Note" IS NULL) AND COALESCE("g"."HasSoulPatch", 0) +FROM "Tags" AS "t" +LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" """); } @@ -4682,9 +4683,10 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( AssertSql( """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" = 1 AND COALESCE("w"."IsAutomatic", 0) +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) """); } @@ -6194,9 +6196,10 @@ public override async Task Coalesce_operator_in_predicate(bool async) AssertSql( """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE COALESCE("w"."IsAutomatic", 0) +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 COALESCE("g"."HasSoulPatch", 0) """); }