From 641a9c8a34fe63889413853c95829289ae960d12 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 20 Aug 2021 15:20:52 +0100 Subject: [PATCH] make SQL startsWith queries case insensitive --- packages/server/src/integrations/base/sql.ts | 2 +- packages/server/src/integrations/tests/sql.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index ca6dcb15fd..f03c0dbd37 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -52,7 +52,7 @@ function addFilters( if (filters.string) { iterate(filters.string, (key, value) => { const fnc = allOr ? "orWhere" : "where" - query = query[fnc](key, "like", `${value}%`) + query = query[fnc](key, "ilike", `${value}%`) }) } if (filters.range) { diff --git a/packages/server/src/integrations/tests/sql.spec.js b/packages/server/src/integrations/tests/sql.spec.js index a02a7e8198..fa8bcd1d86 100644 --- a/packages/server/src/integrations/tests/sql.spec.js +++ b/packages/server/src/integrations/tests/sql.spec.js @@ -82,7 +82,7 @@ describe("SQL query builder", () => { })) expect(query).toEqual({ bindings: ["John%", limit], - sql: `select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" like $1 limit $2` + sql: `select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2` }) })