Dehyphen improvements fixes #387
This commit is contained in:
parent
4bf76920ef
commit
803ff41dc0
3 changed files with 15 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Changes
|
||||
|
||||
* 2.2.next in progress
|
||||
* Address [#387](https://github.com/seancorfield/honeysql/issues/387) by making the function simpler.
|
||||
* Fix [#385](https://github.com/seancorfield/honeysql/issues/385) by quoting inlined UUIDs.
|
||||
* Address [#352](https://github.com/seancorfield/honeysql/issues/352) by treating `:'` as introducing a function name that should be formatted as a SQL entity (respects quoting, dot-splitting, etc).
|
||||
|
||||
|
|
|
|||
|
|
@ -155,14 +155,11 @@
|
|||
:cljs str/upper-case))
|
||||
|
||||
(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!"
|
||||
"Replace _embedded_ hyphens with spaces.
|
||||
|
||||
Hyphens at the start or end of a string should not be touched."
|
||||
[s]
|
||||
(loop [s s prev nil]
|
||||
(if (= s prev)
|
||||
s
|
||||
(recur (str/replace s #"(\w)-(\w)" "$1 $2") s))))
|
||||
(str/replace s #"(\w)-(\w)" "$1 $2"))
|
||||
|
||||
(defn- namespace-_
|
||||
"Return the namespace portion of a symbol, with dashes converted."
|
||||
|
|
|
|||
|
|
@ -866,3 +866,13 @@ ORDER BY id = ? DESC
|
|||
(format {:select :foo :from :bar
|
||||
:offset 20}
|
||||
{:dialect :sqlserver})))))
|
||||
|
||||
(deftest sql-kw-test
|
||||
(is (= "FETCH NEXT" (sut/sql-kw :fetch-next)))
|
||||
(is (= "WHAT IS THIS" (sut/sql-kw :what-is-this)))
|
||||
(is (= "FEE FIE FOE FUM" (sut/sql-kw :fee-fie-foe-fum)))
|
||||
(is (= "-WHAT THE-" (sut/sql-kw :-what-the-)))
|
||||
(is (= "fetch_next" (sut/sql-kw :'fetch-next)))
|
||||
(is (= "what_is_this" (sut/sql-kw :'what-is-this)))
|
||||
(is (= "fee_fie_foe_fum" (sut/sql-kw :'fee-fie-foe-fum)))
|
||||
(is (= "_what_the_" (sut/sql-kw :'-what-the-))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue