[COMPASS-6755] Compass interprets Date() incorrectly in queries Created: 20/Apr/23  Updated: 20/May/23  Resolved: 08/May/23

Status: Closed
Project: Compass
Component/s: Query Bar
Affects Version/s: None
Fix Version/s: 1.37.0

Type: Bug Priority: Minor - P4
Reporter: Tom Hollander Assignee: Le Roux Bodenstein
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS:
node.js / npm versions:
Additional info:


Attachments: PNG File Screenshot 2023-04-20 at 11.37.31.png     PNG File Screenshot 2023-04-20 at 11.39.38.png     PNG File Screenshot 2023-04-20 at 11.39.48.png     PNG File Screenshot 2023-04-20 at 11.40.00.png    
Story Points: 2
Documentation Changes: Not Needed

 Description   

Problem Statement/Rationale

Compass should behave consistently with other tools such as mongosh, Charts and Node with respect to date helpers. Inconsistency leads to customer confusion and bugs (see this Slack discussion for an example)

Steps to Reproduce

  1. Find a collection with a date field.
  2. Use Compass to filter the data using something like this:
     { createDate: { $gt: Date("2001-01-01") }}

Expected Results

  1. Zero documents returned.
  2. This is because as per JavaScript oddities, Date("...") returns the current date as a string, ignoring the arguments.
  3. To get a working date filter, users would need to specify new Date("...") or new ISODate("...") or ISODate("...")

Actual Results

  1. Data is filtered based on the specified date, even though this is not how Javascript works.

Additional Notes

Any additional information that may be useful to include.



 Comments   
Comment by Githook User [ 20/May/23 ]

Author:

{'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}

Message: fix(ejson): Differentiate between new Date() and Date() COMPASS-6755 (#4327)

bump ejson-shell-parser to 1.2.4
Branch: COMPASS-6664-guide-cue-stage-wizard
https://github.com/mongodb-js/compass/commit/52a10750bc6942923c66fd6f564aa06a839c4d2f

Comment by Githook User [ 08/May/23 ]

Author:

{'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}

Message: fix(ejson): Differentiate between new Date() and Date() COMPASS-6755 (#4327)

bump ejson-shell-parser to 1.2.4
Branch: COMPASS-6058-fix-update-on-sharded-collection
https://github.com/mongodb-js/compass/commit/52a10750bc6942923c66fd6f564aa06a839c4d2f

Comment by Githook User [ 08/May/23 ]

Author:

{'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}

Message: fix(ejson): Differentiate between new Date() and Date() COMPASS-6755 (#4327)

bump ejson-shell-parser to 1.2.4
Branch: main
https://github.com/mongodb-js/compass/commit/52a10750bc6942923c66fd6f564aa06a839c4d2f

Generated at Wed Feb 07 22:44:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.