mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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 f67fa9c898
Additional test cases added by me.
This commit is contained in:
parent
8682f578c1
commit
6afe85827c
3 changed files with 48 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue