Skip to content

Commit 45ceaca

Browse files
authored
Add an example usage of the distinct on clause (#41)
1 parent 8d223a6 commit 45ceaca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This library aims to extend the features of honeysql to support postgres specifi
1212
- [Maven](#maven)
1313
- [REPL](#REPL)
1414
- [Breaking Change](#breaking-change)
15+
- [distinct on](#distinct-on)
1516
- [upsert](#upsert)
1617
- [insert into with alias](#insert-into-with-alias)
1718
- [over](#over)
@@ -50,6 +51,16 @@ Implementation of `over` has been changed (from 0.2.2) to accept alias as an opt
5051

5152
The query creation and usage is exactly the same as honeysql.
5253

54+
### distinct-on
55+
`select` can be written with a `distinct on` clause
56+
``` clj
57+
(-> (select :column-1 :column-2 :column-3)
58+
(from :table-name)
59+
(modifiers :distinct-on :column-1 :column-2)
60+
(sql/format))
61+
=> ["SELECT DISTINCT ON(column_1, column_2) column_1, column_2, column_3 FROM table_name"]
62+
```
63+
5364
### upsert
5465
`upsert` can be written either way. You can make use of `do-update-set!` over `do-update-set`, if you want to modify the some column values in case of conflicts.
5566
```clojure

0 commit comments

Comments
 (0)