From 3f0980a815d81be25fccd04d97a3157c374d88ee Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 24 Nov 2026 13:54:45 -0500 Subject: [PATCH] docs(db): UpsertArtist matches on mbid only; the comment said name too Co-Authored-By: Claude Opus 5.5 --- internal/db/dbq/artists.sql.go | 5 ++++- internal/db/queries/artists.sql | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/db/dbq/artists.sql.go b/internal/db/dbq/artists.sql.go index 9011384a..9d862bfc 100644 --- a/internal/db/dbq/artists.sql.go +++ b/internal/db/dbq/artists.sql.go @@ -485,7 +485,10 @@ type UpsertArtistParams struct { Mbid *string } -// Insert or update by mbid when present; otherwise by (name, sort_name). +// Inserts an artist, or updates the row that already has this mbid. Only +// the mbid is matched: called without one, it inserts a new row every time, +// so a caller that may meet the same artist again looks it up by name first +// (the scanner's resolveArtist does). // Callers pass the canonical sort_name; scanner is responsible for derivation. func (q *Queries) UpsertArtist(ctx context.Context, arg UpsertArtistParams) (Artist, error) { row := q.db.QueryRow(ctx, upsertArtist, arg.Name, arg.SortName, arg.Mbid) diff --git a/internal/db/queries/artists.sql b/internal/db/queries/artists.sql index dbb8048f..e4e4ddb8 100644 --- a/internal/db/queries/artists.sql +++ b/internal/db/queries/artists.sql @@ -1,5 +1,8 @@ -- name: UpsertArtist :one --- Insert or update by mbid when present; otherwise by (name, sort_name). +-- Inserts an artist, or updates the row that already has this mbid. Only +-- the mbid is matched: called without one, it inserts a new row every time, +-- so a caller that may meet the same artist again looks it up by name first +-- (the scanner's resolveArtist does). -- Callers pass the canonical sort_name; scanner is responsible for derivation. INSERT INTO artists (name, sort_name, mbid) VALUES ($1, $2, $3)