From 42a748c6b66bd49571d4791ecd63ba18cc4ccb41 Mon Sep 17 00:00:00 2001 From: Linus Vogel Date: Thu, 14 May 2026 20:31:25 +0200 Subject: [PATCH] fixed bug in the database when assigning a state to a top file --- pillar_tool/routers/top.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pillar_tool/routers/top.py b/pillar_tool/routers/top.py index 6c6efae..638de2a 100644 --- a/pillar_tool/routers/top.py +++ b/pillar_tool/routers/top.py @@ -1,6 +1,6 @@ import uuid -from sqlalchemy import select, delete, and_, bindparam +from sqlalchemy import select, delete, and_, or_, bindparam from sqlalchemy.dialects.postgresql import insert from sqlalchemy.orm import Session from starlette.exceptions import HTTPException @@ -136,7 +136,7 @@ def top_state_assign(req: Request, host_name: str, state_name: str): path_labels = host_name.replace("%%2F", "%%2f").split("%%2f") parent_id = None for path in path_labels: - host_stmt = select(Host).where(and_(Host.name == path, Host.parent_id == parent_id)) + host_stmt = select(Host).where(or_(and_(Host.name == path, Host.parent_id == parent_id, Host.is_hostgroup == True), and_(Host.name == path, Host.is_hostgroup == False, len(path_labels) == 1))) # type: ignore host_res = db.execute(host_stmt).fetchall() if len(host_res) != 1: