mirror of https://github.com/jackc/pgx.git
Fix NULL with extendedQueryBuilder
parent
c5a70faea6
commit
be89cce214
|
@ -72,20 +72,29 @@ func (eqb *extendedQueryBuilder) encodeExtendedParamValue(ci *pgtype.ConnInfo, o
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
var buf []byte
|
||||||
pos := len(eqb.paramValueBytes)
|
pos := len(eqb.paramValueBytes)
|
||||||
|
|
||||||
switch arg := arg.(type) {
|
switch arg := arg.(type) {
|
||||||
case pgtype.BinaryEncoder:
|
case pgtype.BinaryEncoder:
|
||||||
eqb.paramValueBytes, err = arg.EncodeBinary(ci, eqb.paramValueBytes)
|
buf, err = arg.EncodeBinary(ci, eqb.paramValueBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if buf == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
eqb.paramValueBytes = buf
|
||||||
return eqb.paramValueBytes[pos:], nil
|
return eqb.paramValueBytes[pos:], nil
|
||||||
case pgtype.TextEncoder:
|
case pgtype.TextEncoder:
|
||||||
eqb.paramValueBytes, err = arg.EncodeText(ci, eqb.paramValueBytes)
|
buf, err = arg.EncodeText(ci, eqb.paramValueBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if buf == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
eqb.paramValueBytes = buf
|
||||||
return eqb.paramValueBytes[pos:], nil
|
return eqb.paramValueBytes[pos:], nil
|
||||||
case string:
|
case string:
|
||||||
return []byte(arg), nil
|
return []byte(arg), nil
|
||||||
|
|
Loading…
Reference in New Issue