File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 1- {:deps {honeysql {:mvn/version " 0.9.4 " :exclusions [org.clojure/clojurescript]}}}
1+ {:deps {honeysql {:mvn/version " 0.9.5 " :exclusions [org.clojure/clojurescript]}}}
Original file line number Diff line number Diff line change 11(ns ^{:doc " Extension of the honeysql format functions specifically for postgreSQL" }
22 honeysql-postgres.format
3- (:require [honeysql.format :as sqlf :refer [fn-handler format-clause]] ; ; multi-methods
3+ (:require [honeysql.format :as sqlf :refer [fn-handler format-clause format-modifiers ]] ; ; multi-methods
44 [honeysql-postgres.util :as util]
55 [clojure.string :as string]))
66
220220 (string/join " EXCEPT ALL " (map sqlf/to-sql maps))))
221221
222222(override-default-clause-priority )
223+
224+ (defmethod format-modifiers :distinct-on [[_ & fields]]
225+ (str " DISTINCT ON(" (sqlf/comma-join (map sqlf/to-sql fields)) " )" ))
Original file line number Diff line number Diff line change 88 create-table rename-table drop-table
99 window create-view over with-columns]]
1010 [honeysql.helpers :as sqlh :refer [insert-into values where select columns
11- from order-by update sset query-values]]
11+ from order-by update sset query-values
12+ modifiers]]
1213 [honeysql.core :as sql]
1314 [clojure.test :as test :refer [deftest is testing]]))
1415
254255 {:except-all
255256 [{:select [:ip ]}
256257 {:select [:ip ] :from [:ip_location ]}]})))))
258+
259+ (deftest select-distinct-on
260+ (testing " select distinct on"
261+ (is (= [" SELECT DISTINCT ON(\" a\" , \" b\" ) \" c\" FROM \" products\" " ]
262+ (-> (select :c )
263+ (from :products )
264+ (modifiers :distinct-on :a :b )
265+ (sql/format :quoting :ansi ))))))
You can’t perform that action at this time.
0 commit comments