diff --git a/pillar_tool/routers/host.py b/pillar_tool/routers/host.py index 2d60ace..5e538be 100644 --- a/pillar_tool/routers/host.py +++ b/pillar_tool/routers/host.py @@ -130,12 +130,9 @@ async def host_add(request: Request, fqdn: str, params: HostCreateParams): # Traverse the parent hierarchy to ensure all components exist parent_id = None - stmt_select_respecting_parent = select(Host).where(and_(Host.name == bindparam("label"), Host.parent_id == bindparam("parent_id"))) for label in parent_labels: - result = db.execute(stmt_select_respecting_parent, { - 'label': label, - 'parent_id': parent_id - }).fetchall() + stmt_select_respecting_parent = select(Host).where(and_(Host.name == label, Host.parent_id == parent_id)) + result = db.execute(stmt_select_respecting_parent).fetchall() if len(result) == 0: raise HTTPException(status_code=400, detail="Parent does not exist")