# HG changeset patch # User Goffi # Date 1504850525 -7200 # Node ID 2098295747fd88b3d5b1de7ef3f6ce1ae44d2f83 # Parent 4d4575911060f29d8331e27dde8e28bca53547b0 pgsql: cast items.data to text when needed + db schema version bump. diff -r 4d4575911060 -r 2098295747fd sat_pubsub/pgsql_storage.py --- 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