Skip to content

Commit 9bf21ef

Browse files
authored
Restores ability to include non pointer keys (#2263)
- Matches the behaviour on parse.com - fixes #2262
1 parent 32f7230 commit 9bf21ef

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

spec/ParseQuery.spec.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,18 +2312,28 @@ describe('Parse.Query testing', () => {
23122312
});
23132313
});
23142314

2315-
it('include on the wrong key type', (done) => {
2316-
var obj = new Parse.Object('TestObject');
2317-
obj.set('foo', 'bar');
2318-
obj.save().then(() => {
2319-
var query = new Parse.Query('TestObject');
2320-
query.include('foo');
2321-
return query.find();
2322-
}).then((results) => {
2323-
console.log('results:', results);
2324-
fail('Should have failed to query.');
2315+
it_exclude_dbs(['postgres'])('supports include on the wrong key type (#2262)', function(done) {
2316+
let childObject = new Parse.Object('TestChildObject');
2317+
childObject.set('hello', 'world');
2318+
childObject.save().then(() => {
2319+
let obj = new Parse.Object('TestObject');
2320+
obj.set('foo', 'bar');
2321+
obj.set('child', childObject);
2322+
return obj.save();
2323+
}).then(() => {
2324+
let q = new Parse.Query('TestObject');
2325+
q.include('child');
2326+
q.include('child.parent');
2327+
q.include('createdAt');
2328+
q.include('createdAt.createdAt');
2329+
return q.find();
2330+
}).then((objs) => {
2331+
expect(objs.length).toBe(1);
2332+
expect(objs[0].get('child').get('hello')).toEqual('world');
2333+
expect(objs[0].createdAt instanceof Date).toBe(true);
23252334
done();
2326-
}, (error) => {
2335+
}, (err) => {
2336+
fail('should not fail');
23272337
done();
23282338
});
23292339
});

src/RestQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,14 @@ function findPointers(object, path) {
527527
}
528528

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

533533
if (path.length == 0) {
534534
if (object.__type == 'Pointer') {
535535
return [object];
536536
}
537-
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'can only include pointer fields');
537+
return [];
538538
}
539539

540540
var subobject = object[path[0]];

0 commit comments

Comments
 (0)