From d708e07e53198d5eb1dab4e1ab9be14e88c66e43 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 13 Oct 2021 23:41:26 +0200 Subject: [PATCH] Add test to reproduce bug #112 Our first bug! --- tests/test_cursor.py | 11 +++++++++++ tests/test_cursor_async.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/test_cursor.py b/tests/test_cursor.py index b6abecc46..1c3fdd246 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -93,6 +93,17 @@ def test_execute_empty_query(conn, query): cur.fetchone() +def test_execute_type_change(conn): + # issue #112 + conn.execute("create table bug_112 (num integer)") + sql = "insert into bug_112 (num) values (%s)" + cur = conn.cursor() + cur.execute(sql, (1,)) + cur.execute(sql, (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 6e1fa5d86..4daab53be 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -96,6 +96,17 @@ async def test_execute_empty_query(aconn, query): await cur.fetchone() +async def test_execute_type_change(aconn): + # issue #112 + await aconn.execute("create table bug_112 (num integer)") + sql = "insert into bug_112 (num) values (%s)" + cur = aconn.cursor() + await cur.execute(sql, (1,)) + await cur.execute(sql, (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"] ) -- 2.47.2