diff --git a/backend/src/services/identity-project/identity-project-dal.ts b/backend/src/services/identity-project/identity-project-dal.ts index 3a73244a4..3e7ca7946 100644 --- a/backend/src/services/identity-project/identity-project-dal.ts +++ b/backend/src/services/identity-project/identity-project-dal.ts @@ -131,8 +131,6 @@ export const identityProjectDALFactory = (db: TDbClient) => { `${TableName.Identity}.id` ) .where(`${TableName.IdentityProjectMembership}.projectId`, projectId) - .offset(filter.offset ?? 0) - .limit(filter.limit ?? 100) .orderBy( `${TableName.Identity}.${filter.orderBy ?? ProjectIdentityOrderBy.Name}`, filter.orderDirection ?? OrderByDirection.ASC @@ -140,6 +138,10 @@ export const identityProjectDALFactory = (db: TDbClient) => { .select(selectAllTableCols(TableName.Identity)) .as(TableName.Identity); // required for subqueries + if (filter.limit) { + void fetchIdentitySubquery.offset(filter.offset ?? 0).limit(filter.limit); + } + const query = (tx || db.replicaNode())(TableName.IdentityProjectMembership) .where(`${TableName.IdentityProjectMembership}.projectId`, projectId) .join(TableName.Project, `${TableName.IdentityProjectMembership}.projectId`, `${TableName.Project}.id`)