Albert S
1849eba190
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.
25 Zeilen
617 B
C++
25 Zeilen
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
|