mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-10 17:30:51 +00:00
Fix lookup workspace filter (#8512)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
afcd637ed2
commit
6a9e0cc1f2
@ -987,11 +987,12 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
|
||||
private buildJoinString (vars: ValuesVariables, value: JoinProps[]): string {
|
||||
const res: string[] = []
|
||||
const wsId = vars.add(this.workspaceId.name, '::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.name, '::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) {
|
||||
@ -1474,8 +1475,9 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
classsesQuery = ` AND ${join.toAlias}._class = ANY (${vars.add(join.classes, '::text[]')})`
|
||||
}
|
||||
}
|
||||
const wsId = vars.add(this.workspaceId.name, '::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