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
@@ -239,10 +239,6 @@ func (src *TimestampArray) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) {
}
func (src *TimestampArray) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) {
return src.encodeBinary(ci, w, TimestampOid)
}
func (src *TimestampArray) encodeBinary(ci *ConnInfo, w io.Writer, elementOid int32) (bool, error) {
switch src.Status {
case Null:
return true, nil
@@ -251,10 +247,15 @@ func (src *TimestampArray) encodeBinary(ci *ConnInfo, w io.Writer, elementOid in
}
arrayHeader := ArrayHeader{
ElementOid: elementOid,
Dimensions: src.Dimensions,
}
if dt, ok := ci.DataTypeForName("timestamp"); ok {
arrayHeader.ElementOid = int32(dt.Oid)
} else {
return false, fmt.Errorf("unable to find oid for type name %v", "timestamp")
}
for i := range src.Elements {
if src.Elements[i].Status == Null {
arrayHeader.ContainsNull = true