Fix can't delete last value for many2many
@@ -308,9 +308,11 @@ func setupSetter(meta *Meta, fieldName string, record interface{}) {
}
}
- if len(primaryKeys) > 0 {
- // set current field value to blank and replace it with new value
+ // set current field value to blank
field.Set(reflect.Zero(field.Type()))
+
+ if len(primaryKeys) > 0 {
+ // replace it with new value
context.GetDB().Where(primaryKeys).Find(field.Addr().Interface())
}
