From 19b19e7f48d6375806f827713a98cffd2c57a434 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Jul 2024 03:06:44 +0900 Subject: refactor(backend): enable emit_pointers_for_null_types in sqlc --- backend/api/handlers.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'backend/api/handlers.go') diff --git a/backend/api/handlers.go b/backend/api/handlers.go index 91cdbc8..cd8b3b5 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -73,14 +73,14 @@ func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID.Valid { - if !row.Title.Valid || !row.Description.Valid { + if row.ProblemID != nil { + if row.Title == nil || row.Description == nil { panic("inconsistent data") } problem = &Problem{ - ProblemId: int(row.ProblemID.Int32), - Title: row.Title.String, - Description: row.Description.String, + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, } } games[i] = Game{ @@ -108,14 +108,14 @@ func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID.Valid { - if !row.Title.Valid || !row.Description.Valid { + if row.ProblemID != nil { + if row.Title == nil || row.Description == nil { panic("inconsistent data") } problem = &Problem{ - ProblemId: int(row.ProblemID.Int32), - Title: row.Title.String, - Description: row.Description.String, + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, } } games[i] = Game{ @@ -147,14 +147,14 @@ func (h *ApiHandler) GetGamesGameId(ctx context.Context, request GetGamesGameIdR startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID.Valid && GameState(row.State) != Closed && GameState(row.State) != WaitingEntries { - if !row.Title.Valid || !row.Description.Valid { + if row.ProblemID != nil && GameState(row.State) != Closed && GameState(row.State) != WaitingEntries { + if row.Title == nil || row.Description == nil { panic("inconsistent data") } problem = &Problem{ - ProblemId: int(row.ProblemID.Int32), - Title: row.Title.String, - Description: row.Description.String, + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, } } game := Game{ -- cgit v1.2.3-70-g09d2