#3571 fix: handle @in and @out internal properties on function results#3577
#3571 fix: handle @in and @out internal properties on function results#3577
Conversation
SuffixIdentifier.execute(Identifiable) only handled @Rid, @type, and @cat as special record attributes but fell through to document.get() for @in and @out, which returned null since these are not stored as regular document properties. Added explicit handling to call Edge.getIn()/getOut(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 addresses a critical bug in the SQL parser where internal 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
Activity
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
|
🧪 CI InsightsHere's what we observed from your CI run for 198f72d. 🟢 All jobs passed!But CI Insights is watching 👀 |
Code ReviewOverall: Good, minimal fix for a real bug. The implementation is correct and well-tested. A few minor observations below. Fix in SuffixIdentifier.javaThe approach is correct. The execute(Identifiable, CommandContext) method was missing explicit handling for @in/@out, causing them to fall through to document.get(recordAttribute.name) which returns null (these are not stored as regular document properties). The new code is consistent with how RecordAttribute.evaluate(Result, CommandContext) already handles @in/@out, and uses the Java 21 pattern-matching syntax (instanceof Edge edge) consistently with the rest of the codebase. One subtle correctness point worth acknowledging: when @in/@out is accessed on a non-Edge Identifiable (e.g. a vertex or document), the new conditions don't match and the code falls through to ((Document) currentRecord.getRecord()).get(recordAttribute.name), which correctly returns null. This is the right behavior and is not a regression. TestsThe test coverage is good - each combination of function access pattern and internal property is exercised. A couple of minor gaps:
SummaryThe fix is correct, appropriately scoped, and the tests cover the primary use cases. The items above are minor suggestions for completeness, not blockers. |
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where internal properties @in and @out were not correctly handled on function results. The change in SuffixIdentifier.java adds explicit handling for these properties, which seems correct. The accompanying tests are comprehensive and verify the fix. I've provided a few suggestions to improve code consistency in the implementation and to enhance the new tests by reducing code duplication and improving efficiency.
| } else if (IN_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge) | ||
| return edge.getIn(); | ||
| else if (OUT_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge) | ||
| return edge.getOut(); |
There was a problem hiding this comment.
For consistency with the preceding if-else blocks that use the doc variable, you could use doc here as well instead of calling currentRecord.getRecord() again.
| } else if (IN_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge) | |
| return edge.getIn(); | |
| else if (OUT_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge) | |
| return edge.getOut(); | |
| } else if (IN_PROPERTY.equalsIgnoreCase(recordAttribute.name) && doc instanceof Edge edge) | |
| return edge.getIn(); | |
| else if (OUT_PROPERTY.equalsIgnoreCase(recordAttribute.name) && doc instanceof Edge edge) | |
| return edge.getOut(); | |
| database.command("sql", "CREATE VERTEX TYPE V3571g IF NOT EXISTS"); | ||
| database.command("sql", "CREATE EDGE TYPE E3571g IF NOT EXISTS"); | ||
| database.command("sql", "DELETE FROM V3571g"); | ||
| database.command("sql", "INSERT INTO V3571g"); | ||
| database.command("sql", "CREATE EDGE E3571g FROM (SELECT FROM V3571g) TO (SELECT FROM V3571g)"); |
There was a problem hiding this comment.
The setup logic for creating vertex and edge types is duplicated across multiple test methods (testInEIndexedAtIn, testInEIndexedAtOut, testInEAtInList, testMapWithAtOut). To improve maintainability and reduce code duplication, consider extracting this logic into a private helper method.
For example:
private void setupGraph(final String vertexType, final String edgeType) {
database.command("sql", "CREATE VERTEX TYPE " + vertexType + " IF NOT EXISTS");
database.command("sql", "CREATE EDGE TYPE " + edgeType + " IF NOT EXISTS");
database.command("sql", "DELETE FROM " + vertexType);
database.command("sql", "INSERT INTO " + vertexType);
database.command("sql", "CREATE EDGE " + edgeType + " FROM (SELECT FROM " + vertexType + ") TO (SELECT FROM " + vertexType + ")");
}Then you can call setupGraph("V3571g", "E3571g"); at the beginning of your test.
| assertThat(map.values().iterator().next()).isNotNull(); | ||
| assertThat(map.values().iterator().next()).isInstanceOf(RID.class); |
There was a problem hiding this comment.
You are calling map.values().iterator().next() twice. This is inefficient and could be problematic with some iterators. It's better to call it once and store the result in a local variable.
final Object value = map.values().iterator().next();
assertThat(value).isNotNull();
assertThat(value).isInstanceOf(RID.class);
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3577 +/- ##
==========================================
- Coverage 65.59% 65.47% -0.12%
==========================================
Files 1514 1514
Lines 103646 103646
Branches 21449 21449
==========================================
- Hits 67987 67867 -120
- Misses 26414 26521 +107
- Partials 9245 9258 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
SuffixIdentifier.execute(Identifiable) only handled @Rid, @type, and @cat as special record attributes but fell through to document.get() for @in and @out, which returned null since these are not stored as regular document properties. Added explicit handling to call Edge.getIn()/getOut().