Skip to content

Commit

Permalink
fix #3226 (#3322)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailaz authored Feb 27, 2024
1 parent 56ef0c0 commit eb0c4b3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
16 changes: 9 additions & 7 deletions contrib/drivers/oracle/oracle_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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(
Expand Down
20 changes: 20 additions & 0 deletions contrib/drivers/oracle/oracle_z_unit_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
})
}

0 comments on commit eb0c4b3

Please sign in to comment.