Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions adbc_drivers_validation/tests/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down