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 9c3e99b611 fix(python/adbc_driver_manager): set boolean connection 
options once (#5022)
9c3e99b611 is described below

commit 9c3e99b6117f333caaf0ed9477019479163b4b4e
Author: Fredrik Fornwall <[email protected]>
AuthorDate: Thu Nov 12 07:04:42 2026 +0100

    fix(python/adbc_driver_manager): set boolean connection options once (#5022)
    
    A boolean passed to `AdbcConnection` was set as a string and then again
    as bytes, which fails on drivers that only accept the string form (like
    for example `adbc.connection.autocommit` with sqlite).
    
    Signed-off-by: Fredrik Fornwall <[email protected]>
---
 python/adbc_driver_manager/adbc_driver_manager/_lib.pyx | 2 +-
 python/adbc_driver_manager/tests/test_lowlevel.py       | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx 
b/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx
index cd04176507..8927aef761 100644
--- a/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx
+++ b/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx
@@ -894,7 +894,7 @@ cdef class AdbcConnection(_AdbcHandle):
                         &self.connection, c_key, c_value, &c_error)
                     if status != ADBC_STATUS_OK:
                         AdbcConnectionRelease(&self.connection, NULL)
-            if isinstance(value, int):
+            elif isinstance(value, int):
                 c_value_int = value
                 with nogil:
                     status = AdbcConnectionSetOptionInt(
diff --git a/python/adbc_driver_manager/tests/test_lowlevel.py 
b/python/adbc_driver_manager/tests/test_lowlevel.py
index 9017420f7d..8b7f220e7e 100644
--- a/python/adbc_driver_manager/tests/test_lowlevel.py
+++ b/python/adbc_driver_manager/tests/test_lowlevel.py
@@ -235,6 +235,10 @@ def test_connection_init() -> None:
         with adbc_driver_manager.AdbcConnection(db, **{option: 42}) as conn:
             assert conn.get_option_int(option) == 42
 
+        option = "adbc.connection.autocommit"
+        with adbc_driver_manager.AdbcConnection(db, **{option: True}) as conn:
+            assert conn.get_option(option) == "true"
+
         # test different data types
         with pytest.raises(
             adbc_driver_manager.NotSupportedError,

Reply via email to