Your Question
my struct is this:
type A struct {
Id int
Name string
BId int
B B
}
type B struct {
Id int
Name string
}
xxx to create A a
tx := db.Begin()
result := tx.Create(&a)
if the field Name of B is a unique key in a mysql table, and insert B into table failed but insert A successful, at this time, result Error is nil and affectedRow is 1, we can not get the real response of the inserting B. gorm skip the error when insert B, after, gorm will insert A
done it have other usage to resolve problem? If yes, I will thanks very much!!!
The document you expected this should be explained
Expected answer
if I can get the error when insert B, I will rollback the all transaction.
Comment From: a631807682
It will return error and affectedRow is 0 in lastest version. If you still have problems after the upgrade to lastest verion, please reopen it with the full code in the playground