Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
""");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public abstract class GearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureB
{
case 1:
case 2:
case 3:
return "LocustHorde";

default:
Expand All @@ -59,6 +60,7 @@ public abstract class GearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureB

case "Queen Myrrah":
case "Unknown":
case "Reyna Diaz":
return "LocustCommander";

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NullSemanticsEntity1>().Where(e => (e.NullableStringA ?? e.NullableStringB) == (e.StringA ?? e.StringB))
ss => ss.Set<NullSemanticsEntity1>().Where(e => (e.NullableStringA ?? e.NullableStringB) == (e.NullableStringC ?? e.StringA))
.Select(e => e.Id));

[ConditionalTheory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public virtual Task ToString_boolean_property_non_nullable(bool async)
async,
ss => ss.Set<Weapon>().Select(w => w.IsAutomatic.ToString()));

[ConditionalTheory]
[ConditionalTheory(Skip = "Issue #33941 Nullable<bool>.ToString() does not match C#")]
[MemberData(nameof(IsAsyncData))]
public virtual Task ToString_boolean_property_nullable(bool async)
=> AssertQuery(
Expand Down Expand Up @@ -1793,21 +1793,21 @@ from g2 in grouping.DefaultIfEmpty()
public virtual Task Coalesce_operator_in_predicate(bool async)
=> AssertQuery(
async,
ss => ss.Set<Weapon>().Where(w => (bool?)w.IsAutomatic ?? false));
ss => ss.Set<CogTag>().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<Weapon>().Where(w => w.AmmunitionType == AmmunitionType.Cartridge && ((bool?)w.IsAutomatic ?? false)));
ss => ss.Set<CogTag>().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<Weapon>().Select(w => w.AmmunitionType == AmmunitionType.Cartridge && ((bool?)w.IsAutomatic ?? false)));
ss => ss.Set<CogTag>().Select(x => x.Note != "K.I.A." && ((bool?)x.Gear.HasSoulPatch ?? false)));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down Expand Up @@ -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<string>(horde, "Name"), Eradicated = EF.Property<bool>((LocustHorde)f, "Eradicated") },
select new { Name = EF.Property<string>(horde, "Name"), Eradicated = EF.Property<bool?>((LocustHorde)f, "Eradicated") },
assertOrder: true);

[ConditionalTheory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2698,7 +2698,7 @@ public virtual Task Filter_coalesce_operator(bool async)
=> AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => (c.CompanyName ?? c.ContactName) == "The Big Cheese"));
.Where(c => (c.ContactName ?? c.CompanyName) == "Liz Nixon"));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ public static IReadOnlyList<LocustLeader> CreateLocustLeaders()
ThreatLevel = 0,
ThreatLevelByte = 0,
ThreatLevelNullableByte = null
},
new LocustCommander
{
Name = "Reyna Diaz",
ThreatLevel = 4,
ThreatLevelByte = 4,
ThreatLevelNullableByte = 4
}
};

Expand All @@ -435,6 +442,13 @@ public static IReadOnlyList<Faction> CreateFactions()
Name = "Swarm",
Eradicated = false,
CommanderName = "Unknown"
},
new LocustHorde
{
Id = 3,
Name = "Future Locust",
Eradicated = null,
CommanderName = "Reyna Diaz"
}
};

Expand Down Expand Up @@ -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(
Expand All @@ -613,5 +636,6 @@ public static void WireUp2(
locustLeaders[3]
];
((LocustHorde)factions[1]).Leaders = [locustLeaders[4], locustLeaders[5]];
((LocustHorde)factions[2]).Leaders = [locustLeaders[6]];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
""");
}

Expand All @@ -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)
""");
}

Expand All @@ -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]
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
""");
}

Expand All @@ -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)
""");
}

Expand All @@ -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]
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
""");
}

Expand All @@ -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)
""");
}

Expand All @@ -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]
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
""");
}

Expand Down Expand Up @@ -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)
""");
}

Expand Down Expand Up @@ -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]
""");
}

Expand Down
Loading