Skip to content

feat(shell-bson-parser): add support for binary constructors createFromHexString and createFromBase64 #507

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
Feb 10, 2025

Conversation

luca-nardelli
Copy link
Contributor

Description

These changes allow users of MongoDB Compass to use Binary.createFromHexString and Binary.createFromBase64 in queries
image

Without these, the only way to query for binary fields would be to use BinData, which forces base64 representation. By just updating the packages, Compass will be able to handle these queries (previously, the validation step would fail and there would be no way to run these queries except for in the shell)

Open Questions

The biggest change here is that I had to enable allowMethods for _parseFilter in packages/query-parser/src/index.ts, but all tests seem to pass with the option set to true.

Checklist

Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, this LGTM!

@@ -120,6 +120,32 @@ describe('mongodb-query-parser', function () {
);
});

// https://www.mongodb.com/docs/manual/reference/method/Binary.createFromHexString/
it('should support Binary.createFromHexString', function () {
assert.deepEqual(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessarily something for this PR, but just a reminder to myself that we'll probably want to turn all of these into assert.deepStrictEqual afterwards 😭

@addaleax addaleax changed the title feat(shell-bson-parser): Add support for binary constructors createFromHexString and createFromBase64 feat(shell-bson-parser): add support for binary constructors createFromHexString and createFromBase64 Feb 10, 2025
@addaleax addaleax merged commit c490159 into mongodb-js:main Feb 10, 2025
6 checks passed
addaleax added a commit to mongodb-js/compass that referenced this pull request Feb 10, 2025
addaleax added a commit to mongodb-js/compass that referenced this pull request Feb 10, 2025
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.

2 participants