Skip to content

Commit 4c019ca

Browse files
committed
fix: remove unnecessary joins in search
1 parent 5a4ba68 commit 4c019ca

File tree

2 files changed

+0
-23
lines changed

2 files changed

+0
-23
lines changed

tagstudio/src/core/library/alchemy/library.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,19 +585,15 @@ def search_library(
585585
elif extensions:
586586
statement = statement.where(Entry.suffix.in_(extensions))
587587

588-
statement = statement.options(
589588
selectinload(Entry.text_fields),
590589
selectinload(Entry.datetime_fields),
591-
selectinload(Entry.tags).options(
592590
selectinload(Tag.aliases), selectinload(Tag.parent_tags)
593591
),
594592
)
595593

596594
statement = statement.distinct(Entry.id)
597-
598595
query_count = select(func.count()).select_from(statement.alias("entries"))
599596
count_all: int = session.execute(query_count).scalar()
600-
601597
statement = statement.limit(search.limit).offset(search.offset)
602598

603599
logger.info(

tagstudio/tests/test_library.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,6 @@ def test_tag_self_parent(library, generate_tag):
101101
assert len(tag.parent_ids) == 0
102102

103103

104-
def test_library_search(library, generate_tag, entry_full):
105-
assert library.entries_count == 2
106-
tag = list(entry_full.tags)[0]
107-
108-
results = library.search_library(
109-
FilterState.from_tag_name(tag.name),
110-
)
111-
112-
assert results.total_count == 1
113-
assert len(results) == 1
114-
115-
entry = results[0]
116-
assert {x.name for x in entry.tags} == {
117-
"foo",
118-
}
119-
120-
assert entry.tags
121-
122-
123104
def test_tag_search(library):
124105
tag = library.tags[0]
125106

0 commit comments

Comments
 (0)