mirror of
https://github.com/jackc/pgx.git
synced 2025-05-28 18:22:15 +00:00
Remove internalNativeGoTypeFormats
This commit is contained in:
parent
b9e2f0e814
commit
ad2ce2ce3c
13
conn.go
13
conn.go
@ -984,7 +984,18 @@ func (c *Conn) sendPreparedQuery(ps *PreparedStatement, arguments ...interface{}
|
||||
case string, *string:
|
||||
wbuf.WriteInt16(TextFormatCode)
|
||||
default:
|
||||
wbuf.WriteInt16(internalNativeGoTypeFormats[oid])
|
||||
if dt, ok := c.ConnInfo.DataTypeForOid(oid); ok {
|
||||
switch dt.Value.(type) {
|
||||
case pgtype.BinaryEncoder:
|
||||
wbuf.WriteInt16(BinaryFormatCode)
|
||||
case pgtype.TextEncoder:
|
||||
wbuf.WriteInt16(TextFormatCode)
|
||||
default:
|
||||
return fmt.Errorf("value for oid %v does not implement pgtype.BinaryEncoder or pgtype.TextEncoder", oid)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("unknown type for oid %v", oid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
35
values.go
35
values.go
@ -72,9 +72,6 @@ const minInt = -maxInt - 1
|
||||
// set here.
|
||||
var DefaultTypeFormats map[string]int16
|
||||
|
||||
// internalNativeGoTypeFormats lists the encoding type for native Go types (not handled with Encoder interface)
|
||||
var internalNativeGoTypeFormats map[pgtype.Oid]int16
|
||||
|
||||
func init() {
|
||||
DefaultTypeFormats = map[string]int16{
|
||||
"_aclitem": TextFormatCode, // Pg's src/backend/utils/adt/acl.c has only in/out (text) not send/recv (bin)
|
||||
@ -111,38 +108,6 @@ func init() {
|
||||
"timestamptz": BinaryFormatCode,
|
||||
"xid": BinaryFormatCode,
|
||||
}
|
||||
|
||||
internalNativeGoTypeFormats = map[pgtype.Oid]int16{
|
||||
BoolArrayOid: BinaryFormatCode,
|
||||
BoolOid: BinaryFormatCode,
|
||||
ByteaArrayOid: BinaryFormatCode,
|
||||
ByteaOid: BinaryFormatCode,
|
||||
CidrArrayOid: BinaryFormatCode,
|
||||
CidrOid: BinaryFormatCode,
|
||||
DateOid: BinaryFormatCode,
|
||||
Float4ArrayOid: BinaryFormatCode,
|
||||
Float4Oid: BinaryFormatCode,
|
||||
Float8ArrayOid: BinaryFormatCode,
|
||||
Float8Oid: BinaryFormatCode,
|
||||
InetArrayOid: BinaryFormatCode,
|
||||
InetOid: BinaryFormatCode,
|
||||
Int2ArrayOid: BinaryFormatCode,
|
||||
Int2Oid: BinaryFormatCode,
|
||||
Int4ArrayOid: BinaryFormatCode,
|
||||
Int4Oid: BinaryFormatCode,
|
||||
Int8ArrayOid: BinaryFormatCode,
|
||||
Int8Oid: BinaryFormatCode,
|
||||
JsonbOid: BinaryFormatCode,
|
||||
JsonOid: BinaryFormatCode,
|
||||
OidOid: BinaryFormatCode,
|
||||
RecordOid: BinaryFormatCode,
|
||||
TextArrayOid: BinaryFormatCode,
|
||||
TimestampArrayOid: BinaryFormatCode,
|
||||
TimestampOid: BinaryFormatCode,
|
||||
TimestampTzArrayOid: BinaryFormatCode,
|
||||
TimestampTzOid: BinaryFormatCode,
|
||||
VarcharArrayOid: BinaryFormatCode,
|
||||
}
|
||||
}
|
||||
|
||||
// SerializationError occurs on failure to encode or decode a value
|
||||
|
Loading…
x
Reference in New Issue
Block a user