Skip to content

Preserve database alias and hints in device managers - #826

Merged
JaeHyuckSa merged 2 commits into
django-commons:masterfrom
vetrovk:codex/fix-device-manager-database
Nov 9, 2026
Merged

JaeHyuckSa merged 2 commits into
django-commons:masterfrom
vetrovk:codex/fix-device-manager-database

Conversation

@vetrovk

@vetrovk vetrovk commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #824.

Pass using=self._db and hints=self._hints when constructing querysets in the GCM, APNS, WNS and WebPush device managers. This preserves database selection through db_manager() while keeping the specialized queryset classes and Django read/write routing intact.

Add regression coverage using two separate SQLite databases for creation and reads, default and explicit aliases, .using(), database routers, routing hints and instance-based fallback. Notification delivery code and migrations are unchanged.

Validation

Verified locally on Django 4.2.30, 5.2.19 and 6.1.3:

  • New manager tests: 8 passed, 44 subtests passed on each version. Before the fix, these tests produced 20 failing subtests.
  • Full suite: 106 passed, 2 skipped, 61 subtests passed on each version. The skips are the existing legacy apns2 modules on modern Python.
  • UNIQUE_REG_ID suite: 4 passed on each version.
  • Flake8 passes for the test settings and new test module. The 11 existing findings in models.py are identical on the unchanged base revision; no new findings were introduced.
  • git diff --check passed.

AI assistance

OpenAI Codex assisted with investigation, implementation and regression tests. The validation results above were obtained by running the tests locally.

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.65%. Comparing base (1fe48b9) to head (86250db).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #826   +/-   ##
=======================================
  Coverage   74.65%   74.65%           
=======================================
  Files          32       32           
  Lines        1365     1365           
  Branches      226      226           
=======================================
  Hits         1019     1019           
  Misses        300      300           
  Partials       46       46           

☔ View full report in Codecov by Harness.
📢 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.

@JaeHyuckSa JaeHyuckSa left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The change looks fine. When you use AI, please give the code another look before opening a PR. Some of these tests weren't needed.

Comment thread tests/test_managers.py Resolved
Comment thread tests/test_managers.py Resolved

@JaeHyuckSa JaeHyuckSa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@vetrovk Thanks!

@JaeHyuckSa
JaeHyuckSa merged commit 455d2f3 into django-commons:master Nov 9, 2026
13 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.

Device managers ignore the database alias set by db_manager()

2 participants