Fix duplicate .sorted() call causing double joins on bookmarks page#1322
Merged
Fix duplicate .sorted() call causing double joins on bookmarks page#1322
Conversation
jmilljr24
requested changes
Mar 3, 2026
Collaborator
|
84fa5a9 to
47448e5
Compare
Collaborator
Author
|
@jmilljr24 would you try again? |
47448e5 to
2e297d8
Compare
421e33a to
ad92c41
Compare
Bookmark.search already calls .sorted() internally, but both BookmarksController#index and #personal were calling .sorted() again on the result. This doubled the SQL joins, causing a ProtocolError in production when sorting by title. Also fixes existing specs that replicated the same double-sort pattern, and adds test coverage for title filter + title sort combinations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ad92c41 to
a303bb7
Compare
jmilljr24
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What is the goal of this PR and why is this important?
ActiveRecord::StatementInvalid: Trilogy::ProtocolError: 1066: Not unique table/alias: 'community_news'onBookmarksController#personalBookmark.searchalready calls.sorted()internally, but both controller actions were calling.sorted()again on the result, doubling the SQL joinsHow did you approach the change?
.sorted()calls fromBookmarksController#indexand#personal—Bookmark.searchalready calls.sorted()internally, so calling it again joined the aliased tables a second timesort=titleandtitle=filter paramsUI Testing Checklist
Anything else to add?
st_prefix insort_by_title,wt_prefix inwindows_type) already on main prevents join conflicts between filter and sort scopes — this PR just removes the redundant second.sorted()call that duplicated the aliased joins🤖 Generated with Claude Code