fix: return NULL from scalar functions given invalid argument types - #114
Merged
j6k4m8 merged 1 commit intoAug 4, 2026
Merged
Conversation
toLower/toUpper/trim called the underlying str method directly, and size called len(), so a non-string argument such as toLower(123), trim(true) or size(123) escaped as a raw AttributeError/TypeError instead of evaluating to NULL. ScalarFunctionExpression.evaluate now catches AttributeError/TypeError from the wrapped function and returns None, matching the way ArithmeticExpression already degrades to NULL on incompatible operands. Adds a parametrized regression test in test_scalar_functions.py covering toLower, toUpper, trim and size with invalid argument types.
j6k4m8
self-requested a review
August 4, 2026 17:54
j6k4m8
approved these changes
Aug 4, 2026
Member
|
Great fix, thank you @Sanjays2402 ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #107
toLower/toUpper/trimcalled the underlyingstrmethod directly andsizecalledlen(), so a non-string argument (toLower(123),trim(true),size(123)) escaped as a rawAttributeError/TypeErrorinstead of evaluating to NULL.ScalarFunctionExpression.evaluatenow catches those and returnsNone, mirroring howArithmeticExpressionalready degrades to NULL on incompatible operands.Added a parametrized regression test in
grandcypher/test_scalar_functions.py; it fails on all four cases without the fix and passes with it. Full suite: 504 passed, 2 xfailed.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.