diff options
author | scgilardi <scgilardi@gmail.com> | 2008-10-06 04:26:18 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2008-10-06 04:26:18 +0000 |
commit | 85f7ac0486fc32702ac7dd6d931815100fa98d0f (patch) | |
tree | d4c0fa9c6fd2867172ddc5edbda177dafcf8582c /src/clojure/contrib/sql | |
parent | 3a6fda18ee812870acae2c86d625aafa1209f642 (diff) |
sql: minor cleanups
Diffstat (limited to 'src/clojure/contrib/sql')
-rw-r--r-- | src/clojure/contrib/sql/internal/internal.clj | 2 | ||||
-rw-r--r-- | src/clojure/contrib/sql/sql.clj | 20 | ||||
-rw-r--r-- | src/clojure/contrib/sql/test/test.clj | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/clojure/contrib/sql/internal/internal.clj b/src/clojure/contrib/sql/internal/internal.clj index e46e9108..239d0434 100644 --- a/src/clojure/contrib/sql/internal/internal.clj +++ b/src/clojure/contrib/sql/internal/internal.clj @@ -6,7 +6,7 @@ ;; this license. You must not remove this notice, or any other, from this ;; software. ;; -;; internal definitions for 'clojure.contrib.sql +;; internal definitions for clojure.contrib.sql ;; ;; scgilardi (gmail) ;; Created 3 October 2008 diff --git a/src/clojure/contrib/sql/sql.clj b/src/clojure/contrib/sql/sql.clj index 25a2e4ea..255924d6 100644 --- a/src/clojure/contrib/sql/sql.clj +++ b/src/clojure/contrib/sql/sql.clj @@ -89,7 +89,7 @@ or keyword) and column specs. A column spec is a vector containing a name and optionally a type and other items such as constraints, each a string or keyword." - [name & cols] + [name & column-specs] (do-commands (format "create table %s (%s)" (the-str name) @@ -97,7 +97,7 @@ (map the-str (apply concat (interpose [", "] - (map (partial interpose " ") cols)))))))) + (map (partial interpose " ") column-specs)))))))) (defn drop-table "Drops a table on the open database connection given its name (a string @@ -110,16 +110,16 @@ "Inserts values into columns of a table. columns is a vector of column names (strings or keywords) and each value is a vector of values for those columns. To insert complete rows (all columns), use insert-rows." - [table columns & values] + [table column-names & values] (let [count (count (first values)) template (apply str (interpose "," (replicate count "?"))) - cols (if (seq columns) + columns (if (seq column-names) (format "(%s)" - (apply str(interpose "," (map the-str columns)))) + (apply str (interpose "," (map the-str column-names)))) "")] (apply do-prepared (format "insert into %s %s values (%s)" - (the-str table) cols template) + (the-str table) columns template) values))) (defn insert-rows @@ -129,10 +129,10 @@ (apply insert-values table nil rows)) (defmacro with-results - "Executes a query and then evaluates body with res bound to a seq of the - results" - [res sql & body] + "Executes a query and then evaluates body with results bound to a seq of + the results" + [results sql & body] `(with-open stmt# (.prepareStatement (connection) ~sql) (with-open rset# (.executeQuery stmt#) - (let [~res (resultset-seq rset#)] + (let [~results (resultset-seq rset#)] ~@body)))) diff --git a/src/clojure/contrib/sql/test/test.clj b/src/clojure/contrib/sql/test/test.clj index eb212dc5..356cf123 100644 --- a/src/clojure/contrib/sql/test/test.clj +++ b/src/clojure/contrib/sql/test/test.clj @@ -8,7 +8,7 @@ ;; ;; test.clj ;; -;; test/example for clojure.contrib.sql.test +;; test/example for clojure.contrib.sql ;; ;; scgilardi (gmail) ;; Created 13 September 2008 |