fix: reference child_id instead of parent_id when deleting tags

Co-Authored-By: Jann Stute <46534683+Computerdores@users.noreply.github.com>
This commit is contained in:
Travis Abendshien
2025-01-10 10:25:21 -08:00
parent 17e0522e45
commit 77d957fd33

View File

@@ -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()