Merge remote-tracking branch 'upstream/master' into params-merge
This commit is contained in:
commit
7115456d9e
3 changed files with 59 additions and 48 deletions
3
.travis.yml
Normal file
3
.travis.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
language: clojure
|
||||||
|
lein: lein2
|
||||||
|
script: lein do check, test
|
||||||
|
|
@ -2,5 +2,7 @@
|
||||||
:description "SQL as Clojure data structures"
|
:description "SQL as Clojure data structures"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
:url https://github.com/jkk/honeysql
|
:url "https://github.com/jkk/honeysql"
|
||||||
|
:scm {:name "git"
|
||||||
|
:url "https://github.com/jkk/honeysql"}
|
||||||
:dependencies [[org.clojure/clojure "1.6.0"]])
|
:dependencies [[org.clojure/clojure "1.6.0"]])
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,8 @@
|
||||||
|
|
||||||
(extend-protocol ToSql
|
(extend-protocol ToSql
|
||||||
clojure.lang.Keyword
|
clojure.lang.Keyword
|
||||||
(-to-sql [x] (let [s ^String (name x)]
|
(-to-sql [x]
|
||||||
|
(let [s (name x)]
|
||||||
(condp = (.charAt s 0)
|
(condp = (.charAt s 0)
|
||||||
\% (let [call-args (string/split (subs s 1) #"\." 2)]
|
\% (let [call-args (string/split (subs s 1) #"\." 2)]
|
||||||
(to-sql (apply call (map keyword call-args))))
|
(to-sql (apply call (map keyword call-args))))
|
||||||
|
|
@ -265,9 +266,11 @@
|
||||||
java.lang.Number
|
java.lang.Number
|
||||||
(-to-sql [x] (str x))
|
(-to-sql [x] (str x))
|
||||||
java.lang.Boolean
|
java.lang.Boolean
|
||||||
(-to-sql [x] (if x "TRUE" "FALSE"))
|
(-to-sql [x]
|
||||||
|
(if x "TRUE" "FALSE"))
|
||||||
clojure.lang.Sequential
|
clojure.lang.Sequential
|
||||||
(-to-sql [x] (if *fn-context?*
|
(-to-sql [x]
|
||||||
|
(if *fn-context?*
|
||||||
;; list argument in fn call
|
;; list argument in fn call
|
||||||
(paren-wrap (comma-join (map to-sql x)))
|
(paren-wrap (comma-join (map to-sql x)))
|
||||||
;; alias
|
;; alias
|
||||||
|
|
@ -280,14 +283,16 @@
|
||||||
(quote-identifier (second x))
|
(quote-identifier (second x))
|
||||||
(to-sql (second x))))))
|
(to-sql (second x))))))
|
||||||
SqlCall
|
SqlCall
|
||||||
(-to-sql [x] (binding [*fn-context?* true]
|
(-to-sql [x]
|
||||||
|
(binding [*fn-context?* true]
|
||||||
(let [fn-name (name (.name x))
|
(let [fn-name (name (.name x))
|
||||||
fn-name (fn-aliases fn-name fn-name)]
|
fn-name (fn-aliases fn-name fn-name)]
|
||||||
(apply fn-handler fn-name (.args x)))))
|
(apply fn-handler fn-name (.args x)))))
|
||||||
SqlRaw
|
SqlRaw
|
||||||
(-to-sql [x] (.s x))
|
(-to-sql [x] (.s x))
|
||||||
clojure.lang.IPersistentMap
|
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
|
sql-str (binding [*subquery?* true
|
||||||
*fn-context?* false]
|
*fn-context?* false]
|
||||||
(space-join
|
(space-join
|
||||||
|
|
@ -299,7 +304,8 @@
|
||||||
nil
|
nil
|
||||||
(-to-sql [x] "NULL")
|
(-to-sql [x] "NULL")
|
||||||
Object
|
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)]
|
(let [pname (param-name x)]
|
||||||
(if (map? @*input-params*)
|
(if (map? @*input-params*)
|
||||||
[(get @*input-params* pname) pname]
|
[(get @*input-params* pname) pname]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue