Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Fix PostgreSQL error when deleting an empty collection in a protected…
Browse files Browse the repository at this point in the history
… resource (fixes #528)
  • Loading branch information
leplatrem committed Oct 30, 2015
1 parent 639ab9d commit 292cba8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ This document describes changes between each past release.
- Follow redirections in batch subrequests (fixes #511)
- Add a ``readonly`` setting to run the service in read-only mode. (#525)

**Bug fixes**

- Fix PostgreSQL error when deleting an empty collection in a protected
resource (fixes #528)

**Internal changes**

- Switch to SQLAlchemy for smarter connections pools.
Expand Down
3 changes: 3 additions & 0 deletions cliquet/permission/postgresql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ def replace_object_permissions(self, object_id, permissions):
conn.execute(insert_query, placeholders)

def delete_object_permissions(self, *object_id_list):
if len(object_id_list) == 0:
return

query = """
DELETE FROM access_control_entries
WHERE object_id IN %(object_id_list)s;"""
Expand Down
3 changes: 3 additions & 0 deletions cliquet/tests/test_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ def test_delete_object_permissions_remove_all_given_objects_acls(self):
self.assertDictEqual(self.permission.object_permissions(
'/url/a/id/3'), {"create": {"user4"}})

def test_delete_object_permissions_supports_empty_list(self):
self.permission.delete_object_permissions() # Not failing


class MemoryPermissionTest(BaseTestPermission, unittest.TestCase):
backend = memory_backend
Expand Down

0 comments on commit 292cba8

Please sign in to comment.