Repro code:
package main
import (
"fmt"
"github.com/gocraft/dbr/v2"
"github.com/gocraft/dbr/v2/dialect"
)
func main() {
q, _ := dbr.InterpolateForDialect("SHOW CREATE TABLE ?;", []interface{}{"foo"}, dialect.MySQL)
fmt.Println(q)
}
Sandbox link showing this execution: https://go.dev/play/p/QGDpepYMCfM
The above code produces the following MySQL statement: SHOW CREATE TABLE 'foo';.
This MySQL statement is not valid, because MySQL is not expecting ' (quotes) around the table name. MySQL docs in question.
Is there a way to invoke InterpolateForDialect in such a way that we can get the injection protection, but avoid quoting a particular parameter? Should we be using a different method entirely?
Repro code:
Sandbox link showing this execution: https://go.dev/play/p/QGDpepYMCfM
The above code produces the following MySQL statement:
SHOW CREATE TABLE 'foo';.This MySQL statement is not valid, because MySQL is not expecting
'(quotes) around the table name. MySQL docs in question.Is there a way to invoke
InterpolateForDialectin such a way that we can get the injection protection, but avoid quoting a particular parameter? Should we be using a different method entirely?