MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / normalizeSQLForParsing

Function normalizeSQLForParsing

integrations/gorm/plugin.go:138–148  ·  view source on GitHub ↗

normalizeSQLForParsing converts GORM-generated SQL into a form that GoSQLX can parse: backtick identifiers become double-quoted, and ? placeholders become $N placeholders.

(sql string)

Source from the content-addressed store, hash-verified

136// can parse: backtick identifiers become double-quoted, and ? placeholders
137// become $N placeholders.
138func 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.
151func (p *Plugin) Stats() PluginStats {

Callers 1

afterStatementMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected