[SERVER-11403] $lt/$lte operator behaves differently when a string comparison is made against a (nested) array of numbers Created: 28/Oct/13  Updated: 10/Dec/14  Resolved: 15/Nov/13

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

Type: Bug Priority: Major - P3
Reporter: Alvin Richards (Inactive) Assignee: hari.khalsa@10gen.com
Resolution: Duplicate 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 server11403.js    
Issue Links:
Duplicate
is duplicated by SERVER-11444 $lt/$lte/$gte/$gt behaves differently... Closed
Related
Operating System: ALL
Participants:

 Description   

Problem:
Appears to be a change in behavior between 2.4.5 and 2.5.4-Pre how $lte and $lt evaluate arrays of numbers.

NOTE: The behavior in 2.5.4-Pre seems to be correct, ticket is to confirm that.

Reproduce:

db.q.drop();
db.q.insert({"d" : [  [  314159265008,  [  314159265014 ] ] ], "a" : { "b" : { "d" : ISODate("2013-09-29T00:00:00Z") } } })
db.q.find( { "d" : { $lt : [  "Before I got married I had six theories about bringing up children; now I have six children and no theories." ] } } ).itcount()
db.q.find( { "d" : { $lte : [  "Before I got married I had six theories about bringing up children; now I have six children and no theories." ] } } ).itcount()

2.4.5: 1 document returned per query
2.5.4-Pre: Zero documents

Note:
These queries produce the same results on both 2.4.5 and 2.5.4-Pre (zero documents)

db.q.find( { "d" : { $gt : [  "Before I got married I had six theories about bringing up children; now I have six children and no theories." ] } } ).itcount()
db.q.find( { "d" : { $gte : [  "Before I got married I had six theories about bringing up children; now I have six children and no theories." ] } } ).itcount()



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

Couple more examples

db.q.drop()
db.q.insert({"d" : [  [  {  "a" : 0 } ] ] })
db.q.insert({"d" : [  true,  [  314159265007,  "" ] ], "b" : 3.14159265359 })
db.q.find( { "d" : { $lte : [ { "d" : 314159265009 } , 1 ] } } )

2.4.5: 2 docs returned
2.5.4-Pre: Zero returned

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

Another example of the same issue

db.q.drop()
db.q.insert({ "c" : [ 	{ 	"c" : "The richest man is not he who has the most, but he who needs the least." }, 	[ 	"" ] ] })
db.q.insert({ "c" : [ 	{ 	"1" : { 	"b" : "I have made this letter longer than usual because I lack the time to make it shorter." }, 	"2" : "" }, 	[ 	0 ] ] })
db.q.insert({ "c" : [  [  0 ],  {   } ] })
db.q.insert({ "c" : [  {  "c" : 314159265003 },  -3.14159265,  [  "" ] ] })
db.q.insert({ "c" : [  [  5e-324 ],  {  "d" : ISODate("2008-02-29T00:00:00Z") } ] })
db.q.insert({ "c" : [  [  314159265010 ],  {  "d" : {   } } ], "d" : [  true ] })
db.q.insert({ "c" : [  {  "d" : -3.14159265859 },  {   },  [  "" ] ] })
db.q.insert({ "c" : [  [  314159265006 ],  {   } ], "a" : ISODate("2008-02-29T00:00:00Z") })
db.q.insert({ "c" : [  {  "b" : {  "c" : ISODate("2013-09-29T10:40:00Z") } },  [  "" ] ], "a" : [  "" ] })
db.q.insert({ "c" : [  {  "c" : 314159265017 },  [  314159265001 ] ] })
db.q.insert({ "b" : 1, "c" : [  {  "a" : -3.14159265 },  [  -3.14159265359,  false ] ] })
db.q.insert({ "d" : [ 	{ 	"0" : "", 	"b" : { 	"b" : [ 	[ 	"We are what we repeatedly do; excellence, then, is not an act but a habit." ] ], 	"a" : { 	"a" : { 	"d" : ISODate("2008-02-29T00:00:00Z") } } } } ], "c" : [  {  "d" : {  "c" : {  "b" : "" } } },  1,  [  1 ] ], "b" : false })
db.q.find( { "c" : { $lte : [ "A wise man gets more use from his enemies than a fool from his friends." ] } } )

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