From 77d957fd337bf325dbed173f543ebaad6ea885e0 Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Fri, 10 Jan 2025 10:25:21 -0800 Subject: [PATCH] fix: reference `child_id` instead of `parent_id` when deleting tags Co-Authored-By: Jann Stute <46534683+Computerdores@users.noreply.github.com> --- tagstudio/src/core/library/alchemy/library.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tagstudio/src/core/library/alchemy/library.py b/tagstudio/src/core/library/alchemy/library.py index eeed607f..717a8f9a 100644 --- a/tagstudio/src/core/library/alchemy/library.py +++ b/tagstudio/src/core/library/alchemy/library.py @@ -683,8 +683,8 @@ class Library: def remove_tag(self, tag: Tag): with Session(self.engine, expire_on_commit=False) as session: try: - parent_tags = session.scalars( - select(TagParent).where(TagParent.parent_id == tag.id) + child_tags = session.scalars( + select(TagParent).where(TagParent.child_id == tag.id) ).all() tags_query = select(Tag).options( selectinload(Tag.parent_tags), selectinload(Tag.aliases) @@ -695,9 +695,9 @@ class Library: for alias in aliases or []: session.delete(alias) - for parent_tag in parent_tags or []: - session.delete(parent_tag) - session.expunge(parent_tag) + for child_tag in child_tags or []: + session.delete(child_tag) + session.expunge(child_tag) session.delete(tag) session.commit()