Browse Source

Merge branch 'feature/mongo_2.6.5_matcher' into feature/mongo_2.6.5_matcher_Equality

* feature/mongo_2.6.5_matcher:
  EAGLESIX-2983: took out extra comment
  EEAGLESIX-2983: should be finished
  EAGLESIX-2983 partial port
Chris Sexton 11 years ago
parent
commit
f19b3baa94
1 changed files with 30 additions and 37 deletions
  1. 30 37
      lib/pipeline/matcher/ArrayMatchingMatchExpression.js

+ 30 - 37
lib/pipeline/matcher/ArrayMatchingMatchExpression.js

@@ -2,11 +2,9 @@
 
 var MatchExpression = require('./MatchExpression');
 
-// Autogenerated by cport.py on 2013-09-17 14:37
 var ArrayMatchingMatchExpression = module.exports = function ArrayMatchingMatchExpression(matchType){
 	base.call(this);
 	this._matchType = matchType;
-	// File: expression_array.h lines: 55-55
 	this._elementPath = new ElementPath();
 }, klass = ArrayMatchingMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
@@ -15,35 +13,8 @@ var errors = require("../../Errors.js"),
 	ErrorCodes = errors.ErrorCodes,
 	ElementPath = require('./ElementPath.js');
 
-// File: expression_array.h lines: 54-54
 proto._path = undefined;
 
-/**
- *
- * Check if the input element is equivalent to us
- * @method equivalent
- * @param
- *
- */
-proto.equivalent = function equivalent(other){
-	// File: expression_array.cpp lines: 63-79
-	if ( this._matchType != other._matchType)
-		return false;
-
-	var realOther = new ArrayMatchingMatchExpression(other);
-
-	if (this._path != realOther._path)
-		return false;
-
-	if (this.numChildren() != realOther.numChildren())
-		return false;
-
-	for (var i = 0; i < this.numChildren(); i++)
-		if (!this.getChild(i).equivalent(realOther.getChild(i)))
-			return false;
-	return true;
-};
-
 /**
  *
  * Initialize the input path as our element path
@@ -52,24 +23,21 @@ proto.equivalent = function equivalent(other){
  *
  */
 proto.initPath = function initPath(path){
-	// File: expression_array.cpp lines: 27-31
 	this._path = path;
 	var status = this._elementPath.init(this._path);
 	this._elementPath.setTraverseLeafArray(false);
 	return status;
 };
 
-
-
 /**
- *
+ * Deviation from mongo:
  * matches checks the input doc against the internal path to see if it is a match
  * @method matches
  * @param doc
  * @param details
  *
  */
-proto.matches = function matches(doc, details){
+ proto.matches = function matches(doc, details){
 	var self = this,
 		checker = function(element) {
 			// we got the whole path, now check it
@@ -99,12 +67,38 @@ proto.matches = function matches(doc, details){
  *
  */
 proto.matchesSingleElement = function matchesSingleElement(element){
-	// File: expression_array.cpp lines: 56-59
-	if (!(element instanceof Array))
+	if (!(element instanceof Array)){
 		return false;
+	}
+
 	return this.matchesArray(element, null);
 };
 
+/**
+ *
+ * Check if the input element is equivalent to us
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent(other){
+	if ( this._matchType != other._matchType)
+		return false;
+
+	var realOther = new ArrayMatchingMatchExpression(other);
+
+	if (this._path != realOther._path)
+		return false;
+
+	if (this.numChildren() != realOther.numChildren())
+		return false;
+
+	for (var i = 0; i < this.numChildren(); i++)
+		if (! (this.getChild(i).equivalent(realOther.getChild(i)) ) )
+			return false;
+	return true;
+};
+
 /**
  *
  * return the internal path
@@ -113,7 +107,6 @@ proto.matchesSingleElement = function matchesSingleElement(element){
  *
  */
 proto.path = function path(){
-	// File: expression_array.h lines: 52-51
 	return this._path;
 };