mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 23:59:10 +00:00
fix: search_library now correctly returns the number of *unique* entries
This commit is contained in:
@@ -18,6 +18,7 @@ from sqlalchemy import (
|
||||
exists,
|
||||
func,
|
||||
or_,
|
||||
distinct,
|
||||
select,
|
||||
update,
|
||||
)
|
||||
@@ -474,9 +475,10 @@ class Library:
|
||||
.options(selectinload(Tag.aliases), selectinload(Tag.subtags)),
|
||||
)
|
||||
|
||||
query_count = select(func.count()).select_from(
|
||||
statement.alias("entries")
|
||||
) # TODO this should count the number of *unique* results
|
||||
aliased_statement = statement.alias("entries")
|
||||
query_count = select(func.count(distinct(aliased_statement.c.id))).select_from(
|
||||
aliased_statement
|
||||
)
|
||||
count_all: int = session.execute(query_count).scalar()
|
||||
|
||||
statement = statement.limit(search.limit).offset(search.offset)
|
||||
|
||||
Reference in New Issue
Block a user