2
0

Add pgtype.Point

This commit is contained in:
Jack Christensen
2017-04-03 17:53:32 -05:00
parent c09c356b19
commit 5a2feadf11
6 changed files with 202 additions and 21 deletions
+14 -1
View File
@@ -710,6 +710,19 @@ func TestQueryRowUnknownType(t *testing.T) {
conn := mustConnect(t, *defaultConnConfig)
defer closeConn(t, conn)
// Clear existing type mappings
conn.ConnInfo = pgtype.NewConnInfo()
conn.ConnInfo.RegisterDataType(pgtype.DataType{
Value: &pgtype.GenericText{},
Name: "point",
Oid: 600,
})
conn.ConnInfo.RegisterDataType(pgtype.DataType{
Value: &pgtype.Int4{},
Name: "int4",
Oid: pgtype.Int4Oid,
})
sql := "select $1::point"
expected := "(1,0)"
var actual string
@@ -751,7 +764,7 @@ func TestQueryRowErrors(t *testing.T) {
{"select $1::badtype", []interface{}{"Jack"}, []interface{}{&actual.i16}, `type "badtype" does not exist`},
{"SYNTAX ERROR", []interface{}{}, []interface{}{&actual.i16}, "SQLSTATE 42601"},
{"select $1::text", []interface{}{"Jack"}, []interface{}{&actual.i16}, "cannot decode"},
{"select $1::point", []interface{}{int(705)}, []interface{}{&actual.s}, "cannot convert 705 to Text"},
{"select $1::point", []interface{}{int(705)}, []interface{}{&actual.s}, "cannot convert 705 to Point"},
}
for i, tt := range tests {