Skip to content

Commit

Permalink
fixes #542 by documenting new clauses
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Corfield <sean@corfield.org>
  • Loading branch information
seancorfield committed Oct 13, 2024
1 parent 170602e commit 35545fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changes

* 2.6.next in progress
* Fix [#548](https://github.com/seancorfield/honeysql/issues/548) which was a regression introduced in [#526](https://github.com/seancorfield/honeysql/issues/526).
* Address [#542](https://github.com/seancorfield/honeysql/issues/542) by adding support for `WITH` query tail options for PostgreSQL. Docs TBD.
* Fix [#548](https://github.com/seancorfield/honeysql/issues/548) which was a regression introduced in [#526](https://github.com/seancorfield/honeysql/issues/526) (in 2.6.1161).
* Address [#542](https://github.com/seancorfield/honeysql/issues/542) by adding support for `WITH` query tail options for PostgreSQL.
* Replace all optional argument destructuring with multiple arities to improve performance.

* 2.6.1196 -- 2024-10-06
Expand Down
21 changes: 21 additions & 0 deletions doc/clause-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,27 @@ user=> (sql/format {:with [[:stuff {:select :*
["WITH stuff AS NOT MATERIALIZED (SELECT * FROM table) SELECT * FROM stuff"]
```

As of 2.6.next, you can specify `SEARCH` and/or `CYCLE` clauses, in place of
or following the `MATERIALIZED` marker:

```clojure
user=> (sql/format {:with-recursive [[:stuff {:select :*
:from :table}
:search-depth-first-by :col :set :search-col]]
:select :*
:from :stuff})
["WITH RECURSIVE stuff AS (SELECT * FROM table) SEARCH DEPTH FIRST BY col SET search_col SELECT * FROM stuff"]
```

```clojure
user=> (sql/format {:with-recursive [[:stuff {:select :*
:from :table}
:cycle [:a :b :c] :set :d :to [:abs :e] :default 42 :using :x]]
:select :*
:from :stuff})
["WITH RECURSIVE stuff AS (SELECT * FROM table) CYCLE a, b, c SET d TO ABS(e) DEFAULT ? USING x SELECT * FROM stuff" 42]
```

`:with-recursive` follows the same rules as `:with` and produces `WITH RECURSIVE` instead of just `WITH`.

## intersect, union, union-all, except, except-all
Expand Down

0 comments on commit 35545fa

Please sign in to comment.