Merge pull request #2426 from Budibase/feature/case-insensitive-sql

make SQL startsWith queries case insensitive
This commit is contained in:
Martin McKeaveney 2021-08-20 17:36:02 +01:00 committed by GitHub
commit 38d82688ef
3 changed files with 3 additions and 3 deletions

View File

@ -94,7 +94,7 @@ describe("/datasources", () => {
.expect(200)
// this is mock data, can't test it
expect(res.body).toBeDefined()
expect(pg.queryMock).toHaveBeenCalledWith(`select "users"."name" as "users.name", "users"."age" as "users.age" from "users" where "users"."name" like $1 limit $2`, ["John%", 5000])
expect(pg.queryMock).toHaveBeenCalledWith(`select "users"."name" as "users.name", "users"."age" as "users.age" from "users" where "users"."name" ilike $1 limit $2`, ["John%", 5000])
})
})

View File

@ -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) {

View File

@ -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`
})
})