From 55a56add235573da4358e3fd52ad4a35b30c92eb Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Wed, 19 Feb 2020 11:58:49 -0600 Subject: [PATCH] Set will call Get on src if possible --- aclitem.go | 12 ++++++++++++ aclitem_array.go | 7 +++++++ bool.go | 7 +++++++ bool_array.go | 7 +++++++ bpchar_array.go | 7 +++++++ bytea.go | 7 +++++++ bytea_array.go | 7 +++++++ cidr_array.go | 7 +++++++ date.go | 7 +++++++ date_array.go | 7 +++++++ enum_array.go | 7 +++++++ ext/gofrs-uuid/uuid.go | 7 +++++++ ext/gofrs-uuid/uuid_test.go | 4 ++++ ext/shopspring-numeric/decimal.go | 7 +++++++ float4.go | 7 +++++++ float4_array.go | 7 +++++++ float8.go | 7 +++++++ float8_array.go | 7 +++++++ go.mod | 1 + go.sum | 2 ++ hstore.go | 7 +++++++ hstore_array.go | 7 +++++++ inet.go | 7 +++++++ inet_array.go | 7 +++++++ int2.go | 7 +++++++ int2_array.go | 7 +++++++ int4.go | 7 +++++++ int4_array.go | 7 +++++++ int8.go | 7 +++++++ int8_array.go | 7 +++++++ interval.go | 7 +++++++ json.go | 7 +++++++ macaddr.go | 7 +++++++ macaddr_array.go | 7 +++++++ numeric.go | 7 +++++++ numeric_array.go | 7 +++++++ qchar.go | 7 +++++++ record.go | 7 +++++++ text.go | 7 +++++++ text_array.go | 7 +++++++ time.go | 7 +++++++ timestamp.go | 7 +++++++ timestamp_array.go | 7 +++++++ timestamptz.go | 7 +++++++ timestamptz_array.go | 7 +++++++ tstzrange_array.go | 7 +++++++ typed_array.go.erb | 7 +++++++ uuid.go | 7 +++++++ uuid_array.go | 7 +++++++ varchar_array.go | 7 +++++++ 50 files changed, 341 insertions(+) diff --git a/aclitem.go b/aclitem.go index 36df71bc..d2fe7529 100644 --- a/aclitem.go +++ b/aclitem.go @@ -24,6 +24,18 @@ type ACLItem struct { } func (dst *ACLItem) Set(src interface{}) error { + if src == nil { + *dst = ACLItem{Status: Null} + return nil + } + + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case string: *dst = ACLItem{String: value, Status: Present} diff --git a/aclitem_array.go b/aclitem_array.go index bfb069fd..1d3de130 100644 --- a/aclitem_array.go +++ b/aclitem_array.go @@ -19,6 +19,13 @@ func (dst *ACLItemArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []string: diff --git a/bool.go b/bool.go index 898197f7..8b03a1af 100644 --- a/bool.go +++ b/bool.go @@ -19,6 +19,13 @@ func (dst *Bool) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case bool: *dst = Bool{Bool: value, Status: Present} diff --git a/bool_array.go b/bool_array.go index 44500b79..c1af1e1f 100644 --- a/bool_array.go +++ b/bool_array.go @@ -21,6 +21,13 @@ func (dst *BoolArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []bool: diff --git a/bpchar_array.go b/bpchar_array.go index 50168f6e..b6eeabd7 100644 --- a/bpchar_array.go +++ b/bpchar_array.go @@ -21,6 +21,13 @@ func (dst *BPCharArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []string: diff --git a/bytea.go b/bytea.go index 507498cb..b9e4d15a 100644 --- a/bytea.go +++ b/bytea.go @@ -18,6 +18,13 @@ func (dst *Bytea) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []byte: if value != nil { diff --git a/bytea_array.go b/bytea_array.go index d0b4b367..6a45e4da 100644 --- a/bytea_array.go +++ b/bytea_array.go @@ -21,6 +21,13 @@ func (dst *ByteaArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case [][]byte: diff --git a/cidr_array.go b/cidr_array.go index b6334f74..4f3097a0 100644 --- a/cidr_array.go +++ b/cidr_array.go @@ -22,6 +22,13 @@ func (dst *CIDRArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []*net.IPNet: diff --git a/date.go b/date.go index 9804672b..10e41fe7 100644 --- a/date.go +++ b/date.go @@ -27,6 +27,13 @@ func (dst *Date) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case time.Time: *dst = Date{Time: value, Status: Present} diff --git a/date_array.go b/date_array.go index ce6b9550..644e78fe 100644 --- a/date_array.go +++ b/date_array.go @@ -22,6 +22,13 @@ func (dst *DateArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []time.Time: diff --git a/enum_array.go b/enum_array.go index 8220d425..a31916dc 100644 --- a/enum_array.go +++ b/enum_array.go @@ -19,6 +19,13 @@ func (dst *EnumArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []string: diff --git a/ext/gofrs-uuid/uuid.go b/ext/gofrs-uuid/uuid.go index a358fead..b0413cae 100644 --- a/ext/gofrs-uuid/uuid.go +++ b/ext/gofrs-uuid/uuid.go @@ -22,6 +22,13 @@ func (dst *UUID) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case uuid.UUID: *dst = UUID{UUID: value, Status: pgtype.Present} diff --git a/ext/gofrs-uuid/uuid_test.go b/ext/gofrs-uuid/uuid_test.go index 124720b8..56814524 100644 --- a/ext/gofrs-uuid/uuid_test.go +++ b/ext/gofrs-uuid/uuid_test.go @@ -21,6 +21,10 @@ func TestUUIDSet(t *testing.T) { source interface{} result gofrs.UUID }{ + { + source: &gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + }, { source: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, diff --git a/ext/shopspring-numeric/decimal.go b/ext/shopspring-numeric/decimal.go index 9fc8b515..70906806 100644 --- a/ext/shopspring-numeric/decimal.go +++ b/ext/shopspring-numeric/decimal.go @@ -24,6 +24,13 @@ func (dst *Numeric) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case decimal.Decimal: *dst = Numeric{Decimal: value, Status: pgtype.Present} diff --git a/float4.go b/float4.go index cef14274..e33dfc75 100644 --- a/float4.go +++ b/float4.go @@ -21,6 +21,13 @@ func (dst *Float4) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case float32: *dst = Float4{Float: value, Status: Present} diff --git a/float4_array.go b/float4_array.go index 4dcdef43..ccd718a1 100644 --- a/float4_array.go +++ b/float4_array.go @@ -21,6 +21,13 @@ func (dst *Float4Array) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []float32: diff --git a/float8.go b/float8.go index 13d6b326..41d0fe70 100644 --- a/float8.go +++ b/float8.go @@ -21,6 +21,13 @@ func (dst *Float8) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case float32: *dst = Float8{Float: float64(value), Status: Present} diff --git a/float8_array.go b/float8_array.go index be3d1d20..740e8558 100644 --- a/float8_array.go +++ b/float8_array.go @@ -21,6 +21,13 @@ func (dst *Float8Array) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []float64: diff --git a/go.mod b/go.mod index 9f47a705..920f4b21 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.12 require ( github.com/gofrs/uuid v3.2.0+incompatible github.com/jackc/pgio v1.0.0 + github.com/jackc/pgx v3.6.2+incompatible github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186 github.com/lib/pq v1.2.0 github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 diff --git a/go.sum b/go.sum index 275e7fe1..7a3fc71e 100644 --- a/go.sum +++ b/go.sum @@ -30,6 +30,8 @@ github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711 h1:vZp4 github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o= +github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96 h1:ylEAOd688Duev/fxTmGdupsbyZfxNMdngIG14DoBKTM= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912 h1:YuOWGsSK5L4Fz81Olx5TNlZftmDuNrfv4ip0Yos77Tw= diff --git a/hstore.go b/hstore.go index fcfd8f9a..3fe50ae5 100644 --- a/hstore.go +++ b/hstore.go @@ -26,6 +26,13 @@ func (dst *Hstore) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case map[string]string: m := make(map[string]Text, len(value)) diff --git a/hstore_array.go b/hstore_array.go index 3ab264f9..54909e42 100644 --- a/hstore_array.go +++ b/hstore_array.go @@ -21,6 +21,13 @@ func (dst *HstoreArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []map[string]string: diff --git a/inet.go b/inet.go index b7bbd9c4..7ab78bdf 100644 --- a/inet.go +++ b/inet.go @@ -27,6 +27,13 @@ func (dst *Inet) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case net.IPNet: *dst = Inet{IPNet: &value, Status: Present} diff --git a/inet_array.go b/inet_array.go index 58cd656b..a663d51d 100644 --- a/inet_array.go +++ b/inet_array.go @@ -22,6 +22,13 @@ func (dst *InetArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []*net.IPNet: diff --git a/int2.go b/int2.go index 7ed76803..54bab272 100644 --- a/int2.go +++ b/int2.go @@ -21,6 +21,13 @@ func (dst *Int2) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case int8: *dst = Int2{Int: int16(value), Status: Present} diff --git a/int2_array.go b/int2_array.go index 1ef24c63..98552171 100644 --- a/int2_array.go +++ b/int2_array.go @@ -21,6 +21,13 @@ func (dst *Int2Array) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []int16: diff --git a/int4.go b/int4.go index efe3916e..66fe9155 100644 --- a/int4.go +++ b/int4.go @@ -22,6 +22,13 @@ func (dst *Int4) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case int8: *dst = Int4{Int: int32(value), Status: Present} diff --git a/int4_array.go b/int4_array.go index 61112f8d..a52ab437 100644 --- a/int4_array.go +++ b/int4_array.go @@ -21,6 +21,13 @@ func (dst *Int4Array) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []int16: diff --git a/int8.go b/int8.go index 526cde94..fd721142 100644 --- a/int8.go +++ b/int8.go @@ -22,6 +22,13 @@ func (dst *Int8) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case int8: *dst = Int8{Int: int64(value), Status: Present} diff --git a/int8_array.go b/int8_array.go index 985b47b8..f6d577f0 100644 --- a/int8_array.go +++ b/int8_array.go @@ -21,6 +21,13 @@ func (dst *Int8Array) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []int16: diff --git a/interval.go b/interval.go index 0afd1cbd..3a91c595 100644 --- a/interval.go +++ b/interval.go @@ -31,6 +31,13 @@ func (dst *Interval) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case time.Duration: *dst = Interval{Microseconds: int64(value) / 1000, Status: Present} diff --git a/json.go b/json.go index 1b99c5c2..c642c727 100644 --- a/json.go +++ b/json.go @@ -18,6 +18,13 @@ func (dst *JSON) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case string: *dst = JSON{Bytes: []byte(value), Status: Present} diff --git a/macaddr.go b/macaddr.go index 55dec4f2..af0901b0 100644 --- a/macaddr.go +++ b/macaddr.go @@ -18,6 +18,13 @@ func (dst *Macaddr) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case net.HardwareAddr: addr := make(net.HardwareAddr, len(value)) diff --git a/macaddr_array.go b/macaddr_array.go index b4d42d61..97b13537 100644 --- a/macaddr_array.go +++ b/macaddr_array.go @@ -22,6 +22,13 @@ func (dst *MacaddrArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []net.HardwareAddr: diff --git a/numeric.go b/numeric.go index 100a7e9c..e6c58391 100644 --- a/numeric.go +++ b/numeric.go @@ -55,6 +55,13 @@ func (dst *Numeric) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case float32: num, exp, err := parseNumericString(strconv.FormatFloat(float64(value), 'f', -1, 64)) diff --git a/numeric_array.go b/numeric_array.go index 224306c1..3cec9fea 100644 --- a/numeric_array.go +++ b/numeric_array.go @@ -21,6 +21,13 @@ func (dst *NumericArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []float32: diff --git a/qchar.go b/qchar.go index d6577248..93964058 100644 --- a/qchar.go +++ b/qchar.go @@ -29,6 +29,13 @@ func (dst *QChar) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case int8: *dst = QChar{Int: value, Status: Present} diff --git a/record.go b/record.go index aecc978b..5c9d7a02 100644 --- a/record.go +++ b/record.go @@ -23,6 +23,13 @@ func (dst *Record) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []Value: *dst = Record{Fields: value, Status: Present} diff --git a/text.go b/text.go index bd5f0689..1f5d2a37 100644 --- a/text.go +++ b/text.go @@ -18,6 +18,13 @@ func (dst *Text) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case string: *dst = Text{String: value, Status: Present} diff --git a/text_array.go b/text_array.go index 9b5fcec6..2130af84 100644 --- a/text_array.go +++ b/text_array.go @@ -21,6 +21,13 @@ func (dst *TextArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []string: diff --git a/time.go b/time.go index 60043fcd..16a2a393 100644 --- a/time.go +++ b/time.go @@ -28,6 +28,13 @@ func (dst *Time) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case time.Time: usec := int64(value.Hour())*microsecondsPerHour + diff --git a/timestamp.go b/timestamp.go index feb88873..35ac5143 100644 --- a/timestamp.go +++ b/timestamp.go @@ -30,6 +30,13 @@ func (dst *Timestamp) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case time.Time: *dst = Timestamp{Time: time.Date(value.Year(), value.Month(), value.Day(), value.Hour(), value.Minute(), value.Second(), value.Nanosecond(), time.UTC), Status: Present} diff --git a/timestamp_array.go b/timestamp_array.go index 063d339b..49ac98fd 100644 --- a/timestamp_array.go +++ b/timestamp_array.go @@ -22,6 +22,13 @@ func (dst *TimestampArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []time.Time: diff --git a/timestamptz.go b/timestamptz.go index 3d3e7143..d390d266 100644 --- a/timestamptz.go +++ b/timestamptz.go @@ -32,6 +32,13 @@ func (dst *Timestamptz) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case time.Time: *dst = Timestamptz{Time: value, Status: Present} diff --git a/timestamptz_array.go b/timestamptz_array.go index 4924498d..2e26692b 100644 --- a/timestamptz_array.go +++ b/timestamptz_array.go @@ -22,6 +22,13 @@ func (dst *TimestamptzArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []time.Time: diff --git a/tstzrange_array.go b/tstzrange_array.go index cf407253..2c365645 100644 --- a/tstzrange_array.go +++ b/tstzrange_array.go @@ -21,6 +21,13 @@ func (dst *TstzrangeArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []Tstzrange: diff --git a/typed_array.go.erb b/typed_array.go.erb index 494bd534..d8ae97dd 100644 --- a/typed_array.go.erb +++ b/typed_array.go.erb @@ -21,6 +21,13 @@ func (dst *<%= pgtype_array_type %>) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { <% go_array_types.split(",").each do |t| %> <% if t != "[]#{pgtype_element_type}" %> diff --git a/uuid.go b/uuid.go index 70a6b7fa..bdbe17e4 100644 --- a/uuid.go +++ b/uuid.go @@ -19,6 +19,13 @@ func (dst *UUID) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case [16]byte: *dst = UUID{Bytes: value, Status: Present} diff --git a/uuid_array.go b/uuid_array.go index 27dcd259..4cd65017 100644 --- a/uuid_array.go +++ b/uuid_array.go @@ -21,6 +21,13 @@ func (dst *UUIDArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case [][16]byte: diff --git a/varchar_array.go b/varchar_array.go index 7f476285..b13f29ce 100644 --- a/varchar_array.go +++ b/varchar_array.go @@ -21,6 +21,13 @@ func (dst *VarcharArray) Set(src interface{}) error { return nil } + if value, ok := src.(interface{ Get() interface{} }); ok { + value2 := value.Get() + if value2 != value { + return dst.Set(value2) + } + } + switch value := src.(type) { case []string: