From 114dd59d703d00efe86ad02eb956aa5343daa08e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Wed, 19 Feb 2025 21:24:47 +0800 Subject: all: Use COALESCE to handle some nullable database fields --- http_handle_repo_contrib_one.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'http_handle_repo_contrib_one.go') diff --git a/http_handle_repo_contrib_one.go b/http_handle_repo_contrib_one.go index 6841f2b..0691050 100644 --- a/http_handle_repo_contrib_one.go +++ b/http_handle_repo_contrib_one.go @@ -16,7 +16,7 @@ func handle_repo_contrib_one(w http.ResponseWriter, r *http.Request, params map[ } var title, status, source_ref, destination_branch string - err = database.QueryRow(r.Context(), "SELECT title, status, source_ref, destination_branch FROM merge_requests WHERE id = $1", mr_id).Scan(&title, &status, &source_ref, &destination_branch) + err = database.QueryRow(r.Context(), "SELECT COALESCE(title, ''), status, source_ref, COALESCE(destination_branch, '') FROM merge_requests WHERE id = $1", mr_id).Scan(&title, &status, &source_ref, &destination_branch) if err != nil { http.Error(w, "Error querying merge request: "+err.Error(), http.StatusInternalServerError) return -- cgit v1.2.3