Check if token is a valid column name in the fts table before treating it as such.

This commit is contained in:
Mattias Andersson 2014-01-13 00:23:54 +01:00
parent 827ed9425c
commit 3f4e8e5b88
1 changed files with 16 additions and 3 deletions

View File

@ -48,10 +48,23 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
token.remove(')');
token.remove('"');
if (token.contains(':'))
query += "fts" + token + "* ";
else
if (token.contains(':')) {
// Only prefix fts if the token is a valid column name.
if (Song::kFtsColumns.contains("fts" + token.section(':', 0, 0),
Qt::CaseInsensitive)) {
// Account for multiple colons.
QString columntoken = token.section(
':', 0, 0, QString::SectionIncludeTrailingSep);
QString subtoken = token.section(':', 1, -1);
subtoken.replace(":", " ");
query += "fts" + columntoken + subtoken + "* ";
} else {
token.replace(':', 1, ' ');
query += token + "* ";
}
} else {
query += token + "* ";
}
}
where_clauses_ << "fts.%fts_table_noprefix MATCH ?";