Documentation
¶
Index ¶
- Variables
- func InitTestDB(t sqlutil.ITestDB, opts ...InitTestDBOpt) *sqlstore.SQLStore
- func InitTestDBWithCfg(t sqlutil.ITestDB, opts ...InitTestDBOpt) (*sqlstore.SQLStore, *setting.Cfg)
- func IsTestDBMSSQL() bool
- func IsTestDbMySQL() bool
- func IsTestDbPostgres() bool
- func IsTestDbSQLite() bool
- type DB
- type InitTestDBOpt
- type SQLBuilder
- func (sb *SQLBuilder) AddParams(params ...any)
- func (sb *SQLBuilder) GetParams() []any
- func (sb *SQLBuilder) GetSQLString() string
- func (sb *SQLBuilder) Write(sql string, params ...any)
- func (sb *SQLBuilder) WriteDashboardPermissionFilter(user identity.Requester, permission dashboardaccess.PermissionType, ...)
- type Session
Constants ¶
This section is empty.
Variables ¶
View Source
var CleanupTestDB = sqlstore.CleanupTestDB
View Source
var ProvideService = sqlstore.ProvideService
View Source
var SetupTestDB = sqlstore.SetupTestDB
Functions ¶
func InitTestDB ¶
func InitTestDB(t sqlutil.ITestDB, opts ...InitTestDBOpt) *sqlstore.SQLStore
func InitTestDBWithCfg ¶
func IsTestDBMSSQL ¶
func IsTestDBMSSQL() bool
func IsTestDbMySQL ¶
func IsTestDbMySQL() bool
func IsTestDbPostgres ¶
func IsTestDbPostgres() bool
func IsTestDbSQLite ¶
func IsTestDbSQLite() bool
Types ¶
type DB ¶
type DB interface {
// WithTransactionalDbSession creates a new SQL transaction to ensure consistency
// for the database operations done within the [sqlstore.DBTransactionFunc].
// It's better to combine InTransaction and WithDbSession instead, as the context
// variable is not updated when using this method.
WithTransactionalDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error
// WithDbSession runs database operations either in an existing transaction available
// through [context.Context] or if that's not present, as non-transactional database
// operations.
WithDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error
// GetDialect returns an object that contains information about the peculiarities of
// the particular database type available to the runtime.
GetDialect() migrator.Dialect
// GetDBType returns the name of the database type available to the runtime.
GetDBType() core.DbType
// GetEngine returns the underlying xorm engine.
GetEngine() *xorm.Engine
// GetSqlxSession is an experimental extension to use sqlx instead of xorm to
// communicate with the database.
// NOTE: when using this session with mysql, the connection will *not* have:
// the expected parameters: "&sql_mode='ANSI_QUOTES" and "&parseTime=true"
// The sqlx session is useful, but be careful not to expect automagic date parsing
GetSqlxSession() *session.SessionDB
// InTransaction creates a new SQL transaction that is placed on the context.
// Use together with [DB.WithDbSession] to run database operations.
InTransaction(ctx context.Context, fn func(ctx context.Context) error) error
// Quote wraps an identifier so that it cannot be mistaken for an SQL keyword.
Quote(value string) string
// RecursiveQueriesAreSupported runs a dummy recursive query and it returns true
// if the query runs successfully or false if it fails with mysqlerr.ER_PARSE_ERROR error or any other error
RecursiveQueriesAreSupported() (bool, error)
}
type InitTestDBOpt ¶
type InitTestDBOpt = sqlstore.InitTestDBOpt
type SQLBuilder ¶
type SQLBuilder struct {
// contains filtered or unexported fields
}
func NewSqlBuilder ¶
func NewSqlBuilder(cfg *setting.Cfg, features featuremgmt.FeatureToggles, dialect migrator.Dialect, recursiveQueriesAreSupported bool) SQLBuilder
func (*SQLBuilder) AddParams ¶
func (sb *SQLBuilder) AddParams(params ...any)
func (*SQLBuilder) GetParams ¶
func (sb *SQLBuilder) GetParams() []any
func (*SQLBuilder) GetSQLString ¶
func (sb *SQLBuilder) GetSQLString() string
func (*SQLBuilder) Write ¶
func (sb *SQLBuilder) Write(sql string, params ...any)
func (*SQLBuilder) WriteDashboardPermissionFilter ¶
func (sb *SQLBuilder) WriteDashboardPermissionFilter(user identity.Requester, permission dashboardaccess.PermissionType, queryType string)
Click to show internal directories.
Click to hide internal directories.