fix: Parse.Query.distinct fails due to invalid aggregate stage 'hint' (#9295)
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
const Parse = require('parse/node');
|
||||
const request = require('../lib/request');
|
||||
const ParseServerRESTController = require('../lib/ParseServerRESTController').ParseServerRESTController;
|
||||
const ParseServer = require('../lib/ParseServer').default;
|
||||
|
||||
const masterKeyHeaders = {
|
||||
'X-Parse-Application-Id': 'test',
|
||||
@@ -5275,4 +5277,33 @@ describe('Parse.Query testing', () => {
|
||||
// Validate
|
||||
expect(result.executionStats).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should query with distinct within eachBatch and direct access enabled', async () => {
|
||||
await reconfigureServer({
|
||||
directAccess: true,
|
||||
});
|
||||
|
||||
Parse.CoreManager.setRESTController(
|
||||
ParseServerRESTController(Parse.applicationId, ParseServer.promiseRouter({ appId: Parse.applicationId }))
|
||||
);
|
||||
|
||||
const user = new Parse.User();
|
||||
user.set('username', 'foo');
|
||||
user.set('password', 'bar');
|
||||
await user.save();
|
||||
|
||||
const score = new Parse.Object('Score');
|
||||
score.set('player', user);
|
||||
score.set('score', 1);
|
||||
await score.save();
|
||||
|
||||
await new Parse.Query('_User')
|
||||
.equalTo('objectId', user.id)
|
||||
.eachBatch(async ([user]) => {
|
||||
const score = await new Parse.Query('Score')
|
||||
.equalTo('player', user)
|
||||
.distinct('score', { useMasterKey: true });
|
||||
expect(score).toEqual([1]);
|
||||
}, { useMasterKey: true });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user