2
0

Value, EncodeBinary, EncodeText, and MarshalJSON on T instead of *T

Methods defined on T are also available on *T. This change makes Value
consistent with database/sql Value implementations. It also makes Value,
EncodeBinary, and EncodeText more convenient to use because you can
pass T or *T as an argument to a query.

The MarshalJSON change is even more significant because without it
json.Marshal would generate the "%v" format instead of the implemented
MarshalJSON.

Thought this technically changes the interface, because *T will be
automatically dereferenced as needed it shouldn't be a breaking change.

See: https://github.com/jackc/pgx/issues/538 for initial discussion.
This commit is contained in:
Jack Christensen
2019-08-27 20:46:16 -05:00
parent b1e25e4ea4
commit a8802b16cc
66 changed files with 222 additions and 222 deletions
+4 -4
View File
@@ -24,8 +24,8 @@ func (dst *GenericBinary) DecodeBinary(ci *ConnInfo, src []byte) error {
return (*Bytea)(dst).DecodeBinary(ci, src)
}
func (src *GenericBinary) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
return (*Bytea)(src).EncodeBinary(ci, buf)
func (src GenericBinary) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
return (Bytea)(src).EncodeBinary(ci, buf)
}
// Scan implements the database/sql Scanner interface.
@@ -34,6 +34,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()
}