"match" fn-handler

This commit is contained in:
Justin Kramer 2012-08-17 10:28:39 -04:00
parent 70235d5140
commit df77e861a3

View file

@ -95,6 +95,22 @@
(defmethod fn-handler "between" [_ field lower upper] (defmethod fn-handler "between" [_ field lower upper]
(str (to-sql field) " BETWEEN " (to-sql lower) " AND " (to-sql 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 (def clause-order
"Determines the order that clauses will be placed within generated SQL" "Determines the order that clauses will be placed within generated SQL"
[:select :from :join :where :group-by :having :order-by :limit :offset]) [:select :from :join :where :group-by :having :order-by :limit :offset])