Skip to content

Commit d755bee

Browse files
committed
fix: keep options on oracle-raw urls
1 parent 8745592 commit d755bee

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

internal/app/urlbuilder/urlbuilder.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,32 @@ func GenOracleRaw(u *dburl.URL) (string, string, error) {
6666

6767
func genJDBCOracle(u *dburl.URL) (string, string, error) {
6868
if u.User == nil {
69-
return go_ora.BuildJDBC("", "", u.Host, map[string]string{}), "", nil
69+
return go_ora.BuildJDBC("", "", u.Host, getOptions(u)), "", nil
7070
}
7171

7272
if un := u.User.Username(); len(un) > 0 {
7373
if up, ok := u.User.Password(); ok {
74-
return go_ora.BuildJDBC(u.User.Username(), up, u.Host, map[string]string{}), "", nil
74+
return go_ora.BuildJDBC(u.User.Username(), up, u.Host, getOptions(u)), "", nil
7575
} else {
76-
return go_ora.BuildJDBC(u.User.Username(), "", u.Host, map[string]string{}), "", nil
76+
return go_ora.BuildJDBC(u.User.Username(), "", u.Host, getOptions(u)), "", nil
7777
}
7878
}
7979

80-
return go_ora.BuildJDBC("", "", u.Host, map[string]string{}), "", nil
80+
return go_ora.BuildJDBC("", "", u.Host, getOptions(u)), "", nil
81+
}
82+
83+
func getOptions(u *dburl.URL) map[string]string {
84+
values := u.Query()
85+
86+
options := make(map[string]string, len(values))
87+
88+
for key, vals := range values {
89+
if len(vals) > 0 {
90+
options[key] = vals[len(vals)-1]
91+
}
92+
}
93+
94+
return options
8195
}
8296

8397
func init() {

0 commit comments

Comments
 (0)