]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: add xfailing test for rowcount in pipelined executemany
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 28 Mar 2022 18:03:55 +0000 (20:03 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 2 Apr 2022 23:23:22 +0000 (01:23 +0200)
tests/test_pipeline.py

index 090fb11f1680946f226b6a4b42c35b33ddd4239c..49a1bca17332d46538efdd2112276604b0cdb2ed 100644 (file)
@@ -168,18 +168,31 @@ def test_executemany(conn):
             "insert into execmanypipeline(num) values (%s) returning id",
             [(10,), (20,)],
         )
-
-        # TODO: this is a bug, it should be 2. It is caused by reentering the
-        # pipeline mode in executemany(). Leaving it here to monitor how it
-        # changes. The snag is in Cursor._set_results_from_pipeline()
-        assert cur.rowcount == 0
-
         assert cur.fetchone() == (1,)
         assert cur.nextset()
         assert cur.fetchone() == (2,)
         assert cur.nextset() is None
 
 
+@pytest.mark.xfail
+def test_executemany_rowcount(conn):
+    conn.autocommit = True
+    conn.execute(
+        "create temp table test_executemany_rowcount ("
+        " id serial primary key, num integer)"
+    )
+    with conn.pipeline(), conn.cursor() as cur:
+        cur.executemany(
+            "insert into test_executemany_rowcount (num) values (%s) returning id",
+            [(10,), (20,)],
+        )
+
+        # TODO: this is a bug. It is caused by reentering the pipeline mode in
+        # executemany(). Leaving it here to monitor how it changes. The snag is
+        # in Cursor._set_results_from_pipeline()
+        assert cur.rowcount == 2
+
+
 def test_prepared(conn):
     conn.autocommit = True
     with conn.pipeline():