From 4da3f3510b20ca47bdba6eda4e9b420fb1013af0 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 4 Sep 2026 21:20:22 -0400 Subject: [PATCH] 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. --- persistence/artwork_queue_repository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence/artwork_queue_repository.go b/persistence/artwork_queue_repository.go index 834af31d1..24b2423af 100644 --- a/persistence/artwork_queue_repository.go +++ b/persistence/artwork_queue_repository.go @@ -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) {