Handle driver.Valuers inside Map.Encode
This commit is contained in:
@@ -1720,6 +1720,17 @@ func (m *Map) Encode(oid uint32, formatCode int16, value interface{}, buf []byte
|
||||
|
||||
plan := m.PlanEncode(oid, formatCode, value)
|
||||
if plan == nil {
|
||||
if dv, ok := value.(driver.Valuer); ok {
|
||||
if dv == nil {
|
||||
return nil, nil
|
||||
}
|
||||
v, err := dv.Value()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m.Encode(oid, formatCode, v, buf)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unable to encode %#v into OID %d", value, oid)
|
||||
}
|
||||
return plan.Encode(value, buf)
|
||||
|
||||
Reference in New Issue
Block a user