Skip to content

Commit

Permalink
Check cursor _query is None
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarar authored and hashhar committed Nov 3, 2023
1 parent e4249f4 commit f99ef24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/unit/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,9 @@ def test_hostname_parsing():
assert only_hostname_with_path.host == "mytrinoserver.domain/some_path"
assert only_hostname_with_path.port == 8080
assert only_hostname_with_path.http_scheme == constants.HTTP


def test_description_is_none_when_cursor_is_not_executed():
connection = Connection("sample_trino_cluster:443")
cursor = connection.cursor()
assert hasattr(cursor, 'description')
2 changes: 1 addition & 1 deletion trino/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def update_type(self):

@property
def description(self) -> List[ColumnDescription]:
if self._query.columns is None:
if self._query is None or self._query.columns is None:
return None

# [ (name, type_code, display_size, internal_size, precision, scale, null_ok) ]
Expand Down

0 comments on commit f99ef24

Please sign in to comment.