diff --git a/array.go b/array.go index 2f9ef66b..e5504455 100644 --- a/array.go +++ b/array.go @@ -18,7 +18,7 @@ import ( type ArrayHeader struct { ContainsNull bool - ElementOid int32 + ElementOID int32 Dimensions []ArrayDimension } @@ -40,7 +40,7 @@ func (dst *ArrayHeader) DecodeBinary(ci *ConnInfo, src []byte) (int, error) { dst.ContainsNull = binary.BigEndian.Uint32(src[rp:]) == 1 rp += 4 - dst.ElementOid = int32(binary.BigEndian.Uint32(src[rp:])) + dst.ElementOID = int32(binary.BigEndian.Uint32(src[rp:])) rp += 4 if numDims > 0 { @@ -69,7 +69,7 @@ func (src *ArrayHeader) EncodeBinary(ci *ConnInfo, buf []byte) []byte { } buf = pgio.AppendInt32(buf, containsNull) - buf = pgio.AppendInt32(buf, src.ElementOid) + buf = pgio.AppendInt32(buf, src.ElementOID) for i := range src.Dimensions { buf = pgio.AppendInt32(buf, src.Dimensions[i].Length) diff --git a/bool_array.go b/bool_array.go index 3c3d4184..e20a0381 100644 --- a/bool_array.go +++ b/bool_array.go @@ -231,7 +231,7 @@ func (src *BoolArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("bool"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "bool") } diff --git a/bytea_array.go b/bytea_array.go index 67e114f5..0d381693 100644 --- a/bytea_array.go +++ b/bytea_array.go @@ -231,7 +231,7 @@ func (src *ByteaArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("bytea"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "bytea") } diff --git a/cidr_array.go b/cidr_array.go index 01237aa1..b8a70d63 100644 --- a/cidr_array.go +++ b/cidr_array.go @@ -260,7 +260,7 @@ func (src *CidrArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("cidr"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "cidr") } diff --git a/date_array.go b/date_array.go index 2175f2aa..ef91cf3e 100644 --- a/date_array.go +++ b/date_array.go @@ -232,7 +232,7 @@ func (src *DateArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("date"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "date") } diff --git a/float4_array.go b/float4_array.go index 37db8acc..a35657b0 100644 --- a/float4_array.go +++ b/float4_array.go @@ -231,7 +231,7 @@ func (src *Float4Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("float4"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "float4") } diff --git a/float8_array.go b/float8_array.go index dd3fccf1..486e3a4e 100644 --- a/float8_array.go +++ b/float8_array.go @@ -231,7 +231,7 @@ func (src *Float8Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("float8"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "float8") } diff --git a/hstore_array.go b/hstore_array.go index 2d61fa52..3e5a003f 100644 --- a/hstore_array.go +++ b/hstore_array.go @@ -231,7 +231,7 @@ func (src *HstoreArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("hstore"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "hstore") } diff --git a/inet_array.go b/inet_array.go index e448a2ca..57123c1c 100644 --- a/inet_array.go +++ b/inet_array.go @@ -260,7 +260,7 @@ func (src *InetArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("inet"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "inet") } diff --git a/int2_array.go b/int2_array.go index 1d145584..e4993104 100644 --- a/int2_array.go +++ b/int2_array.go @@ -259,7 +259,7 @@ func (src *Int2Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("int2"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "int2") } diff --git a/int4_array.go b/int4_array.go index 1c746503..6bc06e86 100644 --- a/int4_array.go +++ b/int4_array.go @@ -259,7 +259,7 @@ func (src *Int4Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("int4"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "int4") } diff --git a/int8_array.go b/int8_array.go index 56ebcab8..4404d22a 100644 --- a/int8_array.go +++ b/int8_array.go @@ -259,7 +259,7 @@ func (src *Int8Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("int8"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "int8") } diff --git a/numeric_array.go b/numeric_array.go index 20f33dff..f193a2a5 100644 --- a/numeric_array.go +++ b/numeric_array.go @@ -259,7 +259,7 @@ func (src *NumericArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) } if dt, ok := ci.DataTypeForName("numeric"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "numeric") } diff --git a/oid.go b/oid.go index 6ceacc73..d37f4e57 100644 --- a/oid.go +++ b/oid.go @@ -9,18 +9,18 @@ import ( "github.com/jackc/pgx/pgio" ) -// Oid (Object Identifier Type) is, according to +// OID (Object Identifier Type) is, according to // https://www.postgresql.org/docs/current/static/datatype-oid.html, used // internally by PostgreSQL as a primary key for various system tables. It is // currently implemented as an unsigned four-byte integer. Its definition can be // found in src/include/postgres_ext.h in the PostgreSQL sources. Because it is -// so frequently required to be in a NOT NULL condition Oid cannot be NULL. To -// allow for NULL Oids use OidValue. -type Oid uint32 +// so frequently required to be in a NOT NULL condition OID cannot be NULL. To +// allow for NULL OIDs use OIDValue. +type OID uint32 -func (dst *Oid) DecodeText(ci *ConnInfo, src []byte) error { +func (dst *OID) DecodeText(ci *ConnInfo, src []byte) error { if src == nil { - return fmt.Errorf("cannot decode nil into Oid") + return fmt.Errorf("cannot decode nil into OID") } n, err := strconv.ParseUint(string(src), 10, 32) @@ -28,13 +28,13 @@ func (dst *Oid) DecodeText(ci *ConnInfo, src []byte) error { return err } - *dst = Oid(n) + *dst = OID(n) return nil } -func (dst *Oid) DecodeBinary(ci *ConnInfo, src []byte) error { +func (dst *OID) DecodeBinary(ci *ConnInfo, src []byte) error { if src == nil { - return fmt.Errorf("cannot decode nil into Oid") + return fmt.Errorf("cannot decode nil into OID") } if len(src) != 4 { @@ -42,27 +42,27 @@ func (dst *Oid) DecodeBinary(ci *ConnInfo, src []byte) error { } n := binary.BigEndian.Uint32(src) - *dst = Oid(n) + *dst = OID(n) return nil } -func (src Oid) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { +func (src OID) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { return append(buf, strconv.FormatUint(uint64(src), 10)...), nil } -func (src Oid) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { +func (src OID) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { return pgio.AppendUint32(buf, uint32(src)), nil } // Scan implements the database/sql Scanner interface. -func (dst *Oid) Scan(src interface{}) error { +func (dst *OID) Scan(src interface{}) error { if src == nil { return fmt.Errorf("cannot scan NULL into %T", src) } switch src := src.(type) { case int64: - *dst = Oid(src) + *dst = OID(src) return nil case string: return dst.DecodeText(nil, []byte(src)) @@ -76,6 +76,6 @@ func (dst *Oid) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Oid) Value() (driver.Value, error) { +func (src OID) Value() (driver.Value, error) { return int64(src), nil } diff --git a/oid_value.go b/oid_value.go index 882d54fb..7eae4bf1 100644 --- a/oid_value.go +++ b/oid_value.go @@ -4,52 +4,52 @@ import ( "database/sql/driver" ) -// OidValue (Object Identifier Type) is, according to -// https://www.postgresql.org/docs/current/static/datatype-OidValue.html, used +// OIDValue (Object Identifier Type) is, according to +// https://www.postgresql.org/docs/current/static/datatype-OIDValue.html, used // internally by PostgreSQL as a primary key for various system tables. It is // currently implemented as an unsigned four-byte integer. Its definition can be // found in src/include/postgres_ext.h in the PostgreSQL sources. -type OidValue pguint32 +type OIDValue pguint32 -// Set converts from src to dst. Note that as OidValue is not a general +// Set converts from src to dst. Note that as OIDValue is not a general // number type Set does not do automatic type conversion as other number // types do. -func (dst *OidValue) Set(src interface{}) error { +func (dst *OIDValue) Set(src interface{}) error { return (*pguint32)(dst).Set(src) } -func (dst *OidValue) Get() interface{} { +func (dst *OIDValue) Get() interface{} { return (*pguint32)(dst).Get() } -// AssignTo assigns from src to dst. Note that as OidValue is not a general number +// AssignTo assigns from src to dst. Note that as OIDValue is not a general number // type AssignTo does not do automatic type conversion as other number types do. -func (src *OidValue) AssignTo(dst interface{}) error { +func (src *OIDValue) AssignTo(dst interface{}) error { return (*pguint32)(src).AssignTo(dst) } -func (dst *OidValue) DecodeText(ci *ConnInfo, src []byte) error { +func (dst *OIDValue) DecodeText(ci *ConnInfo, src []byte) error { return (*pguint32)(dst).DecodeText(ci, src) } -func (dst *OidValue) DecodeBinary(ci *ConnInfo, src []byte) error { +func (dst *OIDValue) DecodeBinary(ci *ConnInfo, src []byte) error { return (*pguint32)(dst).DecodeBinary(ci, src) } -func (src *OidValue) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { +func (src *OIDValue) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { return (*pguint32)(src).EncodeText(ci, buf) } -func (src *OidValue) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { +func (src *OIDValue) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { return (*pguint32)(src).EncodeBinary(ci, buf) } // Scan implements the database/sql Scanner interface. -func (dst *OidValue) Scan(src interface{}) error { +func (dst *OIDValue) Scan(src interface{}) error { return (*pguint32)(dst).Scan(src) } // Value implements the database/sql/driver Valuer interface. -func (src *OidValue) Value() (driver.Value, error) { +func (src *OIDValue) Value() (driver.Value, error) { return (*pguint32)(src).Value() } diff --git a/oid_value_test.go b/oid_value_test.go index 52ce4064..f5ff16cf 100644 --- a/oid_value_test.go +++ b/oid_value_test.go @@ -8,23 +8,23 @@ import ( "github.com/jackc/pgx/pgtype/testutil" ) -func TestOidValueTranscode(t *testing.T) { +func TestOIDValueTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "oid", []interface{}{ - &pgtype.OidValue{Uint: 42, Status: pgtype.Present}, - &pgtype.OidValue{Status: pgtype.Null}, + &pgtype.OIDValue{Uint: 42, Status: pgtype.Present}, + &pgtype.OIDValue{Status: pgtype.Null}, }) } -func TestOidValueSet(t *testing.T) { +func TestOIDValueSet(t *testing.T) { successfulTests := []struct { source interface{} - result pgtype.OidValue + result pgtype.OIDValue }{ - {source: uint32(1), result: pgtype.OidValue{Uint: 1, Status: pgtype.Present}}, + {source: uint32(1), result: pgtype.OIDValue{Uint: 1, Status: pgtype.Present}}, } for i, tt := range successfulTests { - var r pgtype.OidValue + var r pgtype.OIDValue err := r.Set(tt.source) if err != nil { t.Errorf("%d: %v", i, err) @@ -36,17 +36,17 @@ func TestOidValueSet(t *testing.T) { } } -func TestOidValueAssignTo(t *testing.T) { +func TestOIDValueAssignTo(t *testing.T) { var ui32 uint32 var pui32 *uint32 simpleTests := []struct { - src pgtype.OidValue + src pgtype.OIDValue dst interface{} expected interface{} }{ - {src: pgtype.OidValue{Uint: 42, Status: pgtype.Present}, dst: &ui32, expected: uint32(42)}, - {src: pgtype.OidValue{Status: pgtype.Null}, dst: &pui32, expected: ((*uint32)(nil))}, + {src: pgtype.OIDValue{Uint: 42, Status: pgtype.Present}, dst: &ui32, expected: uint32(42)}, + {src: pgtype.OIDValue{Status: pgtype.Null}, dst: &pui32, expected: ((*uint32)(nil))}, } for i, tt := range simpleTests { @@ -61,11 +61,11 @@ func TestOidValueAssignTo(t *testing.T) { } pointerAllocTests := []struct { - src pgtype.OidValue + src pgtype.OIDValue dst interface{} expected interface{} }{ - {src: pgtype.OidValue{Uint: 42, Status: pgtype.Present}, dst: &pui32, expected: uint32(42)}, + {src: pgtype.OIDValue{Uint: 42, Status: pgtype.Present}, dst: &pui32, expected: uint32(42)}, } for i, tt := range pointerAllocTests { @@ -80,10 +80,10 @@ func TestOidValueAssignTo(t *testing.T) { } errorTests := []struct { - src pgtype.OidValue + src pgtype.OIDValue dst interface{} }{ - {src: pgtype.OidValue{Status: pgtype.Null}, dst: &ui32}, + {src: pgtype.OIDValue{Status: pgtype.Null}, dst: &ui32}, } for i, tt := range errorTests { diff --git a/pgtype.go b/pgtype.go index 847fce0f..4c1e86f6 100644 --- a/pgtype.go +++ b/pgtype.go @@ -7,47 +7,47 @@ import ( // PostgreSQL oids for common types const ( - BoolOid = 16 - ByteaOid = 17 - CharOid = 18 - NameOid = 19 - Int8Oid = 20 - Int2Oid = 21 - Int4Oid = 23 - TextOid = 25 - OidOid = 26 - TidOid = 27 - XidOid = 28 - CidOid = 29 - JsonOid = 114 - CidrOid = 650 - CidrArrayOid = 651 - Float4Oid = 700 - Float8Oid = 701 - UnknownOid = 705 - InetOid = 869 - BoolArrayOid = 1000 - Int2ArrayOid = 1005 - Int4ArrayOid = 1007 - TextArrayOid = 1009 - ByteaArrayOid = 1001 - VarcharArrayOid = 1015 - Int8ArrayOid = 1016 - Float4ArrayOid = 1021 - Float8ArrayOid = 1022 - AclitemOid = 1033 - AclitemArrayOid = 1034 - InetArrayOid = 1041 - VarcharOid = 1043 - DateOid = 1082 - TimestampOid = 1114 - TimestampArrayOid = 1115 - DateArrayOid = 1182 - TimestamptzOid = 1184 - TimestamptzArrayOid = 1185 - RecordOid = 2249 - UuidOid = 2950 - JsonbOid = 3802 + BoolOID = 16 + ByteaOID = 17 + CharOID = 18 + NameOID = 19 + Int8OID = 20 + Int2OID = 21 + Int4OID = 23 + TextOID = 25 + OIDOID = 26 + TidOID = 27 + XidOID = 28 + CidOID = 29 + JsonOID = 114 + CidrOID = 650 + CidrArrayOID = 651 + Float4OID = 700 + Float8OID = 701 + UnknownOID = 705 + InetOID = 869 + BoolArrayOID = 1000 + Int2ArrayOID = 1005 + Int4ArrayOID = 1007 + TextArrayOID = 1009 + ByteaArrayOID = 1001 + VarcharArrayOID = 1015 + Int8ArrayOID = 1016 + Float4ArrayOID = 1021 + Float8ArrayOID = 1022 + AclitemOID = 1033 + AclitemArrayOID = 1034 + InetArrayOID = 1041 + VarcharOID = 1043 + DateOID = 1082 + TimestampOID = 1114 + TimestampArrayOID = 1115 + DateArrayOID = 1182 + TimestamptzOID = 1184 + TimestamptzArrayOID = 1185 + RecordOID = 2249 + UuidOID = 2950 + JsonbOID = 3802 ) type Status byte @@ -133,42 +133,42 @@ var errBadStatus = errors.New("invalid status") type DataType struct { Value Value Name string - Oid Oid + OID OID } type ConnInfo struct { - oidToDataType map[Oid]*DataType + oidToDataType map[OID]*DataType nameToDataType map[string]*DataType reflectTypeToDataType map[reflect.Type]*DataType } func NewConnInfo() *ConnInfo { return &ConnInfo{ - oidToDataType: make(map[Oid]*DataType, 256), + oidToDataType: make(map[OID]*DataType, 256), nameToDataType: make(map[string]*DataType, 256), reflectTypeToDataType: make(map[reflect.Type]*DataType, 256), } } -func (ci *ConnInfo) InitializeDataTypes(nameOids map[string]Oid) { - for name, oid := range nameOids { +func (ci *ConnInfo) InitializeDataTypes(nameOIDs map[string]OID) { + for name, oid := range nameOIDs { var value Value if t, ok := nameValues[name]; ok { value = reflect.New(reflect.ValueOf(t).Elem().Type()).Interface().(Value) } else { value = &GenericText{} } - ci.RegisterDataType(DataType{Value: value, Name: name, Oid: oid}) + ci.RegisterDataType(DataType{Value: value, Name: name, OID: oid}) } } func (ci *ConnInfo) RegisterDataType(t DataType) { - ci.oidToDataType[t.Oid] = &t + ci.oidToDataType[t.OID] = &t ci.nameToDataType[t.Name] = &t ci.reflectTypeToDataType[reflect.ValueOf(t.Value).Type()] = &t } -func (ci *ConnInfo) DataTypeForOid(oid Oid) (*DataType, bool) { +func (ci *ConnInfo) DataTypeForOID(oid OID) (*DataType, bool) { dt, ok := ci.oidToDataType[oid] return dt, ok } @@ -186,7 +186,7 @@ func (ci *ConnInfo) DataTypeForValue(v Value) (*DataType, bool) { // DeepCopy makes a deep copy of the ConnInfo. func (ci *ConnInfo) DeepCopy() *ConnInfo { ci2 := &ConnInfo{ - oidToDataType: make(map[Oid]*DataType, len(ci.oidToDataType)), + oidToDataType: make(map[OID]*DataType, len(ci.oidToDataType)), nameToDataType: make(map[string]*DataType, len(ci.nameToDataType)), reflectTypeToDataType: make(map[reflect.Type]*DataType, len(ci.reflectTypeToDataType)), } @@ -195,7 +195,7 @@ func (ci *ConnInfo) DeepCopy() *ConnInfo { ci2.RegisterDataType(DataType{ Value: reflect.New(reflect.ValueOf(dt.Value).Elem().Type()).Interface().(Value), Name: dt.Name, - Oid: dt.Oid, + OID: dt.OID, }) } @@ -250,7 +250,7 @@ func init() { "name": &Name{}, "numeric": &Numeric{}, "numrange": &Numrange{}, - "oid": &OidValue{}, + "oid": &OIDValue{}, "path": &Path{}, "point": &Point{}, "polygon": &Polygon{}, diff --git a/record.go b/record.go index 3b315d40..7c8736df 100644 --- a/record.go +++ b/record.go @@ -88,16 +88,16 @@ func (dst *Record) DecodeBinary(ci *ConnInfo, src []byte) error { if len(src[rp:]) < 8 { return fmt.Errorf("Record incomplete %v", src) } - fieldOid := Oid(binary.BigEndian.Uint32(src[rp:])) + fieldOID := OID(binary.BigEndian.Uint32(src[rp:])) rp += 4 fieldLen := int(int32(binary.BigEndian.Uint32(src[rp:]))) rp += 4 var binaryDecoder BinaryDecoder - if dt, ok := ci.DataTypeForOid(fieldOid); ok { + if dt, ok := ci.DataTypeForOID(fieldOID); ok { if binaryDecoder, ok = dt.Value.(BinaryDecoder); !ok { - return fmt.Errorf("unknown oid while decoding record: %v", fieldOid) + return fmt.Errorf("unknown oid while decoding record: %v", fieldOID) } } diff --git a/text_array.go b/text_array.go index ed240e12..dab7d36e 100644 --- a/text_array.go +++ b/text_array.go @@ -231,7 +231,7 @@ func (src *TextArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { } if dt, ok := ci.DataTypeForName("text"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "text") } diff --git a/timestamp_array.go b/timestamp_array.go index a4f1b9dd..fca9ad93 100644 --- a/timestamp_array.go +++ b/timestamp_array.go @@ -232,7 +232,7 @@ func (src *TimestampArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error } if dt, ok := ci.DataTypeForName("timestamp"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "timestamp") } diff --git a/timestamptz_array.go b/timestamptz_array.go index 34d4f8a8..e0866d69 100644 --- a/timestamptz_array.go +++ b/timestamptz_array.go @@ -232,7 +232,7 @@ func (src *TimestamptzArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, err } if dt, ok := ci.DataTypeForName("timestamptz"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "timestamptz") } diff --git a/typed_array.go.erb b/typed_array.go.erb index 0d454ac8..01072549 100644 --- a/typed_array.go.erb +++ b/typed_array.go.erb @@ -234,7 +234,7 @@ func (src *<%= pgtype_array_type %>) EncodeText(ci *ConnInfo, buf []byte) ([]byt } if dt, ok := ci.DataTypeForName("<%= element_type_name %>"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "<%= element_type_name %>") } diff --git a/varchar_array.go b/varchar_array.go index c34ac0b6..95b5cfc1 100644 --- a/varchar_array.go +++ b/varchar_array.go @@ -231,7 +231,7 @@ func (src *VarcharArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) } if dt, ok := ci.DataTypeForName("varchar"); ok { - arrayHeader.ElementOid = int32(dt.Oid) + arrayHeader.ElementOID = int32(dt.OID) } else { return nil, fmt.Errorf("unable to find oid for type name %v", "varchar") }