fix(pglite): qualify the artwork_queue upsert priority column

In PostgreSQL, a bare column name in ON CONFLICT DO UPDATE is ambiguous
between the target row and excluded, and MAX() is an aggregate rather
than the two-argument function SQLite provides. Every artwork enqueue
failed with 'column reference "priority" is ambiguous' on a real
library.
This commit is contained in:
Deluan 2026-09-04 21:20:22 -04:00
commit 4da3f3510b

View file

@ -47,13 +47,13 @@ func (r *artworkQueueRepository) Get(kind model.Kind, id, imageType string) (*mo
// row's spent retry budget) and clears trace (so explain does not show a prior failure at attempts 0).
func (r *artworkQueueRepository) Enqueue(items ...model.ArtworkQueueItem) error {
return r.enqueue(`ON CONFLICT (item_kind, item_id, image_type) DO UPDATE SET
priority = MAX(priority, excluded.priority), retry_at = excluded.retry_at,
priority = GREATEST(artwork_queue.priority, excluded.priority), retry_at = excluded.retry_at,
attempts = 0, enqueued_at = excluded.enqueued_at, trace = '[]'`, items)
}
func (r *artworkQueueRepository) EnqueuePreservingBackoff(items ...model.ArtworkQueueItem) error {
return r.enqueue(`ON CONFLICT (item_kind, item_id, image_type) DO UPDATE SET
priority = MAX(priority, excluded.priority)`, items)
priority = GREATEST(artwork_queue.priority, excluded.priority)`, items)
}
func (r *artworkQueueRepository) EnqueueAllMissing(kind model.Kind, priority int) (int64, error) {