Skip to content

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jan 14, 2026

πŸ“‘ Description

Related to #1304

This PR fixes an issue where the ORM could not handle nested associations when using load().

βœ… Checks

  • Added test cases for my code

@hwbrzzl hwbrzzl requested a review from a team as a code owner January 14, 2026 10:23
@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 resolves a critical bug in the ORM's Load method that prevented it from accurately processing nested relationships. By introducing a mechanism to correctly identify the top-level relationship within a nested path, the change ensures that associated data is loaded without inadvertently overwriting other fields. This enhancement significantly improves the ORM's ability to handle complex data models and provides more reliable relationship loading functionality.

Highlights

  • Nested Relationship Loading Fix: Addresses an issue where the ORM's Load method failed to correctly handle nested associations, such as Books.Author.
  • Root Relation Identification: Introduces logic to extract the root relationship name (e.g., Books from Books.Author) to ensure proper field preservation during the Load operation.
  • New Test Cases: Adds comprehensive test cases to validate the correct loading of nested relationships, confirming the fix for scenarios like Books.Author and Roles.Users.
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. ↩

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 correctly fixes an issue with loading nested relationships by properly extracting the root relationship name. The logic change in database/gorm/query.go is sound, and the new tests in tests/query_test.go provide good coverage for the fix, including nested loads like Books.Author and Roles.Users.

I've added one suggestion to simplify the string manipulation logic for extracting the root relationship, which could improve code conciseness. Overall, this is a good fix.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             v1.16.x    #1350   +/-   ##
==========================================
  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.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@hwbrzzl hwbrzzl merged commit c3ac1c4 into v1.16.x Jan 15, 2026
17 checks passed
@hwbrzzl hwbrzzl deleted the bowen/fix-load branch January 15, 2026 06:44
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.

2 participants