SQL Server containsAny unit test
This commit is contained in:
parent
4abd984d99
commit
26c8af3c1e
|
@ -177,8 +177,10 @@ class InternalBuilder {
|
||||||
const tableName = fieldNames[0]
|
const tableName = fieldNames[0]
|
||||||
const columnName = fieldNames[1]
|
const columnName = fieldNames[1]
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
query = query[rawFnc](`${not}"${tableName}"."${columnName}"::jsonb ${containsOp} ${wrap}${stringifyArray(
|
query = query[rawFnc](
|
||||||
value, any ? "'" : '"'
|
`${not}"${tableName}"."${columnName}"::jsonb ${containsOp} ${wrap}${stringifyArray(
|
||||||
|
value,
|
||||||
|
any ? "'" : '"'
|
||||||
)}${wrap}`
|
)}${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({
|
const query = new Sql(SqlClients.MS_SQL, 10)._query(generateReadJson({
|
||||||
filters: {
|
filters: {
|
||||||
containsAny: {
|
containsAny: {
|
||||||
age: [20, 25],
|
age: [20],
|
||||||
name: ["John", "Mary"]
|
name: ["John"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`],
|
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}]`
|
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