Skip to content

Add cloneOf or clone method check in clone function to handle odd cloning situations #8299

@stieg

Description

@stieg

Do you want to request a feature or report a bug?
Feature
What is the current behavior?
clone function falls back to valueOf, leading to a situation where valueOf may not give you the cloned value you seek.

If the current behavior is a bug, please provide the steps to reproduce.
See mongoosejs/mongoose-double#7 for background on the issue that lead to this ticket.

What is the expected behavior?
valueOf should return a clone but this is not always possible. Thus we need a method that we can seek and call to generate a proper clone

Suggest adding a cloneOf or clone method (similar to what is done for SchemaTypes) so we can support this would be great.

Per private email conversation with @vkarpov15

At first glance I think it is better to make Mongoose clone handle doubles without relying on valueOf as a clone. Please open up an issue in the mongoose GitHub repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions