additional docs for #531

Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2024-06-09 11:22:55 -07:00
parent 1b7ade9317
commit 2f55f423b9
No known key found for this signature in database
2 changed files with 12 additions and 1 deletions

View file

@ -1,8 +1,8 @@
# Changes
* 2.6.next in progress
* Address [#531](https://github.com/seancorfield/honeysql/issues/531) and [#527](https://github.com/seancorfield/honeysql/issues/527) by adding tests and more documentation for `:composite`.
* Address [#529](https://github.com/seancorfield/honeysql/issues/529) by fixing `:join` special syntax to support aliases and to handle expressions the same way `select` / `from` etc handle them (extra `[...]` nesting).
* Address [#527](https://github.com/seancorfield/honeysql/issues/527) by adding tests and more documentation for `:composite`.
* Add example of mixed `DO UPDATE SET` with `EXCLUDED` and regular SQL expressions.
* Improve exception message when un-`lift`-ed JSON expressions are used in the DSL.
* Update Clojure versions (to 1.11.3 and 1.12.0-alpha12); update other dev/test dependencies.

View file

@ -744,6 +744,17 @@ user=> (sql/format {:update :transport
2]
```
You can also `UPDATE .. FROM (VALUES ..) ..` where you might also need `:composite`:
```clojure
(sql/format {:update :table :set {:a :v.a}
:from [[{:values [[1 2 3]
[4 5 6]]}
[:v [:composite :a :b :c]]]]
:where [:and [:= :x :v.b] [:> :y :v.c]]})
;;=> ["UPDATE table FROM (VALUES (?, ?, ?), (?, ?, ?)) AS v (a, b, c) SET a = v.a WHERE (x = v.b) AND (y > v.c)" 1 2 3 4 5 6]
```
## delete, delete-from
`:delete-from` is the simple use case here, accepting just a