Skip to content
Open
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix unstable ordering in BookCommentResource for PostgreSQL
Add default_sort to Api::V2::BookCommentResource to ensure stable
ordering across cache and non-cache scenarios. Without explicit
ordering, PostgreSQL may return results in different orders, causing
cache test failures.

Fixes: RequestTest#test_pagination_related_resources_data_includes
  • Loading branch information
koji-takao-sp committed Jan 20, 2026
commit 01bdcd47a594f24b1f5f99050701f90aba84f603
5 changes: 5 additions & 0 deletions test/fixtures/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,11 @@ class BookCommentResource < JSONAPI::Resource
records.where(BookComment.arel_table[:body].matches("%#{value[0]}%"))
}

# Add default sort to ensure stable ordering across cache/non-cache scenarios
def self.default_sort
[{field: 'id', direction: :asc}]
end

class << self
def book_comments
BookComment.arel_table
Expand Down
Loading