fix internals not returning the query
This commit is contained in:
parent
d1dd0a3ee0
commit
6055c4ed3b
1 changed files with 4 additions and 1 deletions
|
|
@ -99,12 +99,13 @@ class AsyncSelectPagination(Pagination):
|
||||||
select = select_q.limit(self.per_page).offset(self._query_offset)
|
select = select_q.limit(self.per_page).offset(self._query_offset)
|
||||||
session: AsyncSession = self._query_args["session"]
|
session: AsyncSession = self._query_args["session"]
|
||||||
out = (await session.execute(select)).scalars()
|
out = (await session.execute(select)).scalars()
|
||||||
|
return out
|
||||||
|
|
||||||
async def _query_count(self) -> int:
|
async def _query_count(self) -> int:
|
||||||
select_q: Select = self._query_args["select"]
|
select_q: Select = self._query_args["select"]
|
||||||
sub = select_q.options(lazyload("*")).order_by(None).subquery()
|
sub = select_q.options(lazyload("*")).order_by(None).subquery()
|
||||||
session: AsyncSession = self._query_args["session"]
|
session: AsyncSession = self._query_args["session"]
|
||||||
out = await session.execute(select(func.count()).select_from(sub))
|
out = (await session.execute(select(func.count()).select_from(sub))).scalar()
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
|
@ -140,6 +141,8 @@ class AsyncSelectPagination(Pagination):
|
||||||
|
|
||||||
async def __aiter__(self):
|
async def __aiter__(self):
|
||||||
self.items = await self._query_items()
|
self.items = await self._query_items()
|
||||||
|
if self.items is None:
|
||||||
|
raise RuntimeError('query returned None')
|
||||||
if not self.items and self.page != 1 and self.error_out:
|
if not self.items and self.page != 1 and self.error_out:
|
||||||
raise self.error_out
|
raise self.error_out
|
||||||
if self.has_count:
|
if self.has_count:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue