By-name listings ignore SortBy and SortOrder, and an album with no artist folder borrows from the wrong place #87
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Four by-name listings take a
SortByand aSortOrderfrom the client and answer as if neither had been sent. Both are user-facing controls on those very views, soSortOrder=Descendingon/Artistsis a button that does nothing.Measured against the anchor on
ee063ca, a pair stood up by~/.cache/anchor/pair.sh, first three names of?Limit=5:SortOrder=DescendingSortBy=DateCreated/Genres/MusicGenres/Artists/Artists/AlbumArtists/Studios/Persons/YearsThe bottom three rows are not luck.
StudiosControllerandPersonsControllernever setOrderByat all, so ignoring the parameter there is what upstream does — the gap is exactly the four controllers that do pass it:/MusicGenresagreeing underSortBy=DateCreatedis a coincidence of this library, not support.Concretely:
Why the sort is not simply routed through the query builder
A by-name listing is not one query.
gatheredmerges the rows a scan wrote with the names no row stands for — derived on the spot, with noDateCreated, no rating and no run time — and sorts the merge in memory. Anything but a name has nothing to sort the derived half on./Yearsshows the shape of the answer:orderedmodels two of upstream's comparers, applies them stably in reverse, and leaves the order the walk found for any field it does not model. Its own doc is candid that this is upstream's answer only where upstream's comparer holds the items equal — which is why/Yearsstill differs underSortBy=DateCreated, upstream sorting those by when each year's metadata directory was made.So the work is: give the other four the same treatment, and decide per field whether a derived entry can be ordered by it at all.
A tiebreak that is applied unconditionally
ApplyOrderaddsThenBy(e => e.Name)only when the first ordering isSortNameorDefault:named_inputsBaseItems.Namein itsORDER BYunconditionally, andsort_keycarries the name in its key unconditionally. While these listings ignoreSortBythat is invisible — the sort they actually do is always by sort name — but it becomes wrong the moment the first is anything else. Whoever fixes the above should make it positional at the same time.A second residual, on the same fixed page
MusicAlbum.GetMusicArtistwalks the album's parents for aMusicArtistand, finding none, falls back on the name:So an album with an album artist always resolves to a
MusicArtist— an existing by-name row, or one created for the name. Ourartist_abovewalks the parents the same way and then returns nothing, andimage_parentdrops through to whatever folder encloses the album, lending its pictures.For a flat music library — tracks and albums with no artist folder above them, and no artist row — upstream inherits from the by-name artist and we inherit from the library folder. It does not reproduce on the anchor, whose albums all sit under artist folders. It was unreachable for an album carrying an album artist until the artist batch started missing on purpose; it is reachable now.
Found while closing the last three of #86.
Closed. All three, measured against the anchor.
The four controllers that pass an
OrderBynow reach the query./Genres,/MusicGenres,/Artistsand/Artists/AlbumArtiststakeSortBy/SortOrder;/Studiosand/Personsstill ignore them, which is what upstream does, because their controllers set no ordering at all. Every cell of the table in this issue now agrees — 21 of 21 across the seven routes and the three orderings.The names no row stands for are merged rather than sorted. A derived entry is a name and nothing else: no date, no rating, no run time, because the row it stands for was never written. So it takes part only in an ordering over a name, and under any other it falls where a row holding nothing in that column falls — first ascending, last descending. The rows themselves keep the order the database gave them.
The
Nametiebreak. Upstream adds it behind a leading sort-name ordering and behind no other, and closes with an ascending sort name unless one of the orderings already was a name. It stops there, so rows tied on all of those come back in whatever order its query plan produced; we settle exactly those with the name and then the id, which can only differ where upstream does not decide.The album borrow was narrower than this issue said.
GetImageDisplayParentdoes fall through to the enclosing folder — but only where the artist lookup returned null, andGetArtist(name)is non-null whenever the album names an album artist. So the rule is not "an album never reaches a folder": an album naming no artist correctly takes what it sits in, and only one naming an artist stops short. That is what landed, with a fixture carrying both cases.One residual, unchanged and worth stating: where an album names an artist the page does not credit and no artist stands above it, upstream reaches that artist by name and borrows its pictures, while we borrow nothing. Reaching it needs a by-name lookup keyed on the metadata path rather than on the folded or lowercased name, which no batch here holds. The visible difference is confined to an album whose artist has pictures and is neither its parent nor on its page.
portable.jsonunchanged at 60 responses, 101 differences, 59 agreeing.