Skip to content

Commit 41a2b2f

Browse files
Fix get_driver_connection to return underlying connection
Return connection._connection (the raw dqlite async connection) instead of the AsyncAdaptedConnection wrapper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3782303 commit 41a2b2f

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/sqlalchemydqlite/aio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def connect(self, *cargs: Any, **cparams: Any) -> Any:
151151
return AsyncAdaptedConnection(raw_conn)
152152

153153
def get_driver_connection(self, connection: Any) -> Any:
154-
"""Return the driver-level connection."""
155-
return connection
154+
"""Return the underlying driver-level connection."""
155+
return connection._connection
156156

157157

158158
# Register the dialect

tests/test_dialect.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ def test_parses_version_string(self) -> None:
136136
assert result == (3, 39, 4)
137137

138138

139+
class TestGetDriverConnection:
140+
def test_async_dialect_returns_underlying_connection(self) -> None:
141+
"""get_driver_connection should return the raw connection, not the adapter."""
142+
from unittest.mock import MagicMock
143+
144+
dialect = DqliteDialect_aio()
145+
mock_adapted = MagicMock()
146+
mock_adapted._connection = MagicMock(name="raw_async_connection")
147+
148+
result = dialect.get_driver_connection(mock_adapted)
149+
assert result is mock_adapted._connection, (
150+
"get_driver_connection should unwrap to the underlying connection, "
151+
"not return the AsyncAdaptedConnection wrapper"
152+
)
153+
154+
139155
class TestURLParsing:
140156
def test_parse_basic_url(self) -> None:
141157
url = URL.create("dqlite", host="localhost", port=9001, database="test")

0 commit comments

Comments
 (0)