Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access nested path schemas using Schema#path #10164

Closed
mcat95 opened this issue Apr 21, 2021 · 1 comment
Closed

Unable to access nested path schemas using Schema#path #10164

mcat95 opened this issue Apr 21, 2021 · 1 comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
Milestone

Comments

@mcat95
Copy link

mcat95 commented Apr 21, 2021

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When you try to access the properies of a schema path of a deeply nested schema, it returns undefined.

By bisecting the code between our previous good version (5.10.7) and the current one (5.12.5) we found that the bug was introduced by 037eb14

If the current behavior is a bug, please provide the steps to reproduce.
https://gist.github.com/mcat95/f6dba9774a4c8e02edf169e1f2c12149

What is the expected behavior?

It should return the object with the schema node descriptor:

SchemaBoolean {
  path: 'field3',
  ...
}

Instead, it's returning undefined

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

Node.js: 14.12.0
Mongoose: 5.12.5
Mongodb: Not relevant, since it's not necessary to connect to a server to reproduce the issue

@IslandRhythms
Copy link
Collaborator

const mongoose = require('mongoose');

const schema = mongoose.Schema({
  field1: [mongoose.Schema({
    field2: mongoose.Schema({
      field3: Boolean,
    }),
  })],
});

console.log(schema.path('field1.field2.field3'));

@IslandRhythms IslandRhythms added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue labels Apr 21, 2021
@vkarpov15 vkarpov15 added this to the 5.12.7 milestone Apr 27, 2021
vkarpov15 added a commit that referenced this issue Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
Projects
None yet
Development

No branches or pull requests

3 participants