# HG changeset patch # User Goffi # Date 1546543863 -3600 # Node ID 40e5edd7ea11f2b6938bce50f40d37dc314396a8 # Parent 26e46a3043e530871ace8d1880ddc0f5a98e6b07 storage: changed items order: items were so far ordered by item_id, i.e. by order of creation. This has been changed to order them by date of last update, so an item overwritting an old one appears on top (with former behaviour, it was staying at the same place). The XEP is not clear on that, but this seems more in correct with ยง 6.5.7 which says "implementations SHOULD return the N most recent (as opposed to the N oldest) items". diff -r 26e46a3043e5 -r 40e5edd7ea11 src/pgsql_storage.py --- a/src/pgsql_storage.py Sun Mar 04 21:06:23 2018 +0100 +++ b/src/pgsql_storage.py Thu Jan 03 20:31:03 2019 +0100 @@ -437,7 +437,7 @@ AND node IN %s AND nodes.access_model in %s AND items.access_model in %s - ORDER BY node_id DESC, item_id DESC""", + ORDER BY node_id DESC, items.updated DESC""", (tuple([e.userhost() for e in entities]), nodes, node_accesses, @@ -1031,7 +1031,7 @@ query.extend(query_filters) - return "ORDER BY item_id DESC" + return "ORDER BY items.updated DESC" def _getItems(self, cursor, authorized_groups, unrestricted, maxItems, ext_data, ids_only): self._checkNodeExists(cursor) @@ -1075,7 +1075,7 @@ # if we have maxItems (i.e. a limit), we need to reverse order # in a first query to get the right items query.insert(0,"SELECT * from (") - query.append("ORDER BY item_id ASC LIMIT %s) as x") + query.append("ORDER BY updated ASC LIMIT %s) as x") args.append(maxItems) elif rsm.after: query.append("AND item_id<(SELECT item_id FROM items WHERE item=%s LIMIT 1)")