Repository navigation
fix: support UUID notification references - #12616
SchrodingersGat merged 2 commits into
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR updates notification deduplication tracking so NotificationEntry.uid can store UUID (and other non-integer) primary keys, preventing database errors when notifications reference UUID-backed models.
Changes:
- Change
NotificationEntry.uidfromIntegerFieldtoCharField(max_length=255)and widen type hints forcheck_recent()/notify(). - Add a schema migration altering the
uidfield type. - Add a regression test ensuring UUID-based notification references are supported.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/backend/InvenTree/common/models.py |
Switch NotificationEntry.uid to text storage and update method type hints to accept UUIDs. |
src/backend/InvenTree/common/migrations/0049_notificationentry_charfield_uid.py |
Migration to alter the uid column to a CharField(255). |
src/backend/InvenTree/common/tests.py |
New regression test for UUID notification references. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Notification references may point to models with UUID primary keys. | ||
| # Store the value as text so both integer and non-integer identifiers work. | ||
| uid = models.CharField(max_length=255) | ||
|
|
||
| @classmethod | ||
| def check_recent(cls, key: str, uid: int, delta: timedelta): | ||
| def check_recent(cls, key: str, uid: str | int | uuid.UUID, delta: timedelta): |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12616 +/- ##
==========================================
- Coverage 86.73% 86.73% -0.01%
==========================================
Files 1447 1448 +1
Lines 96780 96789 +9
Branches 11181 11181
==========================================
+ Hits 83946 83952 +6
- Misses 12770 12773 +3
Partials 64 64
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@FurinaDog thanks for the contribution 🙂 |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
* fix: support UUID notification references * test: update notification uid expectation --------- (cherry picked from commit 55a193e) Co-authored-by: FurinaDog <[email protected]> Co-authored-by: FurinaDog <[email protected]>
What problem does this solve?
Fixes #12599.
NotificationEntry.uidwas anIntegerField, but notification deduplication can receive UUID primary keys from models such asMachineConfig. Saving those values caused database errors such asinteger out of range.What changed?
CharField(max_length=255).Validation
python manage.py migrate --noinputpython -m pytest src/backend/InvenTree/common/tests.py -k 'uuid_notification_entry or check_notification_entries' -q --reuse-db(2 passed)python manage.py makemigrations --check --dry-run(no changes detected)