changeset 457:7c9792f934a2

psql: use `created` colum to sort by creation: `item_id` was used to sort by creation because it correspond to it and it's slighly more efficient, but #398 raises the use case of manually modified database to import items. The column has been changed to suit this use case, and `item_id` is now always added as last order, in case of date conflicts. This patch extends a contribution from Stephen Paul Weber (Singpolyma) from the ticket mentioned below. fix: 398
author Goffi <goffi@goffi.org>
date Thu, 30 Sep 2021 18:56:42 +0200
parents b52ebc45b8e3
children bc2e04a4d3c1
files README sat_pubsub/pgsql_storage.py
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/README	Thu Sep 30 16:55:05 2021 +0200
+++ b/README	Thu Sep 30 18:56:42 2021 +0200
@@ -55,6 +55,7 @@
 
 - Arnaud Joset
 - W. Martin Borgert
+- Stephen Paul Weber
 
 
 ** CONTRIBUTIONS **
--- a/sat_pubsub/pgsql_storage.py	Thu Sep 30 16:55:05 2021 +0200
+++ b/sat_pubsub/pgsql_storage.py	Thu Sep 30 18:56:42 2021 +0200
@@ -894,7 +894,7 @@
         cols_statmnt = []
         for key in keys:
             if key == 'creation':
-                column = 'item_id'  # could work with items.created too
+                column = 'created'
             elif key == 'modification':
                 column = 'updated'
             else:
@@ -902,8 +902,7 @@
                 column = 'updated'
             cols_statmnt.append(f"{column} {direction}")
 
-        if len(cols_statmnt) == 1 and column != "item_id":
-            cols_statmnt.append(f"item_id {direction}")
+        cols_statmnt.append(f"item_id {direction}")
         return "ORDER BY " + ",".join([col for col in cols_statmnt])
 
     @defer.inlineCallbacks