Fix FileEntry.findFiles() terms MATCH expr

This commit is contained in:
Bryan Ashby 2018-01-31 22:36:31 -07:00
parent c81aa001f4
commit ec87d11c31
1 changed files with 6 additions and 2 deletions

View File

@ -3,7 +3,10 @@
const fileDb = require('./database.js').dbs.file; const fileDb = require('./database.js').dbs.file;
const Errors = require('./enig_error.js').Errors; const Errors = require('./enig_error.js').Errors;
const getISOTimestampString = require('./database.js').getISOTimestampString; const {
getISOTimestampString,
sanatizeString
} = require('./database.js');
const Config = require('./config.js').config; const Config = require('./config.js').config;
// deps // deps
@ -523,11 +526,12 @@ module.exports = class FileEntry {
} }
if(filter.terms && filter.terms.length > 0) { if(filter.terms && filter.terms.length > 0) {
// note the ':' in MATCH expr., see https://www.sqlite.org/cvstrac/wiki?p=FullTextIndex
appendWhereClause( appendWhereClause(
`f.file_id IN ( `f.file_id IN (
SELECT rowid SELECT rowid
FROM file_fts FROM file_fts
WHERE file_fts MATCH "${filter.terms.replace(/"/g,'""')}" WHERE file_fts MATCH ":${sanatizeString(filter.terms)}"
)` )`
); );
} }