fix #484 by adding TABLE to TRUNCAT
This commit is contained in:
parent
dffedb115e
commit
2efe05def2
5 changed files with 9 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Changes
|
||||
|
||||
* 2.4.next in progress
|
||||
* Fix [#484](https://github.com/seancorfield/honeysql/issues/484) by adding `TABLE` to `TRUNCATE`.
|
||||
* Fix [#483](https://github.com/seancorfield/honeysql/issues/483) by adding a function-like `:join` syntax to produce nested `JOIN` expressions.
|
||||
* 2.4.1011 -- 2023-03-23
|
||||
* Address [#481](https://github.com/seancorfield/honeysql/issues/481) by adding more examples around `:do-update-set`.
|
||||
|
|
|
|||
|
|
@ -518,11 +518,11 @@ If you want to delete everything from a table, you can use `truncate`:
|
|||
```clojure
|
||||
(-> (truncate :films)
|
||||
(sql/format))
|
||||
=> ["TRUNCATE films"]
|
||||
=> ["TRUNCATE TABLE films"]
|
||||
;; or as pure data DSL:
|
||||
(-> {:truncate :films}
|
||||
(sql/format))
|
||||
=> ["TRUNCATE films"]
|
||||
=> ["TRUNCATE TABLE films"]
|
||||
```
|
||||
|
||||
### Set operations
|
||||
|
|
|
|||
|
|
@ -645,9 +645,9 @@ or a table name followed by various options:
|
|||
|
||||
```clojure
|
||||
user=> (sql/format '{truncate transport})
|
||||
["TRUNCATE transport"]
|
||||
["TRUNCATE TABLE transport"]
|
||||
user=> (sql/format '{truncate (transport restart identity)})
|
||||
["TRUNCATE transport RESTART IDENTITY"]
|
||||
["TRUNCATE TABLE transport RESTART IDENTITY"]
|
||||
```
|
||||
|
||||
## columns
|
||||
|
|
|
|||
|
|
@ -998,12 +998,12 @@
|
|||
(when opts
|
||||
(format-ddl-options opts context)))))
|
||||
|
||||
(defn- format-truncate [k xs]
|
||||
(defn- format-truncate [_ xs]
|
||||
(let [[table & options] (ensure-sequential xs)
|
||||
[pre table ine options] (destructure-ddl-item [table options] "truncate")]
|
||||
(when (seq pre) (throw (ex-info "TRUNCATE syntax error" {:unexpected pre})))
|
||||
(when (seq ine) (throw (ex-info "TRUNCATE syntax error" {:unexpected ine})))
|
||||
[(str/join " " (cond-> [(sql-kw k) table]
|
||||
[(str/join " " (cond-> ["TRUNCATE TABLE" table]
|
||||
(seq options)
|
||||
(conj options)))]))
|
||||
|
||||
|
|
|
|||
|
|
@ -562,10 +562,10 @@
|
|||
(format)))))
|
||||
|
||||
(deftest truncate-test
|
||||
(is (= ["TRUNCATE `foo`"]
|
||||
(is (= ["TRUNCATE TABLE `foo`"]
|
||||
(-> {:truncate :foo}
|
||||
(format {:dialect :mysql}))))
|
||||
(is (= ["TRUNCATE `foo` CONTINUE IDENTITY"]
|
||||
(is (= ["TRUNCATE TABLE `foo` CONTINUE IDENTITY"]
|
||||
(-> {:truncate [:foo :continue :identity]}
|
||||
(format {:dialect :mysql})))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue