Skip to content

dql/maps,reflects: _name, _value#2651

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

dql/maps,reflects: _name, _value#2651
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 significantly enhances the Data Query Language (DQL) by standardizing the internal representation of nodes and introducing direct accessors for node names and values. These changes simplify data manipulation and querying across map-based, reflection-based, and HTML DQL contexts, making the API more intuitive and consistent for developers. The refactoring also improves the maintainability and clarity of the codebase by removing unnecessary abstractions and consolidating data access patterns.

Highlights

  • Standardized Node Structure: The internal Node struct in both dql/maps and dql/reflects packages has been refactored to use a Value field instead of Children, providing a more consistent representation across different DQL implementations.
  • New Node Accessors: New _name and _value methods (e.g., XGo_name__0, XGo_value__0) have been introduced for NodeSet in dql/maps and dql/reflects, allowing direct and simplified access to a node's name and its underlying value.
  • HTML Node Naming: The dql/html package now includes Name__0 and Name__1 methods on NodeSet to retrieve the DataAtom string as the name of the first HTML node.
  • Simplified Reflection Logic: Redundant isNodeType and isNode helper functions have been removed from dql/reflects, streamlining the logic for yielding child nodes and improving code clarity.
  • YAML Query Example: A new demo file demo/dql-yaml/yq.xgo has been added to illustrate how to query YAML data and utilize the new _value accessor.

🧠 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
  • demo/dql-yaml/yq.xgo
    • Added a new demo file yq.xgo to showcase querying YAML data.
    • Demonstrated accessing a node's value using feature._value within a loop.
  • dql/html/html.go
    • Introduced Name__0() method to return the name of the first node, handling errors by returning an empty string.
    • Introduced Name__1() method to return the name of the first node and an error if not found.
  • dql/maps/maps.go
    • Renamed the Children field to Value in the Node struct, and updated its comment.
    • Modified New function to initialize Node with Value instead of Children.
    • Updated yieldElem, yieldChildNodes, yieldAnyNodes, and yieldAnyNode functions to use node.Value instead of node.Children.
    • Removed the yieldNode helper function, inlining its logic.
    • Added XGo_name__0() and XGo_name__1() methods to NodeSet for retrieving the name of the first node.
    • Added XGo_value__0() and XGo_value__1() methods to NodeSet for retrieving the value of the first node.
    • Updated XGo_hasAttr and XGo_Attr__1 methods to access node.Value for attribute checks.
  • dql/reflects/reflects.go
    • Renamed the Children field to Value in the Node struct, and updated its comment.
    • Modified New function to initialize Node with Value instead of Children.
    • Updated yieldElem, yieldChildNodes, yieldAnyNodes, and XGo_Child functions to use node.Value instead of node.Children.
    • Removed isNodeType and isNode helper functions, simplifying node type checks.
    • Simplified yieldChildNodes logic for reflect.Struct and reflect.Slice by directly yielding nodes without isNode checks.
    • Added XGo_name__0() and XGo_name__1() methods to NodeSet for retrieving the name of the first node.
    • Added XGo_value__0() and XGo_value__1() methods to NodeSet for retrieving the value of the first node.
    • Moved and updated the XGo_class method to use node.Value.
    • Updated XGo_hasAttr and XGo_Attr__1 methods to access node.Value for attribute checks.
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 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.11%. Comparing base (5c778ba) to head (65c64d3).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2651   +/-   ##
=======================================
  Coverage   94.11%   94.11%           
=======================================
  Files          32       32           
  Lines        9968     9968           
=======================================
  Hits         9381     9381           
  Misses        419      419           
  Partials      168      168           

☔ 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 refactors the dql/maps and dql/reflects packages by renaming Children to Value in the Node struct, simplifying the codebase and enhancing query capabilities to handle scalar values. However, a potential Denial of Service (DoS) vulnerability was identified in the dql/reflects package due to improper handling of unexported struct fields during reflection, which can lead to application panics. This vulnerability needs to be addressed to ensure application stability.

@xgopilot
Copy link

xgopilot bot commented Feb 19, 2026

Code Review Summary

This PR adds _name and _value accessors to DQL NodeSet types and renames Children to Value. The demo file shows good usage examples.

Key concerns:

  1. Panic risk in reflects.XGo_value__1() - Missing CanInterface() guard before calling .Interface() on potentially unexported struct fields

  2. html.Name__1 inconsistency - Uses DataAtom.String() which returns empty for custom HTML elements, while other methods use node.Data

  3. Undocumented behavioral change - Removal of isNode/yieldNode filters now yields primitive values as traversable nodes, broadening query result sets

  4. Type alias comments in dql/json and dql/yaml may still reference the old Children field semantics

The implementation is clean and the field rename from Children to Value improves clarity. Consider addressing the panic risk before merging.

@xushiwei xushiwei merged commit ae0331b into goplus:main Feb 19, 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