File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
packages/postgres-database/src/simcore_postgres_database
services/web/server/src/simcore_service_webserver/projects Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 1010from common_library .basic_types import DEFAULT_FACTORY
1111from common_library .errors_classes import OsparcErrorMixin
1212from pydantic import BaseModel , ConfigDict , Field
13+ from simcore_postgres_database .models .projects import projects
1314from simcore_postgres_database .utils_aiosqlalchemy import map_db_exception
1415from sqlalchemy .dialects .postgresql import insert as pg_insert
1516from sqlalchemy .sql .selectable import Subquery
@@ -124,6 +125,11 @@ def make_workbench_subquery() -> Subquery:
124125 ),
125126 ).label ("workbench" ),
126127 )
128+ .select_from (
129+ projects_nodes .join (
130+ projects , projects_nodes .c .project_uuid == projects .c .uuid
131+ )
132+ )
127133 .group_by (projects_nodes .c .project_uuid )
128134 .subquery ()
129135 )
Original file line number Diff line number Diff line change @@ -123,12 +123,22 @@ async def get_project_with_workbench(
123123 project_uuid : ProjectID ,
124124) -> ProjectWithWorkbenchDBGet :
125125 async with pass_or_acquire_connection (get_asyncpg_engine (app ), connection ) as conn :
126- query = sql .select (
127- * PROJECT_DB_COLS ,
128- sa .func .coalesce (
129- make_workbench_subquery ().c .workbench , sa .text ("'{}'::json" )
130- ).label ("workbench" ),
131- ).where (projects .c .uuid == f"{ project_uuid } " )
126+ workbench_subquery = make_workbench_subquery ()
127+ query = (
128+ sql .select (
129+ * PROJECT_DB_COLS ,
130+ sa .func .coalesce (
131+ workbench_subquery .c .workbench , sa .text ("'{}'::json" )
132+ ).label ("workbench" ),
133+ )
134+ .select_from (
135+ projects .outerjoin (
136+ workbench_subquery ,
137+ projects .c .uuid == workbench_subquery .c .project_uuid ,
138+ )
139+ )
140+ .where (projects .c .uuid == f"{ project_uuid } " )
141+ )
132142 result = await conn .execute (query )
133143 row = result .one_or_none ()
134144 if row is None :
You can’t perform that action at this time.
0 commit comments