]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Add test to reproduce bug #112
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Oct 2021 21:41:26 +0000 (23:41 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Oct 2021 21:49:36 +0000 (23:49 +0200)
Our first bug!

tests/test_cursor.py
tests/test_cursor_async.py

index b6abecc463bd992b7d2fba7e96a7e94cff4615bb..1c3fdd24619ece02107b333831dc9cf48b3dd741 100644 (file)
@@ -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"]
 )
index 6e1fa5d865b3e9931ac9dba9a0f103b8b60b2155..4daab53bef56480050c8982a3875089dd20081d6 100644 (file)
@@ -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"]
 )