diff --git a/pgtype/aclitem.go b/pgtype/aclitem.go index 3ccf8318..ebfcc3e7 100644 --- a/pgtype/aclitem.go +++ b/pgtype/aclitem.go @@ -83,7 +83,7 @@ func (dst *Aclitem) DecodeText(ci *ConnInfo, src []byte) error { return nil } -func (src Aclitem) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Aclitem) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -113,7 +113,7 @@ func (dst *Aclitem) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Aclitem) Value() (driver.Value, error) { +func (src *Aclitem) Value() (driver.Value, error) { switch src.Status { case Present: return src.String, nil diff --git a/pgtype/aclitem_test.go b/pgtype/aclitem_test.go index 5389eab2..13c63395 100644 --- a/pgtype/aclitem_test.go +++ b/pgtype/aclitem_test.go @@ -10,9 +10,9 @@ import ( func TestAclitemTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "aclitem", []interface{}{ - pgtype.Aclitem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present}, - pgtype.Aclitem{String: `postgres=arwdDxt/" tricky, ' } "" \ test user "`, Status: pgtype.Present}, - pgtype.Aclitem{Status: pgtype.Null}, + &pgtype.Aclitem{String: "postgres=arwdDxt/postgres", Status: pgtype.Present}, + &pgtype.Aclitem{String: `postgres=arwdDxt/" tricky, ' } "" \ test user "`, Status: pgtype.Present}, + &pgtype.Aclitem{Status: pgtype.Null}, }) } diff --git a/pgtype/bool.go b/pgtype/bool.go index 1ebf590b..9d309f0c 100644 --- a/pgtype/bool.go +++ b/pgtype/bool.go @@ -90,7 +90,7 @@ func (dst *Bool) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Bool) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Bool) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -109,7 +109,7 @@ func (src Bool) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Bool) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Bool) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -149,7 +149,7 @@ func (dst *Bool) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Bool) Value() (driver.Value, error) { +func (src *Bool) Value() (driver.Value, error) { switch src.Status { case Present: return src.Bool, nil diff --git a/pgtype/bool_test.go b/pgtype/bool_test.go index 31f3d528..2712e3b0 100644 --- a/pgtype/bool_test.go +++ b/pgtype/bool_test.go @@ -10,9 +10,9 @@ import ( func TestBoolTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "bool", []interface{}{ - pgtype.Bool{Bool: false, Status: pgtype.Present}, - pgtype.Bool{Bool: true, Status: pgtype.Present}, - pgtype.Bool{Bool: false, Status: pgtype.Null}, + &pgtype.Bool{Bool: false, Status: pgtype.Present}, + &pgtype.Bool{Bool: true, Status: pgtype.Present}, + &pgtype.Bool{Bool: false, Status: pgtype.Null}, }) } diff --git a/pgtype/bytea.go b/pgtype/bytea.go index 8bf5de2b..3e2661db 100644 --- a/pgtype/bytea.go +++ b/pgtype/bytea.go @@ -102,7 +102,7 @@ func (dst *Bytea) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Bytea) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Bytea) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -119,7 +119,7 @@ func (src Bytea) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Bytea) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Bytea) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -152,7 +152,7 @@ func (dst *Bytea) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Bytea) Value() (driver.Value, error) { +func (src *Bytea) Value() (driver.Value, error) { switch src.Status { case Present: return src.Bytes, nil diff --git a/pgtype/bytea_test.go b/pgtype/bytea_test.go index 7d32e294..fd5a0dec 100644 --- a/pgtype/bytea_test.go +++ b/pgtype/bytea_test.go @@ -10,9 +10,9 @@ import ( func TestByteaTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "bytea", []interface{}{ - pgtype.Bytea{Bytes: []byte{1, 2, 3}, Status: pgtype.Present}, - pgtype.Bytea{Bytes: []byte{}, Status: pgtype.Present}, - pgtype.Bytea{Bytes: nil, Status: pgtype.Null}, + &pgtype.Bytea{Bytes: []byte{1, 2, 3}, Status: pgtype.Present}, + &pgtype.Bytea{Bytes: []byte{}, Status: pgtype.Present}, + &pgtype.Bytea{Bytes: nil, Status: pgtype.Null}, }) } diff --git a/pgtype/cid.go b/pgtype/cid.go index 63ba6a2f..c2b3073b 100644 --- a/pgtype/cid.go +++ b/pgtype/cid.go @@ -43,12 +43,12 @@ func (dst *Cid) DecodeBinary(ci *ConnInfo, src []byte) error { return (*pguint32)(dst).DecodeBinary(ci, src) } -func (src Cid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (pguint32)(src).EncodeText(ci, w) +func (src *Cid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*pguint32)(src).EncodeText(ci, w) } -func (src Cid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (pguint32)(src).EncodeBinary(ci, w) +func (src *Cid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*pguint32)(src).EncodeBinary(ci, w) } // Scan implements the database/sql Scanner interface. @@ -57,6 +57,6 @@ func (dst *Cid) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Cid) Value() (driver.Value, error) { - return (pguint32)(src).Value() +func (src *Cid) Value() (driver.Value, error) { + return (*pguint32)(src).Value() } diff --git a/pgtype/cid_test.go b/pgtype/cid_test.go index 385b8cac..c3bf3132 100644 --- a/pgtype/cid_test.go +++ b/pgtype/cid_test.go @@ -11,8 +11,8 @@ import ( func TestCidTranscode(t *testing.T) { pgTypeName := "cid" values := []interface{}{ - pgtype.Cid{Uint: 42, Status: pgtype.Present}, - pgtype.Cid{Status: pgtype.Null}, + &pgtype.Cid{Uint: 42, Status: pgtype.Present}, + &pgtype.Cid{Status: pgtype.Null}, } eqFunc := func(a, b interface{}) bool { return reflect.DeepEqual(a, b) diff --git a/pgtype/cidr.go b/pgtype/cidr.go index 463b279d..39a87a26 100644 --- a/pgtype/cidr.go +++ b/pgtype/cidr.go @@ -26,10 +26,10 @@ func (dst *Cidr) DecodeBinary(ci *ConnInfo, src []byte) error { return (*Inet)(dst).DecodeBinary(ci, src) } -func (src Cidr) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (Inet)(src).EncodeText(ci, w) +func (src *Cidr) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Inet)(src).EncodeText(ci, w) } -func (src Cidr) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (Inet)(src).EncodeBinary(ci, w) +func (src *Cidr) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Inet)(src).EncodeBinary(ci, w) } diff --git a/pgtype/date.go b/pgtype/date.go index 34753f05..993a04c5 100644 --- a/pgtype/date.go +++ b/pgtype/date.go @@ -125,7 +125,7 @@ func (dst *Date) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Date) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Date) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -148,7 +148,7 @@ func (src Date) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Date) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Date) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -195,7 +195,7 @@ func (dst *Date) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Date) Value() (driver.Value, error) { +func (src *Date) Value() (driver.Value, error) { switch src.Status { case Present: if src.InfinityModifier != None { diff --git a/pgtype/date_test.go b/pgtype/date_test.go index d1493f5e..d98e1652 100644 --- a/pgtype/date_test.go +++ b/pgtype/date_test.go @@ -11,15 +11,15 @@ import ( func TestDateTranscode(t *testing.T) { testutil.TestSuccessfulTranscodeEqFunc(t, "date", []interface{}{ - pgtype.Date{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Date{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Date{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Date{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Date{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Date{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Date{Status: pgtype.Null}, - pgtype.Date{Status: pgtype.Present, InfinityModifier: pgtype.Infinity}, - pgtype.Date{Status: pgtype.Present, InfinityModifier: -pgtype.Infinity}, + &pgtype.Date{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Date{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Date{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Date{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Date{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Date{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Date{Status: pgtype.Null}, + &pgtype.Date{Status: pgtype.Present, InfinityModifier: pgtype.Infinity}, + &pgtype.Date{Status: pgtype.Present, InfinityModifier: -pgtype.Infinity}, }, func(a, b interface{}) bool { at := a.(pgtype.Date) bt := b.(pgtype.Date) diff --git a/pgtype/daterange.go b/pgtype/daterange.go index fbf51980..d78c4803 100644 --- a/pgtype/daterange.go +++ b/pgtype/daterange.go @@ -106,7 +106,7 @@ func (dst *Daterange) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Daterange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Daterange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -166,7 +166,7 @@ func (src Daterange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Daterange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Daterange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -263,6 +263,6 @@ func (dst *Daterange) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Daterange) Value() (driver.Value, error) { +func (src *Daterange) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/daterange_test.go b/pgtype/daterange_test.go index 7dfae0f4..d2af5986 100644 --- a/pgtype/daterange_test.go +++ b/pgtype/daterange_test.go @@ -10,22 +10,22 @@ import ( func TestDaterangeTranscode(t *testing.T) { testutil.TestSuccessfulTranscodeEqFunc(t, "daterange", []interface{}{ - pgtype.Daterange{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, - pgtype.Daterange{ + &pgtype.Daterange{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, + &pgtype.Daterange{ Lower: pgtype.Date{Time: time.Date(1990, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, Upper: pgtype.Date{Time: time.Date(2028, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Daterange{ + &pgtype.Daterange{ Lower: pgtype.Date{Time: time.Date(1800, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, Upper: pgtype.Date{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Daterange{Status: pgtype.Null}, + &pgtype.Daterange{Status: pgtype.Null}, }, func(aa, bb interface{}) bool { a := aa.(pgtype.Daterange) b := bb.(pgtype.Daterange) diff --git a/pgtype/float4.go b/pgtype/float4.go index e92149a6..76be4203 100644 --- a/pgtype/float4.go +++ b/pgtype/float4.go @@ -139,7 +139,7 @@ func (dst *Float4) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Float4) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Float4) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -151,7 +151,7 @@ func (src Float4) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Float4) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Float4) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -184,7 +184,7 @@ func (dst *Float4) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Float4) Value() (driver.Value, error) { +func (src *Float4) Value() (driver.Value, error) { switch src.Status { case Present: return float64(src.Float), nil diff --git a/pgtype/float4_test.go b/pgtype/float4_test.go index 57f4bc34..2ed8d05d 100644 --- a/pgtype/float4_test.go +++ b/pgtype/float4_test.go @@ -10,12 +10,12 @@ import ( func TestFloat4Transcode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "float4", []interface{}{ - pgtype.Float4{Float: -1, Status: pgtype.Present}, - pgtype.Float4{Float: 0, Status: pgtype.Present}, - pgtype.Float4{Float: 0.00001, Status: pgtype.Present}, - pgtype.Float4{Float: 1, Status: pgtype.Present}, - pgtype.Float4{Float: 9999.99, Status: pgtype.Present}, - pgtype.Float4{Float: 0, Status: pgtype.Null}, + &pgtype.Float4{Float: -1, Status: pgtype.Present}, + &pgtype.Float4{Float: 0, Status: pgtype.Present}, + &pgtype.Float4{Float: 0.00001, Status: pgtype.Present}, + &pgtype.Float4{Float: 1, Status: pgtype.Present}, + &pgtype.Float4{Float: 9999.99, Status: pgtype.Present}, + &pgtype.Float4{Float: 0, Status: pgtype.Null}, }) } diff --git a/pgtype/float8.go b/pgtype/float8.go index 4d094757..8cfc53c5 100644 --- a/pgtype/float8.go +++ b/pgtype/float8.go @@ -129,7 +129,7 @@ func (dst *Float8) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Float8) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Float8) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -141,7 +141,7 @@ func (src Float8) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Float8) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Float8) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -174,7 +174,7 @@ func (dst *Float8) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Float8) Value() (driver.Value, error) { +func (src *Float8) Value() (driver.Value, error) { switch src.Status { case Present: return src.Float, nil diff --git a/pgtype/float8_test.go b/pgtype/float8_test.go index b7527b86..46fc8d5d 100644 --- a/pgtype/float8_test.go +++ b/pgtype/float8_test.go @@ -10,12 +10,12 @@ import ( func TestFloat8Transcode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "float8", []interface{}{ - pgtype.Float8{Float: -1, Status: pgtype.Present}, - pgtype.Float8{Float: 0, Status: pgtype.Present}, - pgtype.Float8{Float: 0.00001, Status: pgtype.Present}, - pgtype.Float8{Float: 1, Status: pgtype.Present}, - pgtype.Float8{Float: 9999.99, Status: pgtype.Present}, - pgtype.Float8{Float: 0, Status: pgtype.Null}, + &pgtype.Float8{Float: -1, Status: pgtype.Present}, + &pgtype.Float8{Float: 0, Status: pgtype.Present}, + &pgtype.Float8{Float: 0.00001, Status: pgtype.Present}, + &pgtype.Float8{Float: 1, Status: pgtype.Present}, + &pgtype.Float8{Float: 9999.99, Status: pgtype.Present}, + &pgtype.Float8{Float: 0, Status: pgtype.Null}, }) } diff --git a/pgtype/generic_binary.go b/pgtype/generic_binary.go index f834bfb2..094bd64e 100644 --- a/pgtype/generic_binary.go +++ b/pgtype/generic_binary.go @@ -25,8 +25,8 @@ func (dst *GenericBinary) DecodeBinary(ci *ConnInfo, src []byte) error { return (*Bytea)(dst).DecodeBinary(ci, src) } -func (src GenericBinary) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (Bytea)(src).EncodeBinary(ci, w) +func (src *GenericBinary) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Bytea)(src).EncodeBinary(ci, w) } // Scan implements the database/sql Scanner interface. @@ -35,6 +35,6 @@ func (dst *GenericBinary) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src GenericBinary) Value() (driver.Value, error) { - return (Bytea)(src).Value() +func (src *GenericBinary) Value() (driver.Value, error) { + return (*Bytea)(src).Value() } diff --git a/pgtype/generic_text.go b/pgtype/generic_text.go index 053ec504..5d0d83be 100644 --- a/pgtype/generic_text.go +++ b/pgtype/generic_text.go @@ -25,8 +25,8 @@ func (dst *GenericText) DecodeText(ci *ConnInfo, src []byte) error { return (*Text)(dst).DecodeText(ci, src) } -func (src GenericText) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (Text)(src).EncodeText(ci, w) +func (src *GenericText) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Text)(src).EncodeText(ci, w) } // Scan implements the database/sql Scanner interface. @@ -35,6 +35,6 @@ func (dst *GenericText) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src GenericText) Value() (driver.Value, error) { - return (Text)(src).Value() +func (src *GenericText) Value() (driver.Value, error) { + return (*Text)(src).Value() } diff --git a/pgtype/hstore.go b/pgtype/hstore.go index 5dc78671..3d55f783 100644 --- a/pgtype/hstore.go +++ b/pgtype/hstore.go @@ -151,7 +151,7 @@ func (dst *Hstore) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Hstore) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Hstore) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -203,7 +203,7 @@ func (src Hstore) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Hstore) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Hstore) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -462,6 +462,6 @@ func (dst *Hstore) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Hstore) Value() (driver.Value, error) { +func (src *Hstore) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/hstore_test.go b/pgtype/hstore_test.go index 502a8df0..dc2439fc 100644 --- a/pgtype/hstore_test.go +++ b/pgtype/hstore_test.go @@ -14,12 +14,12 @@ func TestHstoreTranscode(t *testing.T) { } values := []interface{}{ - pgtype.Hstore{Map: map[string]pgtype.Text{}, Status: pgtype.Present}, - pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("bar")}, Status: pgtype.Present}, - pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("bar"), "baz": text("quz")}, Status: pgtype.Present}, - pgtype.Hstore{Map: map[string]pgtype.Text{"NULL": text("bar")}, Status: pgtype.Present}, - pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("NULL")}, Status: pgtype.Present}, - pgtype.Hstore{Status: pgtype.Null}, + &pgtype.Hstore{Map: map[string]pgtype.Text{}, Status: pgtype.Present}, + &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("bar")}, Status: pgtype.Present}, + &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("bar"), "baz": text("quz")}, Status: pgtype.Present}, + &pgtype.Hstore{Map: map[string]pgtype.Text{"NULL": text("bar")}, Status: pgtype.Present}, + &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("NULL")}, Status: pgtype.Present}, + &pgtype.Hstore{Status: pgtype.Null}, } specialStrings := []string{ @@ -33,16 +33,16 @@ func TestHstoreTranscode(t *testing.T) { } for _, s := range specialStrings { // Special key values - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{s + "foo": text("bar")}, Status: pgtype.Present}) // at beginning - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{"foo" + s + "bar": text("bar")}, Status: pgtype.Present}) // in middle - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{"foo" + s: text("bar")}, Status: pgtype.Present}) // at end - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{s: text("bar")}, Status: pgtype.Present}) // is key + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{s + "foo": text("bar")}, Status: pgtype.Present}) // at beginning + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{"foo" + s + "bar": text("bar")}, Status: pgtype.Present}) // in middle + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{"foo" + s: text("bar")}, Status: pgtype.Present}) // at end + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{s: text("bar")}, Status: pgtype.Present}) // is key // Special value values - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text(s + "bar")}, Status: pgtype.Present}) // at beginning - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("foo" + s + "bar")}, Status: pgtype.Present}) // in middle - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("foo" + s)}, Status: pgtype.Present}) // at end - values = append(values, pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text(s)}, Status: pgtype.Present}) // is key + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text(s + "bar")}, Status: pgtype.Present}) // at beginning + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("foo" + s + "bar")}, Status: pgtype.Present}) // in middle + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("foo" + s)}, Status: pgtype.Present}) // at end + values = append(values, &pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text(s)}, Status: pgtype.Present}) // is key } testutil.TestSuccessfulTranscodeEqFunc(t, "hstore", values, func(ai, bi interface{}) bool { diff --git a/pgtype/inet.go b/pgtype/inet.go index 09fce04d..62734088 100644 --- a/pgtype/inet.go +++ b/pgtype/inet.go @@ -149,7 +149,7 @@ func (dst *Inet) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Inet) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Inet) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -162,7 +162,7 @@ func (src Inet) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { } // EncodeBinary encodes src into w. -func (src Inet) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Inet) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -220,6 +220,6 @@ func (dst *Inet) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Inet) Value() (driver.Value, error) { +func (src *Inet) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/inet_test.go b/pgtype/inet_test.go index 532e9abe..b883df8e 100644 --- a/pgtype/inet_test.go +++ b/pgtype/inet_test.go @@ -12,17 +12,17 @@ import ( func TestInetTranscode(t *testing.T) { for _, pgTypeName := range []string{"inet", "cidr"} { testutil.TestSuccessfulTranscode(t, pgTypeName, []interface{}{ - pgtype.Inet{IPNet: mustParseCidr(t, "0.0.0.0/32"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "127.0.0.1/32"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "12.34.56.0/32"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "192.168.1.0/24"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "255.0.0.0/8"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "255.255.255.255/32"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "::/128"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "::/0"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "::1/128"), Status: pgtype.Present}, - pgtype.Inet{IPNet: mustParseCidr(t, "2607:f8b0:4009:80b::200e/128"), Status: pgtype.Present}, - pgtype.Inet{Status: pgtype.Null}, + &pgtype.Inet{IPNet: mustParseCidr(t, "0.0.0.0/32"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "127.0.0.1/32"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "12.34.56.0/32"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "192.168.1.0/24"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "255.0.0.0/8"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "255.255.255.255/32"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "::/128"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "::/0"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "::1/128"), Status: pgtype.Present}, + &pgtype.Inet{IPNet: mustParseCidr(t, "2607:f8b0:4009:80b::200e/128"), Status: pgtype.Present}, + &pgtype.Inet{Status: pgtype.Null}, }) } } diff --git a/pgtype/int2.go b/pgtype/int2.go index 0cb6ef82..4a3beb22 100644 --- a/pgtype/int2.go +++ b/pgtype/int2.go @@ -134,7 +134,7 @@ func (dst *Int2) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Int2) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int2) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -146,7 +146,7 @@ func (src Int2) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Int2) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int2) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -185,7 +185,7 @@ func (dst *Int2) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Int2) Value() (driver.Value, error) { +func (src *Int2) Value() (driver.Value, error) { switch src.Status { case Present: return int64(src.Int), nil @@ -196,7 +196,7 @@ func (src Int2) Value() (driver.Value, error) { } } -func (src Int2) MarshalJSON() ([]byte, error) { +func (src *Int2) MarshalJSON() ([]byte, error) { switch src.Status { case Present: return []byte(strconv.FormatInt(int64(src.Int), 10)), nil diff --git a/pgtype/int2_test.go b/pgtype/int2_test.go index d81405a6..d20bf0ed 100644 --- a/pgtype/int2_test.go +++ b/pgtype/int2_test.go @@ -11,12 +11,12 @@ import ( func TestInt2Transcode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "int2", []interface{}{ - pgtype.Int2{Int: math.MinInt16, Status: pgtype.Present}, - pgtype.Int2{Int: -1, Status: pgtype.Present}, - pgtype.Int2{Int: 0, Status: pgtype.Present}, - pgtype.Int2{Int: 1, Status: pgtype.Present}, - pgtype.Int2{Int: math.MaxInt16, Status: pgtype.Present}, - pgtype.Int2{Int: 0, Status: pgtype.Null}, + &pgtype.Int2{Int: math.MinInt16, Status: pgtype.Present}, + &pgtype.Int2{Int: -1, Status: pgtype.Present}, + &pgtype.Int2{Int: 0, Status: pgtype.Present}, + &pgtype.Int2{Int: 1, Status: pgtype.Present}, + &pgtype.Int2{Int: math.MaxInt16, Status: pgtype.Present}, + &pgtype.Int2{Int: 0, Status: pgtype.Null}, }) } diff --git a/pgtype/int4.go b/pgtype/int4.go index 4a5bca51..f429d887 100644 --- a/pgtype/int4.go +++ b/pgtype/int4.go @@ -125,7 +125,7 @@ func (dst *Int4) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Int4) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int4) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -137,7 +137,7 @@ func (src Int4) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Int4) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int4) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -176,7 +176,7 @@ func (dst *Int4) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Int4) Value() (driver.Value, error) { +func (src *Int4) Value() (driver.Value, error) { switch src.Status { case Present: return int64(src.Int), nil @@ -187,7 +187,7 @@ func (src Int4) Value() (driver.Value, error) { } } -func (src Int4) MarshalJSON() ([]byte, error) { +func (src *Int4) MarshalJSON() ([]byte, error) { switch src.Status { case Present: return []byte(strconv.FormatInt(int64(src.Int), 10)), nil diff --git a/pgtype/int4_test.go b/pgtype/int4_test.go index 1354b47a..02f5409f 100644 --- a/pgtype/int4_test.go +++ b/pgtype/int4_test.go @@ -11,12 +11,12 @@ import ( func TestInt4Transcode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "int4", []interface{}{ - pgtype.Int4{Int: math.MinInt32, Status: pgtype.Present}, - pgtype.Int4{Int: -1, Status: pgtype.Present}, - pgtype.Int4{Int: 0, Status: pgtype.Present}, - pgtype.Int4{Int: 1, Status: pgtype.Present}, - pgtype.Int4{Int: math.MaxInt32, Status: pgtype.Present}, - pgtype.Int4{Int: 0, Status: pgtype.Null}, + &pgtype.Int4{Int: math.MinInt32, Status: pgtype.Present}, + &pgtype.Int4{Int: -1, Status: pgtype.Present}, + &pgtype.Int4{Int: 0, Status: pgtype.Present}, + &pgtype.Int4{Int: 1, Status: pgtype.Present}, + &pgtype.Int4{Int: math.MaxInt32, Status: pgtype.Present}, + &pgtype.Int4{Int: 0, Status: pgtype.Null}, }) } diff --git a/pgtype/int4range.go b/pgtype/int4range.go index cac4484c..8b04cf3c 100644 --- a/pgtype/int4range.go +++ b/pgtype/int4range.go @@ -106,7 +106,7 @@ func (dst *Int4range) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Int4range) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int4range) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -166,7 +166,7 @@ func (src Int4range) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Int4range) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int4range) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -263,6 +263,6 @@ func (dst *Int4range) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Int4range) Value() (driver.Value, error) { +func (src *Int4range) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/int4range_test.go b/pgtype/int4range_test.go index 74a91e59..088097d8 100644 --- a/pgtype/int4range_test.go +++ b/pgtype/int4range_test.go @@ -9,10 +9,10 @@ import ( func TestInt4rangeTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "int4range", []interface{}{ - pgtype.Int4range{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, - pgtype.Int4range{Lower: pgtype.Int4{Int: 1, Status: pgtype.Present}, Upper: pgtype.Int4{Int: 10, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, - pgtype.Int4range{Lower: pgtype.Int4{Int: -42, Status: pgtype.Present}, Upper: pgtype.Int4{Int: -5, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, - pgtype.Int4range{Status: pgtype.Null}, + &pgtype.Int4range{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, + &pgtype.Int4range{Lower: pgtype.Int4{Int: 1, Status: pgtype.Present}, Upper: pgtype.Int4{Int: 10, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, + &pgtype.Int4range{Lower: pgtype.Int4{Int: -42, Status: pgtype.Present}, Upper: pgtype.Int4{Int: -5, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, + &pgtype.Int4range{Status: pgtype.Null}, }) } diff --git a/pgtype/int8.go b/pgtype/int8.go index 0cc3545d..97db8393 100644 --- a/pgtype/int8.go +++ b/pgtype/int8.go @@ -117,7 +117,7 @@ func (dst *Int8) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Int8) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int8) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -129,7 +129,7 @@ func (src Int8) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Int8) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int8) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -162,7 +162,7 @@ func (dst *Int8) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Int8) Value() (driver.Value, error) { +func (src *Int8) Value() (driver.Value, error) { switch src.Status { case Present: return int64(src.Int), nil @@ -173,7 +173,7 @@ func (src Int8) Value() (driver.Value, error) { } } -func (src Int8) MarshalJSON() ([]byte, error) { +func (src *Int8) MarshalJSON() ([]byte, error) { switch src.Status { case Present: return []byte(strconv.FormatInt(src.Int, 10)), nil diff --git a/pgtype/int8_test.go b/pgtype/int8_test.go index d6752205..0b3bb3eb 100644 --- a/pgtype/int8_test.go +++ b/pgtype/int8_test.go @@ -11,12 +11,12 @@ import ( func TestInt8Transcode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "int8", []interface{}{ - pgtype.Int8{Int: math.MinInt64, Status: pgtype.Present}, - pgtype.Int8{Int: -1, Status: pgtype.Present}, - pgtype.Int8{Int: 0, Status: pgtype.Present}, - pgtype.Int8{Int: 1, Status: pgtype.Present}, - pgtype.Int8{Int: math.MaxInt64, Status: pgtype.Present}, - pgtype.Int8{Int: 0, Status: pgtype.Null}, + &pgtype.Int8{Int: math.MinInt64, Status: pgtype.Present}, + &pgtype.Int8{Int: -1, Status: pgtype.Present}, + &pgtype.Int8{Int: 0, Status: pgtype.Present}, + &pgtype.Int8{Int: 1, Status: pgtype.Present}, + &pgtype.Int8{Int: math.MaxInt64, Status: pgtype.Present}, + &pgtype.Int8{Int: 0, Status: pgtype.Null}, }) } diff --git a/pgtype/int8range.go b/pgtype/int8range.go index 44946be9..f8e056cb 100644 --- a/pgtype/int8range.go +++ b/pgtype/int8range.go @@ -106,7 +106,7 @@ func (dst *Int8range) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Int8range) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int8range) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -166,7 +166,7 @@ func (src Int8range) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Int8range) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Int8range) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -263,6 +263,6 @@ func (dst *Int8range) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Int8range) Value() (driver.Value, error) { +func (src *Int8range) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/int8range_test.go b/pgtype/int8range_test.go index 703f476e..c039ec65 100644 --- a/pgtype/int8range_test.go +++ b/pgtype/int8range_test.go @@ -9,10 +9,10 @@ import ( func TestInt8rangeTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "Int8range", []interface{}{ - pgtype.Int8range{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, - pgtype.Int8range{Lower: pgtype.Int8{Int: 1, Status: pgtype.Present}, Upper: pgtype.Int8{Int: 10, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, - pgtype.Int8range{Lower: pgtype.Int8{Int: -42, Status: pgtype.Present}, Upper: pgtype.Int8{Int: -5, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, - pgtype.Int8range{Status: pgtype.Null}, + &pgtype.Int8range{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, + &pgtype.Int8range{Lower: pgtype.Int8{Int: 1, Status: pgtype.Present}, Upper: pgtype.Int8{Int: 10, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, + &pgtype.Int8range{Lower: pgtype.Int8{Int: -42, Status: pgtype.Present}, Upper: pgtype.Int8{Int: -5, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present}, + &pgtype.Int8range{Status: pgtype.Null}, }) } diff --git a/pgtype/interval.go b/pgtype/interval.go index 20a4a419..1cbdffc3 100644 --- a/pgtype/interval.go +++ b/pgtype/interval.go @@ -178,7 +178,7 @@ func (dst *Interval) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Interval) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Interval) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -227,7 +227,7 @@ func (src Interval) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { } // EncodeBinary encodes src into w. -func (src Interval) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Interval) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -266,6 +266,6 @@ func (dst *Interval) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Interval) Value() (driver.Value, error) { +func (src *Interval) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/interval_test.go b/pgtype/interval_test.go index 28e77e0a..18e21ddd 100644 --- a/pgtype/interval_test.go +++ b/pgtype/interval_test.go @@ -9,23 +9,23 @@ import ( func TestIntervalTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "interval", []interface{}{ - pgtype.Interval{Microseconds: 1, Status: pgtype.Present}, - pgtype.Interval{Microseconds: 1000000, Status: pgtype.Present}, - pgtype.Interval{Microseconds: 1000001, Status: pgtype.Present}, - pgtype.Interval{Microseconds: 123202800000000, Status: pgtype.Present}, - pgtype.Interval{Days: 1, Status: pgtype.Present}, - pgtype.Interval{Months: 1, Status: pgtype.Present}, - pgtype.Interval{Months: 12, Status: pgtype.Present}, - pgtype.Interval{Months: 13, Days: 15, Microseconds: 1000001, Status: pgtype.Present}, - pgtype.Interval{Microseconds: -1, Status: pgtype.Present}, - pgtype.Interval{Microseconds: -1000000, Status: pgtype.Present}, - pgtype.Interval{Microseconds: -1000001, Status: pgtype.Present}, - pgtype.Interval{Microseconds: -123202800000000, Status: pgtype.Present}, - pgtype.Interval{Days: -1, Status: pgtype.Present}, - pgtype.Interval{Months: -1, Status: pgtype.Present}, - pgtype.Interval{Months: -12, Status: pgtype.Present}, - pgtype.Interval{Months: -13, Days: -15, Microseconds: -1000001, Status: pgtype.Present}, - pgtype.Interval{Status: pgtype.Null}, + &pgtype.Interval{Microseconds: 1, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: 1000000, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: 1000001, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: 123202800000000, Status: pgtype.Present}, + &pgtype.Interval{Days: 1, Status: pgtype.Present}, + &pgtype.Interval{Months: 1, Status: pgtype.Present}, + &pgtype.Interval{Months: 12, Status: pgtype.Present}, + &pgtype.Interval{Months: 13, Days: 15, Microseconds: 1000001, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: -1, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: -1000000, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: -1000001, Status: pgtype.Present}, + &pgtype.Interval{Microseconds: -123202800000000, Status: pgtype.Present}, + &pgtype.Interval{Days: -1, Status: pgtype.Present}, + &pgtype.Interval{Months: -1, Status: pgtype.Present}, + &pgtype.Interval{Months: -12, Status: pgtype.Present}, + &pgtype.Interval{Months: -13, Days: -15, Microseconds: -1000001, Status: pgtype.Present}, + &pgtype.Interval{Status: pgtype.Null}, }) } diff --git a/pgtype/json.go b/pgtype/json.go index b1c061f9..a027a91c 100644 --- a/pgtype/json.go +++ b/pgtype/json.go @@ -108,7 +108,7 @@ func (dst *Json) DecodeBinary(ci *ConnInfo, src []byte) error { return dst.DecodeText(ci, src) } -func (src Json) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Json) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -120,7 +120,7 @@ func (src Json) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Json) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Json) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { return src.EncodeText(ci, w) } @@ -142,7 +142,7 @@ func (dst *Json) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Json) Value() (driver.Value, error) { +func (src *Json) Value() (driver.Value, error) { switch src.Status { case Present: return string(src.Bytes), nil diff --git a/pgtype/json_test.go b/pgtype/json_test.go index 6d7cccfd..3d8d2a68 100644 --- a/pgtype/json_test.go +++ b/pgtype/json_test.go @@ -11,11 +11,11 @@ import ( func TestJsonTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "json", []interface{}{ - pgtype.Json{Bytes: []byte("{}"), Status: pgtype.Present}, - pgtype.Json{Bytes: []byte("null"), Status: pgtype.Present}, - pgtype.Json{Bytes: []byte("42"), Status: pgtype.Present}, - pgtype.Json{Bytes: []byte(`"hello"`), Status: pgtype.Present}, - pgtype.Json{Status: pgtype.Null}, + &pgtype.Json{Bytes: []byte("{}"), Status: pgtype.Present}, + &pgtype.Json{Bytes: []byte("null"), Status: pgtype.Present}, + &pgtype.Json{Bytes: []byte("42"), Status: pgtype.Present}, + &pgtype.Json{Bytes: []byte(`"hello"`), Status: pgtype.Present}, + &pgtype.Json{Status: pgtype.Null}, }) } diff --git a/pgtype/jsonb.go b/pgtype/jsonb.go index f47476d6..82cbb21f 100644 --- a/pgtype/jsonb.go +++ b/pgtype/jsonb.go @@ -47,11 +47,11 @@ func (dst *Jsonb) DecodeBinary(ci *ConnInfo, src []byte) error { } -func (src Jsonb) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (Json)(src).EncodeText(ci, w) +func (src *Jsonb) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Json)(src).EncodeText(ci, w) } -func (src Jsonb) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Jsonb) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -74,6 +74,6 @@ func (dst *Jsonb) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Jsonb) Value() (driver.Value, error) { - return (Json)(src).Value() +func (src *Jsonb) Value() (driver.Value, error) { + return (*Json)(src).Value() } diff --git a/pgtype/jsonb_test.go b/pgtype/jsonb_test.go index 37c11858..86c8a12c 100644 --- a/pgtype/jsonb_test.go +++ b/pgtype/jsonb_test.go @@ -17,11 +17,11 @@ func TestJsonbTranscode(t *testing.T) { } testutil.TestSuccessfulTranscode(t, "jsonb", []interface{}{ - pgtype.Jsonb{Bytes: []byte("{}"), Status: pgtype.Present}, - pgtype.Jsonb{Bytes: []byte("null"), Status: pgtype.Present}, - pgtype.Jsonb{Bytes: []byte("42"), Status: pgtype.Present}, - pgtype.Jsonb{Bytes: []byte(`"hello"`), Status: pgtype.Present}, - pgtype.Jsonb{Status: pgtype.Null}, + &pgtype.Jsonb{Bytes: []byte("{}"), Status: pgtype.Present}, + &pgtype.Jsonb{Bytes: []byte("null"), Status: pgtype.Present}, + &pgtype.Jsonb{Bytes: []byte("42"), Status: pgtype.Present}, + &pgtype.Jsonb{Bytes: []byte(`"hello"`), Status: pgtype.Present}, + &pgtype.Jsonb{Status: pgtype.Null}, }) } diff --git a/pgtype/macaddr.go b/pgtype/macaddr.go index 2834d69f..cfbb513d 100644 --- a/pgtype/macaddr.go +++ b/pgtype/macaddr.go @@ -106,7 +106,7 @@ func (dst *Macaddr) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Macaddr) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Macaddr) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -119,7 +119,7 @@ func (src Macaddr) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { } // EncodeBinary encodes src into w. -func (src Macaddr) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Macaddr) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -149,6 +149,6 @@ func (dst *Macaddr) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Macaddr) Value() (driver.Value, error) { +func (src *Macaddr) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/macaddr_test.go b/pgtype/macaddr_test.go index c2542da3..5d329249 100644 --- a/pgtype/macaddr_test.go +++ b/pgtype/macaddr_test.go @@ -12,8 +12,8 @@ import ( func TestMacaddrTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "macaddr", []interface{}{ - pgtype.Macaddr{Addr: mustParseMacaddr(t, "01:23:45:67:89:ab"), Status: pgtype.Present}, - pgtype.Macaddr{Status: pgtype.Null}, + &pgtype.Macaddr{Addr: mustParseMacaddr(t, "01:23:45:67:89:ab"), Status: pgtype.Present}, + &pgtype.Macaddr{Status: pgtype.Null}, }) } diff --git a/pgtype/name.go b/pgtype/name.go index cc4ae23b..05e92563 100644 --- a/pgtype/name.go +++ b/pgtype/name.go @@ -40,12 +40,12 @@ func (dst *Name) DecodeBinary(ci *ConnInfo, src []byte) error { return (*Text)(dst).DecodeBinary(ci, src) } -func (src Name) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (Text)(src).EncodeText(ci, w) +func (src *Name) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Text)(src).EncodeText(ci, w) } -func (src Name) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (Text)(src).EncodeBinary(ci, w) +func (src *Name) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Text)(src).EncodeBinary(ci, w) } // Scan implements the database/sql Scanner interface. @@ -54,6 +54,6 @@ func (dst *Name) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Name) Value() (driver.Value, error) { - return (Text)(src).Value() +func (src *Name) Value() (driver.Value, error) { + return (*Text)(src).Value() } diff --git a/pgtype/name_test.go b/pgtype/name_test.go index 348f8d39..ec0820c4 100644 --- a/pgtype/name_test.go +++ b/pgtype/name_test.go @@ -10,9 +10,9 @@ import ( func TestNameTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "name", []interface{}{ - pgtype.Name{String: "", Status: pgtype.Present}, - pgtype.Name{String: "foo", Status: pgtype.Present}, - pgtype.Name{Status: pgtype.Null}, + &pgtype.Name{String: "", Status: pgtype.Present}, + &pgtype.Name{String: "foo", Status: pgtype.Present}, + &pgtype.Name{Status: pgtype.Null}, }) } diff --git a/pgtype/numrange.go b/pgtype/numrange.go index cf42dcbd..a1b5b184 100644 --- a/pgtype/numrange.go +++ b/pgtype/numrange.go @@ -106,7 +106,7 @@ func (dst *Numrange) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Numrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Numrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -166,7 +166,7 @@ func (src Numrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Numrange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Numrange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -263,6 +263,6 @@ func (dst *Numrange) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Numrange) Value() (driver.Value, error) { +func (src *Numrange) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/numrange_test.go b/pgtype/numrange_test.go index 81e73c38..32267c86 100644 --- a/pgtype/numrange_test.go +++ b/pgtype/numrange_test.go @@ -10,25 +10,25 @@ import ( func TestNumrangeTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "numrange", []interface{}{ - pgtype.Numrange{ + &pgtype.Numrange{ LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present, }, - pgtype.Numrange{ + &pgtype.Numrange{ Lower: pgtype.Numeric{Int: big.NewInt(-543), Exp: 3, Status: pgtype.Present}, Upper: pgtype.Numeric{Int: big.NewInt(342), Exp: 1, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Numrange{ + &pgtype.Numrange{ Lower: pgtype.Numeric{Int: big.NewInt(-42), Exp: 1, Status: pgtype.Present}, Upper: pgtype.Numeric{Int: big.NewInt(-5), Exp: 0, Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Numrange{Status: pgtype.Null}, + &pgtype.Numrange{Status: pgtype.Null}, }) } diff --git a/pgtype/oid_value.go b/pgtype/oid_value.go index cb03802e..4a7de921 100644 --- a/pgtype/oid_value.go +++ b/pgtype/oid_value.go @@ -37,12 +37,12 @@ func (dst *OidValue) DecodeBinary(ci *ConnInfo, src []byte) error { return (*pguint32)(dst).DecodeBinary(ci, src) } -func (src OidValue) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (pguint32)(src).EncodeText(ci, w) +func (src *OidValue) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*pguint32)(src).EncodeText(ci, w) } -func (src OidValue) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (pguint32)(src).EncodeBinary(ci, w) +func (src *OidValue) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*pguint32)(src).EncodeBinary(ci, w) } // Scan implements the database/sql Scanner interface. @@ -51,6 +51,6 @@ func (dst *OidValue) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src OidValue) Value() (driver.Value, error) { - return (pguint32)(src).Value() +func (src *OidValue) Value() (driver.Value, error) { + return (*pguint32)(src).Value() } diff --git a/pgtype/oid_value_test.go b/pgtype/oid_value_test.go index d3412159..52ce4064 100644 --- a/pgtype/oid_value_test.go +++ b/pgtype/oid_value_test.go @@ -10,8 +10,8 @@ import ( 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}, }) } diff --git a/pgtype/pguint32.go b/pgtype/pguint32.go index 7138a409..0caa0cba 100644 --- a/pgtype/pguint32.go +++ b/pgtype/pguint32.go @@ -103,7 +103,7 @@ func (dst *pguint32) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src pguint32) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *pguint32) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -115,7 +115,7 @@ func (src pguint32) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src pguint32) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *pguint32) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -151,7 +151,7 @@ func (dst *pguint32) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src pguint32) Value() (driver.Value, error) { +func (src *pguint32) Value() (driver.Value, error) { switch src.Status { case Present: return int64(src.Uint), nil diff --git a/pgtype/qchar.go b/pgtype/qchar.go index 49475bd3..10b56534 100644 --- a/pgtype/qchar.go +++ b/pgtype/qchar.go @@ -136,7 +136,7 @@ func (dst *QChar) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src QChar) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *QChar) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil diff --git a/pgtype/text.go b/pgtype/text.go index de80dd08..8e42a756 100644 --- a/pgtype/text.go +++ b/pgtype/text.go @@ -91,7 +91,7 @@ func (dst *Text) DecodeBinary(ci *ConnInfo, src []byte) error { return dst.DecodeText(ci, src) } -func (src Text) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Text) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -103,7 +103,7 @@ func (src Text) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Text) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Text) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { return src.EncodeText(ci, w) } @@ -125,7 +125,7 @@ func (dst *Text) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Text) Value() (driver.Value, error) { +func (src *Text) Value() (driver.Value, error) { switch src.Status { case Present: return src.String, nil @@ -136,7 +136,7 @@ func (src Text) Value() (driver.Value, error) { } } -func (src Text) MarshalJSON() ([]byte, error) { +func (src *Text) MarshalJSON() ([]byte, error) { switch src.Status { case Present: return json.Marshal(src.String) diff --git a/pgtype/text_test.go b/pgtype/text_test.go index e4c1dbd8..bd971807 100644 --- a/pgtype/text_test.go +++ b/pgtype/text_test.go @@ -12,9 +12,9 @@ import ( func TestTextTranscode(t *testing.T) { for _, pgTypeName := range []string{"text", "varchar"} { testutil.TestSuccessfulTranscode(t, pgTypeName, []interface{}{ - pgtype.Text{String: "", Status: pgtype.Present}, - pgtype.Text{String: "foo", Status: pgtype.Present}, - pgtype.Text{Status: pgtype.Null}, + &pgtype.Text{String: "", Status: pgtype.Present}, + &pgtype.Text{String: "foo", Status: pgtype.Present}, + &pgtype.Text{Status: pgtype.Null}, }) } } diff --git a/pgtype/tid.go b/pgtype/tid.go index b363c1f9..f24c6244 100644 --- a/pgtype/tid.go +++ b/pgtype/tid.go @@ -94,7 +94,7 @@ func (dst *Tid) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Tid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Tid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -106,7 +106,7 @@ func (src Tid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Tid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Tid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -141,6 +141,6 @@ func (dst *Tid) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Tid) Value() (driver.Value, error) { +func (src *Tid) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/tid_test.go b/pgtype/tid_test.go index 7eb7773a..a5430d11 100644 --- a/pgtype/tid_test.go +++ b/pgtype/tid_test.go @@ -9,8 +9,8 @@ import ( func TestTidTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "tid", []interface{}{ - pgtype.Tid{BlockNumber: 42, OffsetNumber: 43, Status: pgtype.Present}, - pgtype.Tid{BlockNumber: 4294967295, OffsetNumber: 65535, Status: pgtype.Present}, - pgtype.Tid{Status: pgtype.Null}, + &pgtype.Tid{BlockNumber: 42, OffsetNumber: 43, Status: pgtype.Present}, + &pgtype.Tid{BlockNumber: 4294967295, OffsetNumber: 65535, Status: pgtype.Present}, + &pgtype.Tid{Status: pgtype.Null}, }) } diff --git a/pgtype/timestamp.go b/pgtype/timestamp.go index e7bc1c7d..694b63c0 100644 --- a/pgtype/timestamp.go +++ b/pgtype/timestamp.go @@ -136,7 +136,7 @@ func (dst *Timestamp) DecodeBinary(ci *ConnInfo, src []byte) error { // EncodeText writes the text encoding of src into w. If src.Time is not in // the UTC time zone it returns an error. -func (src Timestamp) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Timestamp) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -164,7 +164,7 @@ func (src Timestamp) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { // EncodeBinary writes the binary encoding of src into w. If src.Time is not in // the UTC time zone it returns an error. -func (src Timestamp) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Timestamp) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -211,7 +211,7 @@ func (dst *Timestamp) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Timestamp) Value() (driver.Value, error) { +func (src *Timestamp) Value() (driver.Value, error) { switch src.Status { case Present: if src.InfinityModifier != None { diff --git a/pgtype/timestamp_test.go b/pgtype/timestamp_test.go index c0427a5c..267f1a7e 100644 --- a/pgtype/timestamp_test.go +++ b/pgtype/timestamp_test.go @@ -11,19 +11,19 @@ import ( func TestTimestampTranscode(t *testing.T) { testutil.TestSuccessfulTranscodeEqFunc(t, "timestamp", []interface{}{ - pgtype.Timestamp{Time: time.Date(1800, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(1905, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(1940, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(1960, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, - pgtype.Timestamp{Status: pgtype.Null}, - pgtype.Timestamp{Status: pgtype.Present, InfinityModifier: pgtype.Infinity}, - pgtype.Timestamp{Status: pgtype.Present, InfinityModifier: -pgtype.Infinity}, + &pgtype.Timestamp{Time: time.Date(1800, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(1905, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(1940, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(1960, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, + &pgtype.Timestamp{Status: pgtype.Null}, + &pgtype.Timestamp{Status: pgtype.Present, InfinityModifier: pgtype.Infinity}, + &pgtype.Timestamp{Status: pgtype.Present, InfinityModifier: -pgtype.Infinity}, }, func(a, b interface{}) bool { at := a.(pgtype.Timestamp) bt := b.(pgtype.Timestamp) diff --git a/pgtype/timestamptz.go b/pgtype/timestamptz.go index ef2d7498..3c76ec03 100644 --- a/pgtype/timestamptz.go +++ b/pgtype/timestamptz.go @@ -140,7 +140,7 @@ func (dst *Timestamptz) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Timestamptz) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Timestamptz) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -163,7 +163,7 @@ func (src Timestamptz) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Timestamptz) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Timestamptz) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -207,7 +207,7 @@ func (dst *Timestamptz) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Timestamptz) Value() (driver.Value, error) { +func (src *Timestamptz) Value() (driver.Value, error) { switch src.Status { case Present: if src.InfinityModifier != None { diff --git a/pgtype/timestamptz_test.go b/pgtype/timestamptz_test.go index bbc001e5..c326802d 100644 --- a/pgtype/timestamptz_test.go +++ b/pgtype/timestamptz_test.go @@ -11,19 +11,19 @@ import ( func TestTimestamptzTranscode(t *testing.T) { testutil.TestSuccessfulTranscodeEqFunc(t, "timestamptz", []interface{}{ - pgtype.Timestamptz{Time: time.Date(1800, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(1905, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(1940, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(1960, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, - pgtype.Timestamptz{Status: pgtype.Null}, - pgtype.Timestamptz{Status: pgtype.Present, InfinityModifier: pgtype.Infinity}, - pgtype.Timestamptz{Status: pgtype.Present, InfinityModifier: -pgtype.Infinity}, + &pgtype.Timestamptz{Time: time.Date(1800, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(1900, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(1905, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(1940, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(1960, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(1970, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(1999, 12, 31, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(2000, 1, 2, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Time: time.Date(2200, 1, 1, 0, 0, 0, 0, time.Local), Status: pgtype.Present}, + &pgtype.Timestamptz{Status: pgtype.Null}, + &pgtype.Timestamptz{Status: pgtype.Present, InfinityModifier: pgtype.Infinity}, + &pgtype.Timestamptz{Status: pgtype.Present, InfinityModifier: -pgtype.Infinity}, }, func(a, b interface{}) bool { at := a.(pgtype.Timestamptz) bt := b.(pgtype.Timestamptz) diff --git a/pgtype/tsrange.go b/pgtype/tsrange.go index 48992829..3bf5f5ca 100644 --- a/pgtype/tsrange.go +++ b/pgtype/tsrange.go @@ -106,7 +106,7 @@ func (dst *Tsrange) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Tsrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Tsrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -166,7 +166,7 @@ func (src Tsrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Tsrange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Tsrange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -263,6 +263,6 @@ func (dst *Tsrange) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Tsrange) Value() (driver.Value, error) { +func (src *Tsrange) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/tsrange_test.go b/pgtype/tsrange_test.go index 865233c2..78eb1cd3 100644 --- a/pgtype/tsrange_test.go +++ b/pgtype/tsrange_test.go @@ -10,22 +10,22 @@ import ( func TestTsrangeTranscode(t *testing.T) { testutil.TestSuccessfulTranscodeEqFunc(t, "tsrange", []interface{}{ - pgtype.Tsrange{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, - pgtype.Tsrange{ + &pgtype.Tsrange{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, + &pgtype.Tsrange{ Lower: pgtype.Timestamp{Time: time.Date(1990, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, Upper: pgtype.Timestamp{Time: time.Date(2028, 1, 1, 0, 23, 12, 0, time.UTC), Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Tsrange{ + &pgtype.Tsrange{ Lower: pgtype.Timestamp{Time: time.Date(1800, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, Upper: pgtype.Timestamp{Time: time.Date(2200, 1, 1, 0, 23, 12, 0, time.UTC), Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Tsrange{Status: pgtype.Null}, + &pgtype.Tsrange{Status: pgtype.Null}, }, func(aa, bb interface{}) bool { a := aa.(pgtype.Tsrange) b := bb.(pgtype.Tsrange) diff --git a/pgtype/tstzrange.go b/pgtype/tstzrange.go index 61e94ab4..8e80a8f9 100644 --- a/pgtype/tstzrange.go +++ b/pgtype/tstzrange.go @@ -106,7 +106,7 @@ func (dst *Tstzrange) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Tstzrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Tstzrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -166,7 +166,7 @@ func (src Tstzrange) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, nil } -func (src Tstzrange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Tstzrange) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -263,6 +263,6 @@ func (dst *Tstzrange) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Tstzrange) Value() (driver.Value, error) { +func (src *Tstzrange) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/tstzrange_test.go b/pgtype/tstzrange_test.go index 8eb00ab9..a27ddd3a 100644 --- a/pgtype/tstzrange_test.go +++ b/pgtype/tstzrange_test.go @@ -10,22 +10,22 @@ import ( func TestTstzrangeTranscode(t *testing.T) { testutil.TestSuccessfulTranscodeEqFunc(t, "tstzrange", []interface{}{ - pgtype.Tstzrange{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, - pgtype.Tstzrange{ + &pgtype.Tstzrange{LowerType: pgtype.Empty, UpperType: pgtype.Empty, Status: pgtype.Present}, + &pgtype.Tstzrange{ Lower: pgtype.Timestamptz{Time: time.Date(1990, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, Upper: pgtype.Timestamptz{Time: time.Date(2028, 1, 1, 0, 23, 12, 0, time.UTC), Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Tstzrange{ + &pgtype.Tstzrange{ Lower: pgtype.Timestamptz{Time: time.Date(1800, 12, 31, 0, 0, 0, 0, time.UTC), Status: pgtype.Present}, Upper: pgtype.Timestamptz{Time: time.Date(2200, 1, 1, 0, 23, 12, 0, time.UTC), Status: pgtype.Present}, LowerType: pgtype.Inclusive, UpperType: pgtype.Exclusive, Status: pgtype.Present, }, - pgtype.Tstzrange{Status: pgtype.Null}, + &pgtype.Tstzrange{Status: pgtype.Null}, }, func(aa, bb interface{}) bool { a := aa.(pgtype.Tstzrange) b := bb.(pgtype.Tstzrange) diff --git a/pgtype/unknown.go b/pgtype/unknown.go index 2dca0f87..567831d7 100644 --- a/pgtype/unknown.go +++ b/pgtype/unknown.go @@ -39,6 +39,6 @@ func (dst *Unknown) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Unknown) Value() (driver.Value, error) { - return (Text)(src).Value() +func (src *Unknown) Value() (driver.Value, error) { + return (*Text)(src).Value() } diff --git a/pgtype/uuid.go b/pgtype/uuid.go index 88d2195b..03029ffd 100644 --- a/pgtype/uuid.go +++ b/pgtype/uuid.go @@ -126,7 +126,7 @@ func (dst *Uuid) DecodeBinary(ci *ConnInfo, src []byte) error { return nil } -func (src Uuid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Uuid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -138,7 +138,7 @@ func (src Uuid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { return false, err } -func (src Uuid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { +func (src *Uuid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { switch src.Status { case Null: return true, nil @@ -168,6 +168,6 @@ func (dst *Uuid) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Uuid) Value() (driver.Value, error) { +func (src *Uuid) Value() (driver.Value, error) { return encodeValueText(src) } diff --git a/pgtype/uuid_test.go b/pgtype/uuid_test.go index b745d542..4c6ad2cd 100644 --- a/pgtype/uuid_test.go +++ b/pgtype/uuid_test.go @@ -10,8 +10,8 @@ import ( func TestUuidTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "uuid", []interface{}{ - pgtype.Uuid{Bytes: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, - pgtype.Uuid{Status: pgtype.Null}, + &pgtype.Uuid{Bytes: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + &pgtype.Uuid{Status: pgtype.Null}, }) } diff --git a/pgtype/varchar.go b/pgtype/varchar.go index 6c137b9a..80673fa8 100644 --- a/pgtype/varchar.go +++ b/pgtype/varchar.go @@ -32,12 +32,12 @@ func (dst *Varchar) DecodeBinary(ci *ConnInfo, src []byte) error { return (*Text)(dst).DecodeBinary(ci, src) } -func (src Varchar) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (Text)(src).EncodeText(ci, w) +func (src *Varchar) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Text)(src).EncodeText(ci, w) } -func (src Varchar) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (Text)(src).EncodeBinary(ci, w) +func (src *Varchar) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*Text)(src).EncodeBinary(ci, w) } // Scan implements the database/sql Scanner interface. @@ -46,10 +46,10 @@ func (dst *Varchar) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Varchar) Value() (driver.Value, error) { - return (Text)(src).Value() +func (src *Varchar) Value() (driver.Value, error) { + return (*Text)(src).Value() } -func (src Varchar) MarshalJSON() ([]byte, error) { - return (Text)(src).MarshalJSON() +func (src *Varchar) MarshalJSON() ([]byte, error) { + return (*Text)(src).MarshalJSON() } diff --git a/pgtype/xid.go b/pgtype/xid.go index 0a7fc7d9..90a8d691 100644 --- a/pgtype/xid.go +++ b/pgtype/xid.go @@ -46,12 +46,12 @@ func (dst *Xid) DecodeBinary(ci *ConnInfo, src []byte) error { return (*pguint32)(dst).DecodeBinary(ci, src) } -func (src Xid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { - return (pguint32)(src).EncodeText(ci, w) +func (src *Xid) EncodeText(ci *ConnInfo, w io.Writer) (bool, error) { + return (*pguint32)(src).EncodeText(ci, w) } -func (src Xid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { - return (pguint32)(src).EncodeBinary(ci, w) +func (src *Xid) EncodeBinary(ci *ConnInfo, w io.Writer) (bool, error) { + return (*pguint32)(src).EncodeBinary(ci, w) } // Scan implements the database/sql Scanner interface. @@ -60,6 +60,6 @@ func (dst *Xid) Scan(src interface{}) error { } // Value implements the database/sql/driver Valuer interface. -func (src Xid) Value() (driver.Value, error) { - return (pguint32)(src).Value() +func (src *Xid) Value() (driver.Value, error) { + return (*pguint32)(src).Value() } diff --git a/pgtype/xid_test.go b/pgtype/xid_test.go index 868c101e..c4a1bec3 100644 --- a/pgtype/xid_test.go +++ b/pgtype/xid_test.go @@ -11,8 +11,8 @@ import ( func TestXidTranscode(t *testing.T) { pgTypeName := "xid" values := []interface{}{ - pgtype.Xid{Uint: 42, Status: pgtype.Present}, - pgtype.Xid{Status: pgtype.Null}, + &pgtype.Xid{Uint: 42, Status: pgtype.Present}, + &pgtype.Xid{Status: pgtype.Null}, } eqFunc := func(a, b interface{}) bool { return reflect.DeepEqual(a, b)