mirror of
https://github.com/jackc/pgx.git
synced 2025-05-31 11:42:24 +00:00
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.
40 lines
949 B
Go
40 lines
949 B
Go
package pgtype
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
)
|
|
|
|
// GenericText is a placeholder for text format values that no other type exists
|
|
// to handle.
|
|
type GenericText Text
|
|
|
|
func (dst *GenericText) Set(src interface{}) error {
|
|
return (*Text)(dst).Set(src)
|
|
}
|
|
|
|
func (dst *GenericText) Get() interface{} {
|
|
return (*Text)(dst).Get()
|
|
}
|
|
|
|
func (src *GenericText) AssignTo(dst interface{}) error {
|
|
return (*Text)(src).AssignTo(dst)
|
|
}
|
|
|
|
func (dst *GenericText) DecodeText(ci *ConnInfo, src []byte) error {
|
|
return (*Text)(dst).DecodeText(ci, src)
|
|
}
|
|
|
|
func (src GenericText) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
|
|
return (Text)(src).EncodeText(ci, buf)
|
|
}
|
|
|
|
// Scan implements the database/sql Scanner interface.
|
|
func (dst *GenericText) Scan(src interface{}) error {
|
|
return (*Text)(dst).Scan(src)
|
|
}
|
|
|
|
// Value implements the database/sql/driver Valuer interface.
|
|
func (src GenericText) Value() (driver.Value, error) {
|
|
return (Text)(src).Value()
|
|
}
|