mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 07:02:12 +08:00

* Remove dbProviderFunc function. This removes one extra indirection that made the code bit more difficult to navigate. * Remove indirection function types implementing single-method interfaces. This streamlines the code and makes it bit easier to navigate. * Update pkg/storage/unified/sql/sqltemplate/dialect_mysql.go Co-authored-by: Mustafa Sencer Özcan <32759850+mustafasencer@users.noreply.github.com> --------- Co-authored-by: Mustafa Sencer Özcan <32759850+mustafasencer@users.noreply.github.com>
39 lines
829 B
Go
39 lines
829 B
Go
package sqltemplate
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// MySQL is the default implementation of Dialect for the MySQL DMBS,
|
|
// currently supporting MySQL-8.x.
|
|
var MySQL = mysql{}
|
|
|
|
type mysql struct{}
|
|
|
|
func (m mysql) DialectName() string {
|
|
return "mysql"
|
|
}
|
|
|
|
func (m mysql) Ident(s string) (string, error) {
|
|
// MySQL always supports backticks for identifiers
|
|
// https://dev.mysql.com/doc/refman/8.4/en/identifiers.html
|
|
if strings.ContainsRune(s, '`') {
|
|
return "", ErrInvalidIdentInput
|
|
}
|
|
return escapeIdentity(s, '`', func(s string) string {
|
|
return s
|
|
})
|
|
}
|
|
|
|
func (m mysql) ArgPlaceholder(argNum int) string {
|
|
return "?"
|
|
}
|
|
|
|
func (m mysql) SelectFor(s ...string) (string, error) {
|
|
return rowLockingClauseAll.SelectFor(s...)
|
|
}
|
|
|
|
func (mysql) CurrentEpoch() string {
|
|
return "CAST(FLOOR(UNIX_TIMESTAMP(NOW(6)) * 1000000) AS SIGNED)"
|
|
}
|