xwb1989 / sqlparser

SQL Parser implemented in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A question about using sqlparser to parse sql with placeholders

xhjmc opened this issue · comments

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.