1
0
mirror of https://github.com/gogf/gf.git synced 2025-04-05 11:18:50 +08:00
This commit is contained in:
海亮 2024-02-27 20:37:49 +08:00 committed by GitHub
parent 56ef0c0735
commit eb0c4b3824
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 7 deletions

View File

@ -8,13 +8,14 @@ package oracle
import (
"database/sql"
"strings"
gora "github.com/sijms/go-ora/v2"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)
@ -45,12 +46,13 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) {
}
} else {
if config.Extra != "" {
var extraMap map[string]interface{}
if extraMap, err = gstr.Parse(config.Extra); err != nil {
return nil, err
}
for k, v := range extraMap {
options[k] = gconv.String(v)
// fix #3226
list := strings.Split(config.Extra, "&")
for _, v := range list {
kv := strings.Split(v, "=")
if len(kv) == 2 {
options[kv[0]] = kv[1]
}
}
}
source = gora.BuildUrl(

View File

@ -11,6 +11,7 @@ import (
"strings"
"testing"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/frame/g"
@ -692,3 +693,22 @@ func Test_Empty_Slice_Argument(t *testing.T) {
t.Assert(len(result), 0)
})
}
// fix #3226
func Test_Extra(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
nodeLink := gdb.ConfigNode{
Type: TestDbType,
Name: TestDbName,
Link: fmt.Sprintf("%s:%s:%s@tcp(%s:%s)/%s?lob fetch=post&SSL VERIFY=false",
TestDbType, TestDbUser, TestDbPass, TestDbIP, TestDbPort, TestDbName,
),
}
if r, err := gdb.New(nodeLink); err != nil {
gtest.Fatal(err)
} else {
err1 := r.PingMaster()
t.Assert(err1, nil)
}
})
}