[SERVER-11100] $where doesn't find equal NumberLong values Created: 09/Oct/13  Updated: 10/Dec/14  Resolved: 01/Nov/13

Status: Closed
Project: Core Server
Component/s: Querying, Shell
Affects Version/s: 2.4.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kay Agahd Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux 64 bit


Operating System: ALL
Steps To Reproduce:

mongos> db.wheretest.remove()
mongos> db.wheretest.save({a:NumberLong(10), b: NumberLong(10)})
mongos> db.wheretest.save({a:NumberLong(9), b: NumberLong(10)})
mongos> db.wheretest.save({a:NumberLong(10), b: NumberLong(9)})
mongos> db.wheretest.find({$where: "this.a < this.b"},{_id:0,a:1,b:1});//OK
{ "a" : NumberLong(9), "b" : NumberLong(10) }
mongos> db.wheretest.find({$where: "this.a > this.b"},{_id:0,a:1,b:1});//OK
{ "a" : NumberLong(10), "b" : NumberLong(9) }
mongos> db.wheretest.find({$where: "this.a == this.b"},{_id:0,a:1,b:1});//NOT OK
mongos> db.wheretest.find({$where: "this.a.toNumber() == this.b.toNumber()"},{_id:0,a:1,b:1});//WORKAROUND
{ "a" : NumberLong(10), "b" : NumberLong(10) }
mongos> 

Participants:

 Description   

It seems that we need to call .toNumber() even if solely NumberLong values are tested on equality (==) by $where (see below steps to reproduce). The operators > and < work without .toNumer() nevertheless.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 01/Nov/13 ]

I believe this is the same as SERVER-1672

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