0z5a opened a new issue, #5032:
URL: https://github.com/apache/arrow-adbc/issues/5032

   ### What happened?
   
   `Connection.adbc_clone()` does not carry over `autocommit`. If the original 
connection was opened with `dbapi.connect(..., autocommit=True)`, the clone is 
created with autocommit disabled (`adbc.connection.autocommit` reads back as 
`false`). Anything written through the clone without an explicit `commit()` is 
rolled back when the clone is closed, with no error or warning.
   
   I expected the clone to behave like the connection it was cloned from, since 
`adbc_clone()` already forwards the original connection's options. This is easy 
to hit when a connection opened with `autocommit=True` is used as a pool 
factory via `adbc_clone`, as in the connection pooling recipe 
(`sqlalchemy.pool.QueuePool(source.adbc_clone, ...)`): every pooled connection 
then silently ends up in manual-commit mode.
   
   The cause is that `adbc_clone()` builds the new object as 
`Connection(self._db, conn)`, so `autocommit` falls back to its default of 
`False` (and the connection options and DB-API backend are not passed on 
either).
   
   ### Stack Trace
   
   No exception; the data is silently discarded.
   
   ### How can we reproduce the bug?
   
   ```python
   import os
   import tempfile
   
   from adbc_driver_manager import dbapi
   
   d = tempfile.mkdtemp()
   
   # Bug: write through a clone of an autocommit connection
   uri = "file:" + os.path.join(d, "clone.db")
   with dbapi.connect(driver="adbc_driver_sqlite", uri=uri, autocommit=True) as 
conn:
       print("original autocommit:", 
conn.adbc_connection.get_option("adbc.connection.autocommit"))
       with conn.adbc_clone() as clone:
           print("clone autocommit:   ", 
clone.adbc_connection.get_option("adbc.connection.autocommit"))
           with clone.cursor() as cur:
               cur.execute("CREATE TABLE t (a INTEGER)")
               cur.execute("INSERT INTO t VALUES (1)")
   with dbapi.connect(driver="adbc_driver_sqlite", uri=uri, autocommit=True) as 
conn:
       with conn.cursor() as cur:
           cur.execute("SELECT name FROM sqlite_master")
           print("tables after writing through the clone:   ", cur.fetchall())
   
   # Control: the same writes through the original connection
   uri = "file:" + os.path.join(d, "control.db")
   with dbapi.connect(driver="adbc_driver_sqlite", uri=uri, autocommit=True) as 
conn:
       with conn.cursor() as cur:
           cur.execute("CREATE TABLE t (a INTEGER)")
           cur.execute("INSERT INTO t VALUES (1)")
   with dbapi.connect(driver="adbc_driver_sqlite", uri=uri, autocommit=True) as 
conn:
       with conn.cursor() as cur:
           cur.execute("SELECT name FROM sqlite_master")
           print("tables after writing through the original:", cur.fetchall())
   ```
   
   Output:
   
   ```
   original autocommit: true
   clone autocommit:    false
   tables after writing through the clone:    []
   tables after writing through the original: [('t',)]
   ```
   
   ### Environment/Setup
   
   adbc_driver_manager built from main (89fe37cf2) with the SQLite driver, 
Python 3.12, macOS (arm64), pip editable install. The code path is pure Python 
and not platform specific.
   
   I have a fix with a regression test and will open a PR for it.
   
   This issue was drafted with Claude Code (claude-opus-5-5); the results above 
are from the runs described.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to