forked from mirror/gorm
Fix Create error reporting.
This commit is contained in:
parent
94f56e646b
commit
d9faa4949c
|
@ -79,9 +79,15 @@ func Create(scope *Scope) {
|
||||||
if primaryField == nil {
|
if primaryField == nil {
|
||||||
if results, err := scope.SqlDB().Exec(scope.Sql, scope.SqlVars...); err == nil {
|
if results, err := scope.SqlDB().Exec(scope.Sql, scope.SqlVars...); err == nil {
|
||||||
scope.db.RowsAffected, _ = results.RowsAffected()
|
scope.db.RowsAffected, _ = results.RowsAffected()
|
||||||
|
} else {
|
||||||
|
scope.Err(err)
|
||||||
}
|
}
|
||||||
} else if scope.Err(scope.SqlDB().QueryRow(scope.Sql, scope.SqlVars...).Scan(primaryField.Field.Addr().Interface())) == nil {
|
} else {
|
||||||
|
if err := scope.Err(scope.SqlDB().QueryRow(scope.Sql, scope.SqlVars...).Scan(primaryField.Field.Addr().Interface())); err == nil {
|
||||||
scope.db.RowsAffected = 1
|
scope.db.RowsAffected = 1
|
||||||
|
} else {
|
||||||
|
scope.Err(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue