Fix rename table
This commit is contained in:
parent
4b7ded4009
commit
4ce56997c9
3 changed files with 15 additions and 12 deletions
|
|
@ -54,6 +54,7 @@ names: the "from" and the "to" names.
|
||||||
|
|
||||||
## add-index, drop-index
|
## add-index, drop-index
|
||||||
|
|
||||||
|
Used with `:alter-table`,
|
||||||
`:add-index` accepts a single (function) expression
|
`:add-index` accepts a single (function) expression
|
||||||
that describes an index, and `:drop-index` accepts a
|
that describes an index, and `:drop-index` accepts a
|
||||||
single index name:
|
single index name:
|
||||||
|
|
@ -69,6 +70,18 @@ user=> (sql/format {:alter-table :fruit :drop-index :look})
|
||||||
["ALTER TABLE fruit DROP INDEX look"]
|
["ALTER TABLE fruit DROP INDEX look"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## rename-table
|
||||||
|
|
||||||
|
Used with `:alter-table`,
|
||||||
|
`:rename-table` accepts a single table name:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
user=> (sql/format {:alter-table :fruit :rename-table :vegetable})
|
||||||
|
["ALTER TABLE fruit RENAME TO vegetable"]
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note: this would be better as `:rename-to` since there is a `RENAME TABLE old_name TO new_name` SQL statement. _[I may yet add a variant to support that specifically]_
|
||||||
|
|
||||||
## create-table, with-columns
|
## create-table, with-columns
|
||||||
|
|
||||||
`:create-table` can accept a single table name or a pair
|
`:create-table` can accept a single table name or a pair
|
||||||
|
|
@ -129,16 +142,6 @@ user=> (sql/format {:drop-table [:foo :bar]})
|
||||||
["DROP TABLE foo, bar"]
|
["DROP TABLE foo, bar"]
|
||||||
```
|
```
|
||||||
|
|
||||||
## rename-table
|
|
||||||
|
|
||||||
`:rename-table` accepts a pair of the "from" table name
|
|
||||||
and the "to" table names:
|
|
||||||
|
|
||||||
```clojure
|
|
||||||
user=> (sql/format {:rename-table [:fruit :vegetable]})
|
|
||||||
["RENAME TABLE fruit TO vegetable"]
|
|
||||||
```
|
|
||||||
|
|
||||||
## nest
|
## nest
|
||||||
|
|
||||||
This is pseudo-syntax that lets you wrap a substatement
|
This is pseudo-syntax that lets you wrap a substatement
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,7 @@
|
||||||
;; so :add-index works with both [:index] and [:unique]
|
;; so :add-index works with both [:index] and [:unique]
|
||||||
:add-index (fn [_ x] (format-on-expr :add x))
|
:add-index (fn [_ x] (format-on-expr :add x))
|
||||||
:drop-index #'format-selector
|
:drop-index #'format-selector
|
||||||
:rename-table #'format-rename-item
|
:rename-table (fn [_ x] (format-selector :rename-to x))
|
||||||
:create-table #'format-create-table
|
:create-table #'format-create-table
|
||||||
:with-columns #'format-table-columns
|
:with-columns #'format-table-columns
|
||||||
:create-view #'format-create-view
|
:create-view #'format-create-view
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
(defn rename-column [& args] (generic :rename-column args))
|
(defn rename-column [& args] (generic :rename-column args))
|
||||||
(defn add-index [& args] (generic :add-index args))
|
(defn add-index [& args] (generic :add-index args))
|
||||||
(defn drop-index [& args] (generic-1 :drop-index args))
|
(defn drop-index [& args] (generic-1 :drop-index args))
|
||||||
(defn rename-table [& args] (generic :alter-table args))
|
(defn rename-table [& args] (generic-1 :rename-table args))
|
||||||
(defn create-table [& args] (generic :create-table args))
|
(defn create-table [& args] (generic :create-table args))
|
||||||
(defn with-columns [& args]
|
(defn with-columns [& args]
|
||||||
;; special case so (with-columns [[:col-1 :definition] [:col-2 :definition]])
|
;; special case so (with-columns [[:col-1 :definition] [:col-2 :definition]])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue