chore: sqlstore cleanup (#60415)

* chore: remove unused test helper from sqlstore

TimeNow() is no longer used in any tests in this package.

* chore: move sqlstore.SQLBuilder to the infra/db package

This required some minor refactoring; we need to be a little more explicit about passing around the dialect and engine. On the other hand, that's a few fewer uses of the `dialect` global constant!

* chore: move UserDeletions into the only package using it

* cleanup around moving sqlbuilder

* remove dialect and sqlog global vars

* rename userDeletions to serviceAccountDeletions
This commit is contained in:
Kristin Laemmert
2022-12-16 17:09:06 +01:00
committed by GitHub
parent d332dab3ec
commit cc007e9727
12 changed files with 67 additions and 88 deletions

View File

@@ -9,11 +9,12 @@ import (
"xorm.io/xorm"
"github.com/mattn/go-sqlite3"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/util/errutil"
"github.com/grafana/grafana/pkg/util/retryer"
"github.com/mattn/go-sqlite3"
)
var sessionLogger = log.New("sqlstore.session")
@@ -116,7 +117,7 @@ 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{}) (int64, error) {
func (sess *DBSession) InsertId(bean interface{}, dialect migrator.Dialect) (int64, error) {
table := sess.DB().Mapper.Obj2Table(getTypeName(bean))
if err := dialect.PreInsertId(table, sess.Session); err != nil {