Add a table alias function to Source, allowing us to mock alias generation.
This commit is contained in:
parent
5e1648b05f
commit
a5556637e8
1 changed files with 8 additions and 1 deletions
|
@ -36,20 +36,27 @@
|
||||||
attribute-transform
|
attribute-transform
|
||||||
constant-transform
|
constant-transform
|
||||||
|
|
||||||
|
;; `table-alias` is a function from table to alias, e.g., :datoms => :datoms1234.
|
||||||
|
table-alias
|
||||||
|
|
||||||
;; Not currently used.
|
;; Not currently used.
|
||||||
make-constraints ; ?fn [source alias] => [where-clauses]
|
make-constraints ; ?fn [source alias] => [where-clauses]
|
||||||
])
|
])
|
||||||
|
|
||||||
|
(defn gensym-table-alias [table]
|
||||||
|
(gensym (name table)))
|
||||||
|
|
||||||
(defn datoms-source [db]
|
(defn datoms-source [db]
|
||||||
(->Source :datoms
|
(->Source :datoms
|
||||||
[:e :a :v :tx :added]
|
[:e :a :v :tx :added]
|
||||||
transforms/attribute-transform-string
|
transforms/attribute-transform-string
|
||||||
transforms/constant-transform-default
|
transforms/constant-transform-default
|
||||||
|
gensym-table-alias
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
(defn source->from [source]
|
(defn source->from [source]
|
||||||
(let [table (:table source)]
|
(let [table (:table source)]
|
||||||
[table (gensym (name table))]))
|
[table ((:table-alias source) table)]))
|
||||||
|
|
||||||
(defn source->constraints [source alias]
|
(defn source->constraints [source alias]
|
||||||
(when-let [f (:make-constraints source)]
|
(when-let [f (:make-constraints source)]
|
||||||
|
|
Loading…
Reference in a new issue