From a5556637e8d3fee5e9f4e68b422c7ca275510af5 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Tue, 26 Jul 2016 10:50:40 -0700 Subject: [PATCH] Add a table alias function to Source, allowing us to mock alias generation. --- src/datomish/query/source.cljc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/datomish/query/source.cljc b/src/datomish/query/source.cljc index a443c66e..d5df8535 100644 --- a/src/datomish/query/source.cljc +++ b/src/datomish/query/source.cljc @@ -36,20 +36,27 @@ attribute-transform constant-transform + ;; `table-alias` is a function from table to alias, e.g., :datoms => :datoms1234. + table-alias + ;; Not currently used. make-constraints ; ?fn [source alias] => [where-clauses] ]) +(defn gensym-table-alias [table] + (gensym (name table))) + (defn datoms-source [db] (->Source :datoms [:e :a :v :tx :added] transforms/attribute-transform-string transforms/constant-transform-default + gensym-table-alias nil)) (defn source->from [source] (let [table (:table source)] - [table (gensym (name table))])) + [table ((:table-alias source) table)])) (defn source->constraints [source alias] (when-let [f (:make-constraints source)]