postgre 报错 pq: syntax error at or near $

This commit is contained in:
tiancai
2020-07-19 23:24:35 +08:00
parent 0cb77caa2a
commit 7bbc2459ba

View File

@ -65,7 +65,7 @@ func (d *DriverPgsql) HandleSqlBeforeCommit(link Link, sql string, args []interf
// Convert place holder char '?' to string "$vx".
sql, _ = gregex.ReplaceStringFunc("\\?", sql, func(s string) string {
index++
return fmt.Sprintf("$v%d", index)
return fmt.Sprintf("$%d", index)
})
sql, _ = gregex.ReplaceString(` LIMIT (\d+),\s*(\d+)`, ` LIMIT $2 OFFSET $1`, sql)
return sql, args