Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
0224abdf
Unverified
Commit
0224abdf
authored
6 years ago
by
Ryan Senior
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #8645 from metabase/allow-extra-params-for-mysql
Add support for extra parsed params for MySQL app DBs
parents
76d2beca
a1f5b1d1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/db/spec.clj
+24
-11
24 additions, 11 deletions
src/metabase/db/spec.clj
src/metabase/driver/mysql.clj
+6
-4
6 additions, 4 deletions
src/metabase/driver/mysql.clj
with
30 additions
and
15 deletions
src/metabase/db/spec.clj
+
24
−
11
View file @
0224abdf
...
...
@@ -2,7 +2,8 @@
"Functions for creating JDBC DB specs for a given engine.
Only databases that are supported as application DBs should have functions in this namespace;
otherwise, similar functions are only needed by drivers, and belong in those namespaces."
(
:require
[
ring.util.codec
:as
codec
]))
(
:require
[
clojure.string
:as
str
]
[
ring.util.codec
:as
codec
]))
(
defn
h2
...
...
@@ -16,6 +17,15 @@
:subname
db
}
(
dissoc
opts
:db
)))
(
defn-
remove-required-keys
[
db-spec
&
more-keys
]
(
apply
dissoc
db-spec
(
concat
[
:host
:port
:db
:user
:password
:additional-options
]
more-keys
)))
(
defn-
make-subname
[
host
port
db
extra-connection-params
]
(
let
[
query-params
(
codec/form-encode
extra-connection-params
)]
(
str
"//"
host
":"
port
"/"
db
(
when-not
(
str/blank?
query-params
)
(
str
"?"
query-params
)))))
(
defn
postgres
"Create a database specification for a postgres database. Opts should include
keys for :db, :user, and :password. You can also optionally set host and
...
...
@@ -23,11 +33,13 @@
[{
:keys
[
host
port
db
]
:or
{
host
"localhost"
,
port
5432
,
db
""
}
:as
opts
}]
(
let
[
query-params
(
codec/form-encode
(
merge
(
dissoc
opts
:host
:port
:db
:user
:password
:additional-options
:sslfactory
)
{
:OpenSourceSubProtocolOverride
true
}))]
(
merge
{
:classname
"org.postgresql.Driver"
:subprotocol
"postgresql"
:subname
(
str
"//"
host
":"
port
"/"
db
"?"
query-params
)}
(
dissoc
opts
:host
:port
:db
))))
(
let
[
extra-conn-params
(
->
opts
(
remove-required-keys
:sslfactory
)
(
merge
{
:OpenSourceSubProtocolOverride
true
}))]
(
merge
{
:classname
"org.postgresql.Driver"
:subprotocol
"postgresql"
:subname
(
make-subname
host
port
db
extra-conn-params
)}
(
dissoc
opts
:host
:port
:db
))))
(
defn
mysql
"Create a database specification for a mysql database. Opts should include keys
...
...
@@ -36,11 +48,12 @@
[{
:keys
[
host
port
db
]
:or
{
host
"localhost"
,
port
3306
,
db
""
}
:as
opts
}]
(
merge
{
:classname
"com.mysql.jdbc.Driver"
:subprotocol
"mysql"
:subname
(
str
"//"
host
":"
port
"/"
db
)
:delimiters
"`"
}
(
dissoc
opts
:host
:port
:db
)))
(
let
[
extra-connection-params
(
remove-required-keys
opts
)]
(
merge
{
:classname
"com.mysql.jdbc.Driver"
:subprotocol
"mysql"
:subname
(
make-subname
host
port
db
extra-connection-params
)
:delimiters
"`"
}
(
dissoc
opts
:host
:port
:db
))))
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver/mysql.clj
+
6
−
4
View file @
0224abdf
...
...
@@ -88,10 +88,12 @@
"Append `default-connection-args-string` to the connection string in CONNECTION-DETAILS, and an additional option to
explicitly disable SSL if appropriate. (Newer versions of MySQL will complain if you don't explicitly disable SSL.)"
{
:argslist
'
([
connection-spec
details
])}
[{
connection-string
:subname,
:as
connection-spec
}
{
ssl?
:ssl
}]
(
assoc
connection-spec
:subname
(
str
connection-string
"?"
default-connection-args-string
(
when-not
ssl?
"&useSSL=false"
))))
[
connection-spec
{
ssl?
:ssl
}]
(
update
connection-spec
:subname
(
fn
[
subname
]
(
let
[
join-char
(
if
(
str/includes?
subname
"?"
)
"&"
"?"
)]
(
str
subname
join-char
default-connection-args-string
(
when-not
ssl?
"&useSSL=false"
))))))
(
defn-
connection-details->spec
[
details
]
(
->
details
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment