Skip to content

Commit 7d98f12

Browse files
authored
fix(perf): Update list and count (#487)
Return empty list when count = 0
1 parent 8be220d commit 7d98f12

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

advanced_alchemy/repository/_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,8 @@ async def _list_and_count_basic(
17071707
),
17081708
)
17091709
count = count_result.scalar_one()
1710+
if count == 0:
1711+
return [], 0
17101712
result = await self._execute(statement, uniquify=loader_options_have_wildcard)
17111713
instances: list[ModelT] = []
17121714
for (instance,) in result:

advanced_alchemy/repository/_sync.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,8 @@ def _list_and_count_basic(
17061706
),
17071707
)
17081708
count = count_result.scalar_one()
1709+
if count == 0:
1710+
return [], 0
17091711
result = self._execute(statement, uniquify=loader_options_have_wildcard)
17101712
instances: list[ModelT] = []
17111713
for (instance,) in result:

0 commit comments

Comments
 (0)