Closed
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
When you start the server with the option directAccess
, the execution of a pipeline does not return results when you pass a Date
instance to match
.
Steps to reproduce
- The following test fails when
directAccess
is set totrue
and'date': date
- The following test passes when
directAccess
is set tofalse
and'date': date
- The following test passes when
directAccess
is set totrue
orfalse
anddate : date.toISOString()
.
It remains unclear whether this behaviour was intended in previous versions (<5)
it('fails', async () => {
const registration = await Parse.User.signUp("jonas", "test", {});
expect(registration.id).to.be.exist
const user = await Parse.User.logIn("jonas", "test");
expect(user.get('sessionToken')).to.be.exist
expect(user.id).to.be.exist
const TestObject = Parse.Object.extend('TestObject');
const date = new Date()
const testObject = await new TestObject({
date: date,
}).save({}, { useMasterKey : true });
const match = {
'date': { "$gte": date, "$lte": date } // Does not work when directAccess is true
//'date': { "$gte": date.toISOString(), "$lte": date.toISOString()} // Works for both
}
console.log(match)
const pipeline = [
{
"$match" : match
}
]
const query = new Parse.Query(TestObject);
const result = await query.aggregate(pipeline).catch(e => e);
console.log("results=",util.inspect(result, { showHidden: false, depth: null }))
const query2 = new Parse.Query(TestObject);
const result2 = await query2.equalTo('date', date).find().catch(e => e);
console.log("results2=",util.inspect(result2, { showHidden: false, depth: null }))
expect(result).to.be.lengthOf(1)
expect(result2).to.be.lengthOf(1)
expect(result[0].objectId).to.be.equal(result2[0].id)
});
Actual Outcome
When (1)
results= []
results2= [
ParseObjectSubclass {
className: 'TestObject',
_objCount: 9,
id: 'jXEY7xFC3a'
}
]
Expected Outcome
When (2) or (3)
results= [
{
date: { __type: 'Date', iso: '2021-12-28T13:51:11.961Z' },
createdAt: '2021-12-28T13:51:11.962Z',
updatedAt: '2021-12-28T13:51:11.962Z',
objectId: 'xNLwllPXlu'
}
]
results2= [
ParseObjectSubclass {
className: 'TestObject',
_objCount: 9,
id: 'xNLwllPXlu'
}
]
Environment
Server
- Parse Server version:
^5.0.0-beta.4
- Operating system:
macos
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
mongodb
- Database version:
5.0.3
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
na
- SDK version:
na