Backend: Fix AfterCreate after upgrading GORM

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-05-19 12:30:26 +02:00
parent 132db3c0d2
commit 1cf0893b18
4 changed files with 7 additions and 3 deletions

View File

@ -69,7 +69,8 @@ func (m *Country) FirstOrCreate() *Country {
// AfterCreate sets the New column used for database callback
func (m *Country) AfterCreate(scope *gorm.Scope) error {
return scope.SetColumn("New", true)
m.New = true
return nil
}
// Code returns country code

View File

@ -72,7 +72,8 @@ func (m *Label) FirstOrCreate() *Label {
// AfterCreate sets the New column used for database callback
func (m *Label) AfterCreate(scope *gorm.Scope) error {
return scope.SetColumn("New", true)
m.New = true
return nil
}
// SetName changes the label name.

View File

@ -70,6 +70,7 @@ func TestLabel_Update(t *testing.T) {
assert.Equal(t, "label", Label.LabelName)
err := Label.Update(*classifyLabel)
if err != nil {
t.Fatal(err)
}

View File

@ -44,7 +44,8 @@ func CreateUnknownPlace() {
// AfterCreate sets the New column used for database callback
func (m *Place) AfterCreate(scope *gorm.Scope) error {
return scope.SetColumn("New", true)
m.New = true
return nil
}
// FindPlaceByLabel returns a place from an id or a label