handle SqlParam explicitly
This commit is contained in:
parent
f63de95e14
commit
415bbce6b3
1 changed files with 12 additions and 9 deletions
|
|
@ -245,6 +245,16 @@
|
|||
(apply fn-handler fn-name (.args x)))))
|
||||
SqlRaw
|
||||
(-to-sql [x] (.s x))
|
||||
SqlParam
|
||||
(-to-sql [x] (let [pname (param-name x)
|
||||
x (if (map? @*input-params*)
|
||||
(get @*input-params* pname)
|
||||
(let [x (first @*input-params*)]
|
||||
(swap! *input-params* rest)
|
||||
x))]
|
||||
(swap! *param-names* conj pname)
|
||||
(swap! *params* conj x)
|
||||
"?"))
|
||||
clojure.lang.IPersistentMap
|
||||
(-to-sql [x] (let [clause-ops (concat
|
||||
(filter #(contains? x %) clause-order)
|
||||
|
|
@ -260,15 +270,8 @@
|
|||
nil
|
||||
(-to-sql [x] "NULL")
|
||||
Object
|
||||
(-to-sql [x] (let [[x pname] (if (instance? SqlParam x)
|
||||
(let [pname (param-name x)]
|
||||
(if (map? @*input-params*)
|
||||
[(get @*input-params* pname) pname]
|
||||
(let [x (first @*input-params*)]
|
||||
(swap! *input-params* rest)
|
||||
[x pname])))
|
||||
;; Anonymous param name -- :_1, :_2, etc.
|
||||
[x (keyword (str "_" (swap! *param-counter* inc)))])]
|
||||
;; Anonymous param name -- :_1, :_2, etc.
|
||||
(-to-sql [x] (let [pname (keyword (str "_" (swap! *param-counter* inc)))]
|
||||
(swap! *param-names* conj pname)
|
||||
(swap! *params* conj x)
|
||||
"?")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue