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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-6173): add rangeV2 feature flag toggle to Node.js bindings #809

Merged
merged 1 commit into from
May 21, 2024

Conversation

addaleax
Copy link
Contributor

See the ticket for motivation/why it would be convenient to have this earlier than the 'main' range V2 work 馃檪

@@ -514,6 +514,10 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info)
mongocrypt_setopt_bypass_query_analysis(_mongo_crypt.get());
}

if (options.Get("rangeV2").ToBoolean()) {
Copy link

Choose a reason for hiding this comment

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

What happens if rangeV2 is provided? Does it return a false? If it can return null an additional check would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I fully understand your question (probably a "not" missing somewhere?), but this is the equivalent of if (!!options.rangeV2) in JS 鈥撀爓e do a similar check right above this one for bypassQueryAnalysis. This type of check is fine for boolean values, including optional ones.

Copy link

Choose a reason for hiding this comment

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

Ah sorry, just found out that there was a not missing in my question. I was asking because we do options.get(flag).ToBoolean(), so if flag is not provided (is nullable in the ts definition) it would return null and fail with a NPE.

But if this is not the case, LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Null and Undefined are represented in Node-API as distinct values, not a C/C++ nullptr, so that's all good, and .ToBoolean() corresponds directly to the JS standard ToBoolean() operation 馃檪

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

It appears this option will just "pass through" for ClientEncryption but AutoEncryption would need to support it explicitly, will you be needing that?

@nbbeeken nbbeeken added the js-team-review Needs final review from Node.js team label May 20, 2024
@addaleax
Copy link
Contributor Author

@nbbeeken Yeah, not ideal for this that AutoEncrypter doesn't pass through unknown options, but this is something we can work around I'd say

@baileympearson baileympearson merged commit 0d22179 into mongodb:master May 21, 2024
27 of 50 checks passed
@baileympearson baileympearson deleted the node-6173-dev branch May 21, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js-team-review Needs final review from Node.js team
Projects
None yet
5 participants