fixes #340
This commit is contained in:
parent
3288ee7ec5
commit
10e6e755e9
2 changed files with 11 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Changes
|
||||
|
||||
* 2.0.next in progress
|
||||
* Fixes #340 by making hyphen to space logic more general so _operators_ containing `-` should retain the hyphen without special cases.
|
||||
* Documentation improvements: `:fetch`, `:lift`, `:limit`, `:offset`, `:param`, `:select`; also around JSON/PostgreSQL.
|
||||
|
||||
* 2.0.0-rc5 (for testing; 2021-07-17)
|
||||
|
|
|
|||
|
|
@ -146,9 +146,15 @@
|
|||
#?(:clj (fn [^String s] (.. s toString (toUpperCase (java.util.Locale/US))))
|
||||
:cljs str/upper-case))
|
||||
|
||||
(def ^:private keep-hyphen
|
||||
"The set of symbols that should not have `-` replaced by space."
|
||||
#{"-" "<->"})
|
||||
(defn- dehyphen
|
||||
"The loop/recur is because we might need to account for x-y-z in
|
||||
a string where the second - won't get replaced because the regex
|
||||
already matched y. I'm sure there's a more efficent solution!"
|
||||
[s]
|
||||
(loop [s s prev nil]
|
||||
(if (= s prev)
|
||||
s
|
||||
(recur (str/replace s #"(\w)-(\w)" "$1 $2") s))))
|
||||
|
||||
(defn sql-kw
|
||||
"Given a keyword, return a SQL representation of it as a string.
|
||||
|
|
@ -158,8 +164,7 @@
|
|||
|
||||
Any namespace qualifier is ignored."
|
||||
[k]
|
||||
(-> k (name) (upper-case)
|
||||
(as-> s (if (keep-hyphen s) s (str/replace s "-" " ")))))
|
||||
(-> k (name) (dehyphen) (upper-case)))
|
||||
|
||||
(defn- sym->kw
|
||||
"Given a symbol, produce a keyword, retaining the namespace
|
||||
|
|
|
|||
Loading…
Reference in a new issue