mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-13 10:53:06 +00:00
QFIX: PG object query (#8283)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
fdec5500b9
commit
b715b584fb
@ -726,7 +726,7 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
})) as FindResult<T>
|
||||
} catch (err) {
|
||||
const sqlFull = vars.injectVars(fquery)
|
||||
ctx.error('Error in findAll', { err, sql: fquery, sqlFull })
|
||||
ctx.error('Error in findAll', { err, sql: fquery, sqlFull, query })
|
||||
throw err
|
||||
}
|
||||
},
|
||||
@ -1316,6 +1316,7 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
} else if (typeof value === 'object' && !Array.isArray(value)) {
|
||||
// we can have multiple criteria for one field
|
||||
const res: string[] = []
|
||||
const nonOperator: Record<string, any> = {}
|
||||
for (const operator in value) {
|
||||
let val = value[operator]
|
||||
if (tkeyData && (Array.isArray(val) || (typeof val !== 'object' && typeof val !== 'string'))) {
|
||||
@ -1402,10 +1403,14 @@ abstract class PostgresAdapterBase implements DbAdapter {
|
||||
}
|
||||
break
|
||||
default:
|
||||
res.push(`${tkey} @> '[${JSON.stringify(value)}]'`)
|
||||
nonOperator[operator] = value[operator]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (Object.keys(nonOperator).length > 0) {
|
||||
const qkey = tkey.replace('#>>', '->').replace('{', '').replace('}', '')
|
||||
res.push(`(${qkey} @> '${JSON.stringify(nonOperator)}' or ${qkey} @> '[${JSON.stringify(nonOperator)}]')`)
|
||||
}
|
||||
return res.length === 0 ? undefined : res.join(' AND ')
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user