Skip to content

Commit 4b45688

Browse files
author
James Cor
committed
fix and test
1 parent adc2897 commit 4b45688

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

enginetest/queries/variable_queries.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,16 @@ var VariableQueries = []ScriptTest{
338338
{"ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES,STRICT_TRANS_TABLES,TRADITIONAL"},
339339
},
340340
},
341+
{
342+
Name: "set sql_mode variable ignores empty strings",
343+
SetUpScript: []string{
344+
`SET sql_mode = ',,,,STRICT_TRANS_TABLES,,,,,NO_AUTO_VALUE_ON_ZERO,,,,NO_ENGINE_SUBSTITUTION,,,,,,'`,
345+
},
346+
Query: "SELECT @@sql_mode",
347+
Expected: []sql.Row{
348+
{"NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"},
349+
},
350+
},
341351
{
342352
Name: "show variables renders enums after set",
343353
SetUpScript: []string{

sql/types/set.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ func (t SetType) convertStringToBitField(str string) (uint64, error) {
368368
var bitField uint64
369369
vals := strings.Split(str, ",")
370370
for _, val := range vals {
371+
// empty string should hash to 0, so just skip
372+
if val == "" {
373+
continue
374+
}
371375
compareVal := val
372376
if t.collation != sql.Collation_binary {
373377
compareVal = strings.TrimRight(compareVal, " ")

0 commit comments

Comments
 (0)