From ef212e0b83c9baf1d168a72596a19594d080953e Mon Sep 17 00:00:00 2001 From: Yurii Karabas <1998uriyyo@gmail.com> Date: Tue, 19 Mar 2024 22:12:55 +0200 Subject: [PATCH] Return back paginate_query function (#1093) --- fastapi_pagination/ext/sqlalchemy.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fastapi_pagination/ext/sqlalchemy.py b/fastapi_pagination/ext/sqlalchemy.py index 296db8ec..695dacba 100644 --- a/fastapi_pagination/ext/sqlalchemy.py +++ b/fastapi_pagination/ext/sqlalchemy.py @@ -5,6 +5,7 @@ "create_count_query_from_text", "create_paginate_query", "create_count_query", + "paginate_query", "paginate", "Selectable", ] @@ -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 @@ -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))