File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
src/strawberry_sqlalchemy_mapper Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change
1
+ Release type: patch
2
+
3
+ Make sure async session is still open when we call .all()
Original file line number Diff line number Diff line change @@ -45,13 +45,13 @@ def __init__(
45
45
"One of bind or async_bind_factory must be set for loader to function properly."
46
46
)
47
47
48
- async def _scalars (self , * args , ** kwargs ):
48
+ async def _scalars_all (self , * args , ** kwargs ):
49
49
if self ._async_bind_factory :
50
50
async with self ._async_bind_factory () as bind :
51
- return await bind .scalars (* args , ** kwargs )
51
+ return ( await bind .scalars (* args , ** kwargs )). all ( )
52
52
else :
53
53
assert self ._bind is not None
54
- return self ._bind .scalars (* args , ** kwargs )
54
+ return self ._bind .scalars (* args , ** kwargs ). all ()
55
55
56
56
def loader_for (self , relationship : RelationshipProperty ) -> DataLoader :
57
57
"""
@@ -70,7 +70,7 @@ async def load_fn(keys: List[Tuple]) -> List[Any]:
70
70
)
71
71
if relationship .order_by :
72
72
query = query .order_by (* relationship .order_by )
73
- rows = ( await self ._scalars (query )). all ( )
73
+ rows = await self ._scalars_all (query )
74
74
75
75
def group_by_remote_key (row : Any ) -> Tuple :
76
76
return tuple (
You can’t perform that action at this time.
0 commit comments