Skip to content

Commit

Permalink
Use matching type mapping when translating BoolSwitch (#34906)
Browse files Browse the repository at this point in the history
Fixes #34900.
  • Loading branch information
ranma42 authored Oct 16, 2024
1 parent e699666 commit cd28eae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
args => new CaseExpression(
operand: args[0],
[
new CaseWhenClause(new SqlConstantExpression(true, typeMapping: BoolTypeMapping.Default), args[1]),
new CaseWhenClause(new SqlConstantExpression(false, typeMapping: BoolTypeMapping.Default), args[2])
new CaseWhenClause(new SqlConstantExpression(true, typeMapping: args[0].TypeMapping), args[1]),
new CaseWhenClause(new SqlConstantExpression(false, typeMapping: args[0].TypeMapping), args[2])
])));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3939,8 +3939,8 @@ SELECT CASE CASE
WHEN [e].[StringA] = N'Foo' THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END
WHEN 1 THEN 3
WHEN 0 THEN 2
WHEN CAST(1 AS bit) THEN 3
WHEN CAST(0 AS bit) THEN 2
END
FROM [Entities1] AS [e]
ORDER BY [e].[Id]
Expand All @@ -3959,8 +3959,8 @@ WHERE CASE CASE
WHEN [e].[StringA] = N'Foo' THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END
WHEN 1 THEN 3
WHEN 0 THEN 2
WHEN CAST(1 AS bit) THEN 3
WHEN CAST(0 AS bit) THEN 2
END = 2
""");
}
Expand Down

0 comments on commit cd28eae

Please sign in to comment.