diff --git a/CHANGELOG.md b/CHANGELOG.md index 271a6a7..6ae40fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Only accretive/fixative changes will be made from now on. The following changes have been made to **master** since the 1.0.409 build: -* None. +* Fixes #101 by tightening the spec on a JDBC URL to correctly reflect that it must start with `jdbc:`. ## Stable Builds diff --git a/src/next/jdbc/specs.clj b/src/next/jdbc/specs.clj index caec4b1..bb4274d 100644 --- a/src/next/jdbc/specs.clj +++ b/src/next/jdbc/specs.clj @@ -42,7 +42,16 @@ ::host ::port ::dbname-separator ::host-prefix])) -(s/def ::jdbcUrl string?) +(defn jdbc-url-format? + "JDBC URLs must begin with `jdbc:` followed by the `dbtype` and + a second colon. Note: `clojure.java.jdbc` incorrectly allowed + `jdbc:` to be omitted at the beginning of a JDBC URL." + [url] + (re-find #"^jdbc:[^:]+:" url)) +(s/def ::jdbcUrl (s/and string? jdbc-url-format?)) +(comment + (s/explain-data ::jdbcUrl "jdbc:somedb://some-host/dbname") + (s/explain-data ::jdbcUrl "somedb://some-host/dbname")) (s/def ::jdbc-url-map (s/keys :req-un [::jdbcUrl])) (s/def ::connection #(instance? Connection %)) @@ -52,7 +61,7 @@ (s/def ::db-spec (s/or :db-spec ::db-spec-map :jdbc-url ::jdbc-url-map - :string string? + :string ::jdbcUrl :ds ::datasource)) (s/def ::db-spec-or-jdbc (s/or :db-spec ::db-spec-map :jdbc-url ::jdbc-url-map))