|
|
@@ -258,7 +258,7 @@ class PostgresCollectionsHandler(Handler):
|
|
|
user_update_query = f"""
|
|
|
UPDATE {self._get_table_name("users")}
|
|
|
SET collection_ids = array_remove(collection_ids, $1)
|
|
|
- WHERE $1 = ANY(collection_ids)
|
|
|
+ WHERE collection_ids @> ARRAY[$1]::uuid[]
|
|
|
"""
|
|
|
logger.info(f"Deleting collection {collection_id} from users")
|
|
|
await self.connection_manager.execute_query(
|
|
|
@@ -271,7 +271,7 @@ class PostgresCollectionsHandler(Handler):
|
|
|
WITH updated AS (
|
|
|
UPDATE {self._get_table_name("documents")}
|
|
|
SET collection_ids = array_remove(collection_ids, $1)
|
|
|
- WHERE $1 = ANY(collection_ids)
|
|
|
+ WHERE collection_ids @> ARRAY[$1]::uuid[]
|
|
|
RETURNING 1
|
|
|
)
|
|
|
SELECT COUNT(*) AS affected_rows FROM updated
|
|
|
@@ -468,7 +468,7 @@ class PostgresCollectionsHandler(Handler):
|
|
|
assign_query = f"""
|
|
|
UPDATE {self._get_table_name("documents")}
|
|
|
SET collection_ids = array_append(collection_ids, $1)
|
|
|
- WHERE id = $2 AND NOT ($1 = ANY(collection_ids))
|
|
|
+ WHERE id = $2 AND NOT (collection_ids @> ARRAY[$1]::uuid[])
|
|
|
RETURNING id
|
|
|
"""
|
|
|
result = await self.connection_manager.fetchrow_query(
|
|
|
@@ -520,7 +520,7 @@ class PostgresCollectionsHandler(Handler):
|
|
|
query = f"""
|
|
|
UPDATE {self._get_table_name("documents")}
|
|
|
SET collection_ids = array_remove(collection_ids, $1)
|
|
|
- WHERE id = $2 AND $1 = ANY(collection_ids)
|
|
|
+ WHERE id = $2 AND collection_ids @> ARRAY[$1]::uuid[]
|
|
|
RETURNING id
|
|
|
"""
|
|
|
result = await self.connection_manager.fetchrow_query(
|