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.track_number NULLS LAST,
|
||||||
t.id
|
t.id
|
||||||
LIMIT 1)
|
LIMIT 1)
|
||||||
)
|
)::uuid AS id
|
||||||
`
|
`
|
||||||
|
|
||||||
type PickTopPlayedTrackForArtistByUserParams struct {
|
type PickTopPlayedTrackForArtistByUserParams struct {
|
||||||
@@ -301,11 +301,12 @@ type PickTopPlayedTrackForArtistByUserParams struct {
|
|||||||
// "Songs like X" seed selection. Returns the user's most-played non-skipped
|
// "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-
|
// 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.
|
// 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)
|
row := q.db.QueryRow(ctx, pickTopPlayedTrackForArtistByUser, arg.UserID, arg.ArtistID)
|
||||||
var coalesce interface{}
|
var id pgtype.UUID
|
||||||
err := row.Scan(&coalesce)
|
err := row.Scan(&id)
|
||||||
return coalesce, err
|
return id, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const pickTopPlayedTrackForUser = `-- name: PickTopPlayedTrackForUser :one
|
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
|
-- "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-
|
-- 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.
|
-- recent album's first track if no plays exist.
|
||||||
|
-- Cast to uuid so sqlc infers pgtype.UUID rather than interface{}.
|
||||||
SELECT COALESCE(
|
SELECT COALESCE(
|
||||||
(SELECT t.id
|
(SELECT t.id
|
||||||
FROM play_events pe
|
FROM play_events pe
|
||||||
@@ -106,7 +107,7 @@ SELECT COALESCE(
|
|||||||
t.track_number NULLS LAST,
|
t.track_number NULLS LAST,
|
||||||
t.id
|
t.id
|
||||||
LIMIT 1)
|
LIMIT 1)
|
||||||
);
|
)::uuid AS id;
|
||||||
|
|
||||||
-- name: PickTopAlbumCoverForArtistByUser :one
|
-- name: PickTopAlbumCoverForArtistByUser :one
|
||||||
-- "Songs like X" cover. Most-played album by user; tie-break by most-recent
|
-- "Songs like X" cover. Most-played album by user; tie-break by most-recent
|
||||||
|
|||||||
Reference in New Issue
Block a user