Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/basalam/backbone_orm/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .repository_abstract import RepositoryAbstract
from .parameters import Parameters
from pydantic import ConfigDict, BaseModel, Field
from pypika import functions
from pypika import functions, Query
from pypika.queries import QueryBuilder


Expand Down Expand Up @@ -45,9 +45,14 @@ async def make(

if aggregate_query is None:
aggregate_query = query.__copy__()
aggregate_query._selects = []
aggregate_query._orderbys = []
aggregate_query = aggregate_query.select(functions.Count('*').as_('total'))
if query._groupbys:
aggregate_query._limit = None
aggregate_query._offset = None
aggregate_query = Query.from_(aggregate_query).select(functions.Count('*').as_('total'))
else:
aggregate_query._selects = []
aggregate_query = aggregate_query.select(functions.Count('*').as_('total'))

aggregations = (await (cls.repo()).execute_and_fetch(query=aggregate_query, params=params))

Expand Down