src/DistroqueryAPI: getProvidersForRequirementFromDb: fix for requirements not found if of arch 'noarch'

This commit is contained in:
Silvan 2024-11-03 15:45:45 +01:00
parent a89f9552ec
commit fd5a9768da

View File

@ -259,7 +259,7 @@ json DistroqueryAPI::getProvidersForRequirementFromDb(sqlite3 *db , configTag* c
while (ct->repository[i]) {
if (a + i > 0) sql += " UNION ";
sql += "SELECT *,'" + string(ct->repository[i]->tag) + "' AS repository,'" +
arch + "' AS arch "
arch + "' AS qarch "
"FROM '" + string(ct->repository[i]->tag) + "_" + arch + "'.provides,'" +
string(ct->repository[i]->tag) + "_" + arch + "'.packages "
"WHERE providename='" + requirement + "' AND packages.id=provides.id_package";
@ -275,9 +275,10 @@ json DistroqueryAPI::getProvidersForRequirementFromDb(sqlite3 *db , configTag* c
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt, NULL) == SQLITE_OK) {
json providers = json::array();
while (sqlite3_step(stmt) == SQLITE_ROW) {
string arch = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "arch")));
if (!archs.contains(arch)) {
archs[arch] = json::array();
// Differentiate queried arch from package arch which might also be 'noarch'
string qarch = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "qarch")));
if (!archs.contains(qarch)) {
archs[qarch] = json::array();
}
json provider = {};
provider["repository"] = reinterpret_cast<const char*>(sqlite3_column_text(stmt,sqlite3_find_column_id(stmt, NULL, "repository")));
@ -292,7 +293,7 @@ json DistroqueryAPI::getProvidersForRequirementFromDb(sqlite3 *db , configTag* c
continue;
}
archs[arch].push_back(provider);
archs[qarch].push_back(provider);
}
//j["providers"] = providers;
sqlite3_finalize(stmt);