From ec8840d02bc51d5d75395c266619c5da52863382 Mon Sep 17 00:00:00 2001
From: Juergen Hoetzel <juergen@archlinux.org>
Date: Sat, 12 May 2012 18:29:39 +0200
Subject: [PATCH 2/2] distinct? throws clojure.lang.ArityException, when
 applied with no arguments.

HSQLDB returns an empty ResultSet when using (.getGeneratedKeys stmt)
and no keys are generated. So this Exception is thrown for each record
without generated keys.

Also rewrite make-cols-unique implementation using high-order
functions instead of "low-level" loop/recur.
---
 src/main/clojure/clojure/java/jdbc.clj |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/main/clojure/clojure/java/jdbc.clj b/src/main/clojure/clojure/java/jdbc.clj
index 67dcc5d..8878786 100644
--- a/src/main/clojure/clojure/java/jdbc.clj
+++ b/src/main/clojure/clojure/java/jdbc.clj
@@ -201,13 +201,9 @@ generated keys are returned (as a map)." }
   "Given a collection of column names, rename duplicates so
    that the result is a collection of unique column names."
   [cols]
-  (if (apply distinct? cols)
+  (if (or (not (seq cols)) (apply distinct? cols))
     cols
-    (loop [[col-name :as new-cols] (seq cols)
-           unique-cols []]
-      (if (seq new-cols)
-        (recur (rest new-cols) (conj unique-cols (make-name-unique unique-cols col-name 1)))
-        unique-cols))))
+    (reduce (fn [unique-cols col-name] (conj unique-cols (make-name-unique unique-cols col-name 1))) []  cols)))
 
 (defn resultset-seq
   "Creates and returns a lazy sequence of maps corresponding to
-- 
1.7.10.1

