Skip to content

Commit

Permalink
Merge pull request #65 from amalloy/simplify
Browse files Browse the repository at this point in the history
Simplify some stuff
  • Loading branch information
Lau B. Jensen committed Feb 28, 2013
2 parents 73ef085 + f1f0329 commit b18f9bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/clojureql/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
nil? clojureql.predicates/nil?*
in clojureql.predicates/in})

(defn- where* [clause]
(postwalk-replace predicate-symbols clause))

(defmacro where [clause]
"Constructs a where-clause for queries.
Expand All @@ -62,7 +65,7 @@
(:env) you will see the captured environment
Use as: (select tble (where ...))"
`~(postwalk-replace predicate-symbols clause))
(where* clause))

(defmacro case
"Lets you specify a column using the SQL CASE operator.
Expand All @@ -81,7 +84,7 @@
(let [pairs (->> (if (= :else (-> clauses vec rseq second))
(drop-last 2 clauses)
clauses)
`~(postwalk-replace predicate-symbols)
where*
(partition 2))]
{:alias alias
:clauses (vec (map first pairs))
Expand Down

0 comments on commit b18f9bc

Please sign in to comment.