Skip to content

Commit 0b7e272

Browse files
committed
Use matching type mapping when translating BoolSwitch
Fixes #34900.
1 parent 9ec3988 commit 0b7e272

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
137137
args => new CaseExpression(
138138
operand: args[0],
139139
[
140-
new CaseWhenClause(new SqlConstantExpression(true, typeMapping: BoolTypeMapping.Default), args[1]),
141-
new CaseWhenClause(new SqlConstantExpression(false, typeMapping: BoolTypeMapping.Default), args[2])
140+
new CaseWhenClause(new SqlConstantExpression(true, typeMapping: args[0].TypeMapping), args[1]),
141+
new CaseWhenClause(new SqlConstantExpression(false, typeMapping: args[0].TypeMapping), args[2])
142142
])));
143143
}
144144

test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3939,8 +3939,8 @@ SELECT CASE CASE
39393939
WHEN [e].[StringA] = N'Foo' THEN CAST(1 AS bit)
39403940
ELSE CAST(0 AS bit)
39413941
END
3942-
WHEN 1 THEN 3
3943-
WHEN 0 THEN 2
3942+
WHEN CAST(1 AS bit) THEN 3
3943+
WHEN CAST(0 AS bit) THEN 2
39443944
END
39453945
FROM [Entities1] AS [e]
39463946
ORDER BY [e].[Id]
@@ -3959,8 +3959,8 @@ WHERE CASE CASE
39593959
WHEN [e].[StringA] = N'Foo' THEN CAST(1 AS bit)
39603960
ELSE CAST(0 AS bit)
39613961
END
3962-
WHEN 1 THEN 3
3963-
WHEN 0 THEN 2
3962+
WHEN CAST(1 AS bit) THEN 3
3963+
WHEN CAST(0 AS bit) THEN 2
39643964
END = 2
39653965
""");
39663966
}

0 commit comments

Comments
 (0)