Info
Appears to be a change in behavior between 2.4.5 and 2.5.4-Pre how $gte and $gt evaluate arrays of booleans in some cases. The behavior in 2.5.4-Pre seems to be correct, ticket is to confirm that.
Reproduce:
db.q.drop();
db.q.insert({ "b" : [ [ ISODate("2013-09-29T00:00:00Z") ] ] })
db.q.insert({ "b" : [ [ ISODate("2008-02-29T00:00:00Z") ], "An inventor is simply a fellow who doesnt take his education too seriously." ] })
db.q.find( { "b" : { $gte : [ [ true ] ] } } ).itcount()
db.q.find( { "b" : { $gte : [ true ] } } ).itcount()
db.q.find( { "b" : { $gt : [ [ true ] ] } } ).itcount()
db.q.find( { "b" : { $gt : [ true ] } } ).itcount()
2.4.5: 2 documents returned per query
2.5.4-Pre: Zero
Note:
However, these comparisons works the same on both versions
db.q.find( { "b" : { $lte : [ [ true ] ] } } ).itcount()
db.q.find( { "b" : { $lte : [ true ] } } ).itcount()
db.q.find( { "b" : { $lt : [ [ true ] ] } } ).itcount()
db.q.find( { "b" : { $lt : [ true ] } } ).itcount()
db.q.find( { "b" : { $gte : true } } ).itcount()
db.q.find( { "b" : { $gte : true } } ).itcount()
db.q.find( { "b" : { $gt : true } } ).itcount()
db.q.find( { "b" : { $lte : true } } ).itcount()
db.q.find( { "b" : { $lt : true } } ).itcount()
Top User Comments
alvin commented on Mon, 28 Oct 2013 15:48:24 +0000:
Another similar (and probably releated) case is for an array of Booleans
db.q.drop()
db.q.insert({"c" : [ [ false ] ] })
db.q.find( { "c" : { $gte : [ [ ISODate("0000-01-01") ] , ISODate("2008-02-29") ] } } )
db.q.find( { "c" : { $gt : [ [ ISODate("0000-01-01") ] , ISODate("2008-02-29") ] } } )
2.4.5: One doc returned per query
2.5.4-Pre: Zero docs returned per query
Note:
The following return zero documents on both versions
db.q.find( { "c" : { $lte : [ [ ISODate("0000-01-01") ] , ISODate("2008-02-29") ] } } )
db.q.find( { "c" : { $lt : [ [ ISODate("0000-01-01") ] , ISODate("2008-02-29") ] } } )