diff --git a/project.clj b/project.clj index d956579..d3d74b1 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject metabase/connection-pool "1.0.2" +(defproject metabase/connection-pool "1.0.3" :description "Connection pools for JDBC databases. Simple wrapper around C3P0." :url "https://github.com/metabase/connection-pool" :min-lein-version "2.5.0" @@ -7,8 +7,7 @@ :url "https://raw.githubusercontent.com/metabase/connection-pool/master/LICENSE"} :aliases - {"test" ["with-profile" "+expectations" "expectations"] - "bikeshed" ["with-profile" "+bikeshed" "bikeshed" "--max-line-length" "120"] + {"bikeshed" ["with-profile" "+bikeshed" "bikeshed" "--max-line-length" "120"] "check-namespace-decls" ["with-profile" "+check-namespace-decls" "check-namespace-decls"] "eastwood" ["with-profile" "+eastwood" "eastwood"] "docstring-checker" ["with-profile" "+docstring-checker" "docstring-checker"] @@ -22,18 +21,12 @@ {:dev {:dependencies [[org.clojure/clojure "1.10.1"] - [expectations "2.2.0-beta2"]] - - :injections - [(require 'expectations) - ((resolve 'expectations/disable-run-on-shutdown))] + [com.h2database/h2 "1.4.197"] + [pjstadig/humane-test-output "0.9.0"]] :jvm-opts ["-Xverify:none"]} - :expectations - {:plugins [[lein-expectations "0.0.8" :exclusions [expectations]]]} - :eastwood {:plugins [[jonase/eastwood "0.3.6" :exclusions [org.clojure/clojure]]] @@ -56,7 +49,8 @@ :bikeshed {:plugins - [[lein-bikeshed "0.5.2"]]} + [[lein-bikeshed "0.5.2" + :exclusions [org.clojure/tools.namespace]]]} :check-namespace-decls {:plugins [[lein-check-namespace-decls "1.0.2"]] diff --git a/src/metabase/connection_pool.clj b/src/metabase/connection_pool.clj index dff3d26..34b9749 100644 --- a/src/metabase/connection_pool.clj +++ b/src/metabase/connection_pool.clj @@ -7,7 +7,7 @@ for the options, which are c3p0-specific -- consider abstracting those as well?)" (:import com.mchange.v2.c3p0.DataSources [java.sql Driver DriverManager] - [java.util Map Properties] + java.util.Properties javax.sql.DataSource)) ;;; ------------------------------------------------ Proxy DataSource ------------------------------------------------ @@ -54,8 +54,8 @@ ([spec] (DataSources/pooledDataSource (unpooled-data-source spec))) - ([spec, ^Map pool-properties] - (DataSources/pooledDataSource (unpooled-data-source spec), pool-properties))) + ([spec pool-properties-map] + (DataSources/pooledDataSource (unpooled-data-source spec) (map->properties pool-properties-map)))) (defn connection-pool-spec "Create a new connection pool for a JDBC `spec` and return a spec for it. Optionally pass a map of connection pool diff --git a/test/metabase/connection_pool_test.clj b/test/metabase/connection_pool_test.clj new file mode 100644 index 0000000..1afa610 --- /dev/null +++ b/test/metabase/connection_pool_test.clj @@ -0,0 +1,19 @@ +(ns metabase.connection-pool-test + (:require [clojure.test :as t] + [metabase.connection-pool :as connection-pool])) + +(def ^:private spec + {:classname "org.h2.Driver", :subprotocol "h2", :subname "mem:db"}) + +(t/deftest properties-test + (t/testing "Options passed in to `connection-pool-spec` should get parsed correctly" + (let [description (-> (connection-pool/connection-pool-spec spec {"acquireIncrement" 1 + "testConnectionOnCheckin" true}) + :datasource + str)] + (t/is (= "acquireIncrement -> 1" + (re-find #"acquireIncrement -> \d" description)) + "numeric options should get converted correctly") + (t/is (= "testConnectionOnCheckin -> true" + (re-find #"testConnectionOnCheckin -> \w+" description)) + "boolean options should get converted correctly"))))