Details
-
Question
-
Resolution: Done
-
Minor - P4
-
None
-
None
-
None
Description
Hi
I’m seeing an unexpected result while querying with “||” and “”&&” conditioning operations. Looks like this is a bug.
Database records:
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
> db.cars.find()
|
{ "_id" : 100, "available" : 1, "color" : "red", "name" : "GTO", "year" : 3939 } |
|
|
Below commands works as expected:
|
> db.cars.find( {available : 1, year : 3939})
|
{ "_id" : 100, "available" : 1, "color" : "red", "name" : "GTO", "year" : 3939 } |
|
|
>
|
> db.cars.find( { $where: "this.available == 1" && "this.year == 3939" }) |
{ "_id" : 100, "available" : 1, "color" : "red", "name" : "GTO", "year" : 3939 } |
|
|
>
|
>
|
> db.cars.find( { $where: "this.available == 1" || "this.year == 3939" }) |
{ "_id" : 100, "available" : 1, "color" : "red", "name" : "GTO", "year" : 3939 } |
|
|
|
|
Problem seen:
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
> #### The below command uses OR condition operation (i.e using || ) and only one condition is true. But still the entry is not displayed.. This is incorrect. |
> db.cars.find( { $where: "this.available == 11" || "this.year == 3939" }) |
|
|
>#### The below command uses AND condition operation (i.e using && ) and only one condition is true, but entry is displayed which is incorrect. For AND condition both the expression should return TRUE. |
> db.cars.find( { $where: "this.available == 11" && "this.year == 3939" }) |
{ "_id" : 100, "available" : 1, "color" : "red", "name" : "GTO", "year" : 3939 } |
Please let me know any clarification required by sending mail to jayanna.hallur@wipro.com
Regards
Jayanna Hallur
Big Data Analyst,
Wipro Technologies, Bangalore
jayanna.hallur@wipro.com