Skip to content

Commit

Permalink
fix(update): handle casting map paths when map is underneath a single…
Browse files Browse the repository at this point in the history
… nested subdoc

Fix #9298
  • Loading branch information
vkarpov15 committed Aug 28, 2020
1 parent 6e36991 commit 63a34be
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/schema.js
Expand Up @@ -2053,29 +2053,37 @@ Schema.prototype._getSchema = function(path) {
// doesn't work for that.
// If there is no foundschema.schema we are dealing with
// a path like array.$
if (p !== parts.length && foundschema.schema) {
let ret;
if (parts[p] === '$' || isArrayFilter(parts[p])) {
if (p + 1 === parts.length) {
// comments.$
return foundschema;
if (p !== parts.length) {
if (foundschema.schema) {
let ret;
if (parts[p] === '$' || isArrayFilter(parts[p])) {
if (p + 1 === parts.length) {
// comments.$
return foundschema;
}
// comments.$.comments.$.title
ret = search(parts.slice(p + 1), foundschema.schema);
if (ret) {
ret.$isUnderneathDocArray = ret.$isUnderneathDocArray ||
!foundschema.schema.$isSingleNested;
}
return ret;
}
// comments.$.comments.$.title
ret = search(parts.slice(p + 1), foundschema.schema);
// this is the last path of the selector
ret = search(parts.slice(p), foundschema.schema);
if (ret) {
ret.$isUnderneathDocArray = ret.$isUnderneathDocArray ||
!foundschema.schema.$isSingleNested;
}
return ret;
}
// this is the last path of the selector
ret = search(parts.slice(p), foundschema.schema);
if (ret) {
ret.$isUnderneathDocArray = ret.$isUnderneathDocArray ||
!foundschema.schema.$isSingleNested;
}
return ret;
}
} else if (foundschema.$isSchemaMap) {
if (p + 1 >= parts.length) {
return foundschema.$__schemaType;
}
const ret = search(parts.slice(p + 1), foundschema.$__schemaType.schema);
return ret;
}

foundschema.$fullPath = resultPath.join('.');
Expand Down

0 comments on commit 63a34be

Please sign in to comment.