From 020ba82cdb641fa02cbe187e2e72f340bb07eae1 Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Fri, 29 Mar 2019 09:42:25 -0400 Subject: [PATCH] MM-14768: Switches field type from sql.NullBool to a bool pointer. (#10526) --- model/channel.go | 5 ++--- model/channel_test.go | 4 ++-- model/team.go | 35 +++++++++++++++++------------------ model/team_test.go | 4 ++-- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/model/channel.go b/model/channel.go index 387185181d..913310554b 100644 --- a/model/channel.go +++ b/model/channel.go @@ -5,7 +5,6 @@ package model import ( "crypto/sha1" - "database/sql" "encoding/hex" "encoding/json" "io" @@ -52,7 +51,7 @@ type Channel struct { CreatorId string `json:"creator_id"` SchemeId *string `json:"scheme_id"` Props map[string]interface{} `json:"props" db:"-"` - GroupConstrained sql.NullBool `json:"group_constrained"` + GroupConstrained *bool `json:"group_constrained"` } type ChannelWithTeamData struct { @@ -191,7 +190,7 @@ func (o *Channel) Patch(patch *ChannelPatch) { } if patch.GroupConstrained != nil { - o.GroupConstrained.Bool = *patch.GroupConstrained + o.GroupConstrained = patch.GroupConstrained } } diff --git a/model/channel_test.go b/model/channel_test.go index 14463eefc8..2a47cae0d2 100644 --- a/model/channel_test.go +++ b/model/channel_test.go @@ -59,8 +59,8 @@ func TestChannelPatch(t *testing.T) { if *p.Purpose != o.Purpose { t.Fatal("do not match") } - if *p.GroupConstrained != o.GroupConstrained.Bool { - t.Fatalf("expected %v got %v", *p.GroupConstrained, o.GroupConstrained.Bool) + if *p.GroupConstrained != *o.GroupConstrained { + t.Fatalf("expected %v got %v", *p.GroupConstrained, *o.GroupConstrained) } } diff --git a/model/team.go b/model/team.go index 6552deaee8..a2944ea2b3 100644 --- a/model/team.go +++ b/model/team.go @@ -4,7 +4,6 @@ package model import ( - "database/sql" "encoding/json" "fmt" "io" @@ -27,22 +26,22 @@ const ( ) type Team struct { - Id string `json:"id"` - CreateAt int64 `json:"create_at"` - UpdateAt int64 `json:"update_at"` - DeleteAt int64 `json:"delete_at"` - DisplayName string `json:"display_name"` - Name string `json:"name"` - Description string `json:"description"` - Email string `json:"email"` - Type string `json:"type"` - CompanyName string `json:"company_name"` - AllowedDomains string `json:"allowed_domains"` - InviteId string `json:"invite_id"` - AllowOpenInvite bool `json:"allow_open_invite"` - LastTeamIconUpdate int64 `json:"last_team_icon_update,omitempty"` - SchemeId *string `json:"scheme_id"` - GroupConstrained sql.NullBool `json:"group_constrained"` + Id string `json:"id"` + CreateAt int64 `json:"create_at"` + UpdateAt int64 `json:"update_at"` + DeleteAt int64 `json:"delete_at"` + DisplayName string `json:"display_name"` + Name string `json:"name"` + Description string `json:"description"` + Email string `json:"email"` + Type string `json:"type"` + CompanyName string `json:"company_name"` + AllowedDomains string `json:"allowed_domains"` + InviteId string `json:"invite_id"` + AllowOpenInvite bool `json:"allow_open_invite"` + LastTeamIconUpdate int64 `json:"last_team_icon_update,omitempty"` + SchemeId *string `json:"scheme_id"` + GroupConstrained *bool `json:"group_constrained"` } type TeamPatch struct { @@ -278,7 +277,7 @@ func (t *Team) Patch(patch *TeamPatch) { } if patch.GroupConstrained != nil { - t.GroupConstrained.Bool = *patch.GroupConstrained + t.GroupConstrained = patch.GroupConstrained } } diff --git a/model/team_test.go b/model/team_test.go index 89ed5c7ba6..c57cb6a090 100644 --- a/model/team_test.go +++ b/model/team_test.go @@ -171,7 +171,7 @@ func TestTeamPatch(t *testing.T) { if *p.AllowOpenInvite != o.AllowOpenInvite { t.Fatal("AllowOpenInvite did not update") } - if *p.GroupConstrained != o.GroupConstrained.Bool { - t.Fatalf("expected %v got %v", *p.GroupConstrained, o.GroupConstrained.Bool) + if *p.GroupConstrained != *o.GroupConstrained { + t.Fatalf("expected %v got %v", *p.GroupConstrained, *o.GroupConstrained) } }