|
5 | 5 | "create_count_query_from_text", |
6 | 6 | "create_paginate_query", |
7 | 7 | "create_count_query", |
| 8 | + "paginate_query", |
8 | 9 | "paginate", |
9 | 10 | "Selectable", |
10 | 11 | ] |
|
17 | 18 | from sqlalchemy.exc import InvalidRequestError |
18 | 19 | from sqlalchemy.orm import Query, Session, noload, scoped_session |
19 | 20 | from sqlalchemy.sql.elements import TextClause |
20 | | -from typing_extensions import TypeAlias |
| 21 | +from typing_extensions import TypeAlias, deprecated |
21 | 22 |
|
22 | 23 | from ..api import apply_items_transformer, create_page |
23 | 24 | from ..bases import AbstractPage, AbstractParams, is_cursor |
@@ -79,6 +80,15 @@ def create_count_query_from_text(query: str) -> str: |
79 | 80 | return f"SELECT count(*) FROM ({query}) AS __count_query__" # noqa: S608 |
80 | 81 |
|
81 | 82 |
|
| 83 | +@deprecated( |
| 84 | + "fastapi_pagination.ext.sqlalchemy.paginate_query function is deprecated, " |
| 85 | + "please use fastapi_pagination.ext.sqlalchemy.create_paginate_query function instead" |
| 86 | + "This function will be removed in the next major release (0.13.0).", |
| 87 | +) |
| 88 | +def paginate_query(query: Select, params: AbstractParams) -> Select: |
| 89 | + return create_paginate_query(query, params) # type: ignore[return-value] |
| 90 | + |
| 91 | + |
82 | 92 | def create_paginate_query(query: Selectable, params: AbstractParams) -> Selectable: |
83 | 93 | if isinstance(query, TextClause): |
84 | 94 | return text(create_paginate_query_from_text(query.text, params)) |
|
0 commit comments