Fixes Issue unsetting in beforeSave doesn't allow object creation (#4610)

* skip unset fields on canAddField

* removed fit

* add null check
This commit is contained in:
Diamond Lewis
2018-03-08 10:31:53 -06:00
committed by GitHub
parent f03e35ff76
commit f0674df424
2 changed files with 47 additions and 2 deletions

View File

@@ -622,8 +622,12 @@ class DatabaseController {
const fields = Object.keys(object);
const schemaFields = Object.keys(classSchema);
const newKeys = fields.filter((field) => {
// Skip fields that are unset
if (object[field] && object[field].__op && object[field].__op === 'Delete') {
return false;
}
return schemaFields.indexOf(field) < 0;
})
});
if (newKeys.length > 0) {
return schema.validatePermission(className, aclGroup, 'addField');
}