// Use github.com/shopspring/decimal as real-world database/sql custom type // to test against. func TestConnQueryDatabaseSQLDriverValuer(t *testing.T) { t.Parallel() conn := mustConnect(t, *defaultConnConfig) defer closeConn(t, conn) expected, err := decimal.NewFromString("1234.567") if err != nil { t.Fatal(err) } var num decimal.Decimal err = conn.QueryRow("select $1::decimal", expected).Scan(&num) if err != nil { t.Fatalf("Scan failed: %v", err) } if !num.Equals(expected) { t.Errorf("Expected num to be %v, but it was %v", expected, num) } ensureConnValid(t, conn) }