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:
mlr3000
2022-03-12 18:49:07 +08:00
committed by GitHub
parent 7dabec260f
commit 32c88b6352
3 changed files with 28 additions and 2 deletions

View File

@@ -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)