Postgres has all of
This commit is contained in:
parent
cfb5c2d0ca
commit
76e4ffc04d
|
@ -176,10 +176,7 @@ class QueryBuilder {
|
||||||
}
|
}
|
||||||
let andStatement = `${builder.preprocess(value[0], { escape: true })}`
|
let andStatement = `${builder.preprocess(value[0], { escape: true })}`
|
||||||
for (let i = 1; i < value.length; i++) {
|
for (let i = 1; i < value.length; i++) {
|
||||||
andStatement += ` AND ${builder.preprocess(
|
andStatement += ` AND ${builder.preprocess(value[i], { escape: true })}`
|
||||||
value[i],
|
|
||||||
{ escape: true }
|
|
||||||
)}`
|
|
||||||
}
|
}
|
||||||
return `${key}:(${andStatement})`
|
return `${key}:(${andStatement})`
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,16 +230,18 @@ class InternalBuilder {
|
||||||
const fnc = allOr ? "orWhere" : "where"
|
const fnc = allOr ? "orWhere" : "where"
|
||||||
const rawFnc = `${fnc}Raw`
|
const rawFnc = `${fnc}Raw`
|
||||||
if (this.client === SqlClients.POSTGRES) {
|
if (this.client === SqlClients.POSTGRES) {
|
||||||
iterate(filters.contains, (key: string, value: any) => {
|
iterate(filters.contains, (key: string, value: Array<any>) => {
|
||||||
const fieldNames = key.split(/\./g)
|
const fieldNames = key.split(/\./g)
|
||||||
const tableName = fieldNames[0]
|
const tableName = fieldNames[0]
|
||||||
const columnName = fieldNames[1]
|
const columnName = fieldNames[1]
|
||||||
if (typeof value === "string") {
|
for (let i in value) {
|
||||||
value = `"${value}"`
|
if (typeof value[i] === "string") {
|
||||||
|
value[i] = `"${value[i]}"`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
query = query[rawFnc](
|
query = query[rawFnc](
|
||||||
`"${tableName}"."${columnName}"::jsonb @> '[${value}]'`
|
`"${tableName}"."${columnName}"::jsonb @> '[${value.join(",")}]'`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else if (this.client === SqlClients.MY_SQL) {
|
} else if (this.client === SqlClients.MY_SQL) {
|
||||||
|
|
Loading…
Reference in New Issue