comparison src/pgsql_storage.py @ 378:22832c1d2827

storage (pgsql): don't specify table name in ORDER BY clause as it can cause troubles in some requests.
author Goffi <goffi@goffi.org>
date Sat, 12 Jan 2019 16:41:45 +0100
parents 9a787881b824
children aa3a464df605
comparison
equal deleted inserted replaced
377:ded7657b03fa 378:22832c1d2827
841 @param direction (unicode): ORDER BY direction (ASC or DESC) 841 @param direction (unicode): ORDER BY direction (ASC or DESC)
842 @return (unicode): ORDER BY clause to use 842 @return (unicode): ORDER BY clause to use
843 """ 843 """
844 keys = ext_data.get('order_by') 844 keys = ext_data.get('order_by')
845 if not keys: 845 if not keys:
846 return u'ORDER BY items.updated ' + direction 846 return u'ORDER BY updated ' + direction
847 cols_statmnt = [] 847 cols_statmnt = []
848 for key in keys: 848 for key in keys:
849 if key == 'creation': 849 if key == 'creation':
850 column = 'items.item_id' # could work with items.created too 850 column = 'item_id' # could work with items.created too
851 elif key == 'modification': 851 elif key == 'modification':
852 column = 'items.updated' 852 column = 'updated'
853 else: 853 else:
854 log.msg(u"WARNING: Unknown order by key: {key}".format(key=key)) 854 log.msg(u"WARNING: Unknown order by key: {key}".format(key=key))
855 column = 'items.updated' 855 column = 'updated'
856 cols_statmnt.append(column + u' ' + direction) 856 cols_statmnt.append(column + u' ' + direction)
857 857
858 return u"ORDER BY " + u",".join([col for col in cols_statmnt]) 858 return u"ORDER BY " + u",".join([col for col in cols_statmnt])
859 859
860 def storeItems(self, item_data, publisher): 860 def storeItems(self, item_data, publisher):