Fix binding mismatch problem in oneOf queries.

This commit is contained in:
Sam Rose 2024-07-29 14:54:58 +01:00
parent a4b66e00e4
commit 5cb294f33e
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -394,10 +394,9 @@ class InternalBuilder {
(key: string, array) => { (key: string, array) => {
if (this.client === SqlClient.ORACLE) { if (this.client === SqlClient.ORACLE) {
key = convertClobs(this.client, table, key) key = convertClobs(this.client, table, key)
query = query.whereRaw( array = Array.isArray(array) ? array : [array]
`${key} IN (?)`, const binding = new Array(array.length).fill("?").join(",")
Array.isArray(array) ? array : [array] query = query.whereRaw(`${key} IN (${binding})`, array)
)
} else { } else {
query = query[fnc](key, Array.isArray(array) ? array : [array]) query = query[fnc](key, Array.isArray(array) ? array : [array])
} }

View File

@ -22,6 +22,7 @@ export function getNativeSql(
query: Knex.SchemaBuilder | Knex.QueryBuilder query: Knex.SchemaBuilder | Knex.QueryBuilder
): SqlQuery | SqlQuery[] { ): SqlQuery | SqlQuery[] {
let sql = query.toSQL() let sql = query.toSQL()
if (Array.isArray(sql)) { if (Array.isArray(sql)) {
return sql as SqlQuery[] return sql as SqlQuery[]
} }