Skip to content

Commit 6b181b8

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

conversion.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,13 @@ func convertFromDynamicToStaticValue(staticType reflect.Type, dynamicValue inter
129129
t, _ := time.Parse(format, dynamicValue.(string))
130130
staticValue = NewTime(t)
131131
case "Many2One":
132-
name, _ := dynamicValue.([]interface{})[1].(string)
133-
staticValue = NewMany2One(dynamicValue.([]interface{})[0].(int64), name)
132+
if intVal, ok := dynamicValue.(int64); ok {
133+
// for many2one_reference field type
134+
staticValue = NewMany2One(intVal, "")
135+
} else {
136+
name, _ := dynamicValue.([]interface{})[1].(string)
137+
staticValue = NewMany2One(dynamicValue.([]interface{})[0].(int64), name)
138+
}
134139
case "Relation":
135140
staticValue = NewRelation()
136141
staticValue.(*Relation).ids = sliceInterfaceToInt64Slice(dynamicValue.([]interface{}))

0 commit comments

Comments
 (0)