Philipp Hörist pushed to branch master at gajim / gajim

Commits:
d9ab39b0 by Markus Böhme at 2017-03-25T18:58:35+01:00
Fix loading of additional_data column from log database

Currently, the additional_data column is not correctly loaded from the
log database in the logger module's methods get_last_conversation_lines
and get_conversation_for_date. While the JSON data in the column is
parsed, the parsed value is not saved, because the code assumes that
changes to a loop variable are reflected in the list that is iterated
over. Instead, the unparsed JSON string is returned. Fix this by building
a separate list with the JSON string replaced by the parsed JSON object.

- - - - -
6b34ea95 by Philipp Hörist at 2017-03-25T22:19:29+01:00
Merge branch 'fix-additional_data-loading' into 'master'

Fix loading of additional_data column from log database

See merge request !72
- - - - -


1 changed file:

- src/common/logger.py


Changes:

=====================================
src/common/logger.py
=====================================
--- a/src/common/logger.py
+++ b/src/common/logger.py
@@ -609,13 +609,16 @@ class Logger:
                 restore_how_many_rows, pending_how_many), jid_tuple)
 
             results = self.cur.fetchall()
+            messages = []
             for entry in results:
-                entry = list(entry)
-                entry[4] = json.loads(entry[4])
+                additional_data = json.loads(entry[4])
+                parsed_entry = entry[:4] + (additional_data, ) + entry[5:]
+                messages.append(parsed_entry)
         except sqlite.DatabaseError:
             raise exceptions.DatabaseMalformed
-        results.reverse()
-        return results
+
+        messages.reverse()
+        return messages
 
     def get_unix_time_from_date(self, year, month, day):
         # year (fe 2005), month (fe 11), day (fe 25)
@@ -655,10 +658,13 @@ class Logger:
             ''' % (where_sql, start_of_day, last_second_of_day), jid_tuple)
 
         results = self.cur.fetchall()
+        messages = []
         for entry in results:
-            entry = list(entry)
-            entry[6] = json.loads(entry[6])
-        return results
+            additional_data = json.loads(entry[6])
+            parsed_entry = entry[:6] + (additional_data, ) + entry[7:]
+            messages.append(parsed_entry)
+
+        return messages
 
     def get_search_results_for_query(self, jid, query, account, year=False,
         month=False, day=False):



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/fbb19c5c505a6082e3de54cf80e2c64269a315bf...6b34ea957edd58a4e8f7d873252ed68677d2cc25
_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to