Skip to content

Rename VirtualModel user field to avoid conflict #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025

Conversation

hugobessa
Copy link
Contributor

@hugobessa hugobessa commented Jun 4, 2025

Rename internal user attribute from VirtualModel to _user to avoid conflict with ForeignKey and OneToOneField fields with the same name

Summary by Sourcery

Rename the internal user attribute in VirtualModel to _user to prevent naming conflicts with Django field names, bump the package version to 0.3.1, and update the changelog accordingly.

Bug Fixes:

  • Rename internal user attribute to _user in VirtualModel to avoid conflicts with ForeignKey and OneToOneField names.

Documentation:

  • Add version 0.3.1 entry to CHANGELOG outlining the rename.

Chores:

  • Bump package version from 0.3.0 to 0.3.1.

@hugobessa hugobessa requested review from fjsj and Copilot June 4, 2025 23:52
Copy link

sourcery-ai bot commented Jun 4, 2025

Reviewer's Guide

This PR renames the internal user attribute of the VirtualModel field to _user across all class methods to prevent naming conflicts with Django model fields, and updates the package version and changelog to reflect the new release.

Updated class diagram for VirtualModel

classDiagram
    class VirtualModel {
        -user
        +_user
        +__init__(user)
        +get_optimized_queryset(user)
    }
Loading

File-Level Changes

Change Details Files
Renamed internal field attribute and updated references
  • Changed self.user to self._user in the field initializer
  • Updated all user=self.user call sites to user=self._user
  • Ensured nested hydration and queryset methods reference _user
django_virtual_models/fields.py
Updated package version and changelog for new release
  • Bumped __version__ from 0.3.0 to 0.3.1
  • Added 0.3.1 entry in CHANGELOG with description of the rename change
django_virtual_models/__init__.py
CHANGELOG.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR renames the internal "user" attribute in VirtualModel to "_user" to avoid naming conflicts with Django's ForeignKey and OneToOneField fields. The key changes are:

  • Renamed the attribute in django_virtual_models/fields.py and updated its usage.
  • Bumped the package version from 0.3.0 to 0.3.1 in init.py.
  • Updated the CHANGELOG to reflect the renaming change.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
django_virtual_models/fields.py Changed "user" to "_user" in attribute assignment and method call for consistency.
django_virtual_models/init.py Updated version number to reflect the new release version.
CHANGELOG.md Documented the renaming of the "user" attribute to avoid conflicts.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @hugobessa - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@fjsj fjsj left a comment

Choose a reason for hiding this comment

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

Thanks @hugobessa
As the API changed, I suggest a new major or minor version.
Also, please check if self.user is mentioned in docs.

@hugobessa hugobessa merged commit fd36f45 into main Jun 6, 2025
36 checks passed
@hugobessa hugobessa deleted the fix/rename-virtualmodel-user-field branch June 6, 2025 14:23
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.

2 participants