core
core copied to clipboard
Error in Pagination with Order Filter
API Platform version(s) affected: 2.6.8. I'm not sure if other versions are afected
Description
I was working with the Pagination on API Platform in SQL Server 2019 with an order query, and I noted that when I use a order clause, the query does not order by the identity key, so if a record have the same value for the order field, the SQL Server DOES NOT guaranty the order of the set, causing the offset to be incorrect, leading to omit or display duplicate results.
How to reproduce
- Make a entity with a field with OrderFilter and the pagination enabled.
- Insert some repeated values in the order field in the database.
- Try to make a GET request to the paginated collection with the order query.
- Check the records for each page.
Possible Solution
The generated SQL from the ORM should have the identity field in the ORDER BY clause in the end, to preserve the original ORDER BY clause.