Skip to content

Commit 70cf441

Browse files
authored
feat: ensure validation fails if parameters aren't bound (#179)
Closes #177.
1 parent 539ad14 commit 70cf441

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

adbc_drivers_validation/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class DriverFeatures(BaseModel):
132132
# Some databases support temporary tables, but they exist in the same
133133
# namespace as regular tables, so we need to change how we test them.
134134
quirk_bulk_ingest_temporary_shares_namespace: bool = Field(default=False)
135+
# Certain checks that are not strictly required by the spec, but which we
136+
# expect drivers developed by the foundry directly to conform to
137+
quirk_foundry: bool = Field(default=True)
135138
# Some vendors sort the columns, so declaring FOREIGN KEY(b, a) REFERENCES
136139
# foo(d, c) still gets returned in the order (a, c), (b, d)
137140
quirk_get_objects_constraints_foreign_normalized: bool = Field(default=False)

adbc_drivers_validation/tests/ingest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def generate_tests(
4949
for quirks in all_quirks:
5050
driver_param = f"{quirks.name}:{quirks.short_version}"
5151
enabled = {
52+
"test_ingest_no_parameters": quirks.features.statement_bulk_ingest,
5253
"test_not_null": quirks.features.statement_bulk_ingest,
5354
"test_schema": quirks.features.statement_bulk_ingest_schema,
5455
"test_catalog": quirks.features.statement_bulk_ingest_catalog,
@@ -859,6 +860,31 @@ def test_many_columns(
859860
assert result is not None
860861
assert result[0] == num_rows
861862

863+
def test_ingest_no_parameters(
864+
self,
865+
driver: model.DriverQuirks,
866+
conn: adbc_driver_manager.dbapi.Connection,
867+
) -> None:
868+
# Ensure ingest works without parameters bound
869+
table_name = "test_ingest_no_parameters"
870+
with conn.cursor() as cursor:
871+
cursor.adbc_statement.set_options(
872+
**{
873+
adbc_driver_manager.StatementOptions.INGEST_TARGET_TABLE.value: table_name,
874+
}
875+
)
876+
with pytest.raises(adbc_driver_manager.dbapi.Error) as excinfo:
877+
cursor.adbc_statement.execute_update()
878+
879+
if driver.features.quirk_foundry:
880+
assert (
881+
excinfo.value.status_code
882+
== adbc_driver_manager.AdbcStatusCode.INVALID_STATE
883+
)
884+
assert isinstance(
885+
excinfo.value, adbc_driver_manager.dbapi.ProgrammingError
886+
)
887+
862888
def test_ingest_then_query(
863889
self,
864890
driver: model.DriverQuirks,

0 commit comments

Comments
 (0)