diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-08-21 16:38:47 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-08-21 16:38:47 (GMT) |
commit | 6afe85827c209b9d1e76a65ffdb7420b5f46ad3d (patch) | |
tree | 22bc20a3337f66da96a7b90009c3b82fd5b9499a /Modules | |
parent | 8682f578c1c8fd0486c886b001729907a5409a9f (diff) | |
download | cpython-6afe85827c209b9d1e76a65ffdb7420b5f46ad3d.zip cpython-6afe85827c209b9d1e76a65ffdb7420b5f46ad3d.tar.gz cpython-6afe85827c209b9d1e76a65ffdb7420b5f46ad3d.tar.bz2 |
Issue #21718: cursor.description is now available for queries using CTEs
According to PEP 249, cursor.description must be
available for any SELECT statements, such as those
that use CTEs.
Backported from https://github.com/ghaering/pysqlite/commit/f67fa9c898a4713850e16934046f0fe2cba8c44c
Additional test cases added by me.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sqlite/cursor.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 300da28..e1676de 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -646,12 +646,11 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* goto error; } - if (rc == SQLITE_ROW || (rc == SQLITE_DONE && statement_type == STATEMENT_SELECT)) { - if (self->description == Py_None) { - Py_BEGIN_ALLOW_THREADS - numcols = sqlite3_column_count(self->statement->st); - Py_END_ALLOW_THREADS - + if (rc == SQLITE_ROW || rc == SQLITE_DONE) { + Py_BEGIN_ALLOW_THREADS + numcols = sqlite3_column_count(self->statement->st); + Py_END_ALLOW_THREADS + if (self->description == Py_None && numcols > 0) { Py_SETREF(self->description, PyTuple_New(numcols)); if (!self->description) { goto error; |