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 07412d0 commit aa3d548
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions aiohttp_admin2/resources/postgres_resource/postgres_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,10 @@ async def get_list(
res.append(self._row_to_instance(r, res))

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

0 comments on commit aa3d548

Please sign in to comment.