Skip to content

Commit

Permalink
fix: fix tests re: #8062
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 18, 2019
1 parent aa5e737 commit d0fba5e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/schema/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ SchemaArray.prototype.cast = function(value, doc, init) {
value = new MongooseArray(value, this.path, doc);
}

if (this.caster && this.casterConstructor !== Mixed && doc != null && doc.$__ != null && !doc.populated(this.path)) {
const isPopulated = doc != null && doc.$__ != null && doc.populated(this.path);
if (isPopulated) {
return value;
}

if (this.caster && this.casterConstructor !== Mixed) {
try {
for (i = 0, l = value.length; i < l; i++) {
value[i] = this.caster.cast(value[i], doc, init);
Expand Down

0 comments on commit d0fba5e

Please sign in to comment.