fixed sql nested json value dev print log

This commit is contained in:
Gani Georgiev 2025-03-15 12:29:51 +02:00
parent 6e9ecb2b7a
commit 64e2931379
1 changed files with 8 additions and 8 deletions

View File

@ -1139,12 +1139,12 @@ func (app *BaseApp) initDataDB() error {
return nil
}
var sqlLogReplacements = map[string]string{
"{{": "`",
"}}": "`",
"[[": "`",
"]]": "`",
"<nil>": "NULL",
var sqlLogReplacements = map[*regexp.Regexp]string{
regexp.MustCompile(`[^'"]\{\{`): "`",
regexp.MustCompile(`\}\}[^'"]`): "`",
regexp.MustCompile(`[^'"]\[\[`): "`",
regexp.MustCompile(`\]\][^'"]`): "`",
regexp.MustCompile(`<nil>`): "NULL",
}
var sqlLogPrefixedTableIdentifierPattern = regexp.MustCompile(`\[\[([^\[\]\{\}\.]+)\.([^\[\]\{\}\.]+)\]\]`)
var sqlLogPrefixedColumnIdentifierPattern = regexp.MustCompile(`\{\{([^\[\]\{\}\.]+)\.([^\[\]\{\}\.]+)\}\}`)
@ -1157,8 +1157,8 @@ func normalizeSQLLog(sql string) string {
sql = sqlLogPrefixedColumnIdentifierPattern.ReplaceAllString(sql, "`$1`.`$2`")
for old, new := range sqlLogReplacements {
sql = strings.ReplaceAll(sql, old, new)
for pattern, replacement := range sqlLogReplacements {
sql = pattern.ReplaceAllString(sql, replacement)
}
return sql