forked from mirror/gorm
Fix Create when dialect does not support last inserted id
This commit is contained in:
parent
0b8c9f29a9
commit
94f56e646b
|
@ -77,7 +77,7 @@ func Create(scope *Scope) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
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 if scope.Err(scope.SqlDB().QueryRow(scope.Sql, scope.SqlVars...).Scan(primaryField.Field.Addr().Interface())) == nil {
|
} else if scope.Err(scope.SqlDB().QueryRow(scope.Sql, scope.SqlVars...).Scan(primaryField.Field.Addr().Interface())) == nil {
|
||||||
|
|
Loading…
Reference in New Issue