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
55ecc874
Unverified
Commit
55ecc874
authored
4 years ago
by
Raimon Grau
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add 'jdbc:' prefix to connection-uri if needed (#14573)
parent
8f7ec64a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/db/env.clj
+9
-1
9 additions, 1 deletion
src/metabase/db/env.clj
test/metabase/db/env_test.clj
+8
-0
8 additions, 0 deletions
test/metabase/db/env_test.clj
with
17 additions
and
1 deletion
src/metabase/db/env.clj
+
9
−
1
View file @
55ecc874
...
...
@@ -50,8 +50,16 @@
(
let
[
db-file-name
(
config/config-str
:mb-db-file
)]
(
get-db-file
db-file-name
)))))
(
defn-
format-connection-uri
"Prepends \"jdbc:\" to the connection-uri string if needed."
[
connection-uri
]
(
if-let
[
uri
connection-uri
]
(
if
(
re-find
#
"^jdbc:"
uri
)
uri
(
str
"jdbc:"
uri
))))
(
def
^
:private
connection-string
(
delay
(
config/config-str
:mb-db-connection-uri
)))
(
delay
(
format-connection-uri
(
config/config-str
:mb-db-connection-uri
)))
)
(
defn-
connection-string->db-type
[
s
]
(
when
s
...
...
This diff is collapsed.
Click to expand it.
test/metabase/db/env_test.clj
+
8
−
0
View file @
55ecc874
...
...
@@ -20,3 +20,11 @@
clojure.lang.ExceptionInfo
#
"Unsupported application database type: \"sqlserver\""
(
#
'mdb.env/connection-string->db-type
"jdbc:sqlserver://bad"
)))))
(
deftest
format-connection-uri-test
(
let
[
conn-uri
"postgresql://localhost:metabase?username=johndoe"
jdbc-conn-uri
(
str
"jdbc:"
conn-uri
)]
(
doseq
[[
input
expected
]
[[
conn-uri
jdbc-conn-uri
]
[
jdbc-conn-uri
jdbc-conn-uri
]
[
nil
nil
]]]
(
is
(
=
expected
(
#
'mdb.env/format-connection-uri
input
))))))
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