[Python-checkins] bpo-45041: Restore `sqlite3` executescript behaviour for `SELECT` queries (GH-28509)
pablogsal
webhook-mailer at python.org
Thu Oct 7 05:17:04 EDT 2021
https://github.com/python/cpython/commit/3f2c433da560d7999a52f9fcba4bbd0898848520
commit: 3f2c433da560d7999a52f9fcba4bbd0898848520
branch: main
author: Erlend Egeberg Aasland <erlend.aasland at innova.no>
committer: pablogsal <Pablogsal at gmail.com>
date: 2021-10-07T10:16:45+01:00
summary:
bpo-45041: Restore `sqlite3` executescript behaviour for `SELECT` queries (GH-28509)
* bpo-45041: Restore sqlite3 executescript behaviour for select queries
* Add regression test
files:
M Lib/sqlite3/test/test_regression.py
M Modules/_sqlite/cursor.c
diff --git a/Lib/sqlite3/test/test_regression.py b/Lib/sqlite3/test/test_regression.py
index ff356734860b6..3d71809d9c11c 100644
--- a/Lib/sqlite3/test/test_regression.py
+++ b/Lib/sqlite3/test/test_regression.py
@@ -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()
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 38ccdcf5379d0..ca74a68de4dba 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -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);
}
More information about the Python-checkins
mailing list