fix: add unique constraint for saved filter names and fix search sort ordering
Database changes: - Add unique index on saved_filters(user_id, name, resource_type) Prevents duplicate filter names while allowing same name across different users or different resource types Search functionality fix: - Remove DISTINCT ON (mi.id) from SearchMediaItemsUnified query - Remove mi.id from ORDER BY clause (was required by DISTINCT ON) - This allows user-selected sort field to be primary sort criteria - Previously results were always sorted by ID first, making sort dropdown ineffective - Relevance score and title remain as fallback sorts This fixes the sort dropdown functionality on the bookshelf page where changing the sort option appeared to have no effect.
This commit is contained in:
@@ -373,7 +373,7 @@ LEFT JOIN library_visibility lv ON l.id = lv.library_id AND lv.user_id = sqlc.na
|
||||
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
||||
|
||||
-- name: SearchMediaItemsUnified :many
|
||||
SELECT DISTINCT ON (mi.id)
|
||||
SELECT
|
||||
mi.id,
|
||||
mi.library_id,
|
||||
mi.title,
|
||||
@@ -495,7 +495,6 @@ WHERE COALESCE(lv.is_visible, true) = true
|
||||
)
|
||||
)
|
||||
ORDER BY
|
||||
mi.id,
|
||||
-- Primary sort: relevance score when searching
|
||||
CASE
|
||||
WHEN sqlc.narg('search_query') != '' THEN
|
||||
|
||||
Reference in New Issue
Block a user