fix(db): collapse presentation-key groups without min(uuid)
PostgreSQL has no min(uuid) aggregate, so every query that picked a group representative with MIN over the item id failed with 42883: library browse, search, Recently Added, the by-name endpoints and Upcoming. - Pick the representative with an anti-join on (primary version, id) - Cover the collapse with a repository test against a real PostgreSQL
This commit is contained in:
@@ -219,9 +219,11 @@ public sealed partial class BaseItemRepository
|
||||
}
|
||||
else
|
||||
{
|
||||
// The representative is the row no other row in its group sorts before, not MIN(Id):
|
||||
// PostgreSQL has no min(uuid) aggregate, while comparing two uuids is supported everywhere.
|
||||
representativeIds = masterQuery
|
||||
.GroupBy(e => e.PresentationUniqueKey)
|
||||
.Select(g => g.Min(e => e.Id))
|
||||
.Where(e => !masterQuery.Any(o => o.PresentationUniqueKey == e.PresentationUniqueKey && o.Id.CompareTo(e.Id) < 0))
|
||||
.Select(e => e.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user