diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-29 03:06:44 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-29 03:06:44 +0900 |
| commit | 19b19e7f48d6375806f827713a98cffd2c57a434 (patch) | |
| tree | 5b68e70a65a2434517c7e1ea5ea330fd686049d4 /backend/api | |
| parent | d1c8aa42aec32c8b042ae32d249df9c3c969453d (diff) | |
| download | phperkaigi-2025-albatross-19b19e7f48d6375806f827713a98cffd2c57a434.tar.gz phperkaigi-2025-albatross-19b19e7f48d6375806f827713a98cffd2c57a434.tar.zst phperkaigi-2025-albatross-19b19e7f48d6375806f827713a98cffd2c57a434.zip | |
refactor(backend): enable emit_pointers_for_null_types in sqlc
Diffstat (limited to 'backend/api')
| -rw-r--r-- | backend/api/handlers.go | 30 |
1 files changed, 15 insertions, 15 deletions
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{ |
