Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion integration/test/ParseQueryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,9 @@ describe('Parse Query', () => {
query.hint('_id_');
query.explain();
const explain = await query.find();
assert.equal(explain.queryPlanner.winningPlan.inputStage.inputStage.indexName, '_id_');
assert.equal(explain[0].queryPlanner.winningPlan.inputStage.inputStage.indexName, '_id_');
const explainFirst = await query.first();
assert.equal(explainFirst.queryPlanner.winningPlan.inputStage.inputStage.indexName, '_id_');
});

it('can query with select on null field', async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/ParseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,10 @@ class ParseQuery {
if (!objects[0]) {
return undefined;
}
// Return generic object when explain is used
if (this._explain) {
return objects[0];
}
if (!objects[0].className) {
objects[0].className = this.className;
}
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/ParseQuery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,14 @@ describe('ParseQuery', () => {
q.explain();
q.equalTo('size', 'small')
.find()
.then(results => {
expect(results[0].objectId).toBe('I1');
expect(results[0].size).toBe('small');
expect(results[0].name).toEqual('Product 3');
done();
});
q.equalTo('size', 'small')
.first()
.then(result => {
expect(result.objectId).toBe('I1');
expect(result.size).toBe('small');
Expand Down