Allow types to specify preference format result and param formats
This will be useful for array and composite types that may have to support elements that may not support binary encoding. It also is slightly more convenient for text-ish types to have a default format of text.
This commit is contained in:
@@ -128,6 +128,10 @@ func (src *enumType) AssignTo(dst interface{}) error {
|
||||
return errors.Errorf("cannot decode %#v into %T", src, dst)
|
||||
}
|
||||
|
||||
func (enumType) PreferredResultFormat() int16 {
|
||||
return TextFormatCode
|
||||
}
|
||||
|
||||
func (dst *enumType) DecodeText(ci *ConnInfo, src []byte) error {
|
||||
if src == nil {
|
||||
dst.status = Null
|
||||
@@ -152,6 +156,10 @@ func (dst *enumType) DecodeBinary(ci *ConnInfo, src []byte) error {
|
||||
return dst.DecodeText(ci, src)
|
||||
}
|
||||
|
||||
func (enumType) PreferredParamFormat() int16 {
|
||||
return TextFormatCode
|
||||
}
|
||||
|
||||
func (src enumType) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) {
|
||||
switch src.status {
|
||||
case Null:
|
||||
|
||||
Reference in New Issue
Block a user