[SERVER-8386] Compare Date vs timestamp errors out, timestamp vs Date doesn't Created: 29/Jan/13  Updated: 10/Dec/14  Resolved: 01/Nov/13

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.2.2, 2.3.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andre de Frere Assignee: Alberto Lerner
Resolution: Duplicate Votes: 0
Labels: query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-3304 Change comparison order so all Dates ... Closed
Related
Operating System: ALL
Steps To Reproduce:

> db.a.drop()
> db.a.insert({d:new Date(), ts: new Timestamp()})
> db.a.find({ts:Date()})
> db.a.find({d:Timestamp()})
error: { "$err" : "wrong type for field (d) 17 != 9", "code" : 13111 }

Participants:

 Description   

Comparing Date to timestamp causes an error to appear in the shell, comparing timestamp to date does not. Also the error is not very descriptive in the shell.

> db.a.drop()
> db.a.insert({d:new Date(), ts: new Timestamp()})
> db.a.find({ts:Date()})
> db.a.find({d:Timestamp()})
error: { "$err" : "wrong type for field (d) 17 != 9", "code" : 13111 }

Sorting on such a collection is also broken:

> db.a.drop()
> db.a.insert({a:Timestamp()})
> db.a.insert({a:ISODate()})
> db.a.find().sort({a:1})
error: { "$err" : "wrong type for field () 17 != 9", "code" : 13111 }


Generated at Thu Feb 08 03:17:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.