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

fixes problem affecting finding array pointers #1185

Merged
merged 1 commit into from
Mar 25, 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
39 changes: 39 additions & 0 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2170,4 +2170,43 @@ describe('Parse.Query testing', () => {

});

it('should find objects with array of pointers', (done) => {
var objects = [];
while(objects.length != 5) {
var object = new Parse.Object('ContainedObject');
object.set('index', objects.length);
objects.push(object);
}

Parse.Object.saveAll(objects).then((objects) => {
var container = new Parse.Object('Container');
var pointers = objects.map((obj) => {
return {
__type: 'Pointer',
className: 'ContainedObject',
objectId: obj.id
}
})
container.set('objects', pointers);
let container2 = new Parse.Object('Container');
container2.set('objects', pointers.slice(2, 3));
return Parse.Object.saveAll([container, container2]);
}).then(() => {
let inQuery = new Parse.Query('ContainedObject');
inQuery.greaterThanOrEqualTo('index', 1);
let query = new Parse.Query('Container');
query.matchesQuery('objects', inQuery);
return query.find();
}).then((results) => {
if (results) {
expect(results.length).toBe(2);
}
done();
}).fail((err) => {
console.error(err);
fail('should not fail');
done();
})
})

});
2 changes: 1 addition & 1 deletion src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ function transformConstraint(constraint, inArray) {
'bad ' + key + ' value');
}
answer[key] = arr.map((v) => {
return transformAtom(v, true);
return transformAtom(v, true, { inArray: inArray });
});
break;

Expand Down