Don't generate empty SQL commands if no data is to be changed.

sql-rework
Tomasz Golinski 2019-10-01 17:29:17 +02:00
rodzic 2a00a57b3c
commit ab2f66c87a
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -164,6 +164,9 @@ bool OCdb::update_cache(json j) {
if (j["data"]["owner"].count("uuid") > 0 && !j["data"]["owner"]["uuid"].is_null())
fields["owner"] = j["data"]["owner"]["uuid"].get<std::string>();
if (fields.empty() && fields2.empty())
return 2;
std::string sql = "INSERT INTO caches (code,";
for (auto& i : fields)
sql += i.first + ',';
@ -220,6 +223,9 @@ bool OCdb::update_log(json j) {
if (j["data"].count("text") > 0 && !j["data"]["text"].is_null())
fields["text"] = j["data"]["text"].get<std::string>();
if (fields.empty())
return 2;
std::string sql = "INSERT INTO logs (uuid,";
for (auto& i : fields)
sql += i.first + ',';