aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/sql
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2008-10-06 04:57:17 +0000
committerscgilardi <scgilardi@gmail.com>2008-10-06 04:57:17 +0000
commit67eac3c9c687638d972f0bef05900be4866d6380 (patch)
treefa94a55f7721a4e683cc3f993bd7b4b3c8845be2 /src/clojure/contrib/sql
parent5bf1c3b6afa467ffeaddafd8e35b3ca57046b375 (diff)
sql.interal: minor fixes
Diffstat (limited to 'src/clojure/contrib/sql')
-rw-r--r--src/clojure/contrib/sql/internal/internal.clj30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/clojure/contrib/sql/internal/internal.clj b/src/clojure/contrib/sql/internal/internal.clj
index 239d0434..6221d1e2 100644
--- a/src/clojure/contrib/sql/internal/internal.clj
+++ b/src/clojure/contrib/sql/internal/internal.clj
@@ -16,30 +16,28 @@
(def *db* {:connection nil :level 0})
(defn connection
- "Returns the current database connection. Throws an exception if there is
- no curent connection."
+ "Returns the current database connection or throws an exception."
[]
- (if-let connection (:connection *db*)
- connection
- (throw (Exception. "no current database connection"))))
+ (or (:connection *db*)
+ (throw (Exception. "no current database connection"))))
+
+(defn the-str
+ "Returns the name or string representation of x"
+ [x]
+ (if (instance? clojure.lang.Named x)
+ (name x)
+ (str x)))
(defn properties
- "Converts a Clojure map from keywords or symbols to values into a
- java.util.Properties object that maps the names of the keywords or
- symbols to the String representation of the values"
+ "Converts a map from keywords or symbols to values into a
+ java.util.Properties object that maps the same keys to the values with
+ all represented as strings."
[m]
(let [p (java.util.Properties.)]
(when m
(loop [[key & keys] (keys m)
[val & vals] (vals m)]
- (.setProperty p (name key) (str val))
+ (.setProperty p (the-str key) (the-str val))
(when keys
(recur keys vals))))
p))
-
-(defn the-str
- "Returns the String represented by the String, Keyword, or Symbol x"
- [x]
- (if (instance? String x)
- x
- (name x)))