diff --git a/CHANGES.md b/CHANGES.md index 8d9f6c2..e974bb7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ ## 0.8.3 In development +* Allow namespaced keywords and symbols for queries. (@jrdoane) + ## 0.8.2 * Don't parenthesize the subclauses of a UNION, UNION ALL, or INTERSECT clause. (@rnewman) diff --git a/src/honeysql/format.cljc b/src/honeysql/format.cljc index 21e6fc5..c0974b3 100644 --- a/src/honeysql/format.cljc +++ b/src/honeysql/format.cljc @@ -65,7 +65,10 @@ (quote-fns style) *quote-identifier-fn*) s (cond - (or (keyword? x) (symbol? x)) (name-transform-fn (name x)) + (or (keyword? x) (symbol? x)) + (name-transform-fn + (str (when-let [n (namespace x)] + (str n "/")) (name x))) (string? x) (if qf x (name-transform-fn x)) :else (str x))] (if-not qf diff --git a/test/honeysql/format_test.cljc b/test/honeysql/format_test.cljc index ccf1efb..3e6faf7 100644 --- a/test/honeysql/format_test.cljc +++ b/test/honeysql/format_test.cljc @@ -32,6 +32,10 @@ (is (= (quote-identifier :foo-bar.moo-bar :style :ansi) "\"foo-bar\".\"moo-bar\"")))) +(deftest test-namespaced-identifier + (is (= (quote-identifier :foo/bar) "foo/bar")) + (is (= (quote-identifier :foo/bar :style :ansi) "\"foo/bar\""))) + (deftest test-cte (is (= (format-clause (first {:with [[:query {:select [:foo] :from [:bar]}]]}) nil)