SQL Server containsAny unit test
This commit is contained in:
parent
9369498d38
commit
600794de66
|
@ -177,8 +177,10 @@ class InternalBuilder {
|
|||
const tableName = fieldNames[0]
|
||||
const columnName = fieldNames[1]
|
||||
// @ts-ignore
|
||||
query = query[rawFnc](`${not}"${tableName}"."${columnName}"::jsonb ${containsOp} ${wrap}${stringifyArray(
|
||||
value, any ? "'" : '"'
|
||||
query = query[rawFnc](
|
||||
`${not}"${tableName}"."${columnName}"::jsonb ${containsOp} ${wrap}${stringifyArray(
|
||||
value,
|
||||
any ? "'" : '"'
|
||||
)}${wrap}`
|
||||
)
|
||||
})
|
||||
|
|
|
@ -330,18 +330,18 @@ describe("SQL query builder", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("should use OR like expression for MS-SQL when filter is containsAny", () => {
|
||||
it("should use like expression for MS-SQL when filter is containsAny", () => {
|
||||
const query = new Sql(SqlClients.MS_SQL, 10)._query(generateReadJson({
|
||||
filters: {
|
||||
containsAny: {
|
||||
age: [20, 25],
|
||||
name: ["John", "Mary"]
|
||||
age: [20],
|
||||
name: ["John"]
|
||||
}
|
||||
}
|
||||
}))
|
||||
expect(query).toEqual({
|
||||
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`],
|
||||
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where LOWER(${TABLE_NAME}.age) LIKE @p1 and LOWER(${TABLE_NAME}.name) LIKE @p2) as [${TABLE_NAME}]`
|
||||
bindings: [10, "%20%", `%"John"%`],
|
||||
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1) and (LOWER(${TABLE_NAME}.name) LIKE @p2)) as [${TABLE_NAME}]`
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue