Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-2291 - more count fixes

  • Loading branch information...
commit 332d3c2060ae825a64542255603be8ee04bc7f72 1 parent 0753798
Eliot Horowitz erh authored
Showing with 8 additions and 3 deletions.
  1. +5 −2 jstests/counta.js
  2. +3 −1 src/mongo/db/dbcommands.cpp
7 jstests/counta.js
View
@@ -7,5 +7,8 @@ for( i = 0; i < 10; ++i ) {
t.save( {a:i} );
}
-// f() is undefined, causing an assertion which results in count returning 0 rather than the running total already counted.
-assert.eq( 0, t.count( { $where:function() { if ( this.a < 5 ) { return true; } else { f(); } } } ) );
+// f() is undefined, causing an assertion
+assert.throws(
+ function(){
+ t.count( { $where:function() { if ( this.a < 5 ) { return true; } else { f(); } } } );
+ } );
4 src/mongo/db/dbcommands.cpp
View
@@ -771,8 +771,10 @@ namespace mongo {
else if ( n < 0 ) {
nn = 0;
ok = false;
- if ( !err.empty() )
+ if ( !err.empty() ) {
errmsg = err;
+ return false;
+ }
}
result.append("n", (double) nn);
return ok;
Please sign in to comment.
Something went wrong with that request. Please try again.