Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow empty geo objects, but not 1 field which is invalid

  • Loading branch information...
commit bfb09e93ea5efd5ada1addace06ada34062881a8 1 parent 4d38eee
@erh erh authored
Showing with 9 additions and 3 deletions.
  1. +7 −3 db/index_geo2d.cpp
  2. +2 −0  jstests/geo6.js
View
10 db/index_geo2d.cpp
@@ -377,7 +377,11 @@ namespace mongo {
if ( ! geo.isABSONObj() )
return;
- _hash( geo.embeddedObject() ).append( b , "" );
+ BSONObj embed = geo.embeddedObject();
+ if ( embed.isEmpty() )
+ return;
+
+ _hash( embed ).append( b , "" );
for ( size_t i=0; i<_other.size(); i++ ){
BSONElement e = obj[_other[i]];
@@ -397,9 +401,9 @@ namespace mongo {
GeoHash _hash( const BSONObj& o ) const {
BSONObjIterator i(o);
- assert( i.more() );
+ uassert( 13067 , "geo field is empty" , i.more() );
BSONElement x = i.next();
- assert( i.more() );
+ uassert( 13068 , "geo field only has 1 element" , i.more() );
BSONElement y = i.next();
uassert( 13026 , "geo values have to be numbers" , x.isNumber() && y.isNumber() );
View
2  jstests/geo6.js
@@ -19,3 +19,5 @@ assert.eq( 1 , t.find( { loc : { $near : [50,50] } } ).sort( { _id : 1 } ).next(
assert.eq( 2 , t.find( { loc : { $near : [50,50] } } ).sort( { _id : -1 } ).next()._id , "B1" )
+t.insert( { _id : 4 , loc : [] } )
+assert.eq( 4 , t.find().itcount() , "C1" )
Please sign in to comment.
Something went wrong with that request. Please try again.