Skip to content

Commit

Permalink
fix: changed joins to outerjoins and added missing outerjoin
Browse files Browse the repository at this point in the history
  • Loading branch information
Computerdores committed Nov 28, 2024
1 parent 29c899a commit 1f6b437
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tagstudio/src/core/library/alchemy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ def search_library(

if search.ast:
statement = (
statement.join(Entry.tag_box_fields)
.join(TagBoxField.tags)
statement.outerjoin(Entry.tag_box_fields)
.outerjoin(TagBoxField.tags)
.outerjoin(TagAlias)
.where(SQLBoolExpressionBuilder().visit(search.ast))
)
elif search.tag:
Expand Down
10 changes: 3 additions & 7 deletions tagstudio/src/core/library/alchemy/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,16 @@ def visit_constraint(self, node: Constraint) -> ColumnExpressionArgument:
elif node.type == ConstraintType.TagID:
return Tag.id == int(node.value)
elif node.type == ConstraintType.Path:
return Entry.path.ilike(node.value.replace("*", "%")) # TODO TSQLANG this is broken
return Entry.path.ilike(node.value.replace("*", "%"))
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)
) # TODO audio doesn't work on mp3 files (might be my library)
return Entry.suffix.in_(map(lambda x: x.replace(".", ""), extensions))
elif node.type == ConstraintType.FileType:
return Entry.suffix.ilike(
node.value
) # TODO TSQLANG this is broken for mp3, but works for png (might be my library)
return Entry.suffix.ilike(node.value)

raise NotImplementedError("This type of constraint is not implemented yet")

Expand Down

0 comments on commit 1f6b437

Please sign in to comment.