OCDB: Prevent data bleeding through from one cache to another

sql-rework
Tomasz Golinski 2020-06-03 00:21:31 +02:00
rodzic cc40e470ea
commit 3b232142b4
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -314,7 +314,6 @@ bool OCdb::read_revision() {
Caches OCdb::get_user_caches_not_found(const std::string& uuid) const {
int res;
Caches cc;
Cache c;
std::string sql = "SELECT code, location, name, region FROM caches WHERE status = 'Available' AND NOT EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?1) AND owner != ?1;";
@ -328,6 +327,7 @@ Caches OCdb::get_user_caches_not_found(const std::string& uuid) const {
res = sqlite3_step(stmt);
while (res == SQLITE_ROW) {
Cache c;
if (sqlite3_column_text(stmt, 0)) c.code = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
if (sqlite3_column_text(stmt, 1)) c.pos = get_lat_lon(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1)));
if (sqlite3_column_text(stmt, 2)) c.name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
@ -349,7 +349,7 @@ Caches OCdb::get_user_caches_not_found(const std::string& uuid) const {
Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) int count) const {
int res;
Caches cc;
Cache c;
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status TEXT, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT)
std::string sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?);";
@ -363,6 +363,7 @@ Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) in
res = sqlite3_step(stmt);
while (res == SQLITE_ROW) {
Cache c;
if (sqlite3_column_text(stmt, 0)) c.code = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
if (sqlite3_column_text(stmt, 1)) c.pos = get_lat_lon(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1)));
if (sqlite3_column_text(stmt, 2)) c.type = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));