This commit is contained in:
Jinzhu 2020-06-07 15:24:34 +08:00
parent 4a4b8234de
commit d11c424334
9 changed files with 23 additions and 23 deletions

View File

@ -15,12 +15,12 @@ import (
func initializeCallbacks(db *DB) *callbacks {
return &callbacks{
processors: map[string]*processor{
"create": &processor{db: db},
"query": &processor{db: db},
"update": &processor{db: db},
"delete": &processor{db: db},
"row": &processor{db: db},
"raw": &processor{db: db},
"create": {db: db},
"query": {db: db},
"update": {db: db},
"delete": {db: db},
"row": {db: db},
"raw": {db: db},
},
}
}

View File

@ -62,7 +62,7 @@ func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]inter
selectColumns, restricted := SelectAndOmitColumns(stmt, true, false)
var keys []string
for k, _ := range mapValue {
for k := range mapValue {
keys = append(keys, k)
}
sort.Strings(keys)

View File

@ -141,7 +141,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) {
set = make([]clause.Assignment, 0, len(value))
var keys []string
for k, _ := range value {
for k := range value {
keys = append(keys, k)
}
sort.Strings(keys)

View File

@ -180,7 +180,7 @@ func TestBelongsToAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Company").Delete(&users[0].Company); err != nil {
t.Errorf("no error should happend when deleting company, but got %v", err)
t.Errorf("no error should happened when deleting company, but got %v", err)
}
if users[0].CompanyID != nil || users[0].Company.ID != 0 {

View File

@ -234,13 +234,13 @@ func TestHasManyAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Pets").Delete(&users[2].Pets); err != nil {
t.Errorf("no error should happend when deleting pet, but got %v", err)
t.Errorf("no error should happened when deleting pet, but got %v", err)
}
AssertAssociationCount(t, users, "Pets", 4, "after delete")
if err := DB.Model(&users).Association("Pets").Delete(users[0].Pets[0], users[1].Pets[1]); err != nil {
t.Errorf("no error should happend when deleting pet, but got %v", err)
t.Errorf("no error should happened when deleting pet, but got %v", err)
}
AssertAssociationCount(t, users, "Pets", 2, "after delete")
@ -290,13 +290,13 @@ func TestSingleTableHasManyAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Team").Delete(&users[2].Team); err != nil {
t.Errorf("no error should happend when deleting pet, but got %v", err)
t.Errorf("no error should happened when deleting pet, but got %v", err)
}
AssertAssociationCount(t, users, "Team", 4, "after delete")
if err := DB.Model(&users).Association("Team").Delete(users[0].Team[0], users[1].Team[1]); err != nil {
t.Errorf("no error should happend when deleting pet, but got %v", err)
t.Errorf("no error should happened when deleting pet, but got %v", err)
}
AssertAssociationCount(t, users, "Team", 2, "after delete")
@ -439,13 +439,13 @@ func TestPolymorphicHasManyAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Toys").Delete(&users[2].Toys); err != nil {
t.Errorf("no error should happend when deleting toy, but got %v", err)
t.Errorf("no error should happened when deleting toy, but got %v", err)
}
AssertAssociationCount(t, users, "Toys", 4, "after delete")
if err := DB.Model(&users).Association("Toys").Delete(users[0].Toys[0], users[1].Toys[1]); err != nil {
t.Errorf("no error should happend when deleting toy, but got %v", err)
t.Errorf("no error should happened when deleting toy, but got %v", err)
}
AssertAssociationCount(t, users, "Toys", 2, "after delete")

View File

@ -113,7 +113,7 @@ func TestHasOneAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Account").Delete(&users[0].Account); err != nil {
t.Errorf("no error should happend when deleting account, but got %v", err)
t.Errorf("no error should happened when deleting account, but got %v", err)
}
AssertAssociationCount(t, users, "Account", 2, "after delete")
@ -230,7 +230,7 @@ func TestPolymorphicHasOneAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&pets).Association("Toy").Delete(&pets[0].Toy); err != nil {
t.Errorf("no error should happend when deleting toy, but got %v", err)
t.Errorf("no error should happened when deleting toy, but got %v", err)
}
AssertAssociationCount(t, pets, "Toy", 2, "after delete")

View File

@ -147,13 +147,13 @@ func TestMany2ManyAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Languages").Delete(&users[2].Languages); err != nil {
t.Errorf("no error should happend when deleting language, but got %v", err)
t.Errorf("no error should happened when deleting language, but got %v", err)
}
AssertAssociationCount(t, users, "Languages", 4, "after delete")
if err := DB.Model(&users).Association("Languages").Delete(users[0].Languages[0], users[1].Languages[1]); err != nil {
t.Errorf("no error should happend when deleting language, but got %v", err)
t.Errorf("no error should happened when deleting language, but got %v", err)
}
AssertAssociationCount(t, users, "Languages", 2, "after delete")
@ -282,13 +282,13 @@ func TestSingleTableMany2ManyAssociationForSlice(t *testing.T) {
// Delete
if err := DB.Model(&users).Association("Team").Delete(&users[2].Team); err != nil {
t.Errorf("no error should happend when deleting team, but got %v", err)
t.Errorf("no error should happened when deleting team, but got %v", err)
}
AssertAssociationCount(t, users, "Team", 4, "after delete")
if err := DB.Model(&users).Association("Team").Delete(users[0].Team[0], users[1].Team[1]); err != nil {
t.Errorf("no error should happend when deleting team, but got %v", err)
t.Errorf("no error should happened when deleting team, but got %v", err)
}
AssertAssociationCount(t, users, "Team", 2, "after delete")

View File

@ -131,7 +131,7 @@ func TestColumns(t *testing.T) {
}
if err := DB.Table("column_structs").Migrator().AlterColumn(&ColumnStruct2{}, "Name"); err != nil {
t.Fatalf("no error should happend when alter column, but got %v", err)
t.Fatalf("no error should happened when alter column, but got %v", err)
}
if columnTypes, err := DB.Migrator().ColumnTypes(&ColumnStruct{}); err != nil {

View File

@ -38,7 +38,7 @@ func TestScannerValuer(t *testing.T) {
}
if err := DB.Create(&data).Error; err != nil {
t.Errorf("No error should happend when create scanner valuer struct, but got %v", err)
t.Errorf("No error should happened when create scanner valuer struct, but got %v", err)
}
var result ScannerValuerStruct