2
0

Generalize pointer to string uuid transcoding to any non-varchar/text type

This commit is contained in:
Jack Christensen
2015-09-09 18:07:05 -05:00
parent 2184ffb5e9
commit 4ff46becfc
2 changed files with 19 additions and 6 deletions
+12 -3
View File
@@ -199,20 +199,29 @@ func mustParseCIDR(t *testing.T, s string) net.IPNet {
return *ipnet
}
func TestUuidTranscode(t *testing.T) {
func TestStringToNotTextTypeTranscode(t *testing.T) {
t.Parallel()
conn := mustConnect(t, *defaultConnConfig)
defer closeConn(t, conn)
input := "01086ee0-4963-4e35-9116-30c173a8d0bd"
var output string
err := conn.QueryRow("select $1::uuid", &input).Scan(&output)
err := conn.QueryRow("select $1::uuid", input).Scan(&output)
if err != nil {
t.Fatal(err)
}
if input != output {
t.Errorf("uuid: Did not transcode successfully: %s is not %s", input, output)
t.Errorf("uuid: Did not transcode string successfully: %s is not %s", input, output)
}
err = conn.QueryRow("select $1::uuid", &input).Scan(&output)
if err != nil {
t.Fatal(err)
}
if input != output {
t.Errorf("uuid: Did not transcode pointer to string successfully: %s is not %s", input, output)
}
}