Skip to content

Commit

Permalink
fixed pagination for prefiltered selects
Browse files Browse the repository at this point in the history
  • Loading branch information
Arfey committed Apr 5, 2024
1 parent aa3d548 commit f9494ca
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions aiohttp_admin2/resources/postgres_resource/postgres_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,22 @@ async def get_list(
res.append(self._row_to_instance(r, res))

if cursor is None:
count: int = await self._execute_scalar(
conn,
sa.select(func.count()).select_from(query)
)
if filters:
count: int = await self._execute_scalar(
conn,
self.apply_filters(
query=(
sa.select(func.count(self._primary_key))
.select_from(self.get_list_select())
),
filters=filters,
)
)
else:
count: int = await self._execute_scalar(
conn,
sa.select(func.count()).select_from(self.get_list_select())
)
return self.create_paginator(
instances=res,
limit=limit,
Expand Down

0 comments on commit f9494ca

Please sign in to comment.