Allow for multiple distinct links between the same two entities
This commit is contained in:
parent
a855554ed8
commit
9db4e48638
|
@ -86,15 +86,30 @@
|
||||||
|
|
||||||
|
|
||||||
(defn link-table-name
|
(defn link-table-name
|
||||||
"Canonical name of a link table between entity `e1` and entity `e2`."
|
"Canonical name of a link table between entity `e1` and entity `e2`. However, there
|
||||||
[e1 e2]
|
may be different links between the same two tables with different semantics; if
|
||||||
(s/join
|
`property` is specified, and if more than one property in `e1` links to `e2`, generate
|
||||||
"_"
|
a more specific link name."
|
||||||
(cons
|
([e1 e2]
|
||||||
"ln"
|
(s/join
|
||||||
(sort
|
"_"
|
||||||
(list
|
(cons
|
||||||
(:name (:attrs e1)) (:name (:attrs e2)))))))
|
"ln"
|
||||||
|
(sort
|
||||||
|
(list
|
||||||
|
(:name (:attrs e1)) (:name (:attrs e2)))))))
|
||||||
|
([property e1 e2]
|
||||||
|
(if (count
|
||||||
|
(descendants
|
||||||
|
e1
|
||||||
|
#(and
|
||||||
|
(= (-> % :attrs :type) "link")
|
||||||
|
(=
|
||||||
|
(-> % :attrs :entity)
|
||||||
|
(-> property :attrs :entity)))))
|
||||||
|
(s/join
|
||||||
|
"_" (map #(:name (:attrs %)) (list property e1 e2)))
|
||||||
|
(link-table-name e1 e2))))
|
||||||
|
|
||||||
|
|
||||||
(defn children
|
(defn children
|
||||||
|
|
Loading…
Reference in a new issue