cursor.description returns non-pep249 complaint value '()' #104
Closed
Description
Per pep 249, cursor.description is to be a sequence of 7-item tuples describing the columns in a result set. If the operation does not return rows, it is required to be None:
This attribute will be None for operations that do not return rows or if the cursor has not had an operation invoked via the .execute*() method yet.
Per the test case below, a simple "DELETE" SQL statement is returning an empty tuple, rather than None:
from pysqlite2 import dbapi2
print dbapi2.version_info
conn = dbapi2.connect(":memory:")
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE plain_pk (
id INTEGER NOT NULL,
data VARCHAR(50),
PRIMARY KEY (id)
)
""")
cursor.executemany("""
INSERT INTO plain_pk (id, data) VALUES (?, ?)
""", ((1, 'd1'), (2, 'd2'), (3, 'd3')))
cursor.execute("""
DELETE FROM plain_pk WHERE plain_pk.id = ?
""", (2,))
assert cursor.description is None, cursor.description
output:
(2, 8, 2)
Traceback (most recent call last):
File "test.py", line 24, in <module>
assert cursor.description is None, cursor.description
AssertionError: ()
this is a behavioral regression which breaks downstream projects such as SQLAlchemy.
Metadata
Assignees
Labels
No labels