Skip to content

Commit 1ed09e0

Browse files
takutiggreg
authored andcommitted
Set meaningless 5 items to None in Cursor.description
According to PEP249: > The first two items (name and type_code) are mandatory, the other five > are optional and are set to None if no meaningful values can be > provided. https://www.python.org/dev/peps/pep-0249/#description
1 parent 2caf04b commit 1ed09e0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

integration_tests/test_dbapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_select_query(presto_connection):
5656
row = rows[0]
5757
assert row[0] == 'test'
5858
assert row[2] == fixtures.PRESTO_VERSION
59-
columns = dict(cur.description)
59+
columns = dict([desc[:2] for desc in cur.description])
6060
assert columns['node_id'] == 'varchar'
6161
assert columns['http_uri'] == 'varchar'
6262
assert columns['node_version'] == 'varchar'

prestodb/dbapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ def description(self):
210210
if self._query.columns is None:
211211
return None
212212

213+
# [ (name, type_code, display_size, internal_size, precision, scale, null_ok) ]
213214
return [
214-
(col['name'], col['type']) for col in self._query.columns
215+
(col['name'], col['type'], None, None, None, None, None) for col in self._query.columns
215216
]
216217

217218
@property

0 commit comments

Comments
 (0)