Merge pull request #53 from MichaelBlume/format-format
format the format namespace a bit more nicely
This commit is contained in:
commit
d6295a7fc6
1 changed files with 50 additions and 44 deletions
|
|
@ -244,7 +244,8 @@
|
|||
|
||||
(extend-protocol ToSql
|
||||
clojure.lang.Keyword
|
||||
(-to-sql [x] (let [s ^String (name x)]
|
||||
(-to-sql [x]
|
||||
(let [s (name x)]
|
||||
(condp = (.charAt s 0)
|
||||
\% (let [call-args (string/split (subs s 1) #"\." 2)]
|
||||
(to-sql (apply call (map keyword call-args))))
|
||||
|
|
@ -255,9 +256,11 @@
|
|||
java.lang.Number
|
||||
(-to-sql [x] (str x))
|
||||
java.lang.Boolean
|
||||
(-to-sql [x] (if x "TRUE" "FALSE"))
|
||||
(-to-sql [x]
|
||||
(if x "TRUE" "FALSE"))
|
||||
clojure.lang.Sequential
|
||||
(-to-sql [x] (if *fn-context?*
|
||||
(-to-sql [x]
|
||||
(if *fn-context?*
|
||||
;; list argument in fn call
|
||||
(paren-wrap (comma-join (map to-sql x)))
|
||||
;; alias
|
||||
|
|
@ -270,14 +273,16 @@
|
|||
(quote-identifier (second x))
|
||||
(to-sql (second x))))))
|
||||
SqlCall
|
||||
(-to-sql [x] (binding [*fn-context?* true]
|
||||
(-to-sql [x]
|
||||
(binding [*fn-context?* true]
|
||||
(let [fn-name (name (.name x))
|
||||
fn-name (fn-aliases fn-name fn-name)]
|
||||
(apply fn-handler fn-name (.args x)))))
|
||||
SqlRaw
|
||||
(-to-sql [x] (.s x))
|
||||
clojure.lang.IPersistentMap
|
||||
(-to-sql [x] (let [clause-ops (sort-clauses (keys x))
|
||||
(-to-sql [x]
|
||||
(let [clause-ops (sort-clauses (keys x))
|
||||
sql-str (binding [*subquery?* true
|
||||
*fn-context?* false]
|
||||
(space-join
|
||||
|
|
@ -289,7 +294,8 @@
|
|||
nil
|
||||
(-to-sql [x] "NULL")
|
||||
Object
|
||||
(-to-sql [x] (let [[x pname] (if (instance? SqlParam x)
|
||||
(-to-sql [x]
|
||||
(let [[x pname] (if (instance? SqlParam x)
|
||||
(let [pname (param-name x)]
|
||||
(if (map? @*input-params*)
|
||||
[(get @*input-params* pname) pname]
|
||||
|
|
|
|||
Loading…
Reference in a new issue