pgtype.Encode(Binary|Text) do not write length
To aid in composability, these methods no longer write their own length. This is especially useful for text formatted arrays and may be useful for future database/sql compatibility. It also makes the code a little simpler as the types no longer have to compute their own size. Along with this, these methods cannot encode NULL. They now return a boolean if they are NULL. This also benefits text array encoding as numeric arrays require NULL to be exactly `NULL` while string arrays require NULL to be `"NULL"`.
This commit is contained in:
@@ -60,7 +60,7 @@ type forceTextEncoder struct {
|
||||
e pgtype.TextEncoder
|
||||
}
|
||||
|
||||
func (f forceTextEncoder) EncodeText(w io.Writer) error {
|
||||
func (f forceTextEncoder) EncodeText(w io.Writer) (bool, error) {
|
||||
return f.e.EncodeText(w)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ type forceBinaryEncoder struct {
|
||||
e pgtype.BinaryEncoder
|
||||
}
|
||||
|
||||
func (f forceBinaryEncoder) EncodeBinary(w io.Writer) error {
|
||||
func (f forceBinaryEncoder) EncodeBinary(w io.Writer) (bool, error) {
|
||||
return f.e.EncodeBinary(w)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user