normalizeSQLForParsing converts GORM-generated SQL into a form that GoSQLX can parse: backtick identifiers become double-quoted, and ? placeholders become $N placeholders.
(sql string)
| 136 | // can parse: backtick identifiers become double-quoted, and ? placeholders |
| 137 | // become $N placeholders. |
| 138 | func normalizeSQLForParsing(sql string) string { |
| 139 | // Replace backtick-quoted identifiers with double-quoted identifiers. |
| 140 | sql = strings.ReplaceAll(sql, "`", "\"") |
| 141 | // Replace ? positional placeholders with $N. |
| 142 | n := 0 |
| 143 | sql = reQuestionMark.ReplaceAllStringFunc(sql, func(string) string { |
| 144 | n++ |
| 145 | return "$" + strconv.Itoa(n) |
| 146 | }) |
| 147 | return sql |
| 148 | } |
| 149 | |
| 150 | // Stats returns a snapshot of all recorded queries. |
| 151 | func (p *Plugin) Stats() PluginStats { |