fix: recognize json_valid constraint as json field type for database mariadb #2746 (#3309)

This commit is contained in:
oldme
2024-03-06 19:07:31 +08:00
committed by GitHub
parent 97fcd9d726
commit 290f4a3e65
16 changed files with 172 additions and 63 deletions

View File

@ -30,7 +30,7 @@ type ConfigNode struct {
User string `json:"user"` // Authentication username.
Pass string `json:"pass"` // Authentication password.
Name string `json:"name"` // Default used database name.
Type string `json:"type"` // Database type: mysql, sqlite, mssql, pgsql, oracle.
Type string `json:"type"` // Database type: mysql, mariadb, sqlite, mssql, pgsql, oracle, clickhouse, dm.
Link string `json:"link"` // (Optional) Custom link information for all configuration in one single string.
Extra string `json:"extra"` // (Optional) Extra configuration according the registered third-party database driver.
Role string `json:"role"` // (Optional, "master" in default) Node role, used for master-slave mode: master, slave.

View File

@ -929,3 +929,18 @@ func FormatSqlWithArgs(sql string, args []interface{}) string {
})
return newQuery
}
// FormatMultiLineSqlToSingle formats sql template string into one line.
func FormatMultiLineSqlToSingle(sqlTmp string) string {
var err error
// format sql template string.
sqlTmp, err = gregex.ReplaceString(`[\n\r\s]+`, " ", gstr.Trim(sqlTmp))
if err != nil {
panic(err)
}
sqlTmp, err = gregex.ReplaceString(`\s{2,}`, " ", gstr.Trim(sqlTmp))
if err != nil {
panic(err)
}
return sqlTmp
}