Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename pysqlite_check_remaining_sql to lstrip_sql
  • Loading branch information
erlend-aasland committed Jun 8, 2022
commit 7fcca68a093a53ef8cc10dc3cd318f30596ad334
7 changes: 6 additions & 1 deletion Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,14 @@ def test_rowcount_update_returning(self):
self.assertEqual(self.cu.fetchone()[0], 1)
self.assertEqual(self.cu.rowcount, 1)

@unittest.skip("")
def test_rowcount_prefixed_with_comment(self):
# gh-79579: rowcount is updated even if query is prefixed with comments
self.cu.execute("/* foo */ insert into test(name) values (?)", ('foo',))
#self.cu.execute("/* foo */ insert into test(name) values (?)", ('foo',))
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
self.cu.execute("""
-- foo
insert into test(name) values ('foo')
""")
self.assertEqual(self.cu.rowcount, 1)
self.cu.execute("/* bar */ update test set name='bar' where name='foo'")
self.assertEqual(self.cu.rowcount, 2)
Expand Down
6 changes: 3 additions & 3 deletions Modules/_sqlite/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "util.h"

/* prototypes */
static const char *pysqlite_check_remaining_sql(const char *sql);
static const char *lstrip_sql(const char *sql);

typedef enum {
LINECOMMENT_1,
Expand Down Expand Up @@ -73,7 +73,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
return NULL;
}

if (pysqlite_check_remaining_sql(tail)) {
if (lstrip_sql(tail)) {
PyErr_SetString(connection->ProgrammingError,
"You can only execute one statement at a time.");
goto error;
Expand Down Expand Up @@ -147,7 +147,7 @@ stmt_traverse(pysqlite_Statement *self, visitproc visit, void *arg)
* Returns 1 if there is more left than should be. 0 if ok.
*/
static const char *
pysqlite_check_remaining_sql(const char *sql)
lstrip_sql(const char *sql)
{
const char *pos = sql;

Expand Down