From fae5545e8a739e0564250b36464962f9d63933eb Mon Sep 17 00:00:00 2001 From: Mike Blume Date: Sun, 14 Jun 2015 13:16:02 -0700 Subject: [PATCH] move format-predicate down --- src/honeysql/format.clj | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/honeysql/format.clj b/src/honeysql/format.clj index 07bfafa..590bfc7 100644 --- a/src/honeysql/format.clj +++ b/src/honeysql/format.clj @@ -84,8 +84,6 @@ "not-like" "not like" "regex" "regexp"}) -(declare format-predicate*) - (defprotocol ToSql (to-sql [x])) @@ -238,19 +236,6 @@ (into [sql-str] @*params*)) [sql-str]))))) -(defn format-predicate - "Formats a predicate (e.g., for WHERE, JOIN, or HAVING) as a string." - [pred & {:keys [quoting]}] - (binding [*params* (atom []) - *param-counter* (atom 0) - *param-names* (atom []) - *quote-identifier-fn* (or (quote-fns quoting) - *quote-identifier-fn*)] - (let [sql-str (format-predicate* pred)] - (if (seq @*params*) - (into [sql-str] @*params*) - [sql-str])))) - (defprotocol Parameterizable (to-params [value pname])) @@ -382,6 +367,19 @@ (to-sql (apply call pred)))))) +(defn format-predicate + "Formats a predicate (e.g., for WHERE, JOIN, or HAVING) as a string." + [pred & {:keys [quoting]}] + (binding [*params* (atom []) + *param-counter* (atom 0) + *param-names* (atom []) + *quote-identifier-fn* (or (quote-fns quoting) + *quote-identifier-fn*)] + (let [sql-str (format-predicate* pred)] + (if (seq @*params*) + (into [sql-str] @*params*) + [sql-str])))) + (defmulti format-clause "Takes a map entry representing a clause and returns an SQL string" (fn [clause _] (key clause)))