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

Nested Discriminators in multi-dimensonal arrays use name instead of value #13201

Closed
2 tasks done
hasezoey opened this issue Mar 22, 2023 · 3 comments · Fixed by #13202
Closed
2 tasks done

Nested Discriminators in multi-dimensonal arrays use name instead of value #13201

hasezoey opened this issue Mar 22, 2023 · 3 comments · Fixed by #13202
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@hasezoey
Copy link
Collaborator

hasezoey commented Mar 22, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.10.1

Node.js version

19.6.0

MongoDB server version

5.0

Typescript version (if applicable)

4.9.5

Description

I have noticed that nested discriminator multi-dimensonal arrays use the name of the discriminator instead of value, like in non-array or one-dimensonal arrays

function parameter reference: path.discriminator(name, schema, value)

Steps to Reproduce

Reproduction Repository & branch: https://github.com/typegoose/typegoose-testing/tree/mongooseNestedDiscriminatorNaming

also includes commented-out code for a one-dimensonal array

Expected Behavior

to use value like for one-dimensonal arrays and non-arrays


also tested mongoose 7.0.2, with same behavior

@hasezoey hasezoey added the has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue label Mar 22, 2023
@hasezoey
Copy link
Collaborator Author

i think i found the reason:
SchemaArray does not pass-on options (also known as value) to the lower array, like DocumentArrayPath

SchemaArray.prototype.discriminator = function(name, schema) {

DocumentArrayPath.prototype.discriminator = function(name, schema, options) {

@hasezoey hasezoey linked a pull request Mar 22, 2023 that will close this issue
@vkarpov15 vkarpov15 added this to the 6.10.5 milestone Mar 23, 2023
@vkarpov15 vkarpov15 added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue labels Mar 23, 2023
@vkarpov15 vkarpov15 reopened this Mar 23, 2023
@hasezoey
Copy link
Collaborator Author

@vkarpov15 why was this closed again? from what i can tell the master branch (by extension 7.x) does not yet have the changes done for 6.x for this fix

(also from what i can tell branch 7.1 also does not have a merge of 6.x yet)

@vkarpov15
Copy link
Collaborator

@hasezoey I just merged 6.x into main, thanks for pointing this out 👍

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants