fix: COALESCE all bare p.duration_ms to prevent NULL scan crash on focus-context and other queries
This commit is contained in:
parent
10c48f1fd7
commit
c83317c29c
|
|
@ -83,7 +83,7 @@ func (r *PostRepository) CreatePost(ctx context.Context, post *models.Post) erro
|
|||
func (r *PostRepository) GetRandomSponsoredPost(ctx context.Context, userID string) (*models.Post, error) {
|
||||
query := `
|
||||
SELECT
|
||||
p.id, p.author_id, p.category_id, p.body, COALESCE(p.image_url, ''), COALESCE(p.video_url, ''), COALESCE(p.thumbnail_url, ''), p.duration_ms, COALESCE(p.tags, ARRAY[]::text[]), p.created_at,
|
||||
p.id, p.author_id, p.category_id, p.body, COALESCE(p.image_url, ''), COALESCE(p.video_url, ''), COALESCE(p.thumbnail_url, ''), COALESCE(p.duration_ms, 0), COALESCE(p.tags, ARRAY[]::text[]), p.created_at,
|
||||
pr.handle as author_handle, pr.display_name as author_display_name, COALESCE(pr.avatar_url, '') as author_avatar_url,
|
||||
COALESCE(m.like_count, 0) as like_count, COALESCE(m.comment_count, 0) as comment_count,
|
||||
FALSE as is_liked,
|
||||
|
|
@ -295,7 +295,7 @@ func (r *PostRepository) GetPostByID(ctx context.Context, postID string, userID
|
|||
ELSE ''
|
||||
END AS resolved_video_url,
|
||||
COALESCE(NULLIF(p.thumbnail_url, ''), p.image_url, '') AS resolved_thumbnail_url,
|
||||
p.duration_ms,
|
||||
COALESCE(p.duration_ms, 0),
|
||||
COALESCE(p.tags, ARRAY[]::text[]),
|
||||
p.created_at,
|
||||
p.chain_parent_id,
|
||||
|
|
@ -972,7 +972,7 @@ func (r *PostRepository) GetPostFocusContext(ctx context.Context, postID string,
|
|||
ELSE ''
|
||||
END AS resolved_video_url,
|
||||
COALESCE(NULLIF(p.thumbnail_url, ''), p.image_url, '') AS resolved_thumbnail_url,
|
||||
p.duration_ms,
|
||||
COALESCE(p.duration_ms, 0),
|
||||
COALESCE(p.tags, ARRAY[]::text[]),
|
||||
p.created_at,
|
||||
pr.handle as author_handle, pr.display_name as author_display_name, COALESCE(pr.avatar_url, '') as author_avatar_url,
|
||||
|
|
@ -1290,7 +1290,7 @@ func (r *PostRepository) GetPopularPublicPosts(ctx context.Context, viewerID str
|
|||
ELSE ''
|
||||
END AS resolved_video_url,
|
||||
COALESCE(NULLIF(p.thumbnail_url, ''), p.image_url, '') AS resolved_thumbnail_url,
|
||||
p.duration_ms,
|
||||
COALESCE(p.duration_ms, 0),
|
||||
COALESCE(p.tags, ARRAY[]::text[]),
|
||||
p.created_at,
|
||||
pr.handle as author_handle, pr.display_name as author_display_name, COALESCE(pr.avatar_url, '') as author_avatar_url,
|
||||
|
|
|
|||
Loading…
Reference in a new issue