Skip to content

Fix null handling in MethodCall parameter execution#3584

Merged
lvca merged 1 commit intoArcadeData:mainfrom
lekmaneb:claude/fix-transaction-null-error-Sky85
Mar 5, 2026
Merged

Fix null handling in MethodCall parameter execution#3584
lvca merged 1 commit intoArcadeData:mainfrom
lekmaneb:claude/fix-transaction-null-error-Sky85

Conversation

@lekmaneb
Copy link
Contributor

@lekmaneb lekmaneb commented Mar 5, 2026

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 is null by executing the expression with a null Identifiable argument, instead of throwing a CommandExecutionException.

Motivation

The existing code did not account for scenarios where targetObjects could be null when executing method call parameters. This caused failures in complex SQL queries that use LET clauses with string methods (like replace() and ILIKE()) in combination with UNIONALL() 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 using LET to define variables with chained string method calls (replace() operations) followed by UNIONALL() to combine results. The fix allows these expressions to evaluate correctly when intermediate values are null.

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

https://claude.ai/code/session_019HJhUeYmAHEL2wx5monhz9

…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
Copilot AI review requested due to automatic review settings March 5, 2026 14:47
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 MethodCall parsing logic. The change ensures that method parameters correctly process null values, preventing runtime exceptions in complex queries that combine LET clauses with string manipulation and UNIONALL operations.

Highlights

  • Null Pointer Handling: Implemented proper null handling in MethodCall.execute() to prevent CommandExecutionException when method parameters evaluate to null.
  • SQL Query Robustness: Ensured that complex SQL queries involving LET clauses, string methods (replace, ILIKE), and UNIONALL operations correctly propagate null values during method parameter evaluation.
  • Test Coverage: Added a new test case, queryUnionAllWithLetAndStringMethods, to specifically validate the fix for the identified scenario.

🧠 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
  • engine/src/main/java/com/arcadedb/query/sql/parser/MethodCall.java
    • Added a conditional check to handle null values for val during method parameter execution, ensuring expr.execute((Identifiable) null, context) is called instead of throwing an exception.
  • engine/src/test/java/com/arcadedb/function/sql/sql/SQLFunctionsTest.java
    • Introduced a new test method queryUnionAllWithLetAndStringMethods to reproduce and verify the fix for queries using LET with chained string methods and UNIONALL.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@lvca lvca requested review from lvca and removed request for Copilot March 5, 2026 14:50
@lvca lvca added this to the 26.4.1 milestone Mar 5, 2026
@lvca
Copy link
Contributor

lvca commented Mar 5, 2026

Great, thanks! Merging it now.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +626 to +633
"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)",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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)",

@lvca lvca merged commit 0db7907 into ArcadeData:main Mar 5, 2026
9 of 11 checks passed
@mergify
Copy link
Contributor

mergify bot commented Mar 5, 2026

🧪 CI Insights

Here's what we observed from your CI run for 185c73d.

🟢 All jobs passed!

But CI Insights is watching 👀

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.65%. Comparing base (64eb57e) to head (185c73d).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants