5959from sqlalchemy import func , literal_column
6060from sqlalchemy .dialects .postgresql import BOOLEAN , INTEGER
6161from sqlalchemy .dialects .postgresql import insert as pg_insert
62- from sqlalchemy .sql import and_
62+ from sqlalchemy .sql import ColumnElement , CompoundSelect , Select , and_
6363from tenacity import TryAgain
6464from tenacity .asyncio import AsyncRetrying
6565from tenacity .retry import retry_if_exception_type
@@ -540,14 +540,7 @@ async def list_projects( # pylint: disable=too-many-arguments,too-many-statemen
540540 # Attributes Filters
541541 ###
542542
543- attributes_filters = []
544- if filter_tag_ids_list :
545- attributes_filters .append (
546- sa .func .coalesce (
547- project_tags_subquery .c .tags ,
548- sa .cast (sa .text ("'{}'" ), sa .ARRAY (sa .Integer )),
549- ).op ("@>" )(filter_tag_ids_list )
550- )
543+ attributes_filters : list [ColumnElement ] = []
551544 if filter_by_project_type is not None :
552545 attributes_filters .append (
553546 projects .c .type == filter_by_project_type .value
@@ -577,7 +570,13 @@ async def list_projects( # pylint: disable=too-many-arguments,too-many-statemen
577570 | (projects .c .uuid .ilike (f"%{ filter_by_text } %" ))
578571 | (users .c .name .ilike (f"%{ filter_by_text } %" ))
579572 )
580-
573+ if filter_tag_ids_list :
574+ attributes_filters .append (
575+ sa .func .coalesce (
576+ project_tags_subquery .c .tags ,
577+ sa .cast (sa .text ("'{}'" ), sa .ARRAY (sa .Integer )),
578+ ).op ("@>" )(filter_tag_ids_list )
579+ )
581580 if folder_query .folder_scope is not FolderScope .ALL :
582581 if folder_query .folder_scope == FolderScope .SPECIFIC :
583582 attributes_filters .append (
@@ -591,7 +590,7 @@ async def list_projects( # pylint: disable=too-many-arguments,too-many-statemen
591590 # Combined
592591 ###
593592
594- combined_query = None
593+ combined_query : CompoundSelect | Select | None = None
595594 if (
596595 private_workspace_query is not None
597596 and shared_workspace_query is not None
0 commit comments