Fix misleading error message
This commit is contained in:
@@ -530,7 +530,7 @@ func (c *Conn) sendPreparedQuery(ps *PreparedStatement, arguments ...interface{}
|
|||||||
case VarcharArrayOid:
|
case VarcharArrayOid:
|
||||||
err = encodeTextArray(wbuf, arguments[i], VarcharOid)
|
err = encodeTextArray(wbuf, arguments[i], VarcharOid)
|
||||||
default:
|
default:
|
||||||
return SerializationError(fmt.Sprintf("%T is not a core type and it does not implement Encoder", arg))
|
return SerializationError(fmt.Sprintf("Cannot encode %T into oid %v - %T must implement Encoder or be converted to a string", arg, oid, arg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -437,6 +437,7 @@ func TestQueryRowErrors(t *testing.T) {
|
|||||||
|
|
||||||
type allTypes struct {
|
type allTypes struct {
|
||||||
i16 int16
|
i16 int16
|
||||||
|
s string
|
||||||
}
|
}
|
||||||
|
|
||||||
var actual, zero allTypes
|
var actual, zero allTypes
|
||||||
@@ -451,6 +452,7 @@ func TestQueryRowErrors(t *testing.T) {
|
|||||||
{"select $1::badtype", []interface{}{"Jack"}, []interface{}{&actual.i16}, `type "badtype" does not exist`},
|
{"select $1::badtype", []interface{}{"Jack"}, []interface{}{&actual.i16}, `type "badtype" does not exist`},
|
||||||
{"SYNTAX ERROR", []interface{}{}, []interface{}{&actual.i16}, "SQLSTATE 42601"},
|
{"SYNTAX ERROR", []interface{}{}, []interface{}{&actual.i16}, "SQLSTATE 42601"},
|
||||||
{"select $1::text", []interface{}{"Jack"}, []interface{}{&actual.i16}, "Expected type oid 21 but received type oid 25"},
|
{"select $1::text", []interface{}{"Jack"}, []interface{}{&actual.i16}, "Expected type oid 21 but received type oid 25"},
|
||||||
|
{"select $1::int8range", []interface{}{int(705)}, []interface{}{&actual.s}, "Cannot encode int into oid 3926 - int must implement Encoder or be converted to a string"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user