Skip to content

Mongoose v6 ObjectId deepEqual always true #1470

@spaiz

Description

@spaiz

Hi. We did pay attention in our tests that we cannot rely anymore on deep.equal when comparing objects with ObjectId() or even ObjectIds itself.

Env: node v16
Mongoose version: v5 vs v6

For the mongoose v5 tests work as expected.

{
  "dependencies": {
    "chai": "^4.3.6",
    "mocha": "^10.0.0",
    "mongoose": "^5.0.0"
  }
}

Screen Shot 2022-06-13 at 13 42 38

For mongoose v6 tests are passing when they should fail.

{
  "dependencies": {
    "chai": "^4.3.6",
    "mocha": "^10.0.0",
    "mongoose": "^6.0.0"
  }
}

Screen Shot 2022-06-13 at 13 41 55

I did prepare a repo for reproducing the issue: https://github.com/spaiz/objectId_tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions