# HG changeset patch # User Goffi # Date 1633021002 -7200 # Node ID 7c9792f934a226ebc7954bb75eccf5dc03e4ba8f # Parent b52ebc45b8e3eb1b9889214985d33b4248f90d49 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 diff -r b52ebc45b8e3 -r 7c9792f934a2 README --- 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 ** diff -r b52ebc45b8e3 -r 7c9792f934a2 sat_pubsub/pgsql_storage.py --- 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