Skip to content

Fix backward keyset pagination for epics start_date/end_date

Felipe Artur requested to merge issue_281152 into master

What does this MR do?

Fix bug with GraphQL pagination, when sorting epics by start date and fetching last N elements.

Consider the following query:

  group(fullPath: 'anypath') {
    epics(sort: start_date_asc, last: 2) {
       id
    }
  }

When executing this query GraqphQL will call sorted_collection.last(n) which calls sorted_collection.reverse_order which, in this case, throws an ActiveRecord::IrreversibleOrderError: Order "start_date ASC NULLS LAST" cannot be reversed automatically error.

For some reason, Rails is not capable of reversing queries when the NULLS LAST statement is present. This fixes the problem for epics GraphQL queries using keyset pagination implemented on !51481 (merged) which allows specifying a reverse statement to be used.

More information in #281152 (closed)

Edited by Felipe Artur

Merge request reports