From f711b934fa038a6fb4f528e1633226eb94aa911e Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Tue, 22 Feb 2022 21:27:10 -0800 Subject: [PATCH] fix #387 properly --- CHANGELOG.md | 3 +++ src/honey/sql.cljc | 2 +- test/honey/sql_test.cljc | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd0098e..94bd669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changes +* 2.2.next in progress + * Fix [#387](https://github.com/seancorfield/honeysql/issues/387) again. + * 2.2.868 -- 2022-02-21 * 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. diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 95d4b7d..7a19296 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -159,7 +159,7 @@ Hyphens at the start or end of a string should not be touched." [s] - (str/replace s #"(\w)-(\w)" "$1 $2")) + (str/replace s #"(\w)-(?=\w)" "$1 ")) (defn- namespace-_ "Return the namespace portion of a symbol, with dashes converted." diff --git a/test/honey/sql_test.cljc b/test/honey/sql_test.cljc index 6170cd6..4fd4859 100644 --- a/test/honey/sql_test.cljc +++ b/test/honey/sql_test.cljc @@ -868,6 +868,13 @@ ORDER BY id = ? DESC {:dialect :sqlserver}))))) (deftest sql-kw-test + (is (= "-" (sut/sql-kw :-))) + (is (= "-X" (sut/sql-kw :-x))) + (is (= "X-" (sut/sql-kw :x-))) + (is (= "-X-" (sut/sql-kw :-x-))) + (is (= "A B" (sut/sql-kw :a-b))) + (is (= "A B C" (sut/sql-kw :a-b-c))) + (is (= "A B C D" (sut/sql-kw :a-b-c-d))) (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)))