|
|
@@ -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++){
|