Skip to content

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jan 8, 2026

πŸ“‘ Description

Closes goravel/goravel#856

Follow Gemini

βœ… Checks

  • Added test cases for my code

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hwbrzzl, 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 delivers a crucial fix for an issue where the Distinct clause was not correctly honored when used in conjunction with Count operations within the ORM. The primary objective is to ensure the accuracy and reliability of aggregate queries involving distinct values. This is achieved by introducing a comprehensive suite of new and updated test cases that rigorously validate the behavior of Count, Distinct, and Select combinations across various query patterns. The changes also clarify and document specific ORM behaviors, such as how the underlying Gorm library handles COUNT with multiple distinct fields, thereby improving the predictability and robustness of the query builder.

Highlights

  • Distinct with Count Fix: Resolves issue fix: Throw error if Context is http ContextΒ #856, addressing a bug where the Distinct clause had no effect when combined with Count operations, leading to incorrect results.
  • Expanded Count Test Coverage: Significantly increases test coverage for Count() queries, including scenarios with Where() and various Select() statements (e.g., Select("field"), Select("field as alias")) to ensure accurate counting.
  • Comprehensive Distinct Test Cases: Introduces new, detailed test cases for Distinct() in conjunction with Count() and Select(), covering both single and multiple distinct fields, and explicitly handling cases where Distinct().Count() should error or behave differently (e.g., COUNT(*) for multiple distinct fields in Gorm).
  • SQL Generation Validation: Adds tests to to_sql_test.go to verify that the generated SQL for Count() queries with Distinct() and Select() clauses is correct and matches expected database behavior, including specific handling for Gorm's limitations.
  • Paginate with Select Enhancements: Refines existing Paginate tests to ensure proper functionality when Select clauses are used, preventing potential data mapping or counting issues.
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 Jan 8, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v1.16.x@6460b24). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             v1.16.x    #1343   +/-   ##
==========================================
  Coverage           ?   68.04%           
==========================================
  Files              ?      215           
  Lines              ?    11601           
  Branches           ?        0           
==========================================
  Hits               ?     7894           
  Misses             ?     3327           
  Partials           ?      380           

β˜” 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 addresses an issue where Distinct had no effect when used with Count. The fix is validated by an extensive and well-thought-out set of new tests that cover various scenarios involving Count, Select, and Distinct. My main feedback is to refactor the newly added tests to use a table-driven approach. This will significantly reduce code duplication, making the tests more readable and easier to maintain in the future.

@hwbrzzl hwbrzzl marked this pull request as ready for review January 8, 2026 14:16
@hwbrzzl hwbrzzl requested a review from a team as a code owner January 8, 2026 14:16
@hwbrzzl hwbrzzl merged commit d0b798f into v1.16.x Jan 10, 2026
17 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#856 branch January 10, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants