Fix null handling in MethodCall parameter execution#3584
Fix null handling in MethodCall parameter execution#3584lvca merged 1 commit intoArcadeData:mainfrom
Conversation
…T clauses When executing SQL queries with LET variables containing UNIONALL and string method calls (e.g., .replace()), $current can be null while targetObjects is a non-Identifiable/non-Result value. Added an else-if branch to handle null val by passing null Identifiable to Expression.execute(), preventing the CommandExecutionException. https://claude.ai/code/session_019HJhUeYmAHEL2wx5monhz9
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of SQL query execution by addressing a critical null pointer handling issue within the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Great, thanks! Merging it now. |
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a null pointer issue in MethodCall.execute() by adding a check for a null $current variable. The change is minimal and effective. A new test case is added to cover the failing scenario, which is great. I've suggested a small improvement to the test query to enhance its readability and maintainability by reducing code duplication.
| "SELECT expand($c) LET " | ||
| + "$a = (SELECT identity, @rid as id FROM NER " | ||
| + "WHERE identity.replace('\\n', ' ').replace('\\t', ' ').replace(' ', ' ') ILIKE ('%' + :keyWordIdentifier_0 + '%') " | ||
| + "AND identity.replace('\\n', ' ').replace('\\t', ' ').replace(' ', ' ') ILIKE ('%' + :keyWordIdentifier_1 + '%')), " | ||
| + "$b = (SELECT identity, @rid as id FROM THEME " | ||
| + "WHERE identity.replace('\\n', ' ').replace('\\t', ' ').replace(' ', ' ') ILIKE ('%' + :keyWordIdentifier_0 + '%') " | ||
| + "AND identity.replace('\\n', ' ').replace('\\t', ' ').replace(' ', ' ') ILIKE ('%' + :keyWordIdentifier_1 + '%')), " | ||
| + "$c = UNIONALL($a, $b)", |
There was a problem hiding this comment.
The SQL query in this test has a significant amount of duplicated code. The expression identity.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ') is repeated four times. To improve readability and maintainability, you can use a LET clause within the subqueries to define this expression as a variable.
"SELECT expand($c) LET "
+ "$a = (SELECT identity, @rid as id FROM NER "
+ " LET $clean_identity = identity.replace('\\n', ' ').replace('\\t', ' ').replace(' ', ' ') "
+ " WHERE $clean_identity ILIKE ('%' + :keyWordIdentifier_0 + '%') "
+ " AND $clean_identity ILIKE ('%' + :keyWordIdentifier_1 + '%')), "
+ "$b = (SELECT identity, @rid as id FROM THEME "
+ " LET $clean_identity = identity.replace('\\n', ' ').replace('\\t', ' ').replace(' ', ' ') "
+ " WHERE $clean_identity ILIKE ('%' + :keyWordIdentifier_0 + '%') "
+ " AND $clean_identity ILIKE ('%' + :keyWordIdentifier_1 + '%')), "
+ "$c = UNIONALL($a, $b)",
🧪 CI InsightsHere's what we observed from your CI run for 185c73d. 🟢 All jobs passed!But CI Insights is watching 👀 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3584 +/- ##
==========================================
+ Coverage 65.02% 65.65% +0.63%
==========================================
Files 1514 1514
Lines 103659 103660 +1
Branches 21454 21454
==========================================
+ Hits 67403 68058 +655
+ Misses 27075 26362 -713
- Partials 9181 9240 +59 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What does this PR do?
This PR fixes a null pointer handling issue in the
MethodCall.execute()method. When executing method parameters, the code now properly handles the case where the target object isnullby executing the expression with anullIdentifiable argument, instead of throwing aCommandExecutionException.Motivation
The existing code did not account for scenarios where
targetObjectscould benullwhen executing method call parameters. This caused failures in complex SQL queries that useLETclauses with string methods (likereplace()andILIKE()) in combination withUNIONALL()operations. The fix ensures that null values are properly propagated through method parameter evaluation.Related issues
N/A
Additional Notes
The test case
queryUnionAllWithLetAndStringMethods()demonstrates the scenario that was failing: a query usingLETto define variables with chained string method calls (replace()operations) followed byUNIONALL()to combine results. The fix allows these expressions to evaluate correctly when intermediate values are null.Checklist
mvn clean packagecommandhttps://claude.ai/code/session_019HJhUeYmAHEL2wx5monhz9