From: Daniele Varrazzo Date: Wed, 13 Oct 2021 23:32:23 +0000 (+0200) Subject: Add tests on executemany to check the same problem of bug #112 X-Git-Tag: 3.0.1~1^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d3e990777b06bcde10f1a71843e86388f5f38ab;p=thirdparty%2Fpsycopg.git Add tests on executemany to check the same problem of bug #112 --- diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 1c3fdd246..eab60206f 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -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"] ) diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index 4daab53be..3aaa43560 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -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"] )