Permalink
Browse files

fixed; querying array type with single value does not cast to array

  • Loading branch information...
1 parent 8bac66f commit af2d81986e198f37ea59cbe0c3969f6b4044076f @aheckmann aheckmann committed May 19, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/mongoose/schema/array.js
@@ -143,7 +143,9 @@ SchemaArray.prototype.castForQuery = function ($conditional, val) {
return this.cast(val);
} else {
var proto = this.caster.prototype;
- return (proto.castForQuery || proto.cast).call(proto, val);
+ var method = proto.castForQuery || proto.cast;
+ if (method) return method.call(proto, val);
+ return val.toObject ? val.toObject() : val;
}
}
};

0 comments on commit af2d819

Please sign in to comment.