fix place holder for mssql

This commit is contained in:
john
2020-07-20 21:48:44 +08:00
parent 5be30b3684
commit 48c84bf74a
2 changed files with 3 additions and 3 deletions

View File

@ -64,10 +64,10 @@ func (d *DriverMssql) GetChars() (charLeft string, charRight string) {
// HandleSqlBeforeCommit deals with the sql string before commits it to underlying sql driver.
func (d *DriverMssql) HandleSqlBeforeCommit(link Link, sql string, args []interface{}) (string, []interface{}) {
var index int
// Convert place holder char '?' to string "@vx".
// Convert place holder char '?' to string "@px".
str, _ := gregex.ReplaceStringFunc("\\?", sql, func(s string) string {
index++
return fmt.Sprintf("@v%d", index)
return fmt.Sprintf("@p%d", index)
})
str, _ = gregex.ReplaceString("\"", "", str)
return d.parseSql(str), args

View File

@ -553,7 +553,7 @@ func formatError(err error, sql string, args ...interface{}) error {
func FormatSqlWithArgs(sql string, args []interface{}) string {
index := -1
newQuery, _ := gregex.ReplaceStringFunc(
`(\?|:v\d+|\$v\d+|@v\d+)`, sql, func(s string) string {
`(\?|:v\d+|\$v\d+|@p\d+)`, sql, func(s string) string {
index++
if len(args) > index {
if args[index] == nil {