Allow for multiple distinct links between the same two entities
This commit is contained in:
parent
a855554ed8
commit
9db4e48638
|
@ -86,8 +86,11 @@
|
|||
|
||||
|
||||
(defn link-table-name
|
||||
"Canonical name of a link table between entity `e1` and entity `e2`."
|
||||
[e1 e2]
|
||||
"Canonical name of a link table between entity `e1` and entity `e2`. However, there
|
||||
may be different links between the same two tables with different semantics; if
|
||||
`property` is specified, and if more than one property in `e1` links to `e2`, generate
|
||||
a more specific link name."
|
||||
([e1 e2]
|
||||
(s/join
|
||||
"_"
|
||||
(cons
|
||||
|
@ -95,6 +98,18 @@
|
|||
(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
|
||||
|
|
Loading…
Reference in a new issue