MongoDb $where clause returning incorrect results

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.8
    • Component/s: Stability
    • Environment:
    • ALL
    • Hide

      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}});`

      Show
      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}});`
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      $where clause producing inconsistent results

      Please refer the steps to reproduce section for detailed description.

              Assignee:
              Kelsey Schubert
              Reporter:
              Arockia Anto [X]
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: