Repository navigation
Conversation
The hidden_gems, critically_acclaimed, and forgotten_favorites section
recipes failed for viewers scoped to specific libraries:
ERROR: column reference "content_id" is ambiguous (SQLSTATE 42702)
ListByRatingThreshold, ListUnplayedHighRated, and ListForgottenFavorites
join media_item_libraries (which also has a content_id column) when access
is library-restricted, but selected the unqualified itemColumns list,
making the leading content_id ambiguous.
Select qualifiedItemColumns("mi") instead. The SQL-building logic for each
query is extracted into a testable builder so the regression test exercises
the real production query rather than a duplicated copy in the test file.
📝 WalkthroughWalkthroughThe PR extracts SQL-building helpers for three discovery queries (rating-threshold, unplayed-high-rated, forgotten-favorites) to centralize access-filter logic. Each helper returns an empty query string when all libraries are excluded, and public methods now early-return empty results instead of handling this case inline. Column selections are qualified with the ChangesDiscovery Query Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing this in favor of #88. #88 keeps the useful discovery query-builder extraction and column qualification from this PR, then extends the fix to use the existing |
Problem
Two catalog issues were failing in nearby paths:
DiscoveryRepositoryfail at runtime for library-scoped viewers with:This affects the
hidden_gems,critically_acclaimed, andforgotten_favoritessection recipes when access joinsmedia_item_libraries.Root cause
ListByRatingThreshold,ListUnplayedHighRated, andListForgottenFavoritesconditionally joinmedia_item_libraries milto enforce library access.media_item_librariesalso has acontent_idcolumn, but the queries selected from the unqualifieditemColumnsconstant.For late orphan cleanup, the collect/delete SQL fragments used only
orphanedMediaItemSafetyConditionsinstead oforphanedProvisionalMediaItemConditions, dropping themi.status IN (pending, unmatched, ambiguous)guard.Fix
qualifiedItemColumns("mi")in the discovery query builders.orphanedProvisionalMediaItemConditionsin both late orphan collect/delete queries.Testing