2
0

Fix crash reading value after empty array

fixes #51
This commit is contained in:
Jack Christensen
2014-12-19 08:25:33 -06:00
parent c195d9bb96
commit 3c61b16776
2 changed files with 24 additions and 0 deletions
+20
View File
@@ -786,3 +786,23 @@ func TestQueryRowCoreStringSlice(t *testing.T) {
ensureConnValid(t, conn)
}
func TestReadingValueAfterEmptyArray(t *testing.T) {
conn := mustConnect(t, *defaultConnConfig)
defer closeConn(t, conn)
var a []string
var b int32
err := conn.QueryRow("select '{}'::text[], 42::integer").Scan(&a, &b)
if err != nil {
t.Fatalf("conn.QueryRow failed: ", err)
}
if len(a) != 0 {
t.Errorf("Expected 'a' to have length 0, but it was: ", len(a))
}
if b != 42 {
t.Errorf("Expected 'b' to 42, but it was: ", b)
}
}