mirror of https://github.com/jackc/pgx.git
Use pointer methods for all struct pgtypes
Now no need to no whether certain interfaces are implemented by struct or pointer to struct.non-blocking
parent
e380de7cd1
commit
d94f8daeb1
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
6
bool.go
6
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
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
6
bytea.go
6
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
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
12
cid.go
12
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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
8
cidr.go
8
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)
|
||||
}
|
||||
|
|
6
date.go
6
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 {
|
||||
|
|
18
date_test.go
18
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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
6
inet.go
6
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)
|
||||
}
|
||||
|
|
22
inet_test.go
22
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},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
8
int2.go
8
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
|
||||
|
|
12
int2_test.go
12
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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
8
int4.go
8
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
|
||||
|
|
12
int4_test.go
12
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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
8
int8.go
8
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
|
||||
|
|
12
int8_test.go
12
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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
6
json.go
6
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
|
||||
|
|
10
json_test.go
10
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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
10
jsonb.go
10
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()
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
12
name.go
12
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()
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
|
12
oid_value.go
12
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()
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
2
qchar.go
2
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
|
||||
|
|
8
text.go
8
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)
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
6
tid.go
6
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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
6
uuid.go
6
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)
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
16
varchar.go
16
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()
|
||||
}
|
||||
|
|
12
xid.go
12
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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue