Explorar el Código

Refs #3359. Updated arrayfilter somewhat.

Spencer Rathbun hace 12 años
padre
commit
f7a1095b4d

+ 17 - 15
lib/pipeline/matcher/ArrayFilterEntries.js

@@ -6,6 +6,8 @@ var Value = require('../Value');
 var ArrayFilterEntries = module.exports = function ArrayFilterEntries(){
 	this._hasNull = false;
 	this._hasEmptyArray = false;
+	this._equalities = [];
+	this._regexes = [];
 }, klass = ArrayFilterEntries, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 
@@ -42,8 +44,8 @@ proto._regexes = undefined;
  */
 proto.addEquality = function addEquality( e ) {
 	//File expression_leaf.cpp lines 369-387
-	
-	if(Object.keys(e)[0][0] === '$'){
+
+	if(e instanceof Object && Object.keys(e)[0][0] === '$'){
 		return {'code':'BAD_VALUE', 'desc':'cannot next $ under $in'};
 	}
 
@@ -58,14 +60,14 @@ proto.addEquality = function addEquality( e ) {
 	if (e instanceof Array && e.length === 0) {
 		this._hasEmptyArray = true;
 	}
-	
-	this._equalities.insert( e );
+
+	this._equalities.push( e );
 	return {'code':'OK'};
 };
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method addRegex
  * @param
@@ -79,7 +81,7 @@ proto.addRegex = function addRegex( expr ) { //  RegexMatchExpression* expr
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method contains
  * @param
@@ -97,7 +99,7 @@ proto.contains = function contains( elem ) { //  const BSONElement& elem
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method copyTo
  * @param
@@ -113,7 +115,7 @@ proto.copyTo = function copyTo( toFillIn ) { //  ArrayFilterEntries& toFillIn
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method equalities
  * @param
@@ -126,7 +128,7 @@ proto.equalities = function equalities( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method equivalent
  * @param
@@ -147,7 +149,7 @@ proto.equivalent = function equivalent( other ) { //  const ArrayFilterEntries&
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method hasEmptyArray
  * @param
@@ -160,7 +162,7 @@ proto.hasEmptyArray = function hasEmptyArray( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method hasNull
  * @param
@@ -173,7 +175,7 @@ proto.hasNull = function hasNull( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method numRegexes
  * @param
@@ -186,7 +188,7 @@ proto.numRegexes = function numRegexes( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method regex
  * @param
@@ -199,7 +201,7 @@ proto.regex = function regex( idx ) { //  int idx
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method singleNull
  * @param
@@ -212,7 +214,7 @@ proto.singleNull = function singleNull( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method size
  * @param

+ 15 - 10
lib/pipeline/matcher/InMatchExpression.js

@@ -5,8 +5,13 @@ var LeafMatchExpression = require('./LeafMatchExpression');
 // Autogenerated by cport.py on 2013-09-17 14:37
 var InMatchExpression = module.exports = function InMatchExpression(){
 	this._matchType = 'MATCH_IN';
+	this._arrayEntries = new ArrayFilterEntries();
 }, klass = InMatchExpression, base =  LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
+// DEPENDENCIES
+var errors = require("../../Errors.js"),
+	ErrorCodes = errors.ErrorCodes,
+	ArrayFilterEntries = require("./ArrayFilterEntries.js");
 
 // File: expression_leaf.h lines: 294-294
 //         ArrayFilterEntries _arrayEntries;
@@ -14,7 +19,7 @@ var InMatchExpression = module.exports = function InMatchExpression(){
 proto._arrayEntries = undefined;
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method _matchesRealElement
  * @param
@@ -36,7 +41,7 @@ proto._matchesRealElement = function _matchesRealElement( e ) { //  const BSONEl
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method copyTo
  * @param
@@ -50,7 +55,7 @@ proto.copyTo = function copyTo( toFillIn ) { //  InMatchExpression* toFillIn
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method debugString
  * @param
@@ -63,7 +68,7 @@ proto.debugString = function debugString( level ) { //  StringBuilder& debug, in
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method equivalent
  * @param
@@ -79,7 +84,7 @@ proto.equivalent = function equivalent( other ) { //  const MatchExpression* oth
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method getArrayFilterEntries
  * @param
@@ -92,7 +97,7 @@ proto.getArrayFilterEntries = function getArrayFilterEntries( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method getData
  * @param
@@ -105,7 +110,7 @@ proto.getData = function getData( /*  */ ){
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method init
  * @param
@@ -118,7 +123,7 @@ proto.init = function init( path ) { //  const StringData& path
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method matchesSingleElement
  * @param
@@ -138,14 +143,14 @@ proto.matchesSingleElement = function matchesSingleElement( e ) { //  const BSON
 				return true;
 			}
 		}
-		
+
 	}
 	return false;
 };
 
 
 /**
- * 
+ *
  * This documentation was automatically generated. Please update when you touch this function.
  * @method shallowClone
  * @param

+ 3 - 4
lib/pipeline/matcher/MatchExpressionParser.js

@@ -115,7 +115,7 @@ proto._parse = function _parse(obj, topLevel){
 				if ( !topLevel )
 					return StatusWithMatchExpression( ErrorCodes::BadValue, "$where has to be at the top level" );
 				*/
-			
+
 				return {'code':'FAILED_TO_PARSE', 'desc':'Where unimplimented.'};
 
 				status = this.expressionParserWhereCallback(element);
@@ -503,7 +503,7 @@ proto._parseRegexElement = function _parseRegexElement(name, element){
  */
 proto._parseSub = function _parseSub(name, sub, root){
 	// File: expression_parser.cpp lines: 322-337
-	var subkeys = Object.keys(sub), 
+	var subkeys = Object.keys(sub),
 		currname, currval;
 
 	for (var i = 0; i < subkeys.length; i++) {
@@ -668,9 +668,8 @@ proto._parseSubField = function _parseSubField(context, andSoFar, name, element)
 		return this.expressionParserGeoCallback(name, x, context);
 
 	} // end switch
-	debugger;
 
-	
+
 	return {code:ErrorCodes.BadValue, description:"not handled: " + element};
 };