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

Cannot populate using a dynamic ref inside an array of embedded discriminators #2182

Closed
2 of 4 tasks
kiyui opened this issue Jul 7, 2024 · 2 comments
Closed
2 of 4 tasks
Labels

Comments

@kiyui
Copy link

kiyui commented Jul 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Dynamic ref functions do not appear to work in @nestjs/mongoose. The ref function appears to be resolved at the time the schema is created, instead of at runtime.

This has been reported in the past here: #1847

This makes resolving the type for an array of embedded discriminators difficult in deeply nested or dynamic data structures where refPath may not be suitable.

Minimum reproduction code

https://github.com/kiyui/nestjs-mongoose-ref-issue-reproduction

Steps to reproduce

See the proof of work section in the reproduction repository.

Expected behavior

The schema should not resolve a ref function's return at the time of its creation, but allow them to be run at runtime so the behaviour is the same as that of Mongoose.

The reproduction repository shows the difference of behaviour between this module and plain Mongoose and asserts this with integration tests for the two.

Package version

10.0.6

mongoose version

8.4.4

NestJS version

10.3.10

Node.js version

18.20.3, 20.15.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kiyui kiyui added the bug label Jul 7, 2024
@smolinari
Copy link

smolinari commented Jul 9, 2024

Following.... 👀

@kiyui was asked to report his issue from the Discord forum.

Scott

@kamilmysliwiec
Copy link
Member

image

Fixed in 10.0.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants