Skip to content

Conversation

@bckohan
Copy link
Contributor

@bckohan bckohan commented Dec 17, 2025

Closes #334

Copy link
Contributor

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 fixes an infinite recursion bug (issue #334) that occurred when using refresh_from_db() with limited fields on polymorphic models. The bug was caused by the only() method not including polymorphic_ctype_id in the field list, which prevented the polymorphic machinery from determining the correct model type.

Key changes:

  • Modified PolymorphicQuerySet.only() to use a set for deduplication and always include polymorphic_ctype_id
  • Added comprehensive test case reproducing the bug scenario
  • Added codecov configuration for better coverage reporting

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/polymorphic/query.py Fixed only() method to use a set for field deduplication and ensure polymorphic_ctype_id is always included
src/polymorphic/tests/test_orm.py Added test case test_infinite_recursion_with_only that reproduces the bug scenario with refresh_from_db()
src/polymorphic/tests/models.py Added RecursionBug model with __init__ method that triggers the bug when fields are partially loaded
src/polymorphic/tests/migrations/0001_initial.py Regenerated migration to include the new RecursionBug model and reordered dependencies
codecov.yml Added codecov configuration to fix source path mapping in coverage reports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.77%. Comparing base (253abe7) to head (a3c93f5).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
+ Coverage   76.75%   76.77%   +0.01%     
==========================================
  Files          22       22              
  Lines        1368     1369       +1     
  Branches      214      214              
==========================================
+ Hits         1050     1051       +1     
  Misses        250      250              
  Partials       68       68              

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bckohan bckohan merged commit 74d3396 into jazzband:master Dec 17, 2025
41 checks passed
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.

refresh_from_db RecursionError

1 participant