mirror of https://github.com/go-gorm/gorm.git
Fix typo
This commit is contained in:
parent
4a4b8234de
commit
d11c424334
12
callbacks.go
12
callbacks.go
|
@ -15,12 +15,12 @@ import (
|
||||||
func initializeCallbacks(db *DB) *callbacks {
|
func initializeCallbacks(db *DB) *callbacks {
|
||||||
return &callbacks{
|
return &callbacks{
|
||||||
processors: map[string]*processor{
|
processors: map[string]*processor{
|
||||||
"create": &processor{db: db},
|
"create": {db: db},
|
||||||
"query": &processor{db: db},
|
"query": {db: db},
|
||||||
"update": &processor{db: db},
|
"update": {db: db},
|
||||||
"delete": &processor{db: db},
|
"delete": {db: db},
|
||||||
"row": &processor{db: db},
|
"row": {db: db},
|
||||||
"raw": &processor{db: db},
|
"raw": {db: db},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]inter
|
||||||
selectColumns, restricted := SelectAndOmitColumns(stmt, true, false)
|
selectColumns, restricted := SelectAndOmitColumns(stmt, true, false)
|
||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
for k, _ := range mapValue {
|
for k := range mapValue {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
|
@ -141,7 +141,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) {
|
||||||
set = make([]clause.Assignment, 0, len(value))
|
set = make([]clause.Assignment, 0, len(value))
|
||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
for k, _ := range value {
|
for k := range value {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
|
@ -180,7 +180,7 @@ func TestBelongsToAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Company").Delete(&users[0].Company); err != nil {
|
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 {
|
if users[0].CompanyID != nil || users[0].Company.ID != 0 {
|
||||||
|
|
|
@ -234,13 +234,13 @@ func TestHasManyAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Pets").Delete(&users[2].Pets); err != nil {
|
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")
|
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 {
|
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")
|
AssertAssociationCount(t, users, "Pets", 2, "after delete")
|
||||||
|
@ -290,13 +290,13 @@ func TestSingleTableHasManyAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Team").Delete(&users[2].Team); err != nil {
|
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")
|
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 {
|
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")
|
AssertAssociationCount(t, users, "Team", 2, "after delete")
|
||||||
|
@ -439,13 +439,13 @@ func TestPolymorphicHasManyAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Toys").Delete(&users[2].Toys); err != nil {
|
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")
|
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 {
|
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")
|
AssertAssociationCount(t, users, "Toys", 2, "after delete")
|
||||||
|
|
|
@ -113,7 +113,7 @@ func TestHasOneAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Account").Delete(&users[0].Account); err != nil {
|
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")
|
AssertAssociationCount(t, users, "Account", 2, "after delete")
|
||||||
|
@ -230,7 +230,7 @@ func TestPolymorphicHasOneAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&pets).Association("Toy").Delete(&pets[0].Toy); err != nil {
|
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")
|
AssertAssociationCount(t, pets, "Toy", 2, "after delete")
|
||||||
|
|
|
@ -147,13 +147,13 @@ func TestMany2ManyAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Languages").Delete(&users[2].Languages); err != nil {
|
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")
|
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 {
|
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")
|
AssertAssociationCount(t, users, "Languages", 2, "after delete")
|
||||||
|
@ -282,13 +282,13 @@ func TestSingleTableMany2ManyAssociationForSlice(t *testing.T) {
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if err := DB.Model(&users).Association("Team").Delete(&users[2].Team); err != nil {
|
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")
|
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 {
|
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")
|
AssertAssociationCount(t, users, "Team", 2, "after delete")
|
||||||
|
|
|
@ -131,7 +131,7 @@ func TestColumns(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := DB.Table("column_structs").Migrator().AlterColumn(&ColumnStruct2{}, "Name"); err != nil {
|
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 {
|
if columnTypes, err := DB.Migrator().ColumnTypes(&ColumnStruct{}); err != nil {
|
||||||
|
|
|
@ -38,7 +38,7 @@ func TestScannerValuer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := DB.Create(&data).Error; err != nil {
|
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
|
var result ScannerValuerStruct
|
||||||
|
|
Loading…
Reference in New Issue