parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Query on a subfield date on an array with js native date object does not work

Open Olzindel opened this issue 3 years ago • 3 comments
trafficstars

New Issue Checklist

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

Olzindel avatar May 16 '22 16:05 Olzindel

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

hariprasadiit avatar May 16 '22 19:05 hariprasadiit

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:

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.

cbaker6 avatar May 21 '22 13:05 cbaker6