From 590c66aaae7dacc0058a9ea2a9e5f7d1a6e803dc Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Fri, 1 May 2026 10:50:27 -0700 Subject: [PATCH 1/3] Add regression test for update_fields issue --- tests/testapp/tests/integration/test_syncing_models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testapp/tests/integration/test_syncing_models.py b/tests/testapp/tests/integration/test_syncing_models.py index 460b1029..43f6b3ee 100644 --- a/tests/testapp/tests/integration/test_syncing_models.py +++ b/tests/testapp/tests/integration/test_syncing_models.py @@ -67,6 +67,15 @@ def test_syncable_save(self): user.save(update_dirty_bit_to=None) self.assertTrue(MyUser.objects.first()._morango_dirty_bit) + def test_syncable_save_with_update_fields_persists_dirty_bit(self): + user = MyUser.objects.first() + user.save(update_dirty_bit_to=False) + self.assertFalse(MyUser.objects.first()._morango_dirty_bit) + + user.username = "updated-name" + user.save(update_fields=["username"]) + self.assertTrue(MyUser.objects.first()._morango_dirty_bit) + def test_syncing_objects_manager_with_custom_default_manager(self): """Test that syncing_objects manager includes all objects even when default manager filters them out""" # Create some test objects From fa56134d96c1524307da18040a975b49942a6c8b Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Fri, 1 May 2026 10:52:50 -0700 Subject: [PATCH 2/3] Implement fix for update_fields issue --- morango/models/core.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/morango/models/core.py b/morango/models/core.py index 32bef937..f04d663e 100644 --- a/morango/models/core.py +++ b/morango/models/core.py @@ -849,6 +849,13 @@ def save(self, update_dirty_bit_to=True, *args, **kwargs): self._morango_dirty_bit = True elif not update_dirty_bit_to: self._morango_dirty_bit = False + + # ensure the dirty bit field is in the fields to update if present, to keep it in sync + if update_dirty_bit_to is not None and kwargs.get("update_fields") is not None: + kwargs["update_fields"] = set(kwargs["update_fields"]) | { + "_morango_dirty_bit" + } + super(SyncableModel, self).save(*args, **kwargs) def delete( From 109c81c712b1956ecf0b4b05716b6fbc06c1ff2f Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Fri, 1 May 2026 10:57:53 -0700 Subject: [PATCH 3/3] Bump version and update changelog --- CHANGELOG.md | 3 +++ morango/__init__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b4dd4b..450a99be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ List of the most important changes for each release. +## 0.8.12 +- Fixes issue where dirty-bit isn't updated when calling save on a syncable model with `update_fields` + ## 0.8.11 - Adds additional `deserialization_exception` field to `Store` model to track the fully qualified exception path diff --git a/morango/__init__.py b/morango/__init__.py index 1d16920c..cb4382b8 100644 --- a/morango/__init__.py +++ b/morango/__init__.py @@ -1 +1 @@ -__version__ = "0.8.11" +__version__ = "0.8.12"