Skip to content

Commit

Permalink
Fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
elprans committed Oct 18, 2024
1 parent cc891e3 commit 4aa65da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 6 additions & 1 deletion asyncpg/prepared_stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ async def executemany(self, args, *, timeout: float=None):
"""
return await self.__do_execute(
lambda protocol: protocol.bind_execute_many(
self._state, args, '', timeout))
self._state,
args,
portal_name='',
timeout=timeout,
return_rows=False,
))

async def __do_execute(self, executor):
protocol = self._connection._protocol
Expand Down
17 changes: 11 additions & 6 deletions tests/test_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,15 @@ async def test_prepare_explicitly_named(self):
await self.con.prepare('select 1', name='foobar')

async def test_prepare_fetchmany(self):
await self.con.execute('CREATE TABLE mytab (a int, b text)')
tr = self.con.transaction()
await tr.start()
try:
await self.con.execute('CREATE TABLE fetchmany (a int, b text)')

stmt = await self.con.prepare(
'INSERT INTO mytab (a, b) VALUES ($1, $2) RETURNING a, b'
)
result = await stmt.fetchmany([(1, 'a'), (2, 'b'), (3, 'c')])
self.assertEqual(result, [(1, 'a'), (2, 'b'), (3, 'c')])
stmt = await self.con.prepare(
'INSERT INTO fetchmany (a, b) VALUES ($1, $2) RETURNING a, b'
)
result = await stmt.fetchmany([(1, 'a'), (2, 'b'), (3, 'c')])
self.assertEqual(result, [(1, 'a'), (2, 'b'), (3, 'c')])
finally:
await tr.rollback()

0 comments on commit 4aa65da

Please sign in to comment.