Skip to content

Fix cache for string IDs that have exactly 12 bytes #62

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

Merged
merged 1 commit into from
May 27, 2021

Conversation

jonasmeier1212
Copy link

  • The method isValid from MongoDB just checks if a string has 12 bytes. But you could have a string ID which length=12 which would be unintentionally converted to an ObjectID which in returns causes an invalid cache miss.

Closes #60

@lorensr Could you write a test case for this or give me a hint how to do it? I wasn't able to construct a failing one for this case with your setup...

* The method `isValid` from MongoDB just checks if a string has 12 bytes. But you could have a string ID which length=12 which would be unintentionally converted to an ObjectID which in returns causes an invalid cache miss.
@lorensr lorensr merged commit 0f1629e into GraphQLGuide:master May 27, 2021
@lorensr
Copy link
Member

lorensr commented May 27, 2021

Thanks! new ObjectId('5cf82e14a220a607eb64a7d4') === '5cf82e14a220a607eb64a7d4' is false, and it's a valid ObjectId. I changed the code to match the article you linked and added a test: e50b67c

Released in 0.4.1

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.

findManyByIds is broken in last version
2 participants