rails_cursor_pagination
rails_cursor_pagination copied to clipboard
Cursor generation for joined table columns breaks pagination
relation = Member.active.joins("LEFT JOIN memberships ON member.id = memberships.member_id")
RailsCursorPagination::Paginator.new(relation, order_by: "memberships.order", order: :desc)
generates cursors for the records w/o the distinct == or = suffixes (e.g. "W251bGwsMjYxNzRd")
im not sure if this in and of itself is an issue, but trying to use these cursors in further pagination calls always returns empty page data regardless of what combination of first/after or last/before i use.
e.g.
{:page_info=>{:has_previous_page=>true, :has_next_page=>false, :start_cursor=>nil, :end_cursor=>nil}, :page=>[]}
tested some more:
the following are the cursors of the first three records i get back with a simple first: 3
- W251bGwsMjYxNzRd
- W251bGwsMjYxNzNd
- W251bGwsMjYxNzFd
if i use first: 1 with after pointing to the 1st record, i get has_previous_page = true and has_next_page = false
if i use last: 1 with before pointing to the 2nd record, i get has_previous_page = false and has_next_page = true
similarly wonky results occur when i use other combinations
You might find this gem helpful - https://github.com/fatkodima/activerecord_cursor_paginate I created it because I wasn't able to find solutions to this and a few other problems in existing gems.