BSON Int32 Increment Support#10132
Conversation
… local evaluation bug
|
There was a problem hiding this comment.
Code Review
This pull request adds support for local evaluation of numeric transforms on BSON Int32Value and Decimal128Value types. While the changes successfully introduce these types to the local evaluation pipeline, the review highlights critical issues with type promotion. Specifically, if the operand is an Int32Value, it is not correctly treated as an integer type, causing incorrect promotion to Decimal128Value. Additionally, the code should ensure proper Decimal128Value promotion if either operand is a Decimal128Value. Finally, replacing unsafe non-null assertions with optional chaining in asNumber is recommended to prevent potential runtime crashes.
… numeric transform local evaluation
6287d97 to
5aa1e84
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for local evaluation of numeric transform and increment operations on BSON types, specifically Int32Value and Decimal128Value. It updates the transform operations to handle mixed-type math, type promotion, and representation using reserved map keys, and includes comprehensive unit tests to verify these behaviors. There are no review comments, so I have no feedback to provide.
Fixes local evaluation of numeric transforms (
increment,min,max) when mixing BSON (Int32Value/Decimal128Value) and standard JS numbers.Bug: BSON operands failed constructor checks ("transform requires a NumberValue"), and BSON base values were unrecognized by
isNumber()(returning the operand directly).Fix: Unpacked BSON values in
asNumber(), updatedisNumber()to support BSON maps, and implemented precision promotion.Before:
After:
Note: While the SDK doesn't support BSON types as arguments to
increment(), the local evaluation layer still supports it, for the sake of robustness.