2
0

Add DecodeValue and DecodeDatabaseSQLValue for ArrayCodec

This commit is contained in:
Jack Christensen
2022-01-31 20:39:50 -06:00
parent 558748ef9c
commit ef7114a8ce
2 changed files with 53 additions and 12 deletions
+15 -12
View File
@@ -332,26 +332,29 @@ func (spac *scanPlanArrayCodec) Scan(src []byte, dst interface{}) error {
}
}
func (c ArrayCodec) DecodeDatabaseSQLValue(ci *ConnInfo, oid uint32, format int16, src []byte) (driver.Value, error) {
func (c *ArrayCodec) DecodeDatabaseSQLValue(ci *ConnInfo, oid uint32, format int16, src []byte) (driver.Value, error) {
if src == nil {
return nil, nil
}
// var n int64
// err := c.PlanScan(ci, oid, format, &n, true).Scan(ci, oid, format, src, &n)
// return n, err
return nil, fmt.Errorf("not implemented")
switch format {
case TextFormatCode:
return string(src), nil
case BinaryFormatCode:
buf := make([]byte, len(src))
copy(buf, src)
return buf, nil
default:
return nil, fmt.Errorf("unknown format code %d", format)
}
}
func (c ArrayCodec) DecodeValue(ci *ConnInfo, oid uint32, format int16, src []byte) (interface{}, error) {
func (c *ArrayCodec) DecodeValue(ci *ConnInfo, oid uint32, format int16, src []byte) (interface{}, error) {
if src == nil {
return nil, nil
}
// var n int16
// err := c.PlanScan(ci, oid, format, &n, true).Scan(ci, oid, format, src, &n)
// return n, err
return nil, fmt.Errorf("not implemented")
var slice []interface{}
err := ci.PlanScan(oid, format, &slice).Scan(src, &slice)
return slice, err
}