Skip to content

Commit

Permalink
Fix bumping of tombstones timestamps in PostgreSQL storage backend (f…
Browse files Browse the repository at this point in the history
…ixes #1981)
  • Loading branch information
leplatrem committed Jan 21, 2019
1 parent 1bb6658 commit a661069
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes changes between each past release.
12.1.0 (unreleased)
-------------------

- Nothing changed yet.
- Fix bumping of tombstones timestamps when deleting objects in PostgreSQL storage backend (fixes #1981)


12.0.0 (2019-01-10)
Expand Down
2 changes: 1 addition & 1 deletion kinto/core/storage/postgresql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def delete_all(
FOR UPDATE
)
UPDATE objects
SET deleted=TRUE, data=(:deleted_data)::JSONB
SET deleted=TRUE, data=(:deleted_data)::JSONB, last_modified=NULL
FROM matching_objects
WHERE objects.id = matching_objects.id
AND objects.parent_id = matching_objects.parent_id
Expand Down
15 changes: 15 additions & 0 deletions kinto/core/storage/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,10 +1125,25 @@ def test_deleting_without_tombstone_should_raise_not_found(self):
def test_delete_all_deletes_objects(self):
self.create_object()
self.create_object()

self.storage.delete_all(**self.storage_kw)

count = self.storage.count_all(**self.storage_kw)
self.assertEqual(count, 0)

def test_delete_all_bumps_tombstones_timestamps(self):
self.create_object()
self.create_object()
timestamps_before = {r["last_modified"] for r in self.storage.list_all(**self.storage_kw)}

self.storage.delete_all(**self.storage_kw)

timestamps_after = {
r["last_modified"]
for r in self.storage.list_all(include_deleted=True, **self.storage_kw)
}
self.assertTrue(timestamps_after.isdisjoint(timestamps_before))

def test_delete_all_can_delete_by_parent_id(self):
self.create_object(parent_id="abc", resource_name="c")
self.create_object(parent_id="abc", resource_name="c")
Expand Down

0 comments on commit a661069

Please sign in to comment.