orchestracities / anubis

Anubis: a flexible policy enforcement solution for NGSI APIs (and beyond!)
https://anubis-pep.readthedocs.org
Apache License 2.0
7 stars 5 forks source link

Order results when using pagination #208

Closed c0c0n3 closed 1 year ago

c0c0n3 commented 1 year ago

Describe the bug It looks like result sets aren't ordered when using pagination params, e.g.

Without order, pagination will be inconsistent, especially when you have lots of rows in the underlying DB table. For example two pages (as determined by the offset and limit params) may wind up having some rows in common:

table: [r1, r2, ..., r100]

offset = 0 && limit = 3   ~~~> [r1, r2, r3]
offset = 3 && limit = 3   ~~~> [r2, r3, r4]

To Reproduce N/A

Expected behavior All queries involving pagination should also have an order by clause.

Additional context See e.g.

Thus, using different LIMIT/OFFSET values to select different subsets of a query result will give inconsistent results unless you enforce a predictable result ordering with ORDER BY