Files
Peter Štibraný e076c74869 sqltemplate, dbimpl: Remove single-method function types (#107525)
* 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>
2025-07-03 10:38:12 +02:00

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)"
}