parse-server
parse-server copied to clipboard
Query on a subfield date on an array with js native date object does not work
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest version of Parse Server.
Issue Description
PArse.Query on a subfield date on an array with js native date object does not work
Steps to reproduce
quick example:
const obj = new Parse.Object('Example')
obj.set('anArrayField', [{ date: new Date(0) }])
await obj.save()
// Elsewhere later
const query = new Parse.Query('Example')
query.lessThan('anArrayField.date', new Date())
const result = query.find()
// Result is empty but it should contain obj
Actual Outcome
Empty result, maybe related to incorrect handling of native JS date
Expected Outcome
Query a subfield date on an array with js native date object should work
Environment
Version 5.2.1
Server
- Parse Server version:
5.2.1 - Operating system:
OsX - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
4.4.2 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
JavaScript - SDK version:
3.4.2
Thanks for opening this issue!
- 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.
possible duplicate of #7575
Currently, this is suppose to be handled by the Client SDK's (in you case the JS SDK) as the SDK's should ensure the Date is encoded in a way the Parse Server understands. For example:
- Swift SDK: encoding QueryConstraint using a Date extension with proper date formatting
The same goes for decoding dates from the Parse Server.
If someone provides a PR to the server to address this, they should ensure the current way and new way both work in order to not break the Client SDKs that handle this properly.