Revert "fix: Entries without Tags are now searchable"

This reverts commit 19b40af7480b0c068b81b642b51536a9ec96d030.
This commit is contained in:
Jann Stute
2024-11-28 00:27:10 +01:00
parent a636864ed0
commit e2e378f19b
2 changed files with 9 additions and 5 deletions

View File

@@ -420,8 +420,8 @@ class Library:
if search.ast:
statement = (
statement.outerjoin(Entry.tag_box_fields)
.outerjoin(TagBoxField.tags)
statement.join(Entry.tag_box_fields)
.join(TagBoxField.tags)
.where(SQLBoolExpressionBuilder().visit(search.ast))
)
elif search.tag:

View File

@@ -29,16 +29,20 @@ class SQLBoolExpressionBuilder(BaseVisitor):
elif node.type == ConstraintType.TagID:
return Tag.id == int(node.value)
elif node.type == ConstraintType.Path:
return Entry.path.ilike(node.value.replace("*", "%"))
return Entry.path.ilike(node.value.replace("*", "%")) # TODO TSQLANG this is broken
elif node.type == ConstraintType.MediaType:
extensions: set[str] = set[str]()
for media_cat in MediaCategories.ALL_CATEGORIES:
if node.value == media_cat.name:
extensions = extensions | media_cat.extensions
break
return Entry.suffix.in_(map(lambda x: x.replace(".", ""), extensions))
return Entry.suffix.in_(
map(lambda x: x.replace(".", ""), extensions)
) # TODO audio doesn't work on mp3 files (might be my library)
elif node.type == ConstraintType.FileType:
return Entry.suffix.ilike(node.value)
return Entry.suffix.ilike(
node.value
) # TODO TSQLANG this is broken for mp3, but works for png (might be my library)
raise NotImplementedError("This type of constraint is not implemented yet")