2
0

Support nil pointers to value implementing driver.Valuer

fixes #339
This commit is contained in:
Jack Christensen
2017-10-26 21:36:12 -04:00
parent 21ef449944
commit 82cd87d502
4 changed files with 88 additions and 4 deletions
+22
View File
@@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/cockroachdb/apd"
"github.com/jackc/pgx"
"github.com/jackc/pgx/pgtype"
satori "github.com/jackc/pgx/pgtype/ext/satori-uuid"
@@ -1001,6 +1002,27 @@ func TestConnQueryDatabaseSQLDriverValuer(t *testing.T) {
ensureConnValid(t, conn)
}
// https://github.com/jackc/pgx/issues/339
func TestConnQueryDatabaseSQLDriverValuerWithAutoGeneratedPointerReceiver(t *testing.T) {
t.Parallel()
conn := mustConnect(t, *defaultConnConfig)
defer closeConn(t, conn)
mustExec(t, conn, "create temporary table t(n numeric)")
var d *apd.Decimal
commandTag, err := conn.Exec(`insert into t(n) values($1)`, d)
if err != nil {
t.Fatal(err)
}
if commandTag != "INSERT 0 1" {
t.Fatalf("want %s, got %s", "INSERT 0 1", commandTag)
}
ensureConnValid(t, conn)
}
func TestConnQueryDatabaseSQLDriverValuerWithBinaryPgTypeThatAcceptsSameType(t *testing.T) {
t.Parallel()