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

fix(gatsby-source-mongodb): work with _id types that are not ObjectIds #16331

Conversation

senorpedro
Copy link
Contributor

Description

Using mongodb, it is possible to use arbritary values (e.g. strings) as _id.
In that case the current implementation will throw
"TypeError: _id.toHexString is not a function"
This fix will prevent this, at least for string _ids.

@senorpedro senorpedro requested a review from a team as a code owner August 2, 2019 13:53
@senorpedro senorpedro force-pushed the bugfix/handle_custom_mongodb_id_types branch 2 times, most recently from 11cb860 to cc2b92a Compare August 2, 2019 15:58
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

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

I hate that Mongo supports arbitrary data types for _id but this seems like a fair change to handle edge cases like those.

Thank you for patching this @senorpedro 👍

@sidharthachatterjee sidharthachatterjee added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Aug 8, 2019
Using mongodb, it is possible to use arbritary values (e.g. strings) as _id.
In that case the current implementation will throw
"TypeError: _id.toHexString is not a function"
This fix will prevent this, at least for string _ids.
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

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

👍

@sidharthachatterjee sidharthachatterjee merged commit d226fd5 into gatsbyjs:master Aug 8, 2019
@gatsbot
Copy link

gatsbot bot commented Aug 8, 2019

Holy buckets, @senorpedro — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@senorpedro
Copy link
Contributor Author

I hate that Mongo supports arbitrary data types for _id but this seems like a fair change to handle edge cases like those.

Thank you for patching this @senorpedro 👍

You're welcome! Thanks for creating such awesome software! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants