This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 45a17a0fa1 fix(python/adbc_driver_manager): keep autocommit setting in
adbc_clone (#5033)
45a17a0fa1 is described below
commit 45a17a0fa103368720eaa5cc658cc400d85d4d57
Author: 0z5a <[email protected]>
AuthorDate: Wed Nov 18 09:11:42 2026 +0100
fix(python/adbc_driver_manager): keep autocommit setting in adbc_clone
(#5033)
`Connection.adbc_clone()` built the new `Connection` without passing
`autocommit`, so cloning a connection opened with `autocommit=True`
silently turned autocommit off on the clone. The clone now keeps the
original's autocommit setting. It also keeps its connection options and
backend, so cloning a clone behaves the same.
Closes #5032.
Generated-by: Claude Opus 5.5
---
python/adbc_driver_manager/adbc_driver_manager/dbapi.py | 8 +++++++-
python/adbc_driver_manager/tests/test_dbapi.py | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
index e7c51c0c7f..71221f8be5 100644
--- a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
+++ b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
@@ -495,7 +495,13 @@ class Connection(_Closeable):
This is an extension and not part of the DBAPI standard.
"""
conn = _lib.AdbcConnection(self._db._db, **(self._conn_kwargs or {}))
- return Connection(self._db, conn)
+ return Connection(
+ self._db,
+ conn,
+ self._conn_kwargs,
+ autocommit=self._autocommit,
+ backend=self._backend,
+ )
def adbc_get_info(self) -> Dict[Union[str, int], Any]:
"""
diff --git a/python/adbc_driver_manager/tests/test_dbapi.py
b/python/adbc_driver_manager/tests/test_dbapi.py
index aa784a18d8..c130f3fe13 100644
--- a/python/adbc_driver_manager/tests/test_dbapi.py
+++ b/python/adbc_driver_manager/tests/test_dbapi.py
@@ -94,6 +94,22 @@ def test_clone(sqlite) -> None:
assert cur.fetchone() == (1,)
[email protected]
+def test_clone_autocommit(tmp_path: pathlib.Path) -> None:
+ db = tmp_path / "test.db"
+ with dbapi.connect(
+ driver="adbc_driver_sqlite", uri=db.as_uri(), autocommit=True
+ ) as conn:
+ with conn.adbc_clone() as clone:
+ with clone.cursor() as cur:
+ cur.execute("CREATE TABLE temporary (ints)")
+ cur.execute("INSERT INTO temporary VALUES (1)")
+
+ with conn.cursor() as cur:
+ cur.execute("SELECT * FROM temporary")
+ assert cur.fetchall() == [(1,)]
+
+
@pytest.mark.sqlite
def test_get_objects(sqlite) -> None:
with sqlite.cursor() as cur: