Skip to content

dql: only retrieves data from the first node in the NodeSet#2612

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

dql: only retrieves data from the first node in the NodeSet#2612
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 refines the behavior of NodeSet operations across various DQL packages, particularly focusing on ensuring that data retrieval methods consistently operate on and return results from the first node in a NodeSet. It introduces generic sequence utility functions to support this pattern and implements several previously placeholder NodeSet navigation methods, enhancing the robustness and predictability of DQL queries.

Highlights

  • New Generic Sequence Utilities: Introduced First, Single, and Collect functions in dql.go to provide generic ways to retrieve items from sequences, handling cases for single items, the first item, or all items.
  • NodeSet Method Implementations: Implemented several previously stubbed NodeSet methods in dql/html/html.go, including One, Single, ParentN, Parent, PrevSibling, NextSibling, FirstElementChild, and TextNode, providing concrete functionality for navigating and querying HTML nodes.
  • Consistent First Node Retrieval: Refactored NodeSet methods like XGo_Attr, Text, and Int in dql/html/html.go to explicitly retrieve data only from the first node in the NodeSet, aligning with the PR's objective.
  • XGo_Node Method Addition: Added XGo_Node methods across dql/html, dql/maps, dql/reflects, and dql/xml packages, allowing direct retrieval of the first node from a NodeSet using the new dql.First utility.
  • XML Package Method Renaming: Renamed Text() to XGo_text() and Int() to XGo_int() in dql/xml/xml.go to maintain consistency and updated their implementations to use the new first-node retrieval logic.
  • Text Node Property Fix: Corrected a property name from Data to value when filtering text nodes in repoList.xgo.

🧠 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
  • dql/dql.go
    • Added First function for retrieving the first item from a sequence.
    • Added Single function for retrieving a single item from a sequence, with error handling for empty or multiple items.
    • Added Collect function for retrieving all items from a sequence.
  • dql/fetcher/github.com/repoList/repoList.xgo
    • Updated text node attribute comparison from Data to value.
  • dql/html/html.go
    • Added XGo_Node method to return the first node in a NodeSet.
    • Implemented One method to return a NodeSet containing the first node.
    • Implemented Single method to return a NodeSet containing a single node, with error handling.
    • Implemented ParentN method to return a NodeSet containing the N-th parent nodes.
    • Implemented Parent method to return a NodeSet containing the parent nodes.
    • Implemented PrevSibling method to return a NodeSet containing the previous sibling nodes.
    • Implemented NextSibling method to return a NodeSet containing the next sibling nodes.
    • Implemented FirstElementChild method to return a NodeSet containing the first element child.
    • Implemented TextNode method to return a NodeSet containing all text nodes.
    • Added Collect method to retrieve all nodes from the NodeSet.
    • Added First method to return the first node in the NodeSet.
    • Added Value method to return the data content of the first node.
    • Added HasAttr method to check if the first node has a specified attribute.
    • Modified XGo_Attr to retrieve the attribute value only from the first node.
    • Modified Text to retrieve text content only from the first child text node of the first node.
    • Modified valByNodeType to retrieve data content only from the first child node of the specified type of the first node.
    • Modified Int to retrieve integer value only from the first child text node of the first node.
  • dql/maps/maps.go
    • Added XGo_Node method to return the first node in a NodeSet.
  • dql/reflects/reflects.go
    • Added XGo_Node method to return the first node in a NodeSet.
  • dql/xml/xml.go
    • Added XGo_Node method to return the first node in a NodeSet.
    • Renamed Text to XGo_text and updated its implementation.
    • Renamed Int to XGo_int and updated its implementation to use XGo_text.
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 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (9c33cb4) to head (838cfe1).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2612   +/-   ##
=======================================
  Coverage   94.02%   94.02%           
=======================================
  Files          32       32           
  Lines        9891     9891           
=======================================
  Hits         9300     9300           
  Misses        422      422           
  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 generic First, Single, and Collect functions in dql/dql.go to handle sequences, which is a good abstraction. Several NodeSet methods across dql/html/html.go, dql/maps/maps.go, and dql/reflects/reflects.go have been updated to leverage these new generic functions, specifically focusing on retrieving data from the first node in the NodeSet, aligning with the PR's title. However, there are some inconsistencies and incorrect error handling in dql/html/html.go and dql/xml/xml.go that need to be addressed to ensure correct behavior and full adherence to the PR's stated goal.

@xushiwei xushiwei changed the title dql/html: only retrieves data from the first node in the NodeSet dql: only retrieves data from the first node in the NodeSet Feb 12, 2026
@xgopilot
Copy link

xgopilot bot commented Feb 12, 2026

Code Review Summary

Good implementation of the "first node only" semantic for NodeSet operations. The generic sequence utilities (First, Single, Collect) are well-designed and reused effectively across packages.

Key Issues

  1. Doc comment typos: ErrMultipleResultsErrMultiEntities in two places
  2. XGo_Attr behavioral change: Now returns ("", nil) instead of ErrNotFound when attribute missing — breaks error handling for callers
  3. Naming mismatch: Doc says XGo_Text but function is XGo_text

Minor Observations

  • TextNode() comment says "all text nodes" but only yields direct children
  • Consider consistency: xml.XGo_Attr still searches all nodes while html.XGo_Attr now uses first-node-only

@xushiwei xushiwei merged commit 4b6b063 into goplus:main Feb 12, 2026
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