Bladeren bron

ref #3359: Cleaning up MatchExpressionParser to pass test cases

Brennan Chesley 12 jaren geleden
bovenliggende
commit
fbfcabd944
2 gewijzigde bestanden met toevoegingen van 9 en 6 verwijderingen
  1. 1 1
      lib/pipeline/matcher/ArrayFilterEntries.js
  2. 8 5
      lib/pipeline/matcher/MatchExpressionParser.js

+ 1 - 1
lib/pipeline/matcher/ArrayFilterEntries.js

@@ -75,7 +75,7 @@ proto.addEquality = function addEquality( e ) {
  */
 proto.addRegex = function addRegex( expr ) { //  RegexMatchExpression* expr
 // File: expression_leaf.cpp lines: 389-391
-	this._regexes.append( expr );
+	this._regexes.push( expr );
 	return {'code':'OK'};
 };
 

+ 8 - 5
lib/pipeline/matcher/MatchExpressionParser.js

@@ -177,7 +177,7 @@ proto._parseAll = function _parseAll(name, element){
 		return {code:ErrorCodes.BAD_VALUE, description:"$all needs an array"};
 
 	var arr = element;
-	if ((arr[0] instanceof Object) && ("$elemMatch" == arr[0].keys()[0])) {
+	if ((arr[0] instanceof Object) && ("$elemMatch" == Object.keys(arr[0])[0])) {
 		// $all : [ { $elemMatch : {} } ... ]
 
 		var temp = new AllElemMatchOp();
@@ -218,7 +218,7 @@ proto._parseAll = function _parseAll(name, element){
 				return status;
 			myAnd.add(r);
 		}
-		else if ((e instanceof Object) && (e.keys()[0].getGtLtOp(-1) != -1)) {
+		else if ((e instanceof Object) && (typeof(Object.keys(e)[0] == 'string' && Object.keys(e)[0][0] == '$' ))) {
 			return {code:ErrorCodes.BAD_VALUE, description:"no $ expressions in $all"};
 		}
 		else {
@@ -237,6 +237,9 @@ proto._parseAll = function _parseAll(name, element){
 	return {code:ErrorCodes.OK, result:myAnd};
 };
 
+
+
+
 /**
  *
  * This documentation was automatically generated. Please update when you touch this function.
@@ -520,7 +523,7 @@ proto._parseSub = function _parseSub(name, sub, root){
 			root.add(status.result);
 	}
 
-	return {code:ErrorCodes.OK};
+	return {code:ErrorCodes.OK, result:root};
 };
 
 /**
@@ -656,10 +659,10 @@ proto._parseSubField = function _parseSubField(context, andSoFar, name, element)
 		return this._parseRegexDocument(name, context);
 
 	case '$elemMatch':
-		return this._parseElemMatch(name, element);
+		return this._parseElemMatch(name, currval);
 
 	case '$all':
-		return this._parseAll(name, element);
+		return this._parseAll(name, currval);
 
 	case '$geoWithin':
 	case '$geoIntersects':