From f436c50b5bd7e5f9b1cef741a3978d8e7edb3fe9 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 26 Jul 2022 15:59:49 +0100 Subject: [PATCH] Postgres has all of --- .../server/src/api/controllers/row/internalSearch.js | 5 +---- packages/server/src/integrations/base/sql.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index 86f1bb980a..b60d72506b 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -176,10 +176,7 @@ class QueryBuilder { } let andStatement = `${builder.preprocess(value[0], { escape: true })}` for (let i = 1; i < value.length; i++) { - andStatement += ` AND ${builder.preprocess( - value[i], - { escape: true } - )}` + andStatement += ` AND ${builder.preprocess(value[i], { escape: true })}` } return `${key}:(${andStatement})` } diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 750564c6ff..3b01c1dad3 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -230,16 +230,18 @@ class InternalBuilder { const fnc = allOr ? "orWhere" : "where" const rawFnc = `${fnc}Raw` if (this.client === SqlClients.POSTGRES) { - iterate(filters.contains, (key: string, value: any) => { + iterate(filters.contains, (key: string, value: Array) => { const fieldNames = key.split(/\./g) const tableName = fieldNames[0] const columnName = fieldNames[1] - if (typeof value === "string") { - value = `"${value}"` + for (let i in value) { + if (typeof value[i] === "string") { + value[i] = `"${value[i]}"` + } } // @ts-ignore query = query[rawFnc]( - `"${tableName}"."${columnName}"::jsonb @> '[${value}]'` + `"${tableName}"."${columnName}"::jsonb @> '[${value.join(",")}]'` ) }) } else if (this.client === SqlClients.MY_SQL) {