In the conditions illustrated by the test, i.e. with some statements
already prepared and a multiple statements query containing a DROP, the
check for multiple statements wouldn't have been triggered, and the
query would have eventually been asked for preparation, failing because
containing multiple statements.
Clear the internal state and prepare a command to clear the state of
the server.
"""
+ self._counts.clear()
if self._names:
self._names.clear()
self._maint_commands.clear()
assert res == [0] * 10
+def test_no_prepare_multi_with_drop(conn):
+ conn.execute("select 1", prepare=True)
+
+ for i in range(10):
+ conn.execute("drop table if exists noprep; create table noprep()")
+
+ cur = conn.execute("select count(*) from pg_prepared_statements")
+ assert cur.fetchone() == (0,)
+
+
def test_no_prepare_error(conn):
conn.autocommit = True
for i in range(10):