shared: Adjust queries to db revision 2
Tento commit je obsažen v:
rodič
78f38fa418
revize
1da8344295
@ -151,11 +151,14 @@ SaveFileResult SqliteDbService::saveFile(QFileInfo fileInfo, QVector<PageData> &
|
||||
int lastid = inserterQuery.lastInsertId().toInt();
|
||||
for(const PageData &data : pageData)
|
||||
{
|
||||
QSqlQuery ftsQuery(db);
|
||||
ftsQuery.prepare("INSERT INTO fts(content) VALUES(?)");
|
||||
ftsQuery.addBindValue(data.content);
|
||||
ftsQuery.exec();
|
||||
QSqlQuery contentQuery(db);
|
||||
contentQuery.prepare("INSERT INTO content(fileid, page, content) VALUES(?, ?, ?)");
|
||||
contentQuery.prepare("INSERT INTO content(fileid, page, ftsid) VALUES(?, ?, last_insert_rowid())");
|
||||
contentQuery.addBindValue(lastid);
|
||||
contentQuery.addBindValue(data.pagenumber);
|
||||
contentQuery.addBindValue(data.content);
|
||||
if(!contentQuery.exec())
|
||||
{
|
||||
db.rollback();
|
||||
|
@ -115,7 +115,7 @@ QPair<QString, QVector<QString>> SqliteSearch::createSql(const Token &token)
|
||||
}
|
||||
if(token.type == FILTER_CONTENT_CONTAINS)
|
||||
{
|
||||
return {" content.id IN (SELECT content_fts.ROWID FROM content_fts WHERE content_fts.content MATCH ? ORDER BY "
|
||||
return {" content.id IN (SELECT fts.ROWID FROM fts WHERE fts.content MATCH ? ORDER BY "
|
||||
"rank) ",
|
||||
{value}};
|
||||
}
|
||||
@ -141,10 +141,10 @@ QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
|
||||
{
|
||||
if(!ftsAlreadyJoined)
|
||||
{
|
||||
joinSql += " INNER JOIN content_fts ON content.id = content_fts.ROWID ";
|
||||
joinSql += " INNER JOIN fts ON content.ftsid = fts.ROWID ";
|
||||
ftsAlreadyJoined = true;
|
||||
}
|
||||
whereSql += " content_fts.content MATCH ? ";
|
||||
whereSql += " fts.content MATCH ? ";
|
||||
bindValues.append(token.value);
|
||||
}
|
||||
else
|
||||
|
Načítá se…
Odkázat v novém úkolu
Zablokovat Uživatele