Skip to content

Commit 567f15c

Browse files
committed
Fix SQLAlchemy ArgumentError: conditionally bind data_ids
1 parent 193a0dd commit 567f15c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/routers/openml/datasets.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ def quality_clause(
221221
)
222222
params.update(missing_params)
223223

224+
# Use bindparam with expanding=True for list parameters in IN clauses
225+
bind_params = [bindparam("statuses", expanding=True)]
226+
if "data_ids" in params:
227+
bind_params.append(bindparam("data_ids", expanding=True))
228+
224229
matching_filter = text(
225230
f"""
226231
SELECT d.`did`,d.`name`,d.`version`,d.`format`,d.`file_id`,
@@ -233,10 +238,7 @@ def quality_clause(
233238
AND IFNULL(cs.`status`, 'in_preparation') IN :statuses
234239
LIMIT :limit OFFSET :offset
235240
""", # noqa: S608
236-
).bindparams(
237-
bindparam("statuses", expanding=True),
238-
bindparam("data_ids", expanding=True) if "data_ids" in params else bindparam("data_ids"),
239-
)
241+
).bindparams(*bind_params)
240242

241243
columns = ["did", "name", "version", "format", "file_id", "status"]
242244
result = await expdb_db.execute(

0 commit comments

Comments
 (0)