fix(db): collapse presentation-key groups without min(uuid) #10

Merged
benvin merged 1 commits from benvin/fix-guid-aggregate-pg into main 2026-09-13 14:25:19 +10:00
Member

PostgreSQL has no min(uuid) aggregate, so collapsing a presentation-key group with MIN over the item id failed with 42883 on every library browse, search result, Recently Added, by-name and Upcoming query.

  • Pick the group representative with an anti-join: the row no other row in its group sorts before, preferring a NULL PrimaryVersionId and then the lowest id
  • Compare ids natively on both providers, so nothing casts the id away from its index
  • Cover the collapse with a repository test against a real PostgreSQL, run by the postgres-migration-chain step
PostgreSQL has no min(uuid) aggregate, so collapsing a presentation-key group with MIN over the item id failed with 42883 on every library browse, search result, Recently Added, by-name and Upcoming query. - Pick the group representative with an anti-join: the row no other row in its group sorts before, preferring a NULL PrimaryVersionId and then the lowest id - Compare ids natively on both providers, so nothing casts the id away from its index - Cover the collapse with a repository test against a real PostgreSQL, run by the postgres-migration-chain step
unkin-agent added 1 commit 2026-09-13 13:18:24 +10:00
fix(db): collapse presentation-key groups without min(uuid)
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
6e405af1dc
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
benvin merged commit 2370787471 into main 2026-09-13 14:25:19 +10:00
benvin deleted branch benvin/fix-guid-aggregate-pg 2026-09-13 14:25:20 +10:00
Sign in to join this conversation.