]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Add tests on executemany to check the same problem of bug #112
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Oct 2021 23:32:23 +0000 (01:32 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Oct 2021 23:32:23 +0000 (01:32 +0200)
tests/test_cursor.py
tests/test_cursor_async.py

index 1c3fdd24619ece02107b333831dc9cf48b3dd741..eab60206facf4eed9dc54c53b192c4307d466563 100644 (file)
@@ -104,6 +104,15 @@ def test_execute_type_change(conn):
     assert cur.fetchall() == [(1,), (100_000,)]
 
 
+def test_executemany_type_change(conn):
+    conn.execute("create table bug_112 (num integer)")
+    sql = "insert into bug_112 (num) values (%s)"
+    cur = conn.cursor()
+    cur.executemany(sql, [(1,), (100_000,)])
+    cur.execute("select num from bug_112 order by num")
+    assert cur.fetchall() == [(1,), (100_000,)]
+
+
 @pytest.mark.parametrize(
     "query", ["copy testcopy from stdin", "copy testcopy to stdout"]
 )
index 4daab53bef56480050c8982a3875089dd20081d6..3aaa4356049b5f2c17e441d28d3552819b292aaf 100644 (file)
@@ -107,6 +107,15 @@ async def test_execute_type_change(aconn):
     assert (await cur.fetchall()) == [(1,), (100_000,)]
 
 
+async def test_executemany_type_change(aconn):
+    await aconn.execute("create table bug_112 (num integer)")
+    sql = "insert into bug_112 (num) values (%s)"
+    cur = aconn.cursor()
+    await cur.executemany(sql, [(1,), (100_000,)])
+    await cur.execute("select num from bug_112 order by num")
+    assert (await cur.fetchall()) == [(1,), (100_000,)]
+
+
 @pytest.mark.parametrize(
     "query", ["copy testcopy from stdin", "copy testcopy to stdout"]
 )