diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-05-16 15:31:11 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-05-16 18:16:30 -0400 |
commit | c2d7507dab8045b6ad1817ecb650f74fe2652af3 (patch) | |
tree | b5d249de09dde29ad26fba62915e70c39c8f5f99 /src/mongo/db/matcher | |
parent | 6fa7a15256d8058b982bf259cad34c051c1f245a (diff) | |
download | mongo-c2d7507dab8045b6ad1817ecb650f74fe2652af3.tar.gz |
SERVER-6400: fix $in with nested arrays
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r-- | src/mongo/db/matcher/expression_leaf.cpp | 25 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_leaf.h | 3 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp index df697fd38e1..938bc2f8b4c 100644 --- a/src/mongo/db/matcher/expression_leaf.cpp +++ b/src/mongo/db/matcher/expression_leaf.cpp @@ -477,18 +477,35 @@ namespace mongo { _allHaveToMatch = false; } + bool InMatchExpression::_matchesRealElement( const BSONElement& e ) const { + if ( _arrayEntries.contains( e ) ) + return true; + + for ( unsigned i = 0; i < _arrayEntries.numRegexes(); i++ ) { + if ( _arrayEntries.regex(i)->matchesSingleElement( e ) ) + return true; + } + + return false; + } bool InMatchExpression::matchesSingleElement( const BSONElement& e ) const { if ( _arrayEntries.hasNull() && e.eoo() ) return true; - if ( _arrayEntries.contains( e ) ) + if ( _matchesRealElement( e ) ) return true; - for ( unsigned i = 0; i < _arrayEntries.numRegexes(); i++ ) { - if ( _arrayEntries.regex(i)->matchesSingleElement( e ) ) - return true; + /* + if ( e.type() == Array ) { + BSONObjIterator i( e.Obj() ); + while ( i.more() ) { + BSONElement sub = i.next(); + if ( _matchesRealElement( sub ) ) + return true; + } } + */ return false; } diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h index 3f846e0bf18..9bf86c73091 100644 --- a/src/mongo/db/matcher/expression_leaf.h +++ b/src/mongo/db/matcher/expression_leaf.h @@ -48,6 +48,8 @@ namespace mongo { protected: void initPath( const StringData& path ); + bool _matchesElementExpandArray( const BSONElement& e ) const; + bool _allHaveToMatch; private: @@ -304,6 +306,7 @@ namespace mongo { void copyTo( InMatchExpression* toFillIn ) const; private: + bool _matchesRealElement( const BSONElement& e ) const; ArrayFilterEntries _arrayEntries; }; |