1
0
mirror of https://github.com/golang/go synced 2024-10-02 06:38:32 -06:00

database/sql: fix unreachable code in ColumnTypes test

Before this change the ct == 0 check could never be true. Moreover the
values were not properly indirected.

Change-Id: Ice47e36e3492babc4b47d2f9099e8772be231c96
Reviewed-on: https://go-review.googlesource.com/68130
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Julien Schmidt 2017-10-04 17:26:14 +02:00 committed by Daniel Theophanes
parent c80338accb
commit 678ce97635

View File

@ -726,15 +726,15 @@ func TestRowsColumnTypes(t *testing.T) {
if err != nil {
t.Fatalf("failed to scan values in %v", err)
}
if ct == 1 {
if age := *values[0].(*int32); age != 2 {
t.Errorf("Expected 2, got %v", age)
}
if name := *values[1].(*string); name != "Bob" {
t.Errorf("Expected Bob, got %v", name)
}
}
ct++
if ct == 0 {
if values[0].(string) != "Bob" {
t.Errorf("Expected Bob, got %v", values[0])
}
if values[1].(int) != 2 {
t.Errorf("Expected 2, got %v", values[1])
}
}
}
if ct != 3 {
t.Errorf("expected 3 rows, got %d", ct)