2
0

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:
Jack Christensen
2017-03-11 12:32:33 -06:00
parent 361a54abb7
commit e654d1f0fc
37 changed files with 1185 additions and 1285 deletions
+2 -2
View File
@@ -22,10 +22,10 @@ func (dst *CidrArray) DecodeBinary(src []byte) error {
return (*InetArray)(dst).DecodeBinary(src)
}
func (src *CidrArray) EncodeText(w io.Writer) error {
func (src *CidrArray) EncodeText(w io.Writer) (bool, error) {
return (*InetArray)(src).EncodeText(w)
}
func (src *CidrArray) EncodeBinary(w io.Writer) error {
func (src *CidrArray) EncodeBinary(w io.Writer) (bool, error) {
return (*InetArray)(src).encodeBinary(w, CidrOID)
}