summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-10-27 12:56:59 -0400
committerEliot Horowitz <eliot@10gen.com>2009-10-27 12:56:59 -0400
commitbe1b3de4ca39acff3db7088a4f50719f0b9d09bb (patch)
tree3e6a242014304ed4f83354d83d26327935727694
parent3eb4295ae939aa2cd3048e33e0792b64408d0877 (diff)
downloadmongo-be1b3de4ca39acff3db7088a4f50719f0b9d09bb.tar.gz
disintct and eoo fix
-rw-r--r--db/dbcommands.cpp2
-rw-r--r--jstests/distinct2.js7
2 files changed, 9 insertions, 0 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index e643523ea22..82582e2c215 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -1431,6 +1431,8 @@ namespace mongo {
while ( cursor->more() ){
BSONObj o = cursor->next();
BSONObj value = o.extractFields( keyPattern );
+ if ( value.isEmpty() )
+ continue;
if ( map.insert( value ).second ){
size += o.objsize() + 20;
uassert( "distinct too big, 4mb cap" , size < 4 * 1024 * 1024 );
diff --git a/jstests/distinct2.js b/jstests/distinct2.js
index 2cbf9d695d1..41ee78c5117 100644
--- a/jstests/distinct2.js
+++ b/jstests/distinct2.js
@@ -4,3 +4,10 @@ t.drop();
t.save({a:null});
assert.eq( 0 , t.distinct('a.b').length , "A" );
+
+t.drop();
+t.save( { a : 1 } );
+assert.eq( [1] , t.distinct( "a" ) , "B" );
+t.save( {} )
+assert.eq( [1] , t.distinct( "a" ) , "C" );
+