Skip to content
Snippets Groups Projects
Unverified Commit 22be5241 authored by Ryan Senior's avatar Ryan Senior Committed by GitHub
Browse files

Merge pull request #8598 from argvader/query-issue

fix postgres connection string
parents d290275d 5e181964
No related branches found
No related tags found
No related merge requests found
(ns metabase.db.spec
"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.")
otherwise, similar functions are only needed by drivers, and belong in those namespaces."
(:require [ring.util.codec :as codec]))
(defn h2
"Create a database specification for a h2 database. Opts should include a key
......@@ -21,10 +23,11 @@
[{:keys [host port db]
:or {host "localhost", port 5432, db ""}
:as opts}]
(merge {:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname (str "//" host ":" port "/" db "?OpenSourceSubProtocolOverride=true")}
(dissoc opts :host :port :db)))
(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))))
(defn mysql
"Create a database specification for a mysql database. Opts should include keys
......
......@@ -37,7 +37,7 @@
{:user "camsaul"
:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname "//localhost:5432/bird_sightings?OpenSourceSubProtocolOverride=true"
:subname "//localhost:5432/bird_sightings?sslmode=disable&OpenSourceSubProtocolOverride=true"
:sslmode "disable"}
(sql/connection-details->spec pg-driver {:ssl false
:host "localhost"
......@@ -53,7 +53,7 @@
:subprotocol "postgresql"
:user "camsaul"
:sslfactory "org.postgresql.ssl.NonValidatingFactory"
:subname "//localhost:5432/bird_sightings?OpenSourceSubProtocolOverride=true"}
:subname "//localhost:5432/bird_sightings?ssl=true&sslmode=require&OpenSourceSubProtocolOverride=true"}
(sql/connection-details->spec pg-driver {:ssl true
:host "localhost"
:port 5432
......@@ -285,7 +285,7 @@
;; make sure connection details w/ extra params work as expected
(expect
"//localhost:5432/cool?OpenSourceSubProtocolOverride=true&prepareThreshold=0"
"//localhost:5432/cool?sslmode=disable&OpenSourceSubProtocolOverride=true&prepareThreshold=0"
(:subname (sql/connection-details->spec pg-driver {:host "localhost"
:port "5432"
:dbname "cool"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment