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
F3379835: D12778.diff
Wed, Nov 27, 7:32 PM
Unknown Object (File)
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)
Oct 26 2024, 2:46 AM
Unknown Object (File)
Oct 24 2024, 5:42 AM
Unknown Object (File)
Oct 15 2024, 10:21 AM
Unknown Object (File)
Oct 14 2024, 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
Lint
No Lint Coverage
Unit
No Test Coverage

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

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