fix(db/m7-352): cast COALESCE to uuid so sqlc emits typed return
This commit is contained in:
@@ -290,7 +290,7 @@ SELECT COALESCE(
|
||||
t.track_number NULLS LAST,
|
||||
t.id
|
||||
LIMIT 1)
|
||||
)
|
||||
)::uuid AS id
|
||||
`
|
||||
|
||||
type PickTopPlayedTrackForArtistByUserParams struct {
|
||||
@@ -301,11 +301,12 @@ type PickTopPlayedTrackForArtistByUserParams struct {
|
||||
// "Songs like X" seed selection. Returns the user's most-played non-skipped
|
||||
// track by artist X in the last 7 days. Falls back to the artist's most-
|
||||
// recent album's first track if no plays exist.
|
||||
func (q *Queries) PickTopPlayedTrackForArtistByUser(ctx context.Context, arg PickTopPlayedTrackForArtistByUserParams) (interface{}, error) {
|
||||
// Cast to uuid so sqlc infers pgtype.UUID rather than interface{}.
|
||||
func (q *Queries) PickTopPlayedTrackForArtistByUser(ctx context.Context, arg PickTopPlayedTrackForArtistByUserParams) (pgtype.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, pickTopPlayedTrackForArtistByUser, arg.UserID, arg.ArtistID)
|
||||
var coalesce interface{}
|
||||
err := row.Scan(&coalesce)
|
||||
return coalesce, err
|
||||
var id pgtype.UUID
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
const pickTopPlayedTrackForUser = `-- name: PickTopPlayedTrackForUser :one
|
||||
|
||||
@@ -86,6 +86,7 @@ SELECT t.id
|
||||
-- "Songs like X" seed selection. Returns the user's most-played non-skipped
|
||||
-- track by artist X in the last 7 days. Falls back to the artist's most-
|
||||
-- recent album's first track if no plays exist.
|
||||
-- Cast to uuid so sqlc infers pgtype.UUID rather than interface{}.
|
||||
SELECT COALESCE(
|
||||
(SELECT t.id
|
||||
FROM play_events pe
|
||||
@@ -106,7 +107,7 @@ SELECT COALESCE(
|
||||
t.track_number NULLS LAST,
|
||||
t.id
|
||||
LIMIT 1)
|
||||
);
|
||||
)::uuid AS id;
|
||||
|
||||
-- name: PickTopAlbumCoverForArtistByUser :one
|
||||
-- "Songs like X" cover. Most-played album by user; tie-break by most-recent
|
||||
|
||||
Reference in New Issue
Block a user