From 1864d01a7100929561593ca02a1f240c9f077ba0 Mon Sep 17 00:00:00 2001 From: ecrupper Date: Fri, 13 Sep 2024 13:56:40 -0500 Subject: [PATCH] use int64 for DB reps of integer fields --- database/types/hook.go | 10 +++++----- database/types/hook_test.go | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/database/types/hook.go b/database/types/hook.go index f271a80c3..c76422535 100644 --- a/database/types/hook.go +++ b/database/types/hook.go @@ -33,7 +33,7 @@ type Hook struct { ID sql.NullInt64 `sql:"id"` RepoID sql.NullInt64 `sql:"repo_id"` BuildID sql.NullInt64 `sql:"build_id"` - Number sql.NullInt32 `sql:"number"` + Number sql.NullInt64 `sql:"number"` SourceID sql.NullString `sql:"source_id"` Created sql.NullInt64 `sql:"created"` Host sql.NullString `sql:"host"` @@ -76,7 +76,7 @@ func (h *Hook) Nullify() *Hook { } // check if the Number field should be false - if h.Number.Int32 == 0 { + if h.Number.Int64 == 0 { h.Number.Valid = false } @@ -151,7 +151,7 @@ func (h *Hook) ToAPI() *api.Hook { hook.SetID(h.ID.Int64) hook.SetRepo(h.Repo.ToAPI()) - hook.SetNumber(int(h.Number.Int32)) + hook.SetNumber(int(h.Number.Int64)) hook.SetSourceID(h.SourceID.String) hook.SetCreated(h.Created.Int64) hook.SetHost(h.Host.String) @@ -175,7 +175,7 @@ func (h *Hook) Validate() error { } // verify the Number field is populated - if h.Number.Int32 <= 0 { + if h.Number.Int64 <= 0 { return ErrEmptyHookNumber } @@ -211,7 +211,7 @@ func HookFromAPI(h *api.Hook) *Hook { ID: sql.NullInt64{Int64: h.GetID(), Valid: true}, RepoID: sql.NullInt64{Int64: h.GetRepo().GetID(), Valid: true}, BuildID: sql.NullInt64{Int64: h.GetBuild().GetID(), Valid: true}, - Number: sql.NullInt32{Int32: int32(h.GetNumber()), Valid: true}, + Number: sql.NullInt64{Int64: int64(h.GetNumber()), Valid: true}, SourceID: sql.NullString{String: h.GetSourceID(), Valid: true}, Created: sql.NullInt64{Int64: h.GetCreated(), Valid: true}, Host: sql.NullString{String: h.GetHost(), Valid: true}, diff --git a/database/types/hook_test.go b/database/types/hook_test.go index 1944fa466..e9b16dcea 100644 --- a/database/types/hook_test.go +++ b/database/types/hook_test.go @@ -21,7 +21,7 @@ func TestTypes_Hook_Nullify(t *testing.T) { ID: sql.NullInt64{Int64: 0, Valid: false}, RepoID: sql.NullInt64{Int64: 0, Valid: false}, BuildID: sql.NullInt64{Int64: 0, Valid: false}, - Number: sql.NullInt32{Int32: 0, Valid: false}, + Number: sql.NullInt64{Int64: 0, Valid: false}, SourceID: sql.NullString{String: "", Valid: false}, Created: sql.NullInt64{Int64: 0, Valid: false}, Host: sql.NullString{String: "", Valid: false}, @@ -116,7 +116,7 @@ func TestTypes_Hook_Validate(t *testing.T) { failure: true, hook: &Hook{ ID: sql.NullInt64{Int64: 1, Valid: true}, - Number: sql.NullInt32{Int32: 1, Valid: true}, + Number: sql.NullInt64{Int64: 1, Valid: true}, SourceID: sql.NullString{String: "c8da1302-07d6-11ea-882f-4893bca275b8", Valid: true}, WebhookID: sql.NullInt64{Int64: 1, Valid: true}, }, @@ -125,7 +125,7 @@ func TestTypes_Hook_Validate(t *testing.T) { failure: true, hook: &Hook{ ID: sql.NullInt64{Int64: 1, Valid: true}, - Number: sql.NullInt32{Int32: 1, Valid: true}, + Number: sql.NullInt64{Int64: 1, Valid: true}, RepoID: sql.NullInt64{Int64: 1, Valid: true}, WebhookID: sql.NullInt64{Int64: 1, Valid: true}, }, @@ -134,7 +134,7 @@ func TestTypes_Hook_Validate(t *testing.T) { failure: true, hook: &Hook{ ID: sql.NullInt64{Int64: 1, Valid: true}, - Number: sql.NullInt32{Int32: 1, Valid: true}, + Number: sql.NullInt64{Int64: 1, Valid: true}, RepoID: sql.NullInt64{Int64: 1, Valid: true}, SourceID: sql.NullString{String: "c8da1302-07d6-11ea-882f-4893bca275b8", Valid: true}, }, @@ -165,7 +165,7 @@ func TestTypes_HookFromAPI(t *testing.T) { ID: sql.NullInt64{Int64: 1, Valid: true}, RepoID: sql.NullInt64{Int64: 1, Valid: true}, BuildID: sql.NullInt64{Int64: 1, Valid: true}, - Number: sql.NullInt32{Int32: 1, Valid: true}, + Number: sql.NullInt64{Int64: 1, Valid: true}, SourceID: sql.NullString{String: "c8da1302-07d6-11ea-882f-4893bca275b8", Valid: true}, Created: sql.NullInt64{Int64: time.Now().UTC().Unix(), Valid: true}, Host: sql.NullString{String: "github.com", Valid: true}, @@ -209,7 +209,7 @@ func testHook() *Hook { ID: sql.NullInt64{Int64: 1, Valid: true}, RepoID: sql.NullInt64{Int64: 1, Valid: true}, BuildID: sql.NullInt64{Int64: 1, Valid: true}, - Number: sql.NullInt32{Int32: 1, Valid: true}, + Number: sql.NullInt64{Int64: 1, Valid: true}, SourceID: sql.NullString{String: "c8da1302-07d6-11ea-882f-4893bca275b8", Valid: true}, Created: sql.NullInt64{Int64: time.Now().UTC().Unix(), Valid: true}, Host: sql.NullString{String: "github.com", Valid: true},