Skip to content

Commit cf26050

Browse files
committed
don't ignore empty strings in set string conversions
1 parent 5b36e6e commit cf26050

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

enginetest/queries/script_queries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9764,6 +9764,7 @@ where
97649764
},
97659765
},
97669766
{
9767+
// this is failing due to a type coercion bug in comparison.Compare
97679768
Skip: true,
97689769
Query: "select i, s + 0, s from t where s = '';",
97699770
Expected: []sql.Row{
@@ -9773,7 +9774,6 @@ where
97739774
},
97749775
},
97759776
{
9776-
Skip: true,
97779777
Query: "select i, s + 0, s from tt;",
97789778
Expected: []sql.Row{
97799779
{0, float64(3), "something,"},

sql/types/set.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ func (t SetType) convertBitFieldToString(bitField uint64) (string, error) {
347347
if !ok {
348348
return "", sql.ErrInvalidSetValue.New(bitField)
349349
}
350-
if len(val) == 0 {
351-
continue
352-
}
353350
if writeCommas {
354351
strBuilder.WriteByte(',')
355352
} else {
@@ -367,6 +364,7 @@ func (t SetType) convertStringToBitField(str string) (uint64, error) {
367364
return 0, nil
368365
}
369366
var bitField uint64
367+
_, allowEmptyString := t.valToBit[""]
370368
lastI := 0
371369
var val string
372370
for i := 0; i < len(str)+1; i++ {
@@ -375,7 +373,7 @@ func (t SetType) convertStringToBitField(str string) (uint64, error) {
375373
}
376374

377375
// empty string should hash to 0, so just skip
378-
if lastI == i {
376+
if lastI == i && !allowEmptyString {
379377
lastI = i + 1
380378
continue
381379
}

0 commit comments

Comments
 (0)