Skip to content

dql: ns@name#2621

Merged
xushiwei merged 3 commits intogoplus:mainfrom
xushiwei:q
Feb 14, 2026
Merged

dql: ns@name#2621
xushiwei merged 3 commits intogoplus:mainfrom
xushiwei:q

Conversation

@xushiwei
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @xushiwei, 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 DQL (Data Query Language) by introducing more flexible syntax for conditional expressions, allowing users to directly select elements by name using ns@name or ns@"elem-name". This change improves the expressiveness of DQL queries by providing a more direct way to navigate and filter data based on element names. The underlying parsing and compilation mechanisms have been updated to support these new constructs, ensuring they are correctly interpreted and translated into executable code.

Highlights

  • Expanded DQL Conditional Expression Syntax: The DQL (Data Query Language) now supports new forms for conditional expressions using the @ operator, specifically ns@name and ns@"elem-name" for direct element selection, in addition to existing ns@(condExpr) and ns@fn(args).
  • AST and Parser Updates: The CondExpr AST node has been updated to reflect the expanded types of conditions it can hold. The parser logic in parser/parser.go was modified to correctly parse these new syntaxes, distinguishing between identifier-based conditions, function calls, and string literal element names.
  • Compiler Implementation for New Syntax: The DQL compiler (cl/expr.go) now translates ns@name and ns@"elem-name" into calls to a new XGo_Select method on NodeSet, enabling direct selection of elements by name.
  • New DQL Helper Methods: A new XGo_Select method was added to the NodeSet type in cl/internal/dql/dql.go to support the compilation of the new element selection syntax. Additionally, a new NodeSet2 type and associated helper methods were introduced, likely for internal DQL testing or future enhancements.
  • New Test Cases: New test files (cl/_testgop/dql3/in.xgo, cl/_testgop/dql3/out.go, parser/_testdata/dql2/dql.xgo, parser/_testdata/dql2/parser.expect) and an error test (cl/error_msg_test.go) were added to validate the parsing and compilation of the new DQL conditional expression forms.

🧠 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
  • ast/ast_xgo.go
    • Updated comments for CondExpr to clarify new syntax forms (ns@(condExpr), ns@fn(args), ns@"elem-name", ns@name).
    • Modified Cond field in CondExpr to explicitly allow *CallExpr, *ParensExpr, or *Ident.
  • cl/_testgop/dql3/in.xgo
    • Added a new DQL test case demonstrating the doc.*@users@"users".$name syntax.
  • cl/_testgop/dql3/out.go
    • Added the expected Go output for the new DQL test case, showing translation to XGo_Child().XGo_Select("users").XGo_Select("users").XGo_Attr__0("name").
  • cl/error_msg_test.go
    • Added TestErrCondExpr to test error handling for conditional expressions like doc.users@($age < 18).$name.
  • cl/expr.go
    • Modified compileCondExpr to handle *ast.Ident conditions, specifically translating ns@name and ns@"elem-name" to XGo_Select calls.
    • Refactored condExpr and cb variable declarations for scope.
    • Updated XGo_first method call to pass the CondExpr node v as a context argument.
  • cl/internal/dql/dql.go
    • Added XGo_Select(name string) NodeSet method to the NodeSet type.
    • Introduced NodeSet2 type with New2, NodeSet2_Cast, XGo_first, XGo_Enum, XGo_Elem, and XGo_Attr methods.
  • parser/_testdata/dql/dql.xgo
    • Renamed to parser/_testdata/dql1/dql.xgo.
  • parser/_testdata/dql/parser.expect
    • Renamed to parser/_testdata/dql1/parser.expect.
  • parser/_testdata/dql2/dql.xgo
    • Added a new parser test case for echo doc.*@users@"users".$name.
  • parser/_testdata/dql2/parser.expect
    • Added the expected AST structure for the new ns@"elem-name" parser test case.
  • parser/parser.go
    • Updated parseCondExpr to correctly parse token.STRING for ns@"elem-name" by creating an ast.Ident.
    • Modified parseCondExpr to differentiate between token.IDENT followed by LPAREN (function call) and token.IDENT alone (direct name selection).
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.

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.31%. Comparing base (7f8fba4) to head (92b9617).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2621   +/-   ##
=======================================
  Coverage   94.31%   94.31%           
=======================================
  Files          32       32           
  Lines       10335    10350   +15     
=======================================
+ Hits         9747     9762   +15     
  Misses        419      419           
  Partials      169      169           

☔ 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.

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 introduces support for ns@name and ns@"elem-name" syntax in the DQL feature. The changes span the parser and compiler to correctly handle this new syntax. The parser is updated to recognize @name and @"elem-name" as conditional expressions, and the compiler is updated to generate calls to a new XGo_Select method. The implementation is supported by new test cases for both the parser and the compiler, including a new error-handling test. Additionally, there's a small improvement in error reporting by passing down the AST node context. The changes are well-structured and appear correct. I have no specific comments.

@xgopilot
Copy link

xgopilot bot commented Feb 14, 2026

Code Review Summary

This PR extends DQL syntax to support ns@name and ns@"elem-name" forms for name-based selection alongside existing conditional filtering. The implementation is clean and follows established patterns.

Key observations:

  • The early-return fast path for *ast.Ident is a good optimization, avoiding unnecessary closure/type construction
  • Parser restructuring to differentiate @name from @fn(...) is correct
  • Test coverage is adequate with both parser and code generation tests

Minor items noted in inline comments:

  • Typo in AST comment (*ParensExpr*ParenExpr)
  • Missing doc comment on new XGo_Select method
  • Backtick-quoted strings may need handling in the unquote check

@xushiwei xushiwei merged commit 382e1a8 into goplus:main Feb 14, 2026
11 checks passed
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.

1 participant