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

remove obsolete code after upgrading to bson4 #11265

Merged
merged 1 commit into from
Jan 24, 2022
Merged

remove obsolete code after upgrading to bson4 #11265

merged 1 commit into from
Jan 24, 2022

Conversation

Uzlopak
Copy link
Collaborator

@Uzlopak Uzlopak commented Jan 24, 2022

There was a remark to remove a code block if we upgraded to bson4....

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.

Good catch, thanks 👍

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.

I took a closer look and confirmed the original issue no longer happens in Mongoose 6. Below script errors out with BSONTypeError: Unrecognized or invalid _bsontype: ObjectID22

'use strict';
  
const mongoose = require('mongoose');

mongoose.set('debug', true);
mongoose.set('strictQuery', false);

const { Schema } = mongoose;

run().catch(err => console.log(err));

async function run() {
  await mongoose.connect('mongodb://localhost:27017/test');

  await mongoose.connection.dropDatabase();

  const Test = mongoose.model('Test', Schema({ name: String }));

  await Test.create({ name: 'foo' });
  const res = await Test.findOne({ _bsontype: 'ObjectID22' });
  console.log(res);
}

@vkarpov15 vkarpov15 added this to the 6.1.8 milestone Jan 24, 2022
@vkarpov15 vkarpov15 merged commit d2497a1 into Automattic:master Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants