Skip to content
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

🚧 Inject the default schemas properties when loading it #1357

Merged
merged 1 commit into from
Apr 4, 2016
Merged
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
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