From 0851d71688b5e71785f594dead2978275e4c4c27 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Sun, 7 Jun 2020 20:51:59 +0700 Subject: [PATCH] Fix SQLite not understanding escape char I honestly expected Knex.js would've already handled this --- controllers/uploadController.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 88a8b7e..6ab53fb 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -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, '\\']) } }) }