Add support for MySQL REPLACE INTO
This commit is contained in:
parent
cd5824a126
commit
1373867f5c
2 changed files with 17 additions and 0 deletions
|
|
@ -216,6 +216,7 @@
|
|||
:union-all 45
|
||||
:select 50
|
||||
:insert-into 60
|
||||
:replace-into 60
|
||||
:update 70
|
||||
:delete 75
|
||||
:delete-from 80
|
||||
|
|
@ -594,6 +595,15 @@
|
|||
(to-sql (second table))))
|
||||
(str "INSERT INTO " (to-sql table))))
|
||||
|
||||
(defmethod format-clause :replace-into [[_ table] _]
|
||||
(if (and (sequential? table) (sequential? (first table)))
|
||||
(str "REPLACE INTO "
|
||||
(to-sql (ffirst table))
|
||||
" (" (comma-join (map to-sql (second (first table)))) ") "
|
||||
(binding [*subquery?* false]
|
||||
(to-sql (second table))))
|
||||
(str "REPLACE INTO " (to-sql table))))
|
||||
|
||||
(defmethod format-clause :columns [[_ fields] _]
|
||||
(str "(" (comma-join (map to-sql fields)) ")"))
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,13 @@
|
|||
([table] (insert-into nil table))
|
||||
([m table] (build-clause :insert-into m table)))
|
||||
|
||||
(defmethod build-clause :replace-into [_ m table]
|
||||
(assoc m :replace-into table))
|
||||
|
||||
(defn replace-into
|
||||
([table] (replace-into nil table))
|
||||
([m table] (build-clause :replace-into m table)))
|
||||
|
||||
(macros/usetime
|
||||
(defhelper columns [m fields]
|
||||
(assoc m :columns (collify fields))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue