diff --git a/src/honeysql/format.clj b/src/honeysql/format.clj index 0f7d779..18959e4 100644 --- a/src/honeysql/format.clj +++ b/src/honeysql/format.clj @@ -412,15 +412,16 @@ (str "ORDER BY " (comma-join (for [field fields] (if (sequential? field) - (let [[field order & [nulls-order]] field] - ;; Correct way of handling this would be to - ;; expect a dictionary with either order, - ;; nulls order or both at the same - ;; time. However, so far I'm not sure how to - ;; achieve that, so first iteration will have - ;; to use dirty hacks. - (str (to-sql field) " " (if (= :desc order) - "DESC" "ASC"))) + (let [[field & modifiers] field] + (string/join " " + (cons (to-sql field) + (for [modifier modifiers] + (case modifier + :desc "DESC" + :asc "ASC" + :nulls-first "NULLS FIRST" + :nulls-last "NULLS LAST" + ""))))) (to-sql field)))))) (defmethod format-clause :limit [[_ limit] _]