This repository was archived by the owner on Aug 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -169,16 +169,9 @@ async def iterate(
169169 self , query : ClauseElement
170170 ) -> typing .AsyncGenerator [typing .Any , None ]:
171171 assert self ._connection is not None , "Connection is not acquired"
172- transaction = PostgresTransaction (self )
173- await transaction .start ()
174- try :
175- query , args , result_columns = self ._compile (query )
176- async for row in self ._connection .cursor (query , * args ):
177- yield Record (row , result_columns , self ._dialect )
178- except :
179- transaction .rollback ()
180- else :
181- transaction .commit ()
172+ query , args , result_columns = self ._compile (query )
173+ async for row in self ._connection .cursor (query , * args ):
174+ yield Record (row , result_columns , self ._dialect )
182175
183176 def transaction (self ) -> TransactionBackend :
184177 return PostgresTransaction (connection = self )
Original file line number Diff line number Diff line change @@ -219,11 +219,12 @@ async def execute_many(
219219 async def iterate (
220220 self , query : typing .Union [ClauseElement , str ], values : dict = None
221221 ) -> typing .AsyncGenerator [typing .Any , None ]:
222- async with self ._query_lock :
223- async for record in self ._connection .iterate (
224- self ._build_query (query , values )
225- ):
226- yield record
222+ async with self .transaction ():
223+ async with self ._query_lock :
224+ async for record in self ._connection .iterate (
225+ self ._build_query (query , values )
226+ ):
227+ yield record
227228
228229 def transaction (self , * , force_rollback : bool = False ) -> "Transaction" :
229230 return Transaction (self , force_rollback )
You can’t perform that action at this time.
0 commit comments