Fix: Use WHERE instead of HAVING for min_count filter in list_tags()
HAVING requires GROUP BY; count_subq is a correlated scalar subquery, not an aggregate, so PostgreSQL rejects it. WHERE works correctly and the integration tests used SQLite which is permissive about this rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -90,7 +90,7 @@ class TagRepository:
|
||||
if prefix:
|
||||
query = query.where(Tag.name.like(f"{prefix}%"))
|
||||
if min_count > 0:
|
||||
query = query.having(count_subq >= min_count)
|
||||
query = query.where(count_subq >= min_count)
|
||||
|
||||
total_query = select(func.count()).select_from(query.subquery())
|
||||
total_result = await self._session.execute(total_query)
|
||||
|
||||
Reference in New Issue
Block a user