Skip to content

Commit a0586df

Browse files
authored
fix(#338): Query repository list method for custom queries (#379)
fix: query repository list method for custom queries
1 parent 22df9d6 commit a0586df

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

advanced_alchemy/repository/_async.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from sqlalchemy import (
2020
Delete,
2121
Result,
22+
Row,
2223
RowMapping,
2324
Select,
2425
TextClause,
@@ -2184,7 +2185,7 @@ async def _list_and_count_basic(
21842185
instances.append(instance)
21852186
return instances, count
21862187

2187-
async def list(self, statement: Select[Any], **kwargs: Any) -> list[RowMapping]:
2188+
async def list(self, statement: Select[Any], **kwargs: Any) -> list[Row[Any]]:
21882189
"""Get a list of instances, optionally filtered.
21892190
21902191
Args:
@@ -2197,7 +2198,7 @@ async def list(self, statement: Select[Any], **kwargs: Any) -> list[RowMapping]:
21972198
with wrap_sqlalchemy_exception(error_messages=self.error_messages):
21982199
statement = self._filter_statement_by_kwargs(statement, **kwargs)
21992200
result = await self.execute(statement)
2200-
return list(result.scalars())
2201+
return list(result.all())
22012202

22022203
def _filter_statement_by_kwargs(
22032204
self,

advanced_alchemy/repository/_sync.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from sqlalchemy import (
2222
Delete,
2323
Result,
24+
Row,
2425
RowMapping,
2526
Select,
2627
TextClause,
@@ -2181,7 +2182,7 @@ def _list_and_count_basic(
21812182
instances.append(instance)
21822183
return instances, count
21832184

2184-
def list(self, statement: Select[Any], **kwargs: Any) -> list[RowMapping]:
2185+
def list(self, statement: Select[Any], **kwargs: Any) -> list[Row[Any]]:
21852186
"""Get a list of instances, optionally filtered.
21862187
21872188
Args:
@@ -2194,7 +2195,7 @@ def list(self, statement: Select[Any], **kwargs: Any) -> list[RowMapping]:
21942195
with wrap_sqlalchemy_exception(error_messages=self.error_messages):
21952196
statement = self._filter_statement_by_kwargs(statement, **kwargs)
21962197
result = self.execute(statement)
2197-
return list(result.scalars())
2198+
return list(result.all())
21982199

21992200
def _filter_statement_by_kwargs(
22002201
self,

0 commit comments

Comments
 (0)