Skip to content

Fix backward keyset pagination for merged_at

Adam Hegyi requested to merge fix-backward-keyset-pagination-for-merged-at into master

What does this MR do?

This MR fixes backward keyset pagination when ordering by merged_at.

In the Connection class we call last(N) (here) on the scope which reverses the order under the hood (relevant code).

When the ORDER BY expression is too complex, ActiveRecord cannot reverse it, so it raises ActiveRecord::IrreversibleOrderError.

This MR allows developers to "catch/detect" such queries and provide a custom order reverse strategy so the error is avoided.

The root cause is the NULLS LAST ordering, snippet example:

MergeRequest.order_merged_at(:asc).reverse_order

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Adam Hegyi

Merge request reports