Skip to content

Commit

Permalink
fix: adding or modifying a nested property requires addField permissi…
Browse files Browse the repository at this point in the history
…ons (#7679)
  • Loading branch information
bdevore17 committed Dec 6, 2021
1 parent e7c7f44 commit 6a6248b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions spec/schemas.spec.js
Expand Up @@ -1779,6 +1779,34 @@ describe('schemas', () => {
});
});

describe('Nested documents', () => {
beforeAll(async () => {
const testSchema = new Parse.Schema('test_7371');
testSchema.setCLP({
create: { ['*']: true },
update: { ['*']: true },
addField: {},
});
testSchema.addObject('a');
await testSchema.save();
});

it('addField permission not required for adding a nested property', async () => {
const obj = new Parse.Object('test_7371');
obj.set('a', {});
await obj.save();
obj.set('a.b', 2);
await obj.save();
});
it('addField permission not required for modifying a nested property', async () => {
const obj = new Parse.Object('test_7371');
obj.set('a', { b: 1 });
await obj.save();
obj.set('a.b', 2);
await obj.save();
});
});

it('should aceept class-level permission with userid of any length', async done => {
await global.reconfigureServer({
customIdSize: 11,
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/DatabaseController.js
Expand Up @@ -894,7 +894,7 @@ class DatabaseController {
if (object[field] && object[field].__op && object[field].__op === 'Delete') {
return false;
}
return schemaFields.indexOf(field) < 0;
return schemaFields.indexOf(getRootFieldName(field)) < 0;
});
if (newKeys.length > 0) {
// adds a marker that new field is being adding during update
Expand Down

0 comments on commit 6a6248b

Please sign in to comment.