mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 01:40:32 +00:00
Fix lookup workspace filter (#8513)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> Signed-off-by: Andrey Sobolev <haiodo@users.noreply.github.com> Co-authored-by: Andrey Sobolev <haiodo@users.noreply.github.com>
This commit is contained in:
parent
9640a07138
commit
80f67e3d66
@ -985,11 +985,12 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
|
||||
private buildJoinString (vars: ValuesVariables, value: JoinProps[]): string {
|
||||
const res: string[] = []
|
||||
const wsId = vars.add(this.workspaceId, '::uuid')
|
||||
for (const val of value) {
|
||||
if (val.isReverse) continue
|
||||
if (val.table === DOMAIN_MODEL) continue
|
||||
res.push(
|
||||
`LEFT JOIN ${val.table} AS ${val.toAlias} ON ${val.fromAlias}.${val.fromField} = ${val.toAlias}."${val.toField}" AND ${val.toAlias}."workspaceId" = ${vars.add(this.workspaceId, '::uuid')}`
|
||||
`LEFT JOIN ${val.table} AS ${val.toAlias} ON ${val.fromAlias}.${val.fromField} = ${val.toAlias}."${val.toField}" AND ${val.toAlias}."workspaceId" = ${wsId}`
|
||||
)
|
||||
if (val.classes !== undefined) {
|
||||
if (val.classes.length === 1) {
|
||||
@ -1472,8 +1473,9 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
classsesQuery = ` AND ${join.toAlias}._class = ANY (${vars.add(join.classes, '::text[]')})`
|
||||
}
|
||||
}
|
||||
const wsId = vars.add(this.workspaceId, '::uuid')
|
||||
return [
|
||||
`(SELECT jsonb_agg(${join.toAlias}.*) FROM ${join.table} AS ${join.toAlias} WHERE ${join.toAlias}."${join.toField}" = ${join.fromAlias}${join.fromAlias !== '' ? '.' : ''}${join.fromField} ${classsesQuery}) AS ${join.toAlias}`
|
||||
`(SELECT jsonb_agg(${join.toAlias}.*) FROM ${join.table} AS ${join.toAlias} WHERE ${join.toAlias}."${join.toField}" = ${join.fromAlias}${join.fromAlias !== '' ? '.' : ''}${join.fromField} AND ${join.toAlias}."workspaceId" = ${wsId}${classsesQuery}) AS ${join.toAlias}`
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user