[SERVER-11414] $lt/$gt behaves differently when comparing null 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 server11414.js    
Issue Links:
Related
related to SERVER-11422 $gte is behaving differently comparin... Closed
related to SERVER-12444 null equality matches on dotted queri... Closed
Backwards Compatibility: Major Change
Operating System: ALL
Participants:

 Description   

Null is being treated differently by the $gt and $lt operators between versions.

db.q.drop()
db.q.insert({"a" : { "a" : 1 } })
db.q.find( { "b" : { $lt : null } } ).itcount()
db.q.find( { "b" : { $gt : null } } ).itcount()

2.4.5: 1 doc per query
2.5.4-Pre: zero doc per query

Note
The following queries behave the same on both versions and return zero documents

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



 Comments   
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-11414 added test cases for null comparison operations on non-existent fields
Branch: master
https://github.com/mongodb/mongo/commit/0d9c674d959c8209e4056aa825461b4e70d378ff

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