From b40ac15efc177e88c20b0e692041b7cc2f54110b Mon Sep 17 00:00:00 2001 From: Ivan Kotelnikov Date: Sat, 24 Nov 2018 00:06:01 +0200 Subject: [PATCH] rename param name to fetch --- lib/extras.py | 8 ++++---- tests/test_fast_executemany.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/extras.py b/lib/extras.py index 3e113b06..87d04044 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -1198,7 +1198,7 @@ def execute_batch(cur, sql, argslist, page_size=100): cur.execute(b";".join(sqls)) -def execute_values(cur, sql, argslist, template=None, page_size=100, fetch_result=False): +def execute_values(cur, sql, argslist, template=None, page_size=100, fetch=False): '''Execute a statement using :sql:`VALUES` with a sequence of parameters. :param cur: the cursor to use to execute the query. @@ -1229,7 +1229,7 @@ def execute_values(cur, sql, argslist, template=None, page_size=100, fetch_resul statement. If there are more items the function will execute more than one statement. - :param fetch_result: flag indicating that results of query execution should + :param fetch: flag indicating that results of query execution should be returned. Useful for queries with `RETURNING` clause .. __: https://www.postgresql.org/docs/current/static/queries-values.html @@ -1278,10 +1278,10 @@ def execute_values(cur, sql, argslist, template=None, page_size=100, fetch_resul parts.append(b',') parts[-1:] = post cur.execute(b''.join(parts)) - if fetch_result: + if fetch: result.extend(cur.fetchall()) - if fetch_result: + if fetch: return result diff --git a/tests/test_fast_executemany.py b/tests/test_fast_executemany.py index d760393e..661089a6 100755 --- a/tests/test_fast_executemany.py +++ b/tests/test_fast_executemany.py @@ -234,7 +234,7 @@ class TestExecuteValues(FastExecuteTestMixin, testutils.ConnectingTestCase): result = psycopg2.extras.execute_values(cur, "insert into testfast (id, val) values %s returning id", ((i, i * 10) for i in range(25)), - page_size=10, fetch_many=True) + page_size=10, fetch=True) # result contains all returned pages self.assertEqual([r[0] for r in result], list(range(25)))