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
Unknown Object (File)
Wed, Sep 4, 1:58 AM
Unknown Object (File)
Wed, Sep 4, 1:58 AM
Unknown Object (File)
Wed, Sep 4, 1:58 AM
Unknown Object (File)
Wed, Sep 4, 1:58 AM
Unknown Object (File)
Wed, Sep 4, 1:58 AM
Unknown Object (File)
Wed, Sep 4, 1:58 AM
Unknown Object (File)
Sun, Sep 1, 8:08 PM
Unknown Object (File)
Sat, Aug 31, 5:08 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Update SQL formatting

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
1446–1448 ↗(On Diff #42353)

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