-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.4.5
-
Component/s: Querying
-
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
}
> 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 }
-
ALL
Queries for BSON type Object on array elements specified using the dot notation and the $type operator do not match valid documents in a collection.
Example query:
{a: {'b.0': {$type: 3}}} // 3 is BSON type for Object - does not match documents {a: {'b.0': {$type: 2}}} // 2 is BSON type for String - works fine
http://docs.mongodb.org/manual/core/document/#document-dot-notation
http://docs.mongodb.org/manual/reference/operator/query/type/#op._S_type
----------------
Problem:
2.4 executes equality matches differently depending on the structure of the document.
NOTE This appears to be fixed in 2.5.4-Pre
Reproduce:
db.q.drop() db.q.insert({ "b" : [ 314159265011, { "a" : "" } ] }) db.q.insert({ "b" : [ true, { "b" : "I took a speed reading course and read \"War and Peace\" in twenty minutes. It involves Russia." } ] }) db.q.insert({ "b" : [ {}, { "b" : Date(1380451200000) } ] }) db.q.insert({ "b" : [ 314159265004, { "d" : { "d" : 0, "c" : 314159265012 } } ] }) db.q.insert({ "b" : [ 314159265005, { "d" : { "d" : "We are what we repeatedly do; excellence, then, is not an act but a habit." } }, "My pessimism extends to the point of even suspecting the sincerity of the pessimists.", "" ] }) db.q.insert({ "b" : [ 1, { "a" : {} } ] }) db.q.insert({ "b" : [ "", { "2" : { "d" : { "d" : {} } } } ] }) db.q.insert({ "b" : [ "You must be the change you wish to see in the world.", { "a" : true }, false ], "a" : 1 }) db.q.insert({ "b" : [ false, { "c" : "" } ] }) db.q.insert({ "b" : [ 314159265009, {"d" : Date(1380412800000) }, 314159265000 ] }) db.q.insert({ "b" : [ Date(0), { "b" : 0 } ] }) db.q.insert({ "b" : [ Date(1380451200000), { "d" : 0 } ] }) db.q.insert({ "b" : [ 4.940656458412465e-324, { "a" : "To the man who only has a hammer, everything he encounters begins to look like a nail." } ], "c" : Date(1380451200000) }) db.q.insert({ "b" : [ { "b" : "" }, { "0" : { "c" : "Asking a working writer what he thinks about critics is like asking a lamppost how it feels about dogs." } } ] }) db.q.insert({ "b" : [ "", { "a" : 4.940656458412465e-324 } ] }) db.q.insert({ "b" : [ Date(0), {} ] }) db.q.insert({ "b" : [ {}, { "c" : Infinity } ] }) db.q.insert({ "b" : [ 1, { "c" : [ {} ] } ] })
Query 1
db.q.find( { "b.1" : { $type : 3 } } ).count()
2.4.5: 18 docs returned
2.5.4-Pre: Zero docs returned
Query 2
db.q.find( { "x" : { $type : 3 } } ).count()
2.4.5: Zero docs returned
2.5.4-Pre: Zero docs returned