Move boolean coversion down a layer in the stack so it's not tied so directly to search.
This commit is contained in:
parent
4722fd1cab
commit
39f8727830
|
@ -150,6 +150,22 @@ function getTableName(table?: Table): string | undefined {
|
|||
}
|
||||
}
|
||||
|
||||
function convertBooleans(query: SqlQuery | SqlQuery[]): SqlQuery | SqlQuery[] {
|
||||
if (Array.isArray(query)) {
|
||||
return query.map((q: SqlQuery) => convertBooleans(q) as SqlQuery)
|
||||
} else {
|
||||
if (query.bindings) {
|
||||
query.bindings = query.bindings.map(binding => {
|
||||
if (typeof binding === "boolean") {
|
||||
return binding ? 1 : 0
|
||||
}
|
||||
return binding
|
||||
})
|
||||
}
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
class InternalBuilder {
|
||||
private readonly client: string
|
||||
|
||||
|
@ -654,7 +670,11 @@ class SqlQueryBuilder extends SqlTableQueryBuilder {
|
|||
if (opts?.disableBindings) {
|
||||
return { sql: query.toString() }
|
||||
} else {
|
||||
return getNativeSql(query)
|
||||
let native = getNativeSql(query)
|
||||
if (sqlClient === SqlClient.SQL_LITE) {
|
||||
native = convertBooleans(native)
|
||||
}
|
||||
return native
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,12 +165,7 @@ export async function search(
|
|||
}
|
||||
|
||||
let sql = query.sql
|
||||
let bindings = query.bindings?.map(b => {
|
||||
if (typeof b === "boolean") {
|
||||
return b ? 1 : 0
|
||||
}
|
||||
return b
|
||||
})
|
||||
let bindings = query.bindings
|
||||
|
||||
// quick hack for docIds
|
||||
sql = sql.replace(/`doc1`.`rowId`/g, "`doc1.rowId`")
|
||||
|
|
Loading…
Reference in New Issue