#3571 fix: accessing internal properties #3572
Conversation
…ion results In SQLASTBuilder.visitModifier(), property-access modifiers always created a plain Identifier node, even for record attribute tokens like @Rid. This caused expressions like inE().@Rid to return null because the execution path used document.get("@Rid") instead of the record attribute lookup. Fixed by extracting a buildSuffixForIdentifier() helper that recognizes both unquoted record attribute tokens (RID_ATTR, TYPE_ATTR, etc.) and backtick-quoted identifiers whose value matches a known record attribute name. Both visitModifier and visitIdentifierChain now use this helper. 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 bug in the SQL parser that prevented correct retrieval of internal record properties (like @Rid or @type) when accessed as a suffix on the result of a function call. The fix involves refactoring the AST builder to properly identify these special attributes, whether they are unquoted or backtick-quoted, ensuring that SQL queries involving such expressions now return the expected values. 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
|
🧪 CI InsightsHere's what we observed from your CI run for 474698e. 🟢 All jobs passed!But CI Insights is watching 👀 |
Code ReviewGood fix for a clear and well-described bug. The approach is sound. Here are my observations: SummaryThe PR correctly identifies that Issues / Observations1. Inconsistency:
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue where internal properties like @rid were not accessible on function results. The solution involves a new helper method, buildSuffixForIdentifier, to properly recognize and handle these properties in the SQL parser. This is a solid fix, and the addition of a comprehensive test suite is commendable. I have one suggestion to refactor the new helper method for improved readability and to reduce code duplication.
| private SuffixIdentifier buildSuffixForIdentifier(final SQLParser.IdentifierContext idCtx) { | ||
| // Unquoted record attribute tokens (@rid, @type, @in, @out, @this) | ||
| if (idCtx.RID_ATTR() != null || idCtx.TYPE_ATTR() != null || | ||
| idCtx.IN_ATTR() != null || idCtx.OUT_ATTR() != null || | ||
| idCtx.THIS() != null) { | ||
| final RecordAttribute attr = new RecordAttribute(-1); | ||
| attr.setName(idCtx.getText()); | ||
| return new SuffixIdentifier(attr); | ||
| } | ||
| // Quoted identifiers (e.g. `@rid`) or plain identifiers whose value matches a record attribute | ||
| final Identifier id = (Identifier) visit(idCtx); | ||
| if (isRecordAttributeName(id.getStringValue())) { | ||
| final RecordAttribute attr = new RecordAttribute(-1); | ||
| attr.setName(id.getStringValue()); | ||
| return new SuffixIdentifier(attr); | ||
| } | ||
| return new SuffixIdentifier(id); | ||
| } |
There was a problem hiding this comment.
This method can be refactored to improve readability and eliminate code duplication. By determining the record attribute name first and then creating the RecordAttribute object in a single place, the logic becomes clearer and more maintainable.
private SuffixIdentifier buildSuffixForIdentifier(final SQLParser.IdentifierContext idCtx) {
String recordAttributeName = null;
Identifier identifier = null;
// Unquoted record attribute tokens (@rid, @type, @in, @out, @this)
if (idCtx.RID_ATTR() != null || idCtx.TYPE_ATTR() != null ||
idCtx.IN_ATTR() != null || idCtx.OUT_ATTR() != null ||
idCtx.THIS() != null) {
recordAttributeName = idCtx.getText();
} else {
// Quoted identifiers (e.g. `@rid`) or plain identifiers whose value matches a record attribute
identifier = (Identifier) visit(idCtx);
if (isRecordAttributeName(identifier.getStringValue())) {
recordAttributeName = identifier.getStringValue();
}
}
if (recordAttributeName != null) {
final RecordAttribute attr = new RecordAttribute(-1);
attr.setName(recordAttributeName);
return new SuffixIdentifier(attr);
}
return new SuffixIdentifier(identifier);
}…erage - Use buildSuffixForIdentifier for the first identifier in visitIdentifierChain too, so backtick-quoted `@rid` at chain start is handled consistently with the modifier position. - Add @type and @cat test cases (the latter exercises the isRecordAttributeName string-matching fallback since @cat has no dedicated grammar token). - Add DELETE cleanup before INSERT in each test for deterministic assertions (exact count instead of isNotEmpty). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code ReviewThis is a clean, well-scoped fix for issue #3571. Here is my feedback. What the fix does well
Issues / suggestions1. The method uses 2. Namespace-qualified function check still duplicates attribute detection In firstIdCtx.RID_ATTR() == null && firstIdCtx.TYPE_ATTR() == null
&& firstIdCtx.IN_ATTR() == null && firstIdCtx.OUT_ATTR() == null && firstIdCtx.THIS() == nullThis does not cover backtick-quoted variants. Since 3.
4. Minor:
SummaryThe fix is correct and production-ready as-is. Points 1 and 2 are the most substantive; the others are minor gaps in coverage and consistency. Overall a well-handled bug fix with good test coverage. |
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3572 +/- ##
==========================================
- Coverage 65.79% 65.30% -0.49%
==========================================
Files 1506 1506
Lines 103053 103092 +39
Branches 21366 21381 +15
==========================================
- Hits 67801 67329 -472
- Misses 26030 26566 +536
+ Partials 9222 9197 -25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
accessing internal properties (@Rid, @type, etc.) on functionon results
In SQLASTBuilder.visitModifier(), property-access modifiers always created a plain Identifier node, even for record attribute tokens like @Rid. This caused expressions like inE().@Rid to return null because the execution path used document.get("@Rid") instead of the record attribute lookup.
Fixed by extracting a buildSuffixForIdentifier() helper that recognizes both unquoted record attribute tokens (RID_ATTR, TYPE_ATTR, etc.) and backtick-quoted identifiers whose value matches a known record attribute name. Both visitModifier and visitIdentifierChain now use this helper.