:-'Generic Commit'
Some checks failed
Build-Test-Publish / Build (push) Failing after 2s

This commit is contained in:
Your Name
2025-05-29 22:26:48 +12:00
parent 147012bf12
commit f9fee188e8
7 changed files with 109 additions and 175 deletions

View File

@@ -154,19 +154,19 @@ Database::~Database() {
}
}
bool Database::remove(const std::string& labeltag) {
std::string sql = "DELETE FROM objects WHERE labeltag = ?;";
sqlite3_stmt* stmt;
// bool Database::remove(const std::string& labeltag) {
// std::string sql = "DELETE FROM objects WHERE labeltag = ?;";
// sqlite3_stmt* stmt;
if (sqlite3_prepare_v2(db_, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
return false;
}
// if (sqlite3_prepare_v2(db_, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
// return false;
// }
sqlite3_bind_text(stmt, 1, labeltag.c_str(), -1, SQLITE_STATIC);
bool success = sqlite3_step(stmt) == SQLITE_DONE;
sqlite3_finalize(stmt);
return success;
}
// sqlite3_bind_text(stmt, 1, labeltag.c_str(), -1, SQLITE_STATIC);
// bool success = sqlite3_step(stmt) == SQLITE_DONE;
// sqlite3_finalize(stmt);
// return success;
// }
bool Database::remove_by_hash(const std::string& hash) {
std::string sql = "DELETE FROM objects WHERE hash = ?;";
@@ -182,9 +182,9 @@ bool Database::remove_by_hash(const std::string& hash) {
return success;
}
bool Database::get(const std::string& key, dbEntry& entry) {
bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
std::string sql;
if (key.find(':') != std::string::npos) {
if (hash_or_labeltag.find(':') != std::string::npos) {
// Query by label:tag - search for exact match in the JSON array
sql = "SELECT hash, labeltags, metadata FROM objects WHERE json_array_length(labeltags) > 0 AND EXISTS (SELECT 1 FROM json_each(labeltags) WHERE value = ?);";
} else {
@@ -197,12 +197,7 @@ bool Database::get(const std::string& key, dbEntry& entry) {
return false;
}
if (key.find(':') != std::string::npos) {
// For label:tag queries, bind the exact label:tag string
sqlite3_bind_text(stmt, 1, key.c_str(), -1, SQLITE_STATIC);
} else {
sqlite3_bind_text(stmt, 1, key.c_str(), -1, SQLITE_STATIC);
}
sqlite3_bind_text(stmt, 1, hash_or_labeltag.c_str(), -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_ROW) {
sqlite3_finalize(stmt);