Skip to content

Commit 79bc313

Browse files
committed
Merge pull request #284 from ParsePlatform/nlutsenko.query.array
Fixed querying objects with equal constraint on array columns.
2 parents 8d03c54 + 4f05cfc commit 79bc313

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

spec/ParseQuery.spec.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,7 @@ describe('Parse.Query testing', () => {
20562056
});
20572057
});
20582058

2059-
it('query match on array value', (done) => {
2059+
it('query match on array with single object', (done) => {
20602060
var target = {__type: 'Pointer', className: 'TestObject', objectId: 'abc123'};
20612061
var obj = new Parse.Object('TestObject');
20622062
obj.set('someObjs', [target]);
@@ -2072,4 +2072,20 @@ describe('Parse.Query testing', () => {
20722072
});
20732073
});
20742074

2075+
it('query match on array with multiple objects', (done) => {
2076+
var target1 = {__type: 'Pointer', className: 'TestObject', objectId: 'abc'};
2077+
var target2 = {__type: 'Pointer', className: 'TestObject', objectId: '123'};
2078+
var obj= new Parse.Object('TestObject');
2079+
obj.set('someObjs', [target1, target2]);
2080+
obj.save().then(() => {
2081+
var query = new Parse.Query('TestObject');
2082+
query.equalTo('someObjs', target1);
2083+
return query.find();
2084+
}).then((results) => {
2085+
expect(results.length).toEqual(1);
2086+
done();
2087+
}, (error) => {
2088+
console.log(error);
2089+
});
2090+
});
20752091
});

transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function transformKeyValue(schema, className, restKey, restValue, options) {
126126

127127
if (inArray && options.query && !(restValue instanceof Array)) {
128128
return {
129-
key: key, value: [restValue]
129+
key: key, value: { '$all' : [restValue] }
130130
};
131131
}
132132

0 commit comments

Comments
 (0)