[COMPASS-3053] Strict Json $date not interpreted correctly Created: 09/Aug/18  Updated: 26/Aug/20  Resolved: 26/Aug/20

Status: Closed
Project: Compass
Component/s: CRUD
Affects Version/s: 1.14.6, 1.16.0
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: Kevin Arhelger Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OSX


Attachments: PNG File image-2018-08-09-11-43-29-474.png     PNG File image-2018-08-09-12-07-12-312.png    
Documentation Changes: Not Needed

 Description   

This works...

{"expirationDate" : {"$gt" : ISODate("2018-09-04T04:00:00.000Z")}}

This does not...

{"expirationDate" : {"$gt" : {$date : "2018-09-04T04:00:00.000Z"}}}

Looks like $date is sent raw and is not converted to a BSON date type

0000   02 00 00 00 45 00 00 e7 00 00 40 00 40 06 00 00
0010   7f 00 00 01 7f 00 00 01 d4 fb 69 89 50 71 a8 63
0020   c6 2b 88 a7 80 18 28 6f fe db 00 00 01 01 08 0a
0030   2e 7a 72 0b 2e 7a 72 0b b3 00 00 00 02 66 69 6e
0040   64 00 0a 00 00 00 65 6d 70 6c 6f 79 65 65 73 00
0050   03 66 69 6c 74 65 72 00 48 00 00 00 03 65 78 70
0060   69 72 61 74 69 6f 6e 44 61 74 65 00 33 00 00 00
0070   03 24 67 74 00 29 00 00 00 02 24 64 61 74 65 00
0080   19 00 00 00 32 30 31 38 2d 30 39 2d 30 34 54 30
0090   34 3a 30 30 3a 30 30 2e 30 30 30 5a 00 00 00 00
00a0   10 6c 69 6d 69 74 00 14 00 00 00 08 72 65 74 75
00b0   72 6e 4b 65 79 00 00 08 73 68 6f 77 52 65 63 6f
00c0   72 64 49 64 00 00 03 6c 73 69 64 00 1e 00 00 00
00d0   05 69 64 00 10 00 00 00 04 21 bd a5 1b 1f 8c 48
00e0   84 9f 86 e2 60 81 de cb 8f 00 00

Mongodump works correctly with the same syntax.

mongodump -d morphia_example -c employees -q '{"expirationDate" : {"$gt" : {$date : "2018-09-04T04:00:00.000Z"}}}'
2018-08-09T11:44:54.068-0500	writing morphia_example.employees to
2018-08-09T11:44:54.070-0500	done dumping morphia_example.employees (2 documents)

Table:

According to the docs here: https://docs.mongodb.com/manual/reference/mongodb-extended-json/#input-in-strict-mode Compass should correctly work with strict mode.



 Comments   
Comment by Massimiliano Marcon [ 26/Aug/20 ]

That syntax doesn't work in the mongo shell either.

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