diff --git a/src/DistroqueryAPI.cpp b/src/DistroqueryAPI.cpp index bed128a..19ffa8e 100644 --- a/src/DistroqueryAPI.cpp +++ b/src/DistroqueryAPI.cpp @@ -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(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(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(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);