Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2024-07-23 22:22:25 -07:00
parent cbb3b3e90b
commit d24ee428f3
No known key found for this signature in database
2 changed files with 24 additions and 5 deletions

View file

@ -1,6 +1,7 @@
# Changes # Changes
* 2.6.next in progress * 2.6.next in progress
* Address [#536](https://github.com/seancorfield/honeysql/issues/536) by noting what will not work with PostgreSQL (but works with other databases).
* Address [#533](https://github.com/seancorfield/honeysql/issues/533) by adding `honey.sql/*escape-?*` which can be bound to `false` to prevent `?` being escaped to `??` when used as an operator or function. * Address [#533](https://github.com/seancorfield/honeysql/issues/533) by adding `honey.sql/*escape-?*` which can be bound to `false` to prevent `?` being escaped to `??` when used as an operator or function.
* Address [#526](https://github.com/seancorfield/honeysql/issues/526) by using `format-var` in DDL, instead of `format-entity`. * Address [#526](https://github.com/seancorfield/honeysql/issues/526) by using `format-var` in DDL, instead of `format-entity`.
* Update JDK test matrix (adopt -> temurin, 19 -> 21). * Update JDK test matrix (adopt -> temurin, 19 -> 21).

View file

@ -456,11 +456,6 @@ user=> (-> (alter-table :fruit)
(drop-column :skin) (drop-column :skin)
sql/format) sql/format)
["ALTER TABLE fruit DROP COLUMN skin"] ["ALTER TABLE fruit DROP COLUMN skin"]
;; alter table alter column:
user=> (-> (alter-table :fruit)
(alter-column :name [:varchar 64] [:not nil])
sql/format)
["ALTER TABLE fruit ALTER COLUMN name VARCHAR(64) NOT NULL"]
;; alter table rename column: ;; alter table rename column:
user=> (-> (alter-table :fruit) user=> (-> (alter-table :fruit)
(rename-column :cost :price) (rename-column :cost :price)
@ -473,6 +468,29 @@ user=> (-> (alter-table :fruit)
["ALTER TABLE fruit RENAME TO vegetable"] ["ALTER TABLE fruit RENAME TO vegetable"]
``` ```
The following does not work for PostgreSQL, but does work for several other databases:
```clojure
;; alter table alter column:
user=> (-> (alter-table :fruit)
(alter-column :name [:varchar 64] [:not nil])
sql/format)
["ALTER TABLE fruit ALTER COLUMN name VARCHAR(64) NOT NULL"]
```
For PostgreSQL, you need separate statements:
```clojure
user=> (-> (alter-table :fruit)
(alter-column :name :type [:varchar 64])
sql/format)
["ALTER TABLE fruit ALTER COLUMN name TYPE VARCHAR(64)"]
user=> (-> (alter-table :fruit)
(alter-column :name :set [:not nil])
sql/format)
["ALTER TABLE fruit ALTER COLUMN name SET NOT NULL"]
```
The following PostgreSQL-specific DDL statements are supported The following PostgreSQL-specific DDL statements are supported
(with the same syntax as the nilenso library but `sql/format` (with the same syntax as the nilenso library but `sql/format`
takes slightly different options): takes slightly different options):