Fix test and avoid change to array signatures

typed_array.go.erb was not updated back in
a8802b16cc when Value, EncodeBinary,
EncodeText, and MarshalJSON were changed to be defined on T instead of
*T. This has been corrected.
non-blocking
Jack Christensen 2019-11-14 20:40:41 -06:00
parent 0079108e29
commit be36a7e14b
24 changed files with 100 additions and 79 deletions

View File

@ -136,7 +136,7 @@ func (dst *ACLItemArray) DecodeText(ci *ConnInfo, src []byte) error {
return nil
}
func (src *ACLItemArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src ACLItemArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -212,7 +212,7 @@ func (dst *ACLItemArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *ACLItemArray) Value() (driver.Value, error) {
func (src ACLItemArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *BoolArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *BoolArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src BoolArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *BoolArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *BoolArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src BoolArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *BoolArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *BoolArray) Value() (driver.Value, error) {
func (src BoolArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *BPCharArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *BPCharArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src BPCharArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *BPCharArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *BPCharArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src BPCharArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *BPCharArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *BPCharArray) Value() (driver.Value, error) {
func (src BPCharArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *ByteaArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *ByteaArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src ByteaArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *ByteaArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *ByteaArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src ByteaArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *ByteaArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *ByteaArray) Value() (driver.Value, error) {
func (src ByteaArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -209,7 +209,7 @@ func (dst *CIDRArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *CIDRArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src CIDRArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -266,7 +266,7 @@ func (src *CIDRArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *CIDRArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src CIDRArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -329,7 +329,7 @@ func (dst *CIDRArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *CIDRArray) Value() (driver.Value, error) {
func (src CIDRArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -181,7 +181,7 @@ func (dst *DateArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *DateArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src DateArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -238,7 +238,7 @@ func (src *DateArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *DateArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src DateArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -301,7 +301,7 @@ func (dst *DateArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *DateArray) Value() (driver.Value, error) {
func (src DateArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -136,7 +136,7 @@ func (dst *EnumArray) DecodeText(ci *ConnInfo, src []byte) error {
return nil
}
func (src *EnumArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src EnumArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -212,7 +212,7 @@ func (dst *EnumArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *EnumArray) Value() (driver.Value, error) {
func (src EnumArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *Float4Array) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *Float4Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Float4Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *Float4Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *Float4Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Float4Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *Float4Array) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *Float4Array) Value() (driver.Value, error) {
func (src Float4Array) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *Float8Array) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *Float8Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Float8Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *Float8Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *Float8Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Float8Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *Float8Array) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *Float8Array) Value() (driver.Value, error) {
func (src Float8Array) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *HstoreArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *HstoreArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src HstoreArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *HstoreArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *HstoreArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src HstoreArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *HstoreArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *HstoreArray) Value() (driver.Value, error) {
func (src HstoreArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -209,7 +209,7 @@ func (dst *InetArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *InetArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src InetArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -266,7 +266,7 @@ func (src *InetArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *InetArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src InetArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -329,7 +329,7 @@ func (dst *InetArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *InetArray) Value() (driver.Value, error) {
func (src InetArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -208,7 +208,7 @@ func (dst *Int2Array) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *Int2Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Int2Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -265,7 +265,7 @@ func (src *Int2Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *Int2Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Int2Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -328,7 +328,7 @@ func (dst *Int2Array) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *Int2Array) Value() (driver.Value, error) {
func (src Int2Array) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -61,6 +61,25 @@ func (dst *Int4Array) Set(src interface{}) error {
}
}
case []int:
if value == nil {
*dst = Int4Array{Status: Null}
} else if len(value) == 0 {
*dst = Int4Array{Status: Present}
} else {
elements := make([]Int4, len(value))
for i := range value {
if err := elements[i].Set(value[i]); err != nil {
return err
}
}
*dst = Int4Array{
Elements: elements,
Dimensions: []ArrayDimension{{Length: int32(len(elements)), LowerBound: 1}},
Status: Present,
}
}
case []Int4:
if value == nil {
*dst = Int4Array{Status: Null}
@ -117,6 +136,15 @@ func (src *Int4Array) AssignTo(dst interface{}) error {
}
return nil
case *[]int:
*v = make([]int, len(src.Elements))
for i := range src.Elements {
if err := src.Elements[i].AssignTo(&((*v)[i])); err != nil {
return err
}
}
return nil
default:
if nextDst, retry := GetAssignToDstType(dst); retry {
return src.AssignTo(nextDst)
@ -208,7 +236,7 @@ func (dst *Int4Array) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *Int4Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Int4Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -265,7 +293,7 @@ func (src *Int4Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *Int4Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Int4Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -328,7 +356,7 @@ func (dst *Int4Array) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *Int4Array) Value() (driver.Value, error) {
func (src Int4Array) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -208,7 +208,7 @@ func (dst *Int8Array) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *Int8Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Int8Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -265,7 +265,7 @@ func (src *Int8Array) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *Int8Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src Int8Array) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -328,7 +328,7 @@ func (dst *Int8Array) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *Int8Array) Value() (driver.Value, error) {
func (src Int8Array) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -181,7 +181,7 @@ func (dst *MacaddrArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *MacaddrArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src MacaddrArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -238,7 +238,7 @@ func (src *MacaddrArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *MacaddrArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src MacaddrArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -301,7 +301,7 @@ func (dst *MacaddrArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *MacaddrArray) Value() (driver.Value, error) {
func (src MacaddrArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -264,7 +264,7 @@ func (dst *NumericArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *NumericArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src NumericArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -321,7 +321,7 @@ func (src *NumericArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *NumericArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src NumericArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -384,7 +384,7 @@ func (dst *NumericArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *NumericArray) Value() (driver.Value, error) {
func (src NumericArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *TextArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *TextArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TextArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *TextArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *TextArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TextArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *TextArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *TextArray) Value() (driver.Value, error) {
func (src TextArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -181,7 +181,7 @@ func (dst *TimestampArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *TimestampArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TimestampArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -238,7 +238,7 @@ func (src *TimestampArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error)
return buf, nil
}
func (src *TimestampArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TimestampArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -301,7 +301,7 @@ func (dst *TimestampArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *TimestampArray) Value() (driver.Value, error) {
func (src TimestampArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -181,7 +181,7 @@ func (dst *TimestamptzArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *TimestamptzArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TimestamptzArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -238,7 +238,7 @@ func (src *TimestamptzArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error
return buf, nil
}
func (src *TimestamptzArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TimestamptzArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -301,7 +301,7 @@ func (dst *TimestamptzArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *TimestamptzArray) Value() (driver.Value, error) {
func (src TimestamptzArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -29,19 +29,12 @@ func (dst *TstzrangeArray) Set(src interface{}) error {
} else if len(value) == 0 {
*dst = TstzrangeArray{Status: Present}
} else {
elements := make([]Tstzrange, len(value))
for i := range value {
if err := elements[i].Set(value[i]); err != nil {
return err
}
}
*dst = TstzrangeArray{
Elements: elements,
Dimensions: []ArrayDimension{{Length: int32(len(elements)), LowerBound: 1}},
Elements: value,
Dimensions: []ArrayDimension{{Length: int32(len(value)), LowerBound: 1}},
Status: Present,
}
}
default:
if originalSrc, ok := underlyingSliceType(src); ok {
return dst.Set(originalSrc)
@ -168,7 +161,7 @@ func (dst *TstzrangeArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *TstzrangeArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TstzrangeArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -225,7 +218,7 @@ func (src *TstzrangeArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error)
return buf, nil
}
func (src *TstzrangeArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src TstzrangeArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -288,7 +281,7 @@ func (dst *TstzrangeArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *TstzrangeArray) Value() (driver.Value, error) {
func (src TstzrangeArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -23,7 +23,7 @@ func (dst *<%= pgtype_array_type %>) Set(src interface{}) error {
switch value := src.(type) {
<% go_array_types.split(",").each do |t| %>
<% if t != pgtype_element_type %>
<% if t != "[]#{pgtype_element_type}" %>
case <%= t %>:
if value == nil {
*dst = <%= pgtype_array_type %>{Status: Null}
@ -184,7 +184,7 @@ func (dst *<%= pgtype_array_type %>) DecodeBinary(ci *ConnInfo, src []byte) erro
}
<% end %>
func (src *<%= pgtype_array_type %>) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src <%= pgtype_array_type %>) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -242,7 +242,7 @@ func (src *<%= pgtype_array_type %>) EncodeText(ci *ConnInfo, buf []byte) ([]byt
}
<% if binary_format == "true" %>
func (src *<%= pgtype_array_type %>) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src <%= pgtype_array_type %>) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -306,7 +306,7 @@ func (dst *<%= pgtype_array_type %>) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *<%= pgtype_array_type %>) Value() (driver.Value, error) {
func (src <%= pgtype_array_type %>) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -1,10 +1,10 @@
erb pgtype_array_type=Int2Array pgtype_element_type=Int2 go_array_types=[]int16,[]uint16 element_type_name=int2 text_null=NULL binary_format=true typed_array.go.erb > int2_array.go
erb pgtype_array_type=Int4Array pgtype_element_type=Int4 go_array_types=[]int32,[]uint32 element_type_name=int4 text_null=NULL binary_format=true typed_array.go.erb > int4_array.go
erb pgtype_array_type=Int4Array pgtype_element_type=Int4 go_array_types=[]int32,[]uint32,[]int element_type_name=int4 text_null=NULL binary_format=true typed_array.go.erb > int4_array.go
erb pgtype_array_type=Int8Array pgtype_element_type=Int8 go_array_types=[]int64,[]uint64 element_type_name=int8 text_null=NULL binary_format=true typed_array.go.erb > int8_array.go
erb pgtype_array_type=BoolArray pgtype_element_type=Bool go_array_types=[]bool element_type_name=bool text_null=NULL binary_format=true typed_array.go.erb > bool_array.go
erb pgtype_array_type=DateArray pgtype_element_type=Date go_array_types=[]time.Time element_type_name=date text_null=NULL binary_format=true typed_array.go.erb > date_array.go
erb pgtype_array_type=TimestamptzArray pgtype_element_type=Timestamptz go_array_types=[]time.Time element_type_name=timestamptz text_null=NULL binary_format=true typed_array.go.erb > timestamptz_array.go
erb pgtype_array_type=TstzrangeArray pgtype_element_type=Tstzrange go_array_types=[]Tstzrange element_type_name=tstzrange text_null=NULL binary_format=true typed_array.go.erb > tstz_range_array.go
erb pgtype_array_type=TstzrangeArray pgtype_element_type=Tstzrange go_array_types=[]Tstzrange element_type_name=tstzrange text_null=NULL binary_format=true typed_array.go.erb > tstzrange_array.go
erb pgtype_array_type=TimestampArray pgtype_element_type=Timestamp go_array_types=[]time.Time element_type_name=timestamp text_null=NULL binary_format=true typed_array.go.erb > timestamp_array.go
erb pgtype_array_type=Float4Array pgtype_element_type=Float4 go_array_types=[]float32 element_type_name=float4 text_null=NULL binary_format=true typed_array.go.erb > float4_array.go
erb pgtype_array_type=Float8Array pgtype_element_type=Float8 go_array_types=[]float64 element_type_name=float8 text_null=NULL binary_format=true typed_array.go.erb > float8_array.go

View File

@ -236,7 +236,7 @@ func (dst *UUIDArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *UUIDArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src UUIDArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -293,7 +293,7 @@ func (src *UUIDArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *UUIDArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src UUIDArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -356,7 +356,7 @@ func (dst *UUIDArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *UUIDArray) Value() (driver.Value, error) {
func (src UUIDArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err

View File

@ -180,7 +180,7 @@ func (dst *VarcharArray) DecodeBinary(ci *ConnInfo, src []byte) error {
return nil
}
func (src *VarcharArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src VarcharArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -237,7 +237,7 @@ func (src *VarcharArray) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
return buf, nil
}
func (src *VarcharArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
func (src VarcharArray) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
switch src.Status {
case Null:
return nil, nil
@ -300,7 +300,7 @@ func (dst *VarcharArray) Scan(src interface{}) error {
}
// Value implements the database/sql/driver Valuer interface.
func (src *VarcharArray) Value() (driver.Value, error) {
func (src VarcharArray) Value() (driver.Value, error) {
buf, err := src.EncodeText(nil, nil)
if err != nil {
return nil, err