diff --git a/src/honeysql/core.clj b/src/honeysql/core.clj index 327c37d..afa0fd0 100644 --- a/src/honeysql/core.clj +++ b/src/honeysql/core.clj @@ -11,6 +11,7 @@ (defalias param types/param) (defalias format format/format) (defalias format-predicate format/format-predicate) +(defalias quote-identifier format/quote-identifier) (defn qualify "Takes one or more keyword or string qualifers and name. Returns diff --git a/src/honeysql/format.clj b/src/honeysql/format.clj index f721b15..8a9ea9d 100644 --- a/src/honeysql/format.clj +++ b/src/honeysql/format.clj @@ -36,11 +36,16 @@ (def ^:dynamic *quote-identifier-fn* nil) -(defn quote-identifier [x] - (if-not *quote-identifier-fn* - x - (let [parts (string/split (name x) #"\.")] - (string/join "." (map #(*quote-identifier-fn* %) parts))))) +(defn quote-identifier [x & {:keys [style split] :or {split true}}] + (let [qf (if style + (quote-fns style) + *quote-identifier-fn*)] + (if-not qf + x + (if-not split + (qf (name x)) + (let [parts (string/split (name x) #"\.")] + (string/join "." (map qf parts))))))) (def infix-fns #{"+" "-" "*" "/" "%" "mod" "|" "&" "^"