diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts index 97c43ce1f8b6..bb922291eb4c 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts @@ -583,12 +583,22 @@ export class WorkspaceQueryRunnerService { )}; `); - const results = await workspaceDataSource?.query( - `SELECT graphql.resolve($1);`, - [query], - ); + return await workspaceDataSource?.transaction( + async (transactionManager) => { + await transactionManager.query(` + SET search_path TO ${this.workspaceDataSourceService.getSchemaName( + workspaceId, + )}; + `); - return results; + const results = transactionManager.query( + `SELECT graphql.resolve($1);`, + [query], + ); + + return results; + }, + ); } private async parseResult(