Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1450,11 +1450,11 @@ func TestCharset(t *testing.T) {
mustSetCharset("charset=ascii", "ascii")

// when the first charset is invalid, use the second
mustSetCharset("charset=none,utf8", "utf8")
mustSetCharset("charset=none,utf8mb4", "utf8mb4")

// when the first charset is valid, use it
mustSetCharset("charset=ascii,utf8", "ascii")
mustSetCharset("charset=utf8,ascii", "utf8")
mustSetCharset("charset=ascii,utf8mb4", "ascii")
mustSetCharset("charset=utf8mb4,ascii", "utf8mb4")
}

func TestFailingCharset(t *testing.T) {
Expand Down
52 changes: 26 additions & 26 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,40 +761,40 @@ func (rows *textRows) readRow(dest []driver.Value) error {
}

// RowSet Packet
var n int
var isNull bool
pos := 0
var (
n int
isNull bool
pos int = 0
)

for i := range dest {
// Read bytes and convert to string
dest[i], isNull, n, err = readLengthEncodedString(data[pos:])
pos += n
if err == nil {
if !isNull {
if !mc.parseTime {
continue
} else {
switch rows.rs.columns[i].fieldType {
case fieldTypeTimestamp, fieldTypeDateTime,
fieldTypeDate, fieldTypeNewDate:
dest[i], err = parseDateTime(
dest[i].([]byte),
mc.cfg.Loc,
)
if err == nil {
continue
}
default:
continue
}
}

} else {
dest[i] = nil
continue
if err != nil {
return err
}

if isNull {
dest[i] = nil
continue
}

if !mc.parseTime {
continue
}

// Parse time field
switch rows.rs.columns[i].fieldType {
case fieldTypeTimestamp,
fieldTypeDateTime,
fieldTypeDate,
fieldTypeNewDate:
if dest[i], err = parseDateTime(dest[i].([]byte), mc.cfg.Loc); err != nil {
return err
}
}
return err // err != nil
}

return nil
Expand Down