Merge pull request #861 from ParsePlatform/fosco.role1

Fix for related query on non-existing column
This commit is contained in:
Fosco Marotto
2016-03-06 14:35:03 -08:00
2 changed files with 21 additions and 1 deletions

View File

@@ -177,5 +177,25 @@ describe('Parse Role testing', () => {
});
it('can create role and query empty users', (done)=> {
var roleACL = new Parse.ACL();
roleACL.setPublicReadAccess(true);
var role = new Parse.Role('subscribers', roleACL);
role.save({}, {useMasterKey : true})
.then((x)=>{
var query = role.relation('users').query();
query.find({useMasterKey : true})
.then((users)=>{
done();
}, (e)=>{
fail('should not have errors');
done();
});
}, (e) => {
console.log(e);
fail('should not have errored');
});
});
});

View File

@@ -89,7 +89,7 @@ DatabaseController.prototype.loadSchema = function(acceptor = returnsTrue) {
DatabaseController.prototype.redirectClassNameForKey = function(className, key) {
return this.loadSchema().then((schema) => {
var t = schema.getExpectedType(className, key);
var match = t.match(/^relation<(.*)>$/);
var match = t ? t.match(/^relation<(.*)>$/) : false;
if (match) {
return match[1];
} else {