Skip to content

Commit

Permalink
Merge pull request #1357 from ParsePlatform/schema-defaults
Browse files Browse the repository at this point in the history
🚧 Inject the default schemas properties when loading it
  • Loading branch information
drew-gross committed Apr 4, 2016
2 parents acc23d0 + 3a28352 commit 89df778
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/schemas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1511,5 +1511,20 @@ describe('schemas', () => {
fail('should not fail');
done();
});
});

it('can login when addFields is false (issue #1355)', (done) => {
setPermissionsOnClass('_User', {
'addField': {}
}).then(() => {
return Parse.User.signUp('foo', 'bar');
}).then((user) => {
expect(user.getUsername()).toBe('foo');
done()
}, (err) => {
console.error(err);
fail('should create user');
done();
})
})
});
10 changes: 10 additions & 0 deletions src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ class Schema {
}
});
if (className) {
// merge with the default schema
let defaultClassData = Object.assign({}, defaultColumns._Default, defaultColumns[className]);
defaultClassData = Object.keys(defaultClassData).reduce((memo, key) => {
let type = schemaAPITypeToMongoFieldType(defaultClassData[key]).result;
if (type) {
memo[key] = type;
}
return memo;
}, {});
classData = Object.assign({}, defaultClassData, classData);
this.data[className] = classData;
if (permsData) {
this.perms[className] = permsData;
Expand Down

0 comments on commit 89df778

Please sign in to comment.