fixes #542 by documenting new clauses

Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2024-10-13 12:16:59 -07:00
parent 170602e85f
commit 35545facce
No known key found for this signature in database
2 changed files with 23 additions and 2 deletions

View file

@ -1,8 +1,8 @@
# Changes # Changes
* 2.6.next in progress * 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). * 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. Docs TBD. * 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. * Replace all optional argument destructuring with multiple arities to improve performance.
* 2.6.1196 -- 2024-10-06 * 2.6.1196 -- 2024-10-06

View file

@ -486,6 +486,27 @@ user=> (sql/format {:with [[:stuff {:select :*
["WITH stuff AS NOT MATERIALIZED (SELECT * FROM table) SELECT * FROM stuff"] ["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`. `:with-recursive` follows the same rules as `:with` and produces `WITH RECURSIVE` instead of just `WITH`.
## intersect, union, union-all, except, except-all ## intersect, union, union-all, except, except-all