Skip to content

Commit 3243144

Browse files
committed
fix SQLAlchemy queries
1 parent 11b31e7 commit 3243144

File tree

1 file changed

+4
-8
lines changed
  • src/ai/backend/manager/repositories/permission_controller

1 file changed

+4
-8
lines changed

src/ai/backend/manager/repositories/permission_controller/db_source.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ async def check_scope_permission_exist(
140140
scope_id: ScopeId,
141141
operation: OperationType,
142142
) -> bool:
143-
role_query = (
144-
sa.select(sa.func.exist())
143+
exist_query = sa.exists(
144+
sa.select(1)
145145
.select_from(
146-
sa.join(UserRoleRow, RoleRow.id == UserRoleRow.role_id)
146+
sa.join(UserRoleRow, RoleRow, RoleRow.id == UserRoleRow.role_id)
147147
.join(PermissionGroupRow, RoleRow.id == PermissionGroupRow.role_id)
148148
.join(PermissionRow, PermissionGroupRow.id == PermissionRow.permission_group_id)
149149
)
@@ -158,12 +158,8 @@ async def check_scope_permission_exist(
158158
PermissionRow.operation == operation,
159159
)
160160
)
161-
.options(
162-
contains_eager(RoleRow.permission_group_rows).options(
163-
selectinload(PermissionGroupRow.permission_rows)
164-
)
165-
)
166161
)
162+
role_query = sa.select(exist_query)
167163
async with self._db.begin_readonly_session() as db_session:
168164
result = await db_session.scalar(role_query)
169165
return result

0 commit comments

Comments
 (0)