Updated to support "insert into ... select ..."

This commit is contained in:
Gareth 2015-03-30 16:39:29 -04:00
parent 626d0a6bb9
commit 87b3837346
2 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,4 @@
(defproject views "1.2.0"
(defproject views "1.2.1"
:description "A view to the past helps navigate the future."
:url "https://github.com/diligenceengine/views"

View file

@ -8,6 +8,14 @@
(declare query-tables)
(defn- first-leaf
"Retrieves the first leaf in a collection of collections
(first-leaf :table) -> :table
(first-leaf [[:table] [& values]]) -> :table"
[v]
(if (coll? v) (recur (first v)) v))
(defn cte-tables
[query]
(mapcat #(query-tables (second %)) (:with query)))
@ -45,7 +53,7 @@
(defn insert-tables
[query]
(if-let [v (:insert-into query)] [v] []))
(some->> query :insert-into first-leaf vector))
(defn update-tables
[query]