changeset 351:2098295747fd

pgsql: cast items.data to text when needed + db schema version bump.
author Goffi <goffi@goffi.org>
date Fri, 08 Sep 2017 08:02:05 +0200
parents 4d4575911060
children efbdca10f0fb
files sat_pubsub/pgsql_storage.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py	Fri Sep 08 08:02:04 2017 +0200
+++ b/sat_pubsub/pgsql_storage.py	Fri Sep 08 08:02:05 2017 +0200
@@ -75,7 +75,7 @@
 # parseXml manage str, but we get unicode
 parseXml = lambda unicode_data: generic.parseXml(unicode_data.encode('utf-8'))
 PEP_COL_NAME = 'pep'
-CURRENT_VERSION = '2'
+CURRENT_VERSION = '3'
 
 
 def withPEP(query, values, pep, recipient):
@@ -378,7 +378,7 @@
             raise NotImplementedError('only "open" access model is handled for now')
         if not pep:
             raise NotImplementedError(u"getLastItems is only implemented for PEP at the moment")
-        d = self.dbpool.runQuery("""SELECT DISTINCT ON (node_id) pep, node, data, items.access_model
+        d = self.dbpool.runQuery("""SELECT DISTINCT ON (node_id) pep, node, data::text, items.access_model
                                     FROM items
                                     NATURAL JOIN nodes
                                     WHERE nodes.pep IN %s
@@ -891,7 +891,7 @@
         if ids_only:
             query = ["SELECT item"]
         else:
-            query = ["SELECT data,items.access_model,item_id,date"]
+            query = ["SELECT data::text,items.access_model,item_id,date"]
 
         query_order = self._appendSourcesAndFilters(query, args, authorized_groups, unrestricted, ext_data)
 
@@ -976,7 +976,7 @@
         ret = []
         if unrestricted: #we get everything without checking permissions
             for itemIdentifier in itemIdentifiers:
-                cursor.execute("""SELECT data,items.access_model,item_id,date FROM nodes
+                cursor.execute("""SELECT data::text,items.access_model,item_id,date FROM nodes
                                   INNER JOIN items USING (node_id)
                                   WHERE node_id=%s AND item=%s""",
                                (self.nodeDbId,
@@ -1001,7 +1001,7 @@
                 args = [self.nodeDbId, itemIdentifier]
                 if authorized_groups:
                     args.append(authorized_groups)
-                cursor.execute("""SELECT data, date FROM nodes
+                cursor.execute("""SELECT data::text, date FROM nodes
                            INNER  JOIN items USING (node_id)
                            LEFT JOIN item_groups_authorized USING (item_id)
                            WHERE node_id=%s AND item=%s AND