Skip to content

Commit

Permalink
Removed rigger_type.snapshot so that delete triggers will now record …
Browse files Browse the repository at this point in the history
…snapshots
  • Loading branch information
Andrew Stoerkel committed May 20, 2024
1 parent a415da9 commit 32ddc3c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.4.8

* Removed `trigger_type.snapshot` so that delete triggers will now record snapshots


## 3.4.7

* Added a `HISTORY_IGNORE_MODELS` setting to ignore individual models. This should be a
Expand Down
2 changes: 1 addition & 1 deletion history/backends/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def create_trigger(self, model, trigger_type):
table=model._meta.db_table,
ctid=ct.pk,
pk_col=model._meta.pk.column,
snapshots=int(conf.SNAPSHOTS and trigger_type.snapshot),
snapshots=int(conf.SNAPSHOTS),
field_list=", '" + "', '".join(field_names) + "'",
)
)
Expand Down
2 changes: 1 addition & 1 deletion history/backends/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _json_snapshot(self, fields, trigger_type):
Returns an SQL fragment that builds a JSON object from the specified model
fields.
"""
if not conf.SNAPSHOTS or not trigger_type.snapshot:
if not conf.SNAPSHOTS:
return "NULL"
return self._json_object(fields, "NEW")

Expand Down
4 changes: 0 additions & 4 deletions history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class TriggerType(models.TextChoices):
DELETE = "D", _("Delete")
UPDATE = "U", _("Update")

@property
def snapshot(self):
return self in (TriggerType.INSERT, TriggerType.UPDATE)

@property
def changes(self):
return self == TriggerType.UPDATE
Expand Down

0 comments on commit 32ddc3c

Please sign in to comment.