2
0

Add pgtype.HstoreArray

This required restructuring array types to lookup oid of element instead of
hard-coding it due to hstore having a variable oid.
This commit is contained in:
Jack Christensen
2017-03-18 12:40:54 -05:00
parent 19c6689752
commit cf70e6b9f4
18 changed files with 586 additions and 90 deletions
+6 -5
View File
@@ -238,10 +238,6 @@ func (src *Float4Array) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) {
}
func (src *Float4Array) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) {
return src.encodeBinary(ci, w, Float4Oid)
}
func (src *Float4Array) encodeBinary(ci *ConnInfo, w io.Writer, elementOid int32) (bool, error) {
switch src.Status {
case Null:
return true, nil
@@ -250,10 +246,15 @@ func (src *Float4Array) encodeBinary(ci *ConnInfo, w io.Writer, elementOid int32
}
arrayHeader := ArrayHeader{
ElementOid: elementOid,
Dimensions: src.Dimensions,
}
if dt, ok := ci.DataTypeForName("float4"); ok {
arrayHeader.ElementOid = int32(dt.Oid)
} else {
return false, fmt.Errorf("unable to find oid for type name %v", "float4")
}
for i := range src.Elements {
if src.Elements[i].Status == Null {
arrayHeader.ContainsNull = true