Переглянути джерело

EAGLESIX-2653 updated SizeMatchExpression to mongo 2.6.5

Phil Murray 11 роки тому
батько
коміт
16bb7eb109
1 змінених файлів з 14 додано та 17 видалено
  1. 14 17
      lib/pipeline/matcher/SizeMatchExpression.js

+ 14 - 17
lib/pipeline/matcher/SizeMatchExpression.js

@@ -1,14 +1,10 @@
 "use strict";
 var ArrayMatchingMatchExpression = require('./ArrayMatchingMatchExpression');
 
-
-// Autogenerated by cport.py on 2013-09-17 14:37
 var SizeMatchExpression = module.exports = function SizeMatchExpression(){
-	base.call(this);
-	this._matchType = 'SIZE';
+	base.call(this, 'SIZE');
 }, klass = SizeMatchExpression, base =  ArrayMatchingMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
-// File: expression_array.h lines: 131-131
 proto._size = undefined;
 
 /**
@@ -19,8 +15,13 @@ proto._size = undefined;
  *
  */
 proto.debugString = function debugString(level) {
-	// File: expression_array.cpp lines: 259-261
-	return this._debugAddSpace( level ) + this.path() + " $size : " + this._size.toString() + "\n";
+	var debug = this._debugAddSpace( level ) + this.path() + " $size : " + this._size.toString() + "\n";
+	
+	var td = this.tagData();
+	if (td !== null){
+		debug += " " + td.debugString();
+	}
+	return debug;
 };
 
 /**
@@ -31,11 +32,10 @@ proto.debugString = function debugString(level) {
  *
  */
 proto.equivalent = function equivalent(other) {
-	// File: expression_array.cpp lines: 264-269
-	if(other._matchType != 'SIZE') {
+	if(other.matchType() !== this.matchType()) {
 		return false;
 	}
-	return this._size == other._size && this._path == other._path;
+	return this._size === other._size && this.path() === other.path();
 };
 
 /**
@@ -45,7 +45,6 @@ proto.equivalent = function equivalent(other) {
  *
  */
 proto.getData = function getData(){
-	// File: expression_array.h lines: 128-127
 	return this._size;
 };
 
@@ -58,9 +57,6 @@ proto.getData = function getData(){
  *
  */
 proto.init = function init(path,size) {
-	// File: expression_array.cpp lines: 248-250
-	if(size === null)
-		return {code:'BAD_VALUE', 'description':'Cannot assign null to size'};
 	this._size = size;
 	return this.initPath(path);
 };
@@ -74,11 +70,10 @@ proto.init = function init(path,size) {
  *
  */
 proto.matchesArray = function matchesArray(anArray, details) {
-	// File: expression_array.cpp lines: 253-256
 	if(this._size < 0) {
 		return false;
 	}
-	return anArray.length == this._size;
+	return anArray.length === this._size;
 };
 
 /**
@@ -91,6 +86,8 @@ proto.shallowClone = function shallowClone(){
 	// File: expression_array.h lines: 116-119
 	var e = new SizeMatchExpression();
 	e.init(this.path(),this._size);
+	if ( this.getTag() ) {
+		e.setTag(this.getTag().clone());
+	}
 	return e;
 };
-