@@ -1767,15 +1767,12 @@ public function deleteDocuments(string $collection, array $internalIds, array $p
17671767
17681768 try {
17691769 $ name = $ this ->filter ($ collection );
1770- $ where = [];
17711770
1772- if ($ this ->sharedTables ) {
1773- $ where [] = "_tenant = :_tenant " ;
1774- }
1775-
1776- $ where [] = "_id IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ internalIds ))) . ") " ;
1777-
1778- $ sql = "DELETE FROM {$ this ->getSQLTable ($ name )} WHERE " . \implode (' AND ' , $ where );
1771+ $ sql = "
1772+ DELETE FROM {$ this ->getSQLTable ($ name )}
1773+ WHERE _id IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ internalIds ))) . ")
1774+ {$ this ->getTenantQuery ($ collection )}
1775+ " ;
17791776
17801777 $ sql = $ this ->trigger (Database::EVENT_DOCUMENTS_DELETE , $ sql );
17811778
@@ -1797,11 +1794,8 @@ public function deleteDocuments(string $collection, array $internalIds, array $p
17971794 $ sql = "
17981795 DELETE FROM {$ this ->getSQLTable ($ name . '_perms ' )}
17991796 WHERE _document IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ permissionIds ))) . ")
1800- " ;
1801-
1802- if ($ this ->sharedTables ) {
1803- $ sql .= ' AND _tenant = :_tenant ' ;
1804- }
1797+ {$ this ->getTenantQuery ($ collection )}
1798+ " ;
18051799
18061800 $ sql = $ this ->trigger (Database::EVENT_PERMISSIONS_DELETE , $ sql );
18071801
0 commit comments