Add (currently unused) ability to generate CTEs.

This commit is contained in:
Richard Newman 2016-08-27 15:37:39 -07:00
parent f225dbe734
commit a9b26f154a
2 changed files with 4 additions and 0 deletions

View file

@ -65,6 +65,7 @@
known-types ; {?var1 :db.type/integer} known-types ; {?var1 :db.type/integer}
extracted-types ; {?var2 :datoms123.value_type_tag} extracted-types ; {?var2 :datoms123.value_type_tag}
wheres ; [[:= :datoms123.v 15]] wheres ; [[:= :datoms123.v 15]]
ctes ; {:name {:select …}}
]) ])
(defn bind-column-to-var [cc variable table position] (defn bind-column-to-var [cc variable table position]

View file

@ -255,6 +255,7 @@
:extracted-types {} :extracted-types {}
:external-bindings (or external-bindings {}) :external-bindings (or external-bindings {})
:bindings {} :bindings {}
:ctes {}
:wheres []}) :wheres []})
patterns))) patterns)))
@ -265,6 +266,8 @@
[cc] [cc]
(merge (merge
{:from (:from cc)} {:from (:from cc)}
(when-not (empty? (:ctes cc))
{:with (:ctes cc)})
(when-not (empty? (:wheres cc)) (when-not (empty? (:wheres cc))
{:where (cons :and (:wheres cc))}))) {:where (cons :and (:wheres cc))})))