diff options
Diffstat (limited to 'vendor/xorm.io/builder/sql.go')
-rw-r--r-- | vendor/xorm.io/builder/sql.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/vendor/xorm.io/builder/sql.go b/vendor/xorm.io/builder/sql.go index 4250fea18d..a6d1066b82 100644 --- a/vendor/xorm.io/builder/sql.go +++ b/vendor/xorm.io/builder/sql.go @@ -75,6 +75,7 @@ func noSQLQuoteNeeded(a interface{}) bool { } t := reflect.TypeOf(a) + switch t.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return true @@ -133,12 +134,16 @@ func ConvertToBoundSQL(sql string, args []interface{}) (string, error) { return buf.String(), nil } -// ConvertPlaceholder replaces ? to $1, $2 ... or :1, :2 ... according prefix +// ConvertPlaceholder replaces the place holder ? to $1, $2 ... or :1, :2 ... according prefix func ConvertPlaceholder(sql, prefix string) (string, error) { buf := strings.Builder{} var i, j, start int + var ready = true for ; i < len(sql); i++ { - if sql[i] == '?' { + if sql[i] == '\'' && i > 0 && sql[i-1] != '\\' { + ready = !ready + } + if ready && sql[i] == '?' { if _, err := buf.WriteString(sql[start:i]); err != nil { return "", err } |