Skip to content

Commit

Permalink
Fix issue with sqlalchemy select with session.query
Browse files Browse the repository at this point in the history
  • Loading branch information
uriyyo committed Dec 8, 2024
1 parent 3fda91e commit a736e2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fastapi_pagination/ext/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def __init__(self, *_: Any, **__: Any) -> None:
]

Selectable: TypeAlias = Union[Select, TextClause, FromStatement, CompoundSelect]
SelectableOrQuery: TypeAlias = "Union[Selectable, Query[Any]]"


@no_type_check
Expand Down Expand Up @@ -309,10 +310,10 @@ def paginate(
@overload
def paginate(
conn: SyncConn,
query: Selectable,
query: SelectableOrQuery,
params: Optional[AbstractParams] = None,
*,
count_query: Optional[Selectable] = None,
count_query: Optional[SelectableOrQuery] = None,
subquery_count: bool = True,
unwrap_mode: Optional[UnwrapMode] = None,
transformer: Optional[SyncItemsTransformer] = None,
Expand Down Expand Up @@ -445,4 +446,7 @@ def _new_paginate_sign(
bool,
Optional[UnwrapMode],
]:
with suppress(AttributeError):
query = query._statement_20() # type: ignore[attr-defined]

return query, count_query, conn, params, transformer, additional_data, unique, subquery_count, unwrap_mode

0 comments on commit a736e2c

Please sign in to comment.