Skip to content

Conversation

@JohananOppongAmoateng
Copy link
Contributor

@JohananOppongAmoateng JohananOppongAmoateng commented Dec 23, 2025

This PR addresses multiple issues to improve django-polymorphic's reliability and usability.

Saving polymorphic objects from one database to another caused ForeignKeyViolation because polymorphic_ctype_id referenced ContentType IDs from the source database.

Database routers weren't respected - ContentType was always fetched from default database even when routers specified a different database.

Closes #486
Closes #446

@JohananOppongAmoateng JohananOppongAmoateng marked this pull request as draft December 23, 2025 13:22
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.39%. Comparing base (9f5e0fc) to head (a667f57).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #757      +/-   ##
==========================================
+ Coverage   78.28%   78.39%   +0.10%     
==========================================
  Files          26       26              
  Lines        1543     1569      +26     
  Branches      244      248       +4     
==========================================
+ Hits         1208     1230      +22     
- Misses        260      263       +3     
- Partials       75       76       +1     

☔ 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.

@JohananOppongAmoateng JohananOppongAmoateng marked this pull request as ready for review December 23, 2025 14:51
@JohananOppongAmoateng JohananOppongAmoateng self-assigned this Dec 23, 2025
Copy link
Contributor

@bckohan bckohan left a comment

Choose a reason for hiding this comment

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

Great work @JohananOppongAmoateng

I'd like to keep PRs logically homogenous. Could you please separate out the fix for #505 into a separate PR? It is unrelated to the db routing issues (which I want to accept as is). I'm not sure about supporting 505 yet or not.

@JohananOppongAmoateng
Copy link
Contributor Author

Great work @JohananOppongAmoateng

I'd like to keep PRs logically homogenous. Could you please separate out the fix for #505 into a separate PR? It is unrelated to the db routing issues (which I want to accept as is). I'm not sure about supporting 505 yet or not.

@bckohan your requested changes have been done

Copy link
Contributor

@bckohan bckohan left a comment

Choose a reason for hiding this comment

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

Great thanks!

@bckohan bckohan merged commit 8ac278b into jazzband:master Dec 29, 2025
44 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.

ForeignKeyViolation when trying to save an entity when using a non-default db Content types pulled from wrong database when using database routers

2 participants