K8s/Dashboards: Fix dashboard list and add tests (#91523)
This commit is contained in:
@@ -14,8 +14,25 @@ var MySQL = mysql{
|
||||
var _ Dialect = MySQL
|
||||
|
||||
type mysql struct {
|
||||
standardIdent
|
||||
backtickIdent
|
||||
rowLockingClauseMap
|
||||
argPlaceholderFunc
|
||||
name
|
||||
}
|
||||
|
||||
// standardIdent provides standard SQL escaping of identifiers.
|
||||
type backtickIdent struct{}
|
||||
|
||||
var standardFallback = standardIdent{}
|
||||
|
||||
func (backtickIdent) Ident(s string) (string, error) {
|
||||
switch s {
|
||||
// Internal identifiers require backticks to work properly
|
||||
case "user":
|
||||
return "`" + s + "`", nil
|
||||
case "":
|
||||
return "", ErrEmptyIdent
|
||||
}
|
||||
// standard
|
||||
return standardFallback.Ident(s)
|
||||
}
|
||||
|
||||
@@ -116,6 +116,22 @@ func FormatSQL(q string) string {
|
||||
return q
|
||||
}
|
||||
|
||||
// RemoveEmptyLines removes the empty lines from a SQL statement
|
||||
// empty lines are typical when using text template formatting
|
||||
func RemoveEmptyLines(q string) string {
|
||||
var b strings.Builder
|
||||
lines := strings.Split(strings.ReplaceAll(q, "\r\n", "\n"), "\n")
|
||||
for _, line := range lines {
|
||||
if strings.TrimSpace(line) == "" {
|
||||
continue
|
||||
}
|
||||
line = strings.ReplaceAll(line, "\t", " ")
|
||||
b.WriteString(line)
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
type reFormatting struct {
|
||||
re *regexp.Regexp
|
||||
replacement string
|
||||
|
||||
Reference in New Issue
Block a user