diff options
author | scgilardi <scgilardi@gmail.com> | 2009-01-19 23:05:21 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2009-01-19 23:05:21 +0000 |
commit | 871691588879b665fe4f73303695e5ab6bad4f21 (patch) | |
tree | 91f9dc8ce0e2261567ad35f39692f1020728f6a6 /src/clojure/contrib/sql | |
parent | 936ca26a3f7e9b72a8752ba2ce8dbf0a7173e98a (diff) |
sql: provide find-connection, returns current connection or nil
Diffstat (limited to 'src/clojure/contrib/sql')
-rw-r--r-- | src/clojure/contrib/sql/internal.clj | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/clojure/contrib/sql/internal.clj b/src/clojure/contrib/sql/internal.clj index 1c75ee65..9f1aca7e 100644 --- a/src/clojure/contrib/sql/internal.clj +++ b/src/clojure/contrib/sql/internal.clj @@ -32,10 +32,15 @@ (.setProperty p (the-str key) (the-str val))) p)) +(defn find-connection* + "Returns the current database connection (or nil if there is none)" + [] + (:connection *db*)) + (defn connection* "Returns the current database connection (or throws if there is none)" [] - (or (:connection *db*) + (or (find-connection*) (throw (Exception. "no current database connection")))) (defn rollback-only |