mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SQLStore: Fix wrong usage of xorm's insert functions in tests (#63850)
* SQLStore: Fix InsertId * Prefs: Fix Insert return value * Fix tests * Add guidelines
This commit is contained in:
committed by
GitHub
parent
afd5f41780
commit
89569be3a6
@@ -126,21 +126,21 @@ func (ss *SQLStore) withDbSession(ctx context.Context, engine *xorm.Engine, call
|
||||
return retryer.Retry(ss.retryOnLocks(ctx, callback, sess, retry), ss.dbCfg.QueryRetries, time.Millisecond*time.Duration(10), time.Second)
|
||||
}
|
||||
|
||||
func (sess *DBSession) InsertId(bean interface{}, dialect migrator.Dialect) (int64, error) {
|
||||
func (sess *DBSession) InsertId(bean interface{}, dialect migrator.Dialect) error {
|
||||
table := sess.DB().Mapper.Obj2Table(getTypeName(bean))
|
||||
|
||||
if err := dialect.PreInsertId(table, sess.Session); err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
id, err := sess.Session.InsertOne(bean)
|
||||
_, err := sess.Session.InsertOne(bean)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
if err := dialect.PostInsertId(table, sess.Session); err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
|
||||
return id, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sess *DBSession) WithReturningID(driverName string, query string, args []interface{}) (int64, error) {
|
||||
|
||||
Reference in New Issue
Block a user