diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index ffc0ecd..afc8389 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -1513,9 +1513,9 @@ (let [[sql & params] (format-expr x {:nested true})] (into [(str "NOT " sql)] params))) :order-by - (fn [k [e q]] + (fn [k [e & qs]] (let [[sql-e & params-e] (format-expr e) - [sql-q & params-q] (format-dsl {k [q]})] + [sql-q & params-q] (format-dsl {k qs})] (-> [(str sql-e " " sql-q)] (into params-e) (into params-q)))) diff --git a/test/honey/sql/postgres_test.cljc b/test/honey/sql/postgres_test.cljc index 120a13e..03af583 100644 --- a/test/honey/sql/postgres_test.cljc +++ b/test/honey/sql/postgres_test.cljc @@ -388,6 +388,18 @@ (modifiers :distinct-on :a :b) (sql/format :quoting :ansi)))))) +(deftest select-agg-order-by-test + (testing "single expression in order by" + (is (= ["SELECT ARRAY_AGG(a ORDER BY x) FROM products"]) + (sql/format + {:select [[[:array_agg [:order-by :a :x]]]] + :from :products}))) + (testing "multiple expressions in order by" + (is (= ["SELECT ARRAY_AGG(a ORDER BY x ASC, y DESC, z ASC) FROM products"] + (sql/format + {:select [[[:array_agg [:order-by :a [:x :asc] [:y :desc] :z]]]] + :from :products}))))) + (deftest create-extension-test ;; previously, honeysql required :allow-dashed-names? true (testing "create extension"