Re-occurrence of embedded discriminator not calling pre('validate')
(discriminator defined without path
)
#14961
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
8.7.1
Node.js version
20
MongoDB server version
6.9.0
Typescript version (if applicable)
No response
Description
Thanks guys for all your hard work on Mongoose!
I'm upgrading from 7.6.5 to 8.7.1.
I'm having an issue where pre('validate') isn't called on a discriminated schema embedded in an array.
Many of our discriminators are defined at the root level, not under a subkey.
This test passes in 7.6.5:
But it fails in 8.7.1.
Note that this works if you define
But we don't have this luxury, as we're not using subkeys.
Original test shamelessly stolen from here:
#5706 (comment)
With changes:
trackedSchema
moved to the end as recommended in the docs (i.e. definepre
hooks on schema before including in parent)path
key and define discriminators directly oneventSchema
Steps to Reproduce
vs
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: