parent
9d370bcb3e
commit
5e599a07ec
2
scan.go
2
scan.go
@ -244,7 +244,7 @@ func Scan(rows Rows, db *DB, mode ScanMode) {
|
|||||||
rel = rel.FieldSchema.Relationships.Relations[name]
|
rel = rel.FieldSchema.Relationships.Relations[name]
|
||||||
relFields = append(relFields, rel.Field)
|
relFields = append(relFields, rel.Field)
|
||||||
}
|
}
|
||||||
// lastest name is raw dbname
|
// latest name is raw dbname
|
||||||
dbName := names[subNameCount-1]
|
dbName := names[subNameCount-1]
|
||||||
if field := rel.FieldSchema.LookUpField(dbName); field != nil && field.Readable {
|
if field := rel.FieldSchema.LookUpField(dbName); field != nil && field.Readable {
|
||||||
fields[idx] = field
|
fields[idx] = field
|
||||||
|
@ -279,6 +279,6 @@ func TestEmbeddedTagSetting(t *testing.T) {
|
|||||||
err = DB.Save(&t1).Error
|
err = DB.Save(&t1).Error
|
||||||
AssertEqual(t, err, nil)
|
AssertEqual(t, err, nil)
|
||||||
if t1.Tag1.Id == 0 {
|
if t1.Tag1.Id == 0 {
|
||||||
t.Errorf("embedded struct's primary field should be rewrited")
|
t.Errorf("embedded struct's primary field should be rewritten")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func TestNonStdPrimaryKeyAndDefaultValues(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
animal = Animal{From: "somewhere"} // No name fields, should be filled with the default value (galeone)
|
animal = Animal{From: "somewhere"} // No name fields, should be filled with the default value (galeone)
|
||||||
DB.Save(&animal).Update("From", "a nice place") // The name field shoul be untouched
|
DB.Save(&animal).Update("From", "a nice place") // The name field should be untouched
|
||||||
DB.First(&animal, animal.Counter)
|
DB.First(&animal, animal.Counter)
|
||||||
if animal.Name != "galeone" {
|
if animal.Name != "galeone" {
|
||||||
t.Errorf("Name fields shouldn't be changed if untouched, but got %v", animal.Name)
|
t.Errorf("Name fields shouldn't be changed if untouched, but got %v", animal.Name)
|
||||||
|
@ -1337,7 +1337,7 @@ func TestQueryResetNullValue(t *testing.T) {
|
|||||||
Number1 int64 `gorm:"default:NULL"`
|
Number1 int64 `gorm:"default:NULL"`
|
||||||
Number2 uint64 `gorm:"default:NULL"`
|
Number2 uint64 `gorm:"default:NULL"`
|
||||||
Number3 float64 `gorm:"default:NULL"`
|
Number3 float64 `gorm:"default:NULL"`
|
||||||
Now *time.Time `gorm:"defalut:NULL"`
|
Now *time.Time `gorm:"default:NULL"`
|
||||||
Item1Id string
|
Item1Id string
|
||||||
Item1 *QueryResetItem `gorm:"references:ID"`
|
Item1 *QueryResetItem `gorm:"references:ID"`
|
||||||
Item2Id string
|
Item2Id string
|
||||||
@ -1427,7 +1427,7 @@ func TestQueryScanToArray(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if users[0] == nil || users[0].Name != "testname1" {
|
if users[0] == nil || users[0].Name != "testname1" {
|
||||||
t.Error("users[0] not covere")
|
t.Error("users[0] not covered")
|
||||||
}
|
}
|
||||||
if users[1] != nil {
|
if users[1] != nil {
|
||||||
t.Error("users[1] should be empty")
|
t.Error("users[1] should be empty")
|
||||||
|
@ -67,7 +67,7 @@ func TestTransaction(t *testing.T) {
|
|||||||
return tx5.First(&User{}, "name = ?", "transaction-2").Error
|
return tx5.First(&User{}, "name = ?", "transaction-2").Error
|
||||||
})
|
})
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
t.Fatalf("prepare statement and nested transcation coexist" + err.Error())
|
t.Fatalf("prepare statement and nested transaction coexist" + err.Error())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user