1
0

shared: Adjust queries to db revision 2

Este cometimento está contido em:
Albert S. 2022-07-28 13:58:25 +02:00
ascendente 78f38fa418
cometimento 1da8344295
2 ficheiros modificados com 8 adições e 5 eliminações

Ver ficheiro

@ -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();

Ver ficheiro

@ -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