This commit is contained in:
Sean Corfield 2021-09-25 17:35:02 -07:00
parent 92e0a04a84
commit feb0c9a6f8
2 changed files with 12 additions and 2 deletions

View file

@ -5,6 +5,7 @@
* Fix #363 and #362 by aligning more closely the semantics of `:inline` syntax with the `:inline true` option. A side effect of this is that `[:inline [:param :foo]]` will now (correctly) inline the value of the parameter `:foo` whereas it previously produced `PARAMS SOURCE`. In addition, inlining has been extended to vector values, so `[:inline ["a" "b" "c"]]` will now produce `('a', 'b', 'c')` and `[:inline [:lift ["a" "b" "c"]]]` will now produce `['a', 'b', 'c']` which is what people seemed to expect (the behavior was previously unspecified). * Fix #363 and #362 by aligning more closely the semantics of `:inline` syntax with the `:inline true` option. A side effect of this is that `[:inline [:param :foo]]` will now (correctly) inline the value of the parameter `:foo` whereas it previously produced `PARAMS SOURCE`. In addition, inlining has been extended to vector values, so `[:inline ["a" "b" "c"]]` will now produce `('a', 'b', 'c')` and `[:inline [:lift ["a" "b" "c"]]]` will now produce `['a', 'b', 'c']` which is what people seemed to expect (the behavior was previously unspecified).
* Fix #353 by correcting handling of strings used as SQL entities (such as table names); this was a regression introduced by a recent enhancement to `:create-table`. * Fix #353 by correcting handling of strings used as SQL entities (such as table names); this was a regression introduced by a recent enhancement to `:create-table`.
* Fix #349 by adding an optional `:quoted` argument to `set-dialect!`. * Fix #349 by adding an optional `:quoted` argument to `set-dialect!`.
* Address #347 by adding example of adding a primary key to an existing table via `:add-index`.
* Support `AS` aliasing in `DELETE FROM`. * Support `AS` aliasing in `DELETE FROM`.
* Switch from `readme` to `test-doc-blocks` so all documentation is tested! * Switch from `readme` to `test-doc-blocks` so all documentation is tested!
* Clean up build/update deps. * Clean up build/update deps.

View file

@ -18,7 +18,7 @@ The examples herein assume:
```clojure ```clojure
(refer-clojure :exclude '[partition-by]) (refer-clojure :exclude '[partition-by])
(require '[honey.sql :as sql] (require '[honey.sql :as sql]
'[honey.sql.helpers :refer [select from join-by left-join join '[honey.sql.helpers :as h :refer [select from join-by left-join join
where order-by over partition-by window]]) where order-by over partition-by window]])
``` ```
@ -89,6 +89,15 @@ user=> (sql/format {:alter-table :fruit :drop-index :look})
["ALTER TABLE fruit DROP INDEX look"] ["ALTER TABLE fruit DROP INDEX look"]
``` ```
You can use `:add-index` to add a primary key to an existing table, as follows:
```clojure
user=> (-> (h/alter-table :fruit)
(h/add-index :primary-key :id)
(sql/format))
["ALTER TABLE fruit ADD PRIMARY KEY(id)"]
```
### rename-table ### rename-table
Used with `:alter-table`, Used with `:alter-table`,