Skip to content

test: add comprehensive tests for SQLMethodValues including document …#3047

Merged
robfrank merged 1 commit intomainfrom
imp/2964-add-tests
Dec 17, 2025
Merged

test: add comprehensive tests for SQLMethodValues including document …#3047
robfrank merged 1 commit intomainfrom
imp/2964-add-tests

Conversation

@robfrank
Copy link
Collaborator

This pull request significantly expands the test coverage for the SQLMethodValuesTest class, adding comprehensive tests for the .values() SQL method across various input types and edge cases. The new tests cover handling of documents, collections, results, mixed and unsupported types, nested structures, and integration with SQL queries. The changes also highlight and document several known bugs in the current implementation, such as improper value flattening and exceptions thrown for unsupported input types.

The most important changes include:

Expanded Test Coverage for .values() Method:

  • Added tests for handling Document and collections of Document objects, verifying current (buggy) behavior where values are wrapped in an extra list and include internal fields.
  • Added tests for handling collections of Result objects, ensuring values are correctly flattened.
  • Added tests for mixed collections (e.g., maps and strings) and unsupported types, confirming that the current implementation throws NullPointerException in these cases.
  • Added tests for empty collections and nested collections, verifying correct flattening or empty results.
  • Added SQL integration tests to check .values() behavior in query results and documented failures due to known bugs.

Test Infrastructure Improvements:

  • Updated the test class to extend TestHelper, enabling database setup and transaction management for integration-style tests.

Documentation of Known Bugs:

  • Inline comments in new tests document known issues in the current implementation, such as extra list wrapping and exceptions when processing unsupported types or nested structures.

These changes greatly improve the reliability of the .values() method by exposing current limitations and edge cases through thorough testing.

@robfrank robfrank linked an issue Dec 17, 2025 that may be closed by this pull request
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @robfrank, 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 test suite for the SQLMethodValuesTest class, focusing on the .values() SQL method. It introduces comprehensive tests for various data types and edge cases, including documents, collections, and SQL query integration. A key aspect is the explicit documentation of existing bugs within the implementation, aiming to improve the method's reliability by exposing current limitations and edge cases through thorough testing.

Highlights

  • Expanded Test Coverage for .values() Method: Comprehensive tests have been added for the .values() SQL method, covering various input types such as Document objects, collections of Document and Result objects, mixed and unsupported types, empty and nested collections, and integration with SQL queries.
  • Test Infrastructure Improvements: The SQLMethodValuesTest class now extends TestHelper, enabling proper database setup and transaction management for more robust integration-style tests.
  • Documentation of Known Bugs: New tests include inline comments that explicitly document existing bugs in the current implementation, such as improper value flattening (extra list wrapping for documents) and NullPointerException exceptions when processing unsupported types or nested structures.
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.

@robfrank robfrank merged commit c0be729 into main Dec 17, 2025
6 of 8 checks passed
@robfrank robfrank deleted the imp/2964-add-tests branch December 17, 2025 18:14
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 adds a comprehensive suite of tests for the SQLMethodValues class, covering various data types and edge cases, and importantly, documenting existing bugs. The new tests are well-structured and significantly improve test coverage. My review includes a couple of suggestions to make the assertions in the new tests more concise and idiomatic using AssertJ, which will improve their readability and maintainability.

Comment on lines +157 to +158
List<Object> valueList = new ArrayList<>(flattenedValues);
assertThat(valueList).containsAll(Arrays.asList("Alice", 30, "Bob", 25));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion can be made more concise and expressive by using containsExactlyInAnyOrder directly on the result collection. This avoids creating an intermediate ArrayList and is more idiomatic for AssertJ.

Suggested change
List<Object> valueList = new ArrayList<>(flattenedValues);
assertThat(valueList).containsAll(Arrays.asList("Alice", 30, "Bob", 25));
assertThat(flattenedValues).containsExactlyInAnyOrder("Alice", 30, "Bob", 25);

Comment on lines +210 to +211
List<Object> valueList = new ArrayList<>(flattenedValues);
assertThat(valueList).containsAll(Arrays.asList(1, 2, 3));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to another test, this assertion can be simplified. Using containsExactlyInAnyOrder is more direct and improves readability by removing the need for an intermediate list.

Suggested change
List<Object> valueList = new ArrayList<>(flattenedValues);
assertThat(valueList).containsAll(Arrays.asList(1, 2, 3));
assertThat(flattenedValues).containsExactlyInAnyOrder(1, 2, 3);

@mergify
Copy link
Contributor

mergify bot commented Dec 17, 2025

🧪 CI Insights

Here's what we observed from your CI run for 7ac80f9.

🟢 All jobs passed!

But CI Insights is watching 👀

@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.22%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (4fed172) 75737 48396 63.90%
Head commit (7ac80f9) 75737 (+0) 48233 (-163) 63.68% (-0.22%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3047) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

robfrank added a commit that referenced this pull request Feb 11, 2026
…ument and collection handling (#3047)

(cherry picked from commit c0be729)
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.

SQL: "keys" method behaves differently than "values" method

1 participant