Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Few fixes in DBAPI #1085

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions google/cloud/spanner_dbapi/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,11 @@ def _release_session(self):

The session will be returned into the sessions pool.
"""
if self._session is None:
return
if self.database is None:
raise ValueError("Database needs to be passed for this operation")
if self._session is not None:
self.database._pool.put(self._session)
self.database._pool.put(self._session)
self._session = None

def transaction_checkout(self):
Expand Down
8 changes: 7 additions & 1 deletion google/cloud/spanner_dbapi/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ def description(self):
:rtype: tuple
:returns: The result columns' description.
"""
if not getattr(self._result_set, "metadata", None):
if (
self._result_set is None
or self._result_set.metadata is None
or self._result_set.metadata.row_type is None
or self._result_set.metadata.row_type.fields is None
or len(self._result_set.metadata.row_type.fields) == 0
):
return

columns = []
Expand Down