From e404c47d835cbc41f4dce93c8e49eb6867ea2708 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Wed, 13 Nov 2019 10:40:59 -0800 Subject: [PATCH] Fixes #74 by mollifying Eastwood --- .gitignore | 1 + CHANGELOG.md | 1 + src/next/jdbc.clj | 2 +- src/next/jdbc/connection.clj | 5 ++--- test/next/jdbc/connection_test.clj | 4 ++-- test/next/jdbc_test.clj | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index b2d07b5..b4e10e2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ pom.xml.asc *.jar *.class /.cpcache +/.eastwood /.lein-* /.nrepl-history /.nrepl-port diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f74a96..935cc6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Only accretive/fixative changes will be made from now on. The following changes have been committed to the **master** branch since the 1.0.9 release: * Fix link to **All The Options** in **Migration from `clojure.java.jdbc`**. PR #71 (@laurio). +* Address #74 by making several small changes to satisfy Eastwood. * Address #70 by adding **CLOB & BLOB SQL Types** to the **Tips & Tricks** section of **Friendly SQL Functions** and by adding `next.jdbc.result-set/clob-column-reader` and `next.jdbc.result-set/clob->string` helper to make it easier to deal with `CLOB` column data. * Clarify what `execute!` and `execute-one!` produce when the result set is empty (`[]` and `nil` respectively, and there are now tests for this). Similarly for `find-by-keys` and `get-by-id`. * Add **MS SQL Server** section to **Tips & Tricks** to note that returns an empty string for table names by default (so table-qualified column names are not available). Using the `:result-type` (scroll) and `:concurrency` options will cause table names to be returned. diff --git a/src/next/jdbc.clj b/src/next/jdbc.clj index 35a1d82..aad83b8 100644 --- a/src/next/jdbc.clj +++ b/src/next/jdbc.clj @@ -232,4 +232,4 @@ * `:rollback-only` -- `true` / `false`." [[sym transactable opts] & body] (let [con (vary-meta sym assoc :tag 'java.sql.Connection)] - `(transact ~transactable (^{:once true} fn* [~con] ~@body) (or ~opts {})))) + `(transact ~transactable (^{:once true} fn* [~con] ~@body) ~(or opts {})))) diff --git a/src/next/jdbc/connection.clj b/src/next/jdbc/connection.clj index c3e21ca..b452248 100644 --- a/src/next/jdbc/connection.clj +++ b/src/next/jdbc/connection.clj @@ -183,9 +183,8 @@ (if-let [class-name (or classname (-> dbtype dbtypes :classname))] (swap! driver-cache update class-name #(if % % - (do - ;; force DriverManager to be loaded - (DriverManager/getLoginTimeout) + (let [;; force DriverManager to be loaded + _ (DriverManager/getLoginTimeout)] (if (string? class-name) (clojure.lang.RT/loadClassForName class-name) (loop [[clazz & more] class-name] diff --git a/test/next/jdbc/connection_test.clj b/test/next/jdbc/connection_test.clj index 0f6b9e4..eb3c2b4 100644 --- a/test/next/jdbc/connection_test.clj +++ b/test/next/jdbc/connection_test.clj @@ -107,8 +107,8 @@ (let [[url etc] (#'c/spec->url+etc db) ds (p/get-datasource (assoc etc :jdbcUrl url))] (if (= "derby" (:dbtype db)) - (is {:create true} etc) - (is {} etc)) + (is (= {:create true} etc)) + (is (= {} etc))) (is (instance? javax.sql.DataSource ds)) (is (str/index-of (pr-str ds) (str "jdbc:" (:dbtype db)))) ;; checks get-datasource on a DataSource is identity diff --git a/test/next/jdbc_test.clj b/test/next/jdbc_test.clj index d09a1c6..93d5ebc 100644 --- a/test/next/jdbc_test.clj +++ b/test/next/jdbc_test.clj @@ -194,8 +194,8 @@ VALUES ('Pear', 'green', 49, 47) (let [[url etc] (#'c/spec->url+etc (db)) ds (jdbc/get-datasource (assoc etc :jdbcUrl url))] (if (derby?) - (is {:create true} etc) - (is {} etc)) + (is (= {:create true} etc)) + (is (= {} etc))) (is (instance? javax.sql.DataSource ds)) (is (str/index-of (pr-str ds) (str "jdbc:" (:dbtype (db))))) ;; checks get-datasource on a DataSource is identity