]> git.sesse.net Git - ccbs/commitdiff
Handle NULL values in scores better.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 16:42:37 +0000 (16:42 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 16:42:37 +0000 (16:42 +0000)
bigscreen/fetch_group.cpp
bigscreen/group.h

index e1d0112160f2fa6f9e85d692e731f5f0e32fd9d1..7962897ca328a7eb9a7f2fae5a04ebfe873d03e6 100644 (file)
@@ -35,13 +35,24 @@ void FetchGroup::operator() (pqxx::transaction<> &t)
                Score sc;
                Song so;
 
-               so.id = i["song"].as(so.id);
-               so.title = i["song"].as(so.title);
-               so.artist = i["song"].as(so.artist);
+               if (i["song"].is_null()) {
+                       so.id = -1;
+               } else {
+                       so.id = i["song"].as(so.id);
+                       so.title = i["song"].as(so.title);
+                       so.artist = i["song"].as(so.artist);
+               }
        
                sc.song = so;
                sc.chosen = i["chosen"].as(sc.chosen);
-               sc.score = i["score"].as(sc.score);
+
+               if (i["score"].is_null()) {
+                       sc.score = -1;
+               } else {
+                       sc.score = i["score"].as(sc.score);
+               }
+
+               std::printf("score: %u\n", sc.score);
                
                curr_group.players[curr_group.players.size() - 1].scores.push_back(sc);
        }
index f6348c0cab71576d49ddcd26700586164e24a4c3..c57f7b3aba6a2b368d0495bcf4469c921c216c0b 100644 (file)
@@ -6,13 +6,13 @@
 
 /* This more or less mimics the structures from show-tournament.pl */
 struct Song {
-       unsigned id;
+       int id;
        widestring title, artist;
 };
 struct Score {
        Song song;
        bool chosen;
-       unsigned score;
+       int score;
 };
 struct Player {
        unsigned id;