Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Nov 14, 2024
1 parent 0b6a1cb commit 5607e70
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions papermerge/core/features/nodes/db/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,17 @@ def delete_nodes(
orm.Node.id.in_(all_ids_to_be_deleted), orm.Node.user_id == user_id
)

# This second delete statement - is extra hack for Sqlite DB
# For some reason, the (Polymorphic?) cascading does not work
# in Sqlite, so here it is required to manually delete associated
# custom fields
sqlite_hack_stmt = delete(orm.CustomFieldValue).where(
orm.CustomFieldValue.document_id.in_(all_ids_to_be_deleted)
)

try:
db_session.execute(stmt)
db_session.execute(sqlite_hack_stmt)
db_session.commit()
except Exception as e:
error = schema.Error(messages=[str(e)])
Expand Down

0 comments on commit 5607e70

Please sign in to comment.