xwb1989 / sqlparser

SQL Parser implemented in Go
Apache License 2.0
1.49k stars 240 forks source link

A question about using sqlparser to parse sql with placeholders #62

Closed xhjmc closed 4 years ago

xhjmc commented 4 years ago

HI. When I use sqlparser to parse sql with "?", and then call function stmt.Format, the "?" in the sql will be replaced with ":v1". Is this a bug? Here is an example.

sql := "select * from tbl where id = ?"
stmt, _ := sqlparser.Parse(sql)
buf := sqlparser.NewTrackedBuffer(nil)
stmt.Format(buf)
newSql := buf.String()
fmt.Println(newSql) // the newSql is "select * from tbl where id = :v1"

Thank you in advance for your answer.