[SERVER-26056] MongoDb $where clause returning incorrect results Created: 11/Sep/16  Updated: 12/Sep/16  Resolved: 12/Sep/16

Status: Closed
Project: Core Server
Component/s: Stability
Affects Version/s: 3.2.8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Arockia Anto [X] Assignee: Kelsey Schubert
Resolution: Cannot Reproduce Votes: 0
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

{
"version" : "3.2.8",
"gitVersion" : "ed70e33130c977bda0024c125b56d159573dbaf0",
"targetMinOS" : "Windows Vista/Windows Server 2008",
"modules" : [ ],
"allocator" : "tcmalloc",
"javascriptEngine" : "mozjs",
"sysInfo" : "deprecated",
"versionArray" : [
3,
2,
8,
0
],
"openssl" :

{ "running" : "disabled", "compiled" : "disabled" }

,
"buildEnvironment" :

{ "distmod" : "", "distarch" : "i386", "cc" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86", "ccflags" : "/nologo /EHsc /W3 /wd4355 /wd4800 /wd4267 /wd4244 /wd4290 /wd4068 /wd4351 /we4013 /we4099 /we4930 /Z7 /errorReport:none /MT /O2 /Oy- /Gw /Gy /Zc:inline", "cxx" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86", "cxxflags" : "/TP", "linkflags" : "/nologo /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /OPT:REF", "target_arch" : "i386", "target_os" : "windows" }

,
"bits" : 32,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"storageEngines" : [
"devnull",
"ephemeralForTest",
"mmapv1"
],
"ok" : 1
}


Operating System: ALL
Steps To Reproduce:

Create collection (EMPLOYEES) and insert the below doc.

{"_id" : ObjectId("57d1a113666f6fc012f2708f"), "employee_id" : 107, "first_name" : "Diana", "last_name" : "Lorentz", "email" : "DLORENTZ", "phone_number" : "590.423.5567", "hire_date" : "07-FEB-99", "job_id" : "IT_PROG", "salary" : 4200, "manager_id" : 103, "department_id" : 60}

Now execute the below 2 query and compare the results

db.EMPLOYEES.find({$where: " return false "});`

if i execute the the same logic in other way using the below query, its returning records from EMPLOYEES collection which is incorrect.

`db.EMPLOYEES.find({$where: function(){return false}});`

Participants:

 Description   

$where clause producing inconsistent results

Please refer the steps to reproduce section for detailed description.



 Comments   
Comment by Kelsey Schubert [ 12/Sep/16 ]

Hi ArockiAnto,

Thank you for the detailed report. Please be aware that this build of MongoDB is deprecated.

Unfortunately, we were unable to reproduce this behavior with the same 32-bit build. For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group.

Kind regards,
Thomas

Generated at Thu Feb 08 04:11:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.