File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -638,10 +638,15 @@ func TestBeforeUpdateWithStructColumn(t *testing.T) {
638
638
t .Fatalf ("create struct failed: %v" , err )
639
639
}
640
640
641
- sql := DB .ToSQL (func (tx * gorm.DB ) * gorm.DB {
642
- return tx .Model (& su ).Update ("name" , "demoManito" )
643
- })
644
- if sql != "UPDATE `struct_updates` SET `name`='demoManito',`version`=2 WHERE `id` = 1" {
645
- t .Fatalf ("invalid sql: %v" , sql )
641
+ err = DB .Model (& su ).Update ("name" , "demoManito" ).Error
642
+ if err != nil {
643
+ t .Fatalf ("update struct failed: %v" , err )
644
+ }
645
+ if su .Version != 2 {
646
+ t .Fatalf ("update version failed: %v" , su .Version )
647
+ }
648
+ err = DB .Find (& su , "id = ?" , 1 ).Error
649
+ if err != nil {
650
+ t .Fatalf ("find struct failed: %v" , err )
646
651
}
647
652
}
You can’t perform that action at this time.
0 commit comments