Skip to content

Commit

Permalink
bpo-45041: Restore sqlite3 executescript behaviour for SELECT que…
Browse files Browse the repository at this point in the history
…ries (GH-28509)

* bpo-45041: Restore sqlite3 executescript behaviour for select queries

* Add regression test
  • Loading branch information
Erlend Egeberg Aasland committed Oct 7, 2021
1 parent dd02a69 commit 3f2c433
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Lib/sqlite3/test/test_regression.py
Expand Up @@ -475,6 +475,17 @@ def dup(v):
con.execute("drop table t")
con.commit()

def test_executescript_step_through_select(self):
with managed_connect(":memory:", in_mem=True) as con:
values = [(v,) for v in range(5)]
with con:
con.execute("create table t(t)")
con.executemany("insert into t values(?)", values)
steps = []
con.create_function("step", 1, lambda x: steps.append((x,)))
con.executescript("select step(t) from t")
self.assertEqual(steps, values)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion Modules/_sqlite/cursor.c
Expand Up @@ -760,7 +760,7 @@ pysqlite_cursor_executescript_impl(pysqlite_Cursor *self,
&tail);
if (rc == SQLITE_OK) {
do {
(void)sqlite3_step(stmt);
rc = sqlite3_step(stmt);
} while (rc == SQLITE_ROW);
rc = sqlite3_finalize(stmt);
}
Expand Down

0 comments on commit 3f2c433

Please sign in to comment.