fix #243 by producing keywords (from properties)

This commit is contained in:
Sean Corfield 2023-03-12 16:59:24 -07:00
parent f6489e0078
commit 70a5db8b29
3 changed files with 15 additions and 1 deletions

View file

@ -2,6 +2,9 @@
Only accretive/fixative changes will be made from now on.
* 1.3.next in progress
* Fix [#243](https://github.com/seancorfield/next-jdbc/issues/243) by ensure URI properties become keywords.
* 1.3.858 -- 2023-03-05
* Address [#241](https://github.com/seancorfield/next-jdbc/issues/241) by correcting link to PostgreSQL docs.
* Address [clj-kondo#1685](https://github.com/clj-kondo/clj-kondo/issues/1685) by using `.clj_kondo` extension for hook files.

View file

@ -365,7 +365,8 @@
[user password] (when (seq userInfo) (str/split userInfo #":"))
properties (when (seq query)
(into {}
(map #(str/split % #"="))
(map #(let [[k v] (str/split % #"=")]
[(keyword k) v]))
(str/split query #"\&")))]
(cond-> (assoc properties
:dbtype scheme

View file

@ -188,3 +188,13 @@
(testing "connection via map (Object)"
(with-open [con (p/get-connection db {})]
(is (instance? java.sql.Connection con))))))
(deftest issue-243-uri->db-spec
(is (= {:dbtype "mysql" :dbname "mydb"
:host "myserver" :port 1234
:user "foo" :password "bar"}
(c/uri->db-spec "mysql://foo:bar@myserver:1234/mydb")))
(is (= {:dbtype "mysql" :dbname "mydb"
:host "myserver" :port 1234
:user "foo" :password "bar"}
(c/uri->db-spec "jdbc:mysql://myserver:1234/mydb?user=foo&password=bar"))))