[SERVER-12495] Queries with {$not: {$lt: 0}} are not the same as {$gte: 0} Created: 27/Jan/14  Updated: 10/Dec/14  Resolved: 29/Jan/14

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

Type: Bug Priority: Major - P3
Reporter: Andrew Emil (Inactive) Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File gtdiff.out    
Issue Links:
Duplicate
is duplicated by SERVER-12501 $lte and $not producing different res... Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Its possible to get logically impossible results using $not in 2.5.5-pre

2.5.5-pre:

> db.thurs6.find({_id: {$lt: 0}})
{ "_id" : -314159265359 }
{ "_id" : -3.14159265859 }
> db.thurs6.find({_id: {$not: {$gte: 0}}}).count()
134
> db.runCommand({buildinfo: 1})
{
        "version" : "2.5.5-pre-",
        "gitVersion" : "4e62d347f090ce1afd91dc59b3db2fab8f930bc0",
        "OpenSSLVersion" : "",
        "sysInfo" : "Darwin Andrew-Emil-MacBook-Pro.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49",
        "loaderFlags" : "-fPIC -pthread -Wl,-bind_at_load -mmacosx-version-min=10.6",
        "compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -mmacosx-version-min=10.6",
        "allocator" : "tcmalloc",
        "versionArray" : [
                2,
                5,
                5,
                -100
        ],
        "javascriptEngine" : "V8",
        "bits" : 64,
        "debug" : false,
        "maxBsonObjectSize" : 16777216,
        "ok" : 1
}

Complete output of results from above attached to ticket.



 Comments   
Comment by Benety Goh [ 29/Jan/14 ]

{$not: {$lt: 0}} should be interpreted as "all values that are not numbers or numbers that are greater than or equal to zero".

Comment by Andrew Emil (Inactive) [ 27/Jan/14 ]

Note: in 2.4.9 the two queries output the same thing:

MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:28000/test
results from {_id: {$lt: 0}}
{ "_id" : -314159265359 }
{ "_id" : -3.14159265859 }
results from {_id: {$not: {$gte: 0}}}
{ "_id" : -314159265359 }
{ "_id" : -3.14159265859 }

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