Skip to content

Commit 1a23242

Browse files
committed
Avoid phantom nil values
1 parent cd41d9f commit 1a23242

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

driver_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,16 @@ func TestNULL(t *testing.T) {
613613
dbt.Error("Unexpected NullString value:" + ns.String + " (should be `1`)")
614614
}
615615

616+
// bytes
617+
// Check input==output with input!=nil
618+
b := []byte("")
619+
if err = dbt.db.QueryRow("SELECT ?", b).Scan(&b); err != nil {
620+
dbt.Fatal(err)
621+
}
622+
if b == nil {
623+
dbt.Error("nil echo from non-nil input")
624+
}
625+
616626
// Insert NULL
617627
dbt.mustExec("CREATE TABLE test (dummmy1 int, value int, dummy2 int)")
618628

utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func readLengthEnodedString(b []byte) ([]byte, bool, int, error) {
349349
// Get length
350350
num, isNull, n := readLengthEncodedInteger(b)
351351
if num < 1 {
352-
return nil, isNull, n, nil
352+
return b[n:n], isNull, n, nil
353353
}
354354

355355
n += int(num)

0 commit comments

Comments
 (0)