Skip to content

Commit

Permalink
Return back paginate_query function (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
uriyyo authored Mar 19, 2024
1 parent 0fe686a commit ef212e0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fastapi_pagination/ext/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"create_count_query_from_text",
"create_paginate_query",
"create_count_query",
"paginate_query",
"paginate",
"Selectable",
]
Expand All @@ -17,7 +18,7 @@
from sqlalchemy.exc import InvalidRequestError
from sqlalchemy.orm import Query, Session, noload, scoped_session
from sqlalchemy.sql.elements import TextClause
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias, deprecated

from ..api import apply_items_transformer, create_page
from ..bases import AbstractPage, AbstractParams, is_cursor
Expand Down Expand Up @@ -79,6 +80,15 @@ def create_count_query_from_text(query: str) -> str:
return f"SELECT count(*) FROM ({query}) AS __count_query__" # noqa: S608


@deprecated(
"fastapi_pagination.ext.sqlalchemy.paginate_query function is deprecated, "
"please use fastapi_pagination.ext.sqlalchemy.create_paginate_query function instead"
"This function will be removed in the next major release (0.13.0).",
)
def paginate_query(query: Select, params: AbstractParams) -> Select:
return create_paginate_query(query, params) # type: ignore[return-value]


def create_paginate_query(query: Selectable, params: AbstractParams) -> Selectable:
if isinstance(query, TextClause):
return text(create_paginate_query_from_text(query.text, params))
Expand Down

0 comments on commit ef212e0

Please sign in to comment.