fix: Error in afterSave trigger for Parse.Role due to name field (#9883)
This commit is contained in:
@@ -1743,6 +1743,14 @@ RestWrite.prototype.buildParseObjects = function () {
|
||||
const readOnlyAttributes = className.constructor.readOnlyAttributes
|
||||
? className.constructor.readOnlyAttributes()
|
||||
: [];
|
||||
|
||||
// For _Role class, 'name' cannot be set after the role has an objectId.
|
||||
// In afterSave context, _handleSaveResponse has already set the objectId,
|
||||
// so we treat 'name' as read-only to avoid Parse SDK validation errors.
|
||||
const isRoleAfterSave = this.className === '_Role' && this.response && !this.query;
|
||||
if (isRoleAfterSave && this.data.name && !readOnlyAttributes.includes('name')) {
|
||||
readOnlyAttributes.push('name');
|
||||
}
|
||||
if (!this.originalData) {
|
||||
for (const attribute of readOnlyAttributes) {
|
||||
extraData[attribute] = this.data[attribute];
|
||||
|
||||
Reference in New Issue
Block a user