feat: support oracle :N dynamic parameters (#1552)
* chore:use struct pointer * feat: support oracle :N dynamic parameters * Update utils.go * Update utils.go * Update utils.go pg argIndex will not always go up * Update utils_test.go * Keep the original * Update utils_test.go
This commit is contained in:
@@ -67,7 +67,7 @@ func format(query string, args ...interface{}) (string, error) {
|
||||
|
||||
writeValue(&b, args[argIndex])
|
||||
argIndex++
|
||||
case '$':
|
||||
case ':', '$':
|
||||
var j int
|
||||
for j = i + 1; j < bytes; j++ {
|
||||
char := query[j]
|
||||
@@ -81,10 +81,11 @@ func format(query string, args ...interface{}) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// index starts from 1 for pg
|
||||
// index starts from 1 for pg or oracle
|
||||
if index > argIndex {
|
||||
argIndex = index
|
||||
}
|
||||
|
||||
index--
|
||||
if index < 0 || numArgs <= index {
|
||||
return "", fmt.Errorf("error: wrong index %d in sql", index)
|
||||
|
||||
Reference in New Issue
Block a user