Skip to content
Merged
Changes from all 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
10 changes: 5 additions & 5 deletions google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
@listens_for(Pool, "reset")
def reset_connection(dbapi_conn, connection_record):
"""An event of returning a connection back to a pool."""
if dbapi_conn.connection.inside_transaction:
dbapi_conn.connection.rollback()
if isinstance(dbapi_conn.connection, spanner_dbapi.Connection):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resetting attributes only in case it's a Spanner connection. Otherwise doing rollback(), which is the default behavior of the resetting method.

if dbapi_conn.connection.inside_transaction:
dbapi_conn.connection.rollback()

if getattr(dbapi_conn.connection, "staleness", None) is not None:
dbapi_conn.connection.staleness = None

if getattr(dbapi_conn.connection, "read_only", None) is not None:
dbapi_conn.connection.read_only = False
else:
dbapi_conn.connection.rollback()


# register a method to get a single value of a JSON object
Expand Down