Mercurial > libervia-pubsub
diff sat_pubsub/pgsql_storage.py @ 450:96059231d58f
pgsql: fix RSM before and after subqueries
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 22 Apr 2021 18:27:03 +0200 |
parents | 074037832daf |
children | 0e6e176cb572 |
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py Thu Apr 22 18:26:12 2021 +0200 +++ b/sat_pubsub/pgsql_storage.py Thu Apr 22 18:27:03 2021 +0200 @@ -1177,8 +1177,11 @@ args.append(item_id) elif rsm.before is not None: if rsm.before != '': - query.append("AND item_id>(SELECT item_id FROM items WHERE item=%s LIMIT 1)") - args.append(rsm.before) + query.append( + "AND item_id>(SELECT item_id FROM items WHERE node_id=%s AND " + "item=%s LIMIT 1)" + ) + args.extend((self.nodeDbId, rsm.before)) if maxItems is not None: # if we have maxItems (i.e. a limit), we need to reverse order # in a first query to get the right items @@ -1187,8 +1190,11 @@ query.append("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)") - args.append(rsm.after) + query.append( + "AND item_id<(SELECT item_id FROM items WHERE node_id=%s AND item=%s " + "LIMIT 1)" + ) + args.extend((self.nodeDbId, rsm.after)) query.append(query_order)