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)