From 4aa65da292053efa590a90235d9c235730aafcc2 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Fri, 18 Oct 2024 08:37:44 -0700 Subject: [PATCH] Fixups --- asyncpg/prepared_stmt.py | 7 ++++++- tests/test_prepare.py | 17 +++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/asyncpg/prepared_stmt.py b/asyncpg/prepared_stmt.py index 45b238cb..d66a5ad3 100644 --- a/asyncpg/prepared_stmt.py +++ b/asyncpg/prepared_stmt.py @@ -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 diff --git a/tests/test_prepare.py b/tests/test_prepare.py index 348c5afc..661021bd 100644 --- a/tests/test_prepare.py +++ b/tests/test_prepare.py @@ -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()