chore(qbz-library): address Task 1 review nits

- Replace the false "SQLite ORDER BY fragility" rationale on the
  Rust-side sort in list_folder_children with the actual reason
  (rows already in memory; Rust case-insensitive compare clearer
  than COLLATE NOCASE on a CASE-derived column).
- Drop the redundant ESCAPE '\\' clause on the literal '%/%' pattern
  in list_folder_tracks. The pattern contains no escape character;
  the clause was a copy-paste artifact from the user-input LIKE
  patterns where ESCAPE is required.

No behaviour change.

cc
This commit is contained in:
vicrodh committed 2026-05-08 14:05:49 -06:00
1 parent 8481f7e8b3
commit 1bb353429c
1 file changed
+4 -4
+4 -4
View File
@@ -1537,9 +1537,9 @@ impl LibraryDatabase {
}
// Sort: folders first, then tracks; alphabetical (case-insensitive)
// within each group. Done in Rust because SQLite's ORDER BY on a
// boolean expression like `(kind = 'track')` is fragile across
// versions and we already have all rows in memory.
// within each group. Done in Rust because we already have all rows
// in memory after the GROUP BY, and Rust's case-insensitive compare
// is more obvious than COLLATE NOCASE on a CASE-derived column.
entries.sort_by(|a, b| {
let kind_rank = |e: &FolderTreeEntry| match e {
FolderTreeEntry::Folder { .. } => 0,
@@ -1574,7 +1574,7 @@ impl LibraryDatabase {
let sql = format!(
"SELECT {cols} FROM local_tracks \
WHERE file_path LIKE ?1 || '/%' ESCAPE '\\' \
AND substr(file_path, length(?2) + 2) NOT LIKE '%/%' ESCAPE '\\' \
AND substr(file_path, length(?2) + 2) NOT LIKE '%/%' \
AND COALESCE(source, 'user') = 'user' \
ORDER BY disc_number ASC NULLS LAST, \
track_number ASC NULLS LAST, \