Page MenuHomePhabricator

[native] Add SQLiteQueryExecutor code for inserting into the search table
ClosedPublic

Authored by inka on Jul 16 2024, 7:54 AM.
Tags
None
Referenced Files
F3174254: D12778.id42662.diff
Thu, Nov 7, 4:02 PM
Unknown Object (File)
Mon, Nov 4, 3:51 AM
Unknown Object (File)
Fri, Nov 1, 7:41 PM
Unknown Object (File)
Sat, Oct 26, 2:46 AM
Unknown Object (File)
Thu, Oct 24, 5:42 AM
Unknown Object (File)
Tue, Oct 15, 10:21 AM
Unknown Object (File)
Mon, Oct 14, 5:13 PM
Unknown Object (File)
Mon, Oct 14, 5:13 PM
Subscribers

Details

Summary

issue: ENG-8642
Usage of SQLiteStatementWrapper, bindStringToSQL, bindResult, sqlite3_step based on rekeyAllEntities
The UPDATE case is for edits - we want to update the entry for the original message. We want original_message_id to always point at the oldest message, message_id to point at the newest edit, and`processed_content` to be the content of the newest edit.
original_message_id == message_id means that the message is the original message, not an edit.

Test Plan

Added the following code at the end of updateMessageSearchResult, and verified that a non zero count if found after calling the function.

std::string query =
  "SELECT * FROM message_search";

comm::SQLiteStatementWrapper preparedSQL1(
    db,
    query,
    "Failed to fetch from search");
int count  = 0;
for (int stepResult = sqlite3_step(preparedSQL1); stepResult == SQLITE_ROW;
    stepResult = sqlite3_step(preparedSQL1)) {
  count++;
}
Logger::log("message search row count: "+ std::to_string(count));

Update tested with tests while developing search query

Diff Detail

Repository
rCOMM Comm
Branch
inka/search
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Update SQL formatting

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
1446–1448

Formatting based on this

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 16 2024, 8:32 AM
Harbormaster failed remote builds in B30391: Diff 42354!
inka requested review of this revision.Jul 17 2024, 3:43 AM
tomek added inline comments.
native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
171 ↗(On Diff #42377)

This name is a bit strange - we update a (virtual) table and not the result. I think updateMessageSearchTable is a better name, or even updateMessageSearchIndex, but it's up to you - keeping the current name also makes some sense.

This revision is now accepted and ready to land.Jul 17 2024, 4:48 AM

It might be a good idea to test both insert and update.

Rename to updateMessageSearchIndex

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
1492 ↗(On Diff #42462)

Don't we normally use two spaces for indents rather than one?

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
1516 ↗(On Diff #42618)

Two spaces for indents