Skip to content

Allow modify object key without addField permission #7372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions spec/schemas.spec.js
Original file line number Diff line number Diff line change
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 not required for adding a nested field (#7371)', async () => {
const obj = new Parse.Object('test_7371');
obj.set('a', {});
await obj.save();
obj.set('a.b', 2);
await obj.save();
});
it('addField not required for modifying a nested field (#7371)', 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
Original file line number Diff line number Diff line change
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