We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 476bc79 commit b090c10Copy full SHA for b090c10
1 file changed
fastapi_amis_admin/crud/_sqlalchemy.py
@@ -513,9 +513,9 @@ async def route(
513
if data.filters:
514
sel = sel.filter(*self.calc_filter_clause(data.filters))
515
if paginator.show_total:
516
- data.total = await self.db.async_scalar(
517
- select(func.count("*")).select_from(sel.with_only_columns(self.pk).subquery())
518
- )
+ data.total = await self.db.async_scalar(sel.with_only_columns(func.count("*")))
+ if data.total == 0:
+ return BaseApiOut(data=data)
519
orderBy = self._calc_ordering(paginator.orderBy, paginator.orderDir)
520
if orderBy:
521
sel = sel.order_by(*orderBy)
0 commit comments