Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Fix #15108

Summary

#15108 is due to Mongoose change tracking not cleaning up modified paths underneath maps of subdocs when overwriting the entire subdoc. So doc.map.delete('subdoc') will still leave any subpaths of map.subdoc modified. This PR cleans up those paths.

Examples

@vkarpov15 vkarpov15 added this to the 8.9.2 milestone Dec 17, 2024
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@vkarpov15 vkarpov15 merged commit c393154 into master Dec 18, 2024
73 of 74 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-15108 branch December 18, 2024 14:19
@eldhoseelias
Copy link

node_modules/mongoose/types/types.d.ts:63:83 - error TS2344: Type 'Subdocument<InferId, any, T> & T' does not satisfy the constraint 'Subdocument<any, any, any>'.
The types returned by 'toJSON(...)' are incompatible between these types.
Type 'ObjectIdToString<FlattenMaps<Require_id>>' is not assignable to type '{ [x: string]: any; }'.
Type 'string | (FlattenMaps<Require_id> extends TreatAsPrimitives ? TreatAsPrimitives & FlattenMaps<Require_id> : FlattenMaps<...> extends Record<...> ? { [K in keyof FlattenMaps<...>]: F
lattenMaps<...>[K] extends ObjectId ? string : FlattenMaps<...>[K] extends DocumentArray<...> ? DocumentArray<...> : FlattenMaps<....' is not assignable to type '{ [x: string]: any; }'.
Type 'string' is not assignable to type '{ [x: string]: any; }'.

63 class DocumentArray<T, THydratedDocumentType extends Types.Subdocument = Types.Subdocument<InferId, any, T> & T> extends Types.Array {

Getting this error, anyone else faced this issue ?

@hasezoey
Copy link
Collaborator

@eldhoseelias likely not related to this PR, please search for or open a new issue / discussion. Also make sure you are on a new (or better latest) version of mongoose and typescript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants