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

Restores ability to include non pointer keys #2263

Merged
merged 1 commit into from
Jul 13, 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
32 changes: 21 additions & 11 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2312,18 +2312,28 @@ describe('Parse.Query testing', () => {
});
});

it('include on the wrong key type', (done) => {
var obj = new Parse.Object('TestObject');
obj.set('foo', 'bar');
obj.save().then(() => {
var query = new Parse.Query('TestObject');
query.include('foo');
return query.find();
}).then((results) => {
console.log('results:', results);
fail('Should have failed to query.');
it_exclude_dbs(['postgres'])('supports include on the wrong key type (#2262)', function(done) {
let childObject = new Parse.Object('TestChildObject');
childObject.set('hello', 'world');
childObject.save().then(() => {
let obj = new Parse.Object('TestObject');
obj.set('foo', 'bar');
obj.set('child', childObject);
return obj.save();
}).then(() => {
let q = new Parse.Query('TestObject');
q.include('child');
q.include('child.parent');
q.include('createdAt');
q.include('createdAt.createdAt');
return q.find();
}).then((objs) => {
expect(objs.length).toBe(1);
expect(objs[0].get('child').get('hello')).toEqual('world');
expect(objs[0].createdAt instanceof Date).toBe(true);
done();
}, (error) => {
}, (err) => {
fail('should not fail');
done();
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/RestQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,14 @@ function findPointers(object, path) {
}

if (typeof object !== 'object') {
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'can only include pointer fields');
return [];
}

if (path.length == 0) {
if (object.__type == 'Pointer') {
return [object];
}
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'can only include pointer fields');
return [];
}

var subobject = object[path[0]];
Expand Down