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.
38 lines
814 B
Go
38 lines
814 B
Go
package pgtype
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
)
|
|
|
|
type Bit Varbit
|
|
|
|
func (dst *Bit) Set(src interface{}) error {
|
|
return (*Varbit)(dst).Set(src)
|
|
}
|
|
|
|
func (dst *Bit) Get() interface{} {
|
|
return (*Varbit)(dst).Get()
|
|
}
|
|
|
|
func (src *Bit) AssignTo(dst interface{}) error {
|
|
return (*Varbit)(src).AssignTo(dst)
|
|
}
|
|
|
|
func (dst *Bit) DecodeBinary(ci *ConnInfo, src []byte) error {
|
|
return (*Varbit)(dst).DecodeBinary(ci, src)
|
|
}
|
|
|
|
func (src Bit) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
|
|
return (Varbit)(src).EncodeBinary(ci, buf)
|
|
}
|
|
|
|
// Scan implements the database/sql Scanner interface.
|
|
func (dst *Bit) Scan(src interface{}) error {
|
|
return (*Varbit)(dst).Scan(src)
|
|
}
|
|
|
|
// Value implements the database/sql/driver Valuer interface.
|
|
func (src Bit) Value() (driver.Value, error) {
|
|
return (Varbit)(src).Value()
|
|
}
|