Skip to content

Commit 1876d3f

Browse files
committed
Add doesNotMatchKeyInQuery case...
1 parent 4ceff38 commit 1876d3f

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

spec/ParseQuery.spec.js

+43
Original file line numberDiff line numberDiff line change
@@ -3248,4 +3248,47 @@ describe('Parse.Query testing', () => {
32483248
}))
32493249
})
32503250
});
3251+
3252+
it('should match complex structure with dot notation when using matchesKeyInQuery', function(done) {
3253+
const group1 = new Parse.Object('Group', {
3254+
name: 'Group #1'
3255+
});
3256+
3257+
const group2 = new Parse.Object('Group', {
3258+
name: 'Group #2'
3259+
});
3260+
3261+
Parse.Object.saveAll([group1, group2])
3262+
.then(() => {
3263+
const role1 = new Parse.Object('Role', {
3264+
name: 'Role #1',
3265+
type: 'x',
3266+
belongsTo: group1
3267+
});
3268+
3269+
const role2 = new Parse.Object('Role', {
3270+
name: 'Role #2',
3271+
type: 'y',
3272+
belongsTo: group1
3273+
});
3274+
3275+
return Parse.Object.saveAll([role1, role2]);
3276+
})
3277+
.then(() => {
3278+
const rolesOfTypeX = new Parse.Query('Role');
3279+
rolesOfTypeX.equalTo('type', 'x');
3280+
3281+
const groupsWithRoleX = new Parse.Query('Group');
3282+
groupsWithRoleX.doesNotMatchKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
3283+
3284+
groupsWithRoleX.find(expectSuccess({
3285+
success: function(results) {
3286+
equal(results.length, 1);
3287+
equal(results[0].get('name'), group2.get('name'));
3288+
done();
3289+
}
3290+
}))
3291+
})
3292+
});
3293+
32513294
});

src/RestQuery.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ RestQuery.prototype.replaceSelect = function() {
392392
const transformDontSelect = (dontSelectObject, key, objects) => {
393393
var values = [];
394394
for (var result of objects) {
395-
values.push(result[key]);
395+
values.push(key.split('.').reduce((o,i)=>o[i], result));
396396
}
397397
delete dontSelectObject['$dontSelect'];
398398
if (Array.isArray(dontSelectObject['$nin'])) {

0 commit comments

Comments
 (0)