]> git.sesse.net Git - pkanalytics/commitdiff
Fix export of nulls in the player JSON objects.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 9 May 2023 06:36:00 +0000 (08:36 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 9 May 2023 06:36:00 +0000 (08:36 +0200)
json.cpp

index 56b2000da510bb15acfb76a4fe22c0eb7ed5656d..ec7d3eb3c58a78714c6b7acf5a546015646ddd7e 100644 (file)
--- a/json.cpp
+++ b/json.cpp
@@ -61,7 +61,11 @@ QJsonArray export_matches_to_json(sqlite3 *db)
 
                        QJsonObject e;
                        e.insert("t", sqlite3_column_int(stmt, 1));
-                       e.insert("player", sqlite3_column_int(stmt, 2));
+                       if (sqlite3_column_type(stmt, 2) == SQLITE_INTEGER) {
+                               e.insert("player", sqlite3_column_int(stmt, 2));
+                       } else {
+                               e.insert("player", QJsonValue());  // null
+                       }
                        e.insert("type", (const char *)sqlite3_column_text(stmt, 3));
                        events_per_match[match]->push_back(std::move(e));
                } else if (ret == SQLITE_DONE) {