Sfoglia il codice sorgente

Refs #2378: fix bug with null in ObjectExpression

Kyle P Davis 12 anni fa
parent
commit
1970f5f9f4
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      lib/pipeline/expressions/ObjectExpression.js

+ 3 - 3
lib/pipeline/expressions/ObjectExpression.js

@@ -142,7 +142,7 @@ var ObjectExpression = module.exports = (function(){
 			}
 
 			// Check if this expression replaces the whole field
-			if ((fieldValue.constructor !== Object && fieldValue.constructor !== Array) || !(expr instanceof ObjectExpression)) {
+			if (!(fieldValue instanceof Object) || (fieldValue.constructor !== Object && fieldValue.constructor !== Array) || !(expr instanceof ObjectExpression)) {
 				var pValue = expr.evaluate(rootDoc);
 
 				// don't add field if nothing was found in the subobject
@@ -155,9 +155,9 @@ var ObjectExpression = module.exports = (function(){
 			}
 
 			// Check on the type of the input value.  If it's an object, just walk down into that recursively, and add it to the result.
-			if (fieldValue.constructor === Object) {
+			if (fieldValue instanceof Object && fieldValue.constructor === Object) {
 				pResult[fieldName] = expr.addToDocument({}, fieldValue, rootDoc);	//TODO: pretty sure this is broken;
-			} else if (fieldValue.constructor == Array) {
+			} else if (fieldValue instanceof Object && fieldValue.constructor === Array) {
 				// If it's an array, we have to do the same thing, but to each array element.  Then, add the array of results to the current document.
 				var result = [];
 				for(var fvi = 0, fvl = fieldValue.length; fvi < fvl; fvi++){