From d4b2e84b1aa5a42f7cc289ea0fb1d40f22469c74 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 13 Jul 2026 18:58:31 +0200 Subject: [PATCH] test(connection): int-typed getter coherence for autocommit set via SetOptionInt adbc.h (AdbcConnectionGetOptionInt): 'For standard options, drivers must always support getting the option value (if they support getting option values at all) via the type specified in the option. (For example, an option set via SetOptionDouble must be retrievable via GetOptionDouble.)' test_option_autocommit_int_coherence sets adbc.connection.autocommit through SetOptionInt (a plain Python int via set_options) and, when the driver accepts that set, requires GetOptionInt to succeed and agree (and the string getter to agree as well). Drivers that reject the integer-typed set are skipped, not failed. Gated on connection_transactions since the test toggles autocommit off; restores autocommit afterwards like test_transaction_toggle. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01LGf8PVEe2tYkw8Q6Pd95tq Signed-off-by: Fredrik Fornwall --- adbc_drivers_validation/tests/connection.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/adbc_drivers_validation/tests/connection.py b/adbc_drivers_validation/tests/connection.py index 6298a4d..843abc5 100644 --- a/adbc_drivers_validation/tests/connection.py +++ b/adbc_drivers_validation/tests/connection.py @@ -1244,6 +1244,38 @@ def test_get_table_schema_schema( ) assert len(schema) == 2 + @pytest.mark.requires_features(["connection_transactions"]) + def test_option_autocommit_int_coherence( + self, + driver: model.DriverQuirks, + conn: adbc_driver_manager.dbapi.Connection, + ) -> None: + # adbc.h (AdbcConnectionGetOptionInt): "For standard options, drivers + # must always support getting the option value (if they support + # getting option values at all) via the type specified in the option. + # (For example, an option set via SetOptionDouble must be retrievable + # via GetOptionDouble.)" So if a driver accepts setting + # adbc.connection.autocommit via SetOptionInt, GetOptionInt on the + # same key must succeed and agree (and the string getter must agree + # too). Drivers that reject the integer-typed set are skipped. + key = "adbc.connection.autocommit" + handle = conn.adbc_connection + try: + # A plain (non-bool) Python int routes through SetOptionInt. + handle.set_options(**{key: 1}) + except conn.Error: + pytest.skip("driver does not accept an integer-typed autocommit") + try: + assert handle.get_option_int(key) == 1 + assert handle.get_option(key) == "true" + + handle.set_options(**{key: 0}) + assert handle.get_option_int(key) == 0 + assert handle.get_option(key) == "false" + finally: + # Restore autocommit (the fixture connection default). + handle.set_options(**{key: True}) + def test_unknown_option( self, subtests: pytest.Subtests,