address #352 by treating :'foo literally
This commit is contained in:
parent
1d22086fce
commit
1f2773bd16
2 changed files with 18 additions and 4 deletions
|
|
@ -167,12 +167,17 @@
|
|||
(defn sql-kw
|
||||
"Given a keyword, return a SQL representation of it as a string.
|
||||
|
||||
A `:kebab-case` keyword becomes a `KEBAB CASE` (uppercase) string
|
||||
with hyphens replaced by spaces, e.g., `:insert-into` => `INSERT INTO`.
|
||||
A keyword whose name begins with a single quote is left exactly as-is
|
||||
(with the `:` and `'` removed), otherwise a `:kebab-case` keyword
|
||||
becomes a `KEBAB CASE` (uppercase) string with hyphens replaced
|
||||
by spaces, e.g., `:insert-into` => `INSERT INTO`.
|
||||
|
||||
Any namespace qualifier is ignored."
|
||||
[k]
|
||||
(-> k (name) (dehyphen) (upper-case)))
|
||||
(let [n (name k)]
|
||||
(if (= \' (first n))
|
||||
(subs n 1 (count n))
|
||||
(-> n (dehyphen) (upper-case)))))
|
||||
|
||||
(defn- sym->kw
|
||||
"Given a symbol, produce a keyword, retaining the namespace
|
||||
|
|
|
|||
|
|
@ -794,7 +794,16 @@ ORDER BY id = ? DESC
|
|||
(format {:select (keyword "%mixed-kebab.yum-yum/bar-bar.a-b/c-d")} :dialect :mysql :quoted-snake true)))
|
||||
(is (= ["SELECT RANSOM(`NoTe`)"]
|
||||
(format {:select [[[:ransom :NoTe]]]} :dialect :mysql)
|
||||
(format {:select :%ransom.NoTe} :dialect :mysql)))))
|
||||
(format {:select :%ransom.NoTe} :dialect :mysql))))
|
||||
(testing "issue 352: literal function calls"
|
||||
(is (= ["SELECT sysdate()"]
|
||||
(format {:select [[[:'sysdate]]]})))
|
||||
(is (= ["SELECT count(*)"]
|
||||
(format {:select [[[:'count :*]]]})))
|
||||
(is (= ["SELECT Mixed-Kebab(`yum-yum`)"]
|
||||
(format {:select [[[:'Mixed-Kebab :yum-yum]]]} :dialect :mysql)))
|
||||
(is (= ["SELECT other-project.other_dataset.other_function(?, ?)" 1 2]
|
||||
(format {:select [[[:'other-project.other_dataset.other_function 1 2]]]})))))
|
||||
|
||||
(deftest join-without-on-using
|
||||
;; essentially issue 326
|
||||
|
|
|
|||
Loading…
Reference in a new issue