Skip to content

Commit 072415e

Browse files
authored
fix: don't reset attributes of non-Spanner connections (#222)
1 parent 3f9a1b6 commit 072415e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
@listens_for(Pool, "reset")
4949
def reset_connection(dbapi_conn, connection_record):
5050
"""An event of returning a connection back to a pool."""
51-
if dbapi_conn.connection.inside_transaction:
52-
dbapi_conn.connection.rollback()
51+
if isinstance(dbapi_conn.connection, spanner_dbapi.Connection):
52+
if dbapi_conn.connection.inside_transaction:
53+
dbapi_conn.connection.rollback()
5354

54-
if getattr(dbapi_conn.connection, "staleness", None) is not None:
5555
dbapi_conn.connection.staleness = None
56-
57-
if getattr(dbapi_conn.connection, "read_only", None) is not None:
5856
dbapi_conn.connection.read_only = False
57+
else:
58+
dbapi_conn.connection.rollback()
5959

6060

6161
# register a method to get a single value of a JSON object

0 commit comments

Comments
 (0)