rename param name to fetch

This commit is contained in:
Ivan Kotelnikov 2018-11-24 00:06:01 +02:00
parent e2b99d3a8e
commit b40ac15efc
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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)))