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

chore: bump bson to match mongodb@5.9.0 exactly #13947

Merged
merged 1 commit into from Oct 9, 2023

Conversation

hasezoey
Copy link
Collaborator

@hasezoey hasezoey commented Oct 7, 2023

Summary

This PR bumps the bson dependency to match the installed mongodb's one, because otherwise some package managers (example yarn-v1) will install the old bson for mongoose and the new bson for mongodb driver, causing confusing test failures.

i noticed this while trying to install mongoose@7.6.0 for typegoose

context: https://unpkg.com/browse/mongodb@5.9.0/package.json#L28

Some test failure examples from typegoose
 FAIL  test/tests/ref.test.ts (5.488 s)
  ● check reference with buffer _id

    Expected "refFieldBuffer" to be "mongoose.Types.Buffer | Buffer"

      171 |   const { _id: refBufferId } = await RefTestModel.create({ refFieldBuffer: _id1 });
      172 |   const { refFieldBuffer } = await RefTestModel.findById(refBufferId).orFail().exec();
    > 173 |   assertion(isRefType(refFieldBuffer, Buffer), new Error('Expected "refFieldBuffer" to be "mongoose.Types.Buffer | Buffer"'));
          |                                                ^
      174 |   expect(_id1.equals(refFieldBuffer)).toEqual(true);
      175 |   const { _id: refArrayId } = await RefTestModel.create({ refArrayBuffer: [_id1, _id2] });
      176 |   const { refArrayBuffer } = await RefTestModel.findById(refArrayId).orFail().exec();

      at Object.<anonymous> (test/tests/ref.test.ts:173:48)

  ● check typeguards

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      220 |   expect(Array.isArray(foundPopulated.refArrayString)).toBe(true);
      221 |   expect(Array.isArray(foundPopulated.refArrayNumber)).toBe(true);
    > 222 |   expect(Array.isArray(foundPopulated.refArrayBuffer)).toBe(true);
          |                                                        ^
      223 |
      224 |   expect(foundPopulated.refArray!.length).toEqual(2);
      225 |   expect(foundPopulated.refArrayString!.length).toEqual(2);

      at Object.<anonymous> (test/tests/ref.test.ts:222:56)

  ● Reference-Maps should work and be populated

    expect(received).toBeInstanceOf(expected)

    Expected constructor: ObjectId
    Received constructor: ObjectId

      422 |
      423 |   found.mapped.forEach((v) => {
    > 424 |     expect(v).toBeInstanceOf(mongoose.Types.ObjectId);
          |               ^
      425 |   });
      426 |
      427 |   await found.populate('mapped.$*');

      at test/tests/ref.test.ts:424:15
          at MongooseMap.forEach (<anonymous>)
      at Object.<anonymous> (test/tests/ref.test.ts:423:16)

@hasezoey hasezoey added the dependencies Pull requests that update a dependency file label Oct 7, 2023
@hasezoey hasezoey added this to the 7.6.1 milestone Oct 7, 2023
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Good catch, thanks 👍

@vkarpov15 vkarpov15 merged commit 17c4ec3 into Automattic:master Oct 9, 2023
25 checks passed
@vkarpov15 vkarpov15 modified the milestones: 7.6.2, 7.6.1 Oct 9, 2023
@hasezoey hasezoey deleted the fixbson branch October 10, 2023 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants