Skip to content

Commit

Permalink
fix and test
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cor committed Nov 22, 2024
1 parent adc2897 commit 4b45688
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions enginetest/queries/variable_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ var VariableQueries = []ScriptTest{
{"ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES,STRICT_TRANS_TABLES,TRADITIONAL"},
},
},
{
Name: "set sql_mode variable ignores empty strings",
SetUpScript: []string{
`SET sql_mode = ',,,,STRICT_TRANS_TABLES,,,,,NO_AUTO_VALUE_ON_ZERO,,,,NO_ENGINE_SUBSTITUTION,,,,,,'`,
},
Query: "SELECT @@sql_mode",
Expected: []sql.Row{
{"NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"},
},
},
{
Name: "show variables renders enums after set",
SetUpScript: []string{
Expand Down
4 changes: 4 additions & 0 deletions sql/types/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ func (t SetType) convertStringToBitField(str string) (uint64, error) {
var bitField uint64
vals := strings.Split(str, ",")
for _, val := range vals {
// empty string should hash to 0, so just skip
if val == "" {
continue
}
compareVal := val
if t.collation != sql.Collation_binary {
compareVal = strings.TrimRight(compareVal, " ")
Expand Down

0 comments on commit 4b45688

Please sign in to comment.