Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 417b8b8

Browse files
author
Ilya Gurov
authored
fix: connection reset fails when an additional dialect is used (#188)
1 parent eb3fb45 commit 417b8b8

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
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-
dbapi_conn.connection.staleness = None
51+
if getattr(dbapi_conn.connection, "staleness", None) is not None:
52+
dbapi_conn.connection.staleness = None
5253

5354

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

test/test_suite.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,9 @@ def test_staleness(self):
16161616
with self._engine.connect() as connection:
16171617
assert connection.connection.staleness is None
16181618

1619+
with self._engine.connect() as connection:
1620+
del connection.staleness
1621+
16191622

16201623
class LimitOffsetTest(fixtures.TestBase):
16211624
"""

0 commit comments

Comments
 (0)