Skip to content
Permalink
Browse files

Use the depth function to handle nested vectors in [:where]

  • Loading branch information...
swlkr committed Mar 19, 2019
1 parent b5582e1 commit bf1b91fa60c3cf3304cc880b0aea067fc9fc47f6
Showing with 1 addition and 10 deletions.
  1. +1 −10 src/coast/db/sql.clj
@@ -80,15 +80,6 @@
(string/join " " parts)))))


(defn depth
([val]
(depth val 0))
([val idx]
(if (sequential? val)
(depth (first val) (inc idx))
idx)))


(defn last-or-rest [v]
(if (utils/sql-vec? v)
(rest v)
@@ -99,7 +90,7 @@
(if (utils/sql-vec? v)
{:where (str "where " (first v))
:args (rest v)}
(let [v (if (> (depth v) 2)
(let [v (if (> (utils/depth v) 2)
(first v)
v)]
{:where (str "where " (string/join " and " (mapv #(utils/surround "()" %) (mapv where-part v))))

0 comments on commit bf1b91f

Please sign in to comment.
You can’t perform that action at this time.