looqs/shared/sqlitesearch.h
Albert S 1849eba190 shared: sqlitesearch: Escape FTS arguments
Most users are not to be expected to be familiar with
sqlite's FTS syntax. It also leads to unnnecessary
arrows in some instances.

So wrap every space separated word in quotes, unless
it's already in quotes. Then we just escape those with
double-quotes.
2022-07-28 17:49:40 +02:00

25 rindas
617 B
C++

#ifndef SQLITESEARCH_H
#define SQLITESEARCH_H
#include <QSqlDatabase>
#include <QPair>
#include "searchresult.h"
#include "token.h"
#include "../shared/looqsquery.h"
class SqliteSearch
{
public:
SqliteSearch(QSqlDatabase &db);
QVector<SearchResult> search(const LooqsQuery &query);
private:
QSqlDatabase *db;
QSqlQuery makeSqlQuery(const LooqsQuery &query);
QString fieldToColumn(QueryField field);
QPair<QString, QVector<QString>> createSql(const Token &token);
QString createSortSql(const QVector<SortCondition> sortConditions);
QString escapeFtsArgument(QString ftsArg);
};
#endif // SQLITESEARCH_H