Fix SQLite not understanding escape char

I honestly expected Knex.js would've already handled this
This commit is contained in:
Bobby Wibowo 2020-06-07 20:51:59 +07:00
parent 8bcee712ac
commit 0851d71688
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -1236,8 +1236,8 @@ self.list = async (req, res) => {
this.andWhere(function () {
if (!filterObj.queries.text) return
for (const pattern of filterObj.queries.text) {
this.orWhere('name', 'like', pattern)
this.orWhere('original', 'like', pattern)
this.orWhereRaw('?? like ? escape ?', ['name', pattern, '\\'])
this.orWhereRaw('?? like ? escape ?', ['original', pattern, '\\'])
}
})
@ -1245,8 +1245,8 @@ self.list = async (req, res) => {
this.andWhere(function () {
if (!filterObj.queries.exclude.text) return
for (const pattern of filterObj.queries.exclude.text) {
this.andWhere('name', 'not like', pattern)
this.andWhere('original', 'not like', pattern)
this.andWhereRaw('?? not like ? escape ?', ['name', pattern, '\\'])
this.andWhereRaw('?? not like ? escape ?', ['original', pattern, '\\'])
}
})
}