[SERVER-11422] $gte is behaving differently comparing nulls Created: 28/Oct/13  Updated: 10/Dec/14  Resolved: 23/Nov/13

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

Type: Bug Priority: Major - P3
Reporter: Alvin Richards (Inactive) Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa, nqf, query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> db.serverBuildInfo()
{
"version" : "2.5.4-pre-",
"gitVersion" : "d8ca8b5faa1447365403cfb8da16a041e7d31d95",
"OpenSSLVersion" : "",
"sysInfo" : "Darwin vero 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~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 -Wno-unknown-pragmas -Winvalid-pch -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -mmacosx-version-min=10.6",
"allocator" : "tcmalloc",
"versionArray" : [
2,
5,
4,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}


Attachments: File server11422.js    
Issue Links:
Duplicate
is duplicated by SERVER-12444 null equality matches on dotted queri... Closed
Related
is related to SERVER-11414 $lt/$gt behaves differently when comp... Closed
Backwards Compatibility: Major Change
Operating System: ALL
Participants:

 Description   

$gte comparing null with number differs

For the most part $gte is behaving differently between versions
2.4.5 0 $gte null : False
2.5.4 0 $gte null : True

It does seem to be affected by schema, see second case below.

Reproduce:

db.q.drop()
db.q.insert({"b" : [ { "d" : 314159265019 }, { "b" : 0 }, { "0" : 314159265019 } ] })
db.q.find( { "b.b" : { $gte : null } } ).itcount()

2.4.5: Zero documents returned
2.5.4-Pre: 1 Document returned

As the structure changes, the behavior changes

db.q.drop()
db.q.insert({"b" : [ { "b" : 0 } ] })
db.q.find( { "b.b" : { $gte : null } } ).itcount()

2.4.5: Zero documents returned
2.5.4-Pre: Zero Document returned



 Comments   
Comment by Githook User [ 18/Dec/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-11422 better test names. additional test case for path to nested empty array
Branch: master
https://github.com/mongodb/mongo/commit/9b6697949d5e9e2c7d330f8e01c663ccfbb38f35

Comment by Benety Goh [ 23/Nov/13 ]

test suite expanded to illustrate behavior described in ticket

Comment by Githook User [ 23/Nov/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-11422 added test cases for null comparison
Branch: master
https://github.com/mongodb/mongo/commit/37ede6b109228b1c12b6e08914fe10b0183bbe48

Comment by Alvin Richards (Inactive) [ 28/Oct/13 ]

Additional test cases

db.q.drop()
db.q.insert({"b" : [3.14159265359] })
db.q.insert({"b" : 3.14159265359 })
db.q.find( { "b.b" : { $gte : null } } ).itcount()

2.4.5: 2 docs
2.5.4-Pre: 1 doc

db.q.find( { "b.b" : { $gt : null } } ).itcount()

2.4.5: 2 docs
2.5.4-Pre: 0 doc

db.q.find( { "b.b" : { $lte : null } } ).itcount()

2.4.5: 2 docs
2.5.4-Pre: 1 doc

db.q.find( { "b.b" : { $lt : null } } ).itcount()

2.4.5: 2 docs
2.5.4-Pre: 0 doc

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