enable identity column insert optionally for mssql ref: https://github.com/jinzhu/gorm/issues/647
This commit is contained in:
parent
b71fda1a1a
commit
a739f8b035
@ -33,11 +33,22 @@ func TestCustomizeColumn(t *testing.T) {
|
|||||||
t.Errorf("CustomizeColumn should have primary key %s, but got %q", col, scope.PrimaryKey())
|
t.Errorf("CustomizeColumn should have primary key %s, but got %q", col, scope.PrimaryKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableName := "customize_columns"
|
||||||
|
idInsRes := DB.EnableIdentityInsert(&DB, tableName)
|
||||||
|
if idInsRes.Error != nil {
|
||||||
|
t.Errorf("Error while setting IDENTITY_INSERT ON for table:%v :%v", tableName, idInsRes.Error)
|
||||||
|
}
|
||||||
|
|
||||||
expected := "foo"
|
expected := "foo"
|
||||||
cc := CustomizeColumn{ID: 666, Name: expected, Date: time.Now()}
|
cc := CustomizeColumn{ID: 666, Name: expected, Date: time.Now()}
|
||||||
|
|
||||||
if count := DB.Create(&cc).RowsAffected; count != 1 {
|
res := DB.Create(&cc)
|
||||||
t.Error("There should be one record be affected when create record")
|
if res.Error != nil {
|
||||||
|
t.Errorf("Error while creating CustomizeColumn:%v", res.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if count := res.RowsAffected; count != 1 {
|
||||||
|
t.Errorf("There should be one record be affected when create record. count:%v", count)
|
||||||
}
|
}
|
||||||
|
|
||||||
var cc1 CustomizeColumn
|
var cc1 CustomizeColumn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user