summaryrefslogtreecommitdiff
path: root/db/clientcursor.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-07-01 10:07:38 -0400
committerEliot Horowitz <eliot@10gen.com>2011-07-01 10:07:38 -0400
commit3a5096deb4c733a35d910d57ca3d523037d1517a (patch)
tree448051fd9ab772a5e464494d152a0c4503aeb83b /db/clientcursor.cpp
parenta55f19fc477ba83f6fd6660c91d132a4a8446336 (diff)
downloadmongo-3a5096deb4c733a35d910d57ca3d523037d1517a.tar.gz
ClientCursor::getFieldsDotted safe for v1 indexes
Diffstat (limited to 'db/clientcursor.cpp')
-rw-r--r--db/clientcursor.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/db/clientcursor.cpp b/db/clientcursor.cpp
index b918abb4b52..bb6804df9bc 100644
--- a/db/clientcursor.cpp
+++ b/db/clientcursor.cpp
@@ -338,19 +338,20 @@ namespace mongo {
return true;
}
- BSONElement ClientCursor::getFieldDotted( const string& name , bool * fromKey ) {
+ BSONElement ClientCursor::getFieldDotted( const string& name , BSONObj& holder , bool * fromKey ) {
map<string,int>::const_iterator i = _indexedFields.find( name );
if ( i == _indexedFields.end() ) {
if ( fromKey )
*fromKey = false;
- return current().getFieldDotted( name );
+ holder = current();
+ return holder.getFieldDotted( name );
}
int x = i->second;
- BSONObj ck = currKey();
- BSONObjIterator it( ck );
+ holder = currKey();
+ BSONObjIterator it( holder );
while ( x && it.more() ) {
it.next();
x--;
@@ -364,14 +365,16 @@ namespace mongo {
BSONObj ClientCursor::extractFields(const BSONObj &pattern , bool fillWithNull ) {
BSONObjBuilder b( pattern.objsize() * 2 );
+
+ BSONObj holder;
BSONObjIterator i( pattern );
while ( i.more() ) {
BSONElement key = i.next();
- BSONElement value = getFieldDotted( key.fieldName() );
+ BSONElement value = getFieldDotted( key.fieldName() , holder );
if ( value.type() ) {
- b.append( value );
+ b.appendAs( value , key.fieldName() );
continue;
}