Skip to content

Commit 1bf0d9a

Browse files
StolexiyOleksiy Stepaniuk
andauthored
Fix interface conversion panic for binary field type (#57)
Co-authored-by: Oleksiy Stepaniuk <[email protected]>
1 parent 6b181b8 commit 1bf0d9a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

conversion.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ func convertFromDynamicToStaticValue(staticType reflect.Type, dynamicValue inter
114114
if !(dynamicValue == nil || (reflect.ValueOf(dynamicValue).Kind() == reflect.Bool && typeName != "Bool")) {
115115
switch typeName {
116116
case "String":
117-
staticValue = NewString(dynamicValue.(string))
117+
if strVal, ok := dynamicValue.(string); ok {
118+
staticValue = NewString(strVal)
119+
} else {
120+
// We use "String" for Odoo Binary field type also, which is used to store binary data.
121+
// However, in rare cases (compute fields), this field might return "[]interface{}" instead of "[]byte".
122+
// @TODO: It's important to handle this scenario as well.
123+
}
118124
case "Int":
119125
staticValue = NewInt(dynamicValue.(int64))
120126
case "Selection":

0 commit comments

Comments
 (0)