mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
With group_by_meta_id, the sibling-dedup window picks each group's representative by main-sibling/prerelease/region rank, and the outer ORDER BY only ever saw that rom's own sort key, so a group whose rank-preferred copy was never touched sorted into the NULL tail even when another sibling was played yesterday. RomUser-column sorts now aggregate the key across the group inside the existing window pass (MAX descending, MIN ascending, so a group lands in the NULL bucket only when every sibling's key is NULL), and the outer ordering reads that group value through a null-safe outer join that keeps the covering-index plan (the inner-join and CTE shapes measured 3-7x worse; this one is ~1.55x master on the one family it fixes and compiles byte-identically everywhere else). The displayed representative stays the rank-preferred one. Metadata and Rom-side grouped sorts keep representative order deliberately, since materializing a roms-side key into the window drops it off idx_roms_sibling_cover, the regression migration 0107 prevents. Fixes #4447 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ldi4YaXJWDDmFdbKfQay8L