Skip to content

Commit 0057019

Browse files
elianddbclaude
andcommitted
Fix CI failures: Properly handle NULL values and empty strings
- Fixed CONCAT_WS to skip NULL values returned from Convert (matches MySQL) - Fixed ConvertToBytes to return empty slice [] for empty strings, not nil - Ensures empty strings are preserved while invalid UTF-8 becomes NULL - All string type tests and expression function tests now pass - Maintains MySQL-compatible behavior for all string operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6c52a62 commit 0057019

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

sql/expression/function/concat_ws.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ func (f *ConcatWithSeparator) Eval(ctx *sql.Context, row sql.Row) (interface{},
127127
return nil, err
128128
}
129129

130+
// Skip NULL values returned from Convert (e.g., invalid UTF-8 data)
131+
if val == nil {
132+
continue
133+
}
134+
130135
parts = append(parts, val.(string))
131136
}
132137

sql/types/strings.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ func (t StringType) Convert(ctx context.Context, v interface{}) (interface{}, sq
335335
}
336336

337337
// If ConvertToBytes returned nil for invalid UTF-8, return nil (matches MySQL)
338+
// Note: empty strings return empty slice [], not nil, so they should be preserved
338339
if val == nil {
339340
return nil, sql.InRange, nil
340341
}
@@ -400,6 +401,10 @@ func ConvertToBytes(ctx context.Context, v interface{}, t sql.StringType, dest [
400401
val = strconv.AppendUint(dest, s, 10)
401402
case string:
402403
val = append(dest, s...)
404+
// Ensure empty strings return empty slice, not nil
405+
if val == nil && len(s) == 0 {
406+
val = []byte{}
407+
}
403408
case []byte:
404409
// We can avoid copying the slice if this isn't a conversion to BINARY
405410
// We'll check for that below, immediately before extending the slice.

0 commit comments

Comments
 (0)