Skip to content

Commit

Permalink
Fix interface conversion panic for binary field type (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksiy Stepaniuk <ostepaniuk@skilld.fr>
  • Loading branch information
Stolexiy and Oleksiy Stepaniuk authored May 14, 2024
1 parent 6b181b8 commit 1bf0d9a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ func convertFromDynamicToStaticValue(staticType reflect.Type, dynamicValue inter
if !(dynamicValue == nil || (reflect.ValueOf(dynamicValue).Kind() == reflect.Bool && typeName != "Bool")) {
switch typeName {
case "String":
staticValue = NewString(dynamicValue.(string))
if strVal, ok := dynamicValue.(string); ok {
staticValue = NewString(strVal)
} else {
// We use "String" for Odoo Binary field type also, which is used to store binary data.
// However, in rare cases (compute fields), this field might return "[]interface{}" instead of "[]byte".
// @TODO: It's important to handle this scenario as well.
}
case "Int":
staticValue = NewInt(dynamicValue.(int64))
case "Selection":
Expand Down

0 comments on commit 1bf0d9a

Please sign in to comment.