From df77e861a3399a241e71a02d84c03fd51972c5ad Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Fri, 17 Aug 2012 10:28:39 -0400 Subject: [PATCH] "match" fn-handler --- src/honeysql/format.clj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/honeysql/format.clj b/src/honeysql/format.clj index 64e6852..c9f2e69 100644 --- a/src/honeysql/format.clj +++ b/src/honeysql/format.clj @@ -95,6 +95,22 @@ (defmethod fn-handler "between" [_ field lower upper] (str (to-sql field) " BETWEEN " (to-sql lower) " AND " (to-sql upper))) +;; Handles MySql's MATCH (field) AGAINST (pattern). The third argument +;; can be a set containing one or more of :boolean, :natural, or :expand. +(defmethod fn-handler "match" [_ fields pattern & [opts]] + (str "MATCH (" + (comma-join + (map to-sql (if (coll? fields) fields [fields]))) + ") AGAINST (" + (to-sql pattern) + (when (seq opts) + (str " " (space-join (for [opt opts] + (condp = opt + :boolean "IN BOOLEAN MODE" + :natural "IN NATURAL LANGUAGE MODE" + :expand "WITH QUERY EXPANSION"))))) + ")")) + (def clause-order "Determines the order that clauses will be placed within generated SQL" [:select :from :join :where :group-by :having :order-by :limit :offset])