Skip to content

Commit e03d7bd

Browse files
author
James Cor
committed
fix and test
1 parent d5eeb13 commit e03d7bd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

enginetest/queries/script_queries.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7531,6 +7531,23 @@ where
75317531
},
75327532
},
75337533
},
7534+
{
7535+
Name: "multi enum return types",
7536+
SetUpScript: []string{
7537+
"create table t (i int primary key, e enum('abc', 'def', 'ghi'));",
7538+
"insert into t values (1, 'abc'), (2, 'def'), (3, 'ghi');",
7539+
},
7540+
Assertions: []ScriptTestAssertion{
7541+
{
7542+
Query: "select i, (case e when 'abc' then e when 'def' then e when 'ghi' then e end) as e from t;",
7543+
Expected: []sql.Row{
7544+
{1, "abc"},
7545+
{2, "def"},
7546+
{3, "ghi"},
7547+
},
7548+
},
7549+
},
7550+
},
75347551
}
75357552

75367553
var SpatialScriptTests = []ScriptTest{

sql/expression/case.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ func combinedCaseBranchType(left, right sql.Type) sql.Type {
5252
if right == types.Null {
5353
return left
5454
}
55+
if types.IsEnum(left) && types.IsEnum(right) {
56+
return right
57+
}
58+
if types.IsSet(left) && types.IsSet(right) {
59+
return right
60+
}
5561
if types.IsTextOnly(left) && types.IsTextOnly(right) {
5662
return types.LongText
5763
}

0 commit comments

Comments
 (0)