Allow for multiple distinct links between the same two entities.
This commit is contained in:
parent
66d4b2af4d
commit
7d62976880
|
@ -306,7 +306,7 @@
|
|||
"\n\tAND " entity-name "." link-field " = :id")
|
||||
(order-by-clause entity "lv_"))
|
||||
"link" (let [link-table-name
|
||||
(link-table-name entity far-entity)]
|
||||
(link-table-name % entity far-entity)]
|
||||
(list
|
||||
(str "-- :name " query-name " " signature)
|
||||
(str "-- :doc links all existing " pretty-name " records related to a given " pretty-far)
|
||||
|
|
|
@ -37,6 +37,12 @@
|
|||
;;; to-hugsql-queries, because essentially we need one JSON entry point to wrap
|
||||
;;; each query.
|
||||
|
||||
;;; TODO: memoisation of handlers probably doesn't make sense, because every request
|
||||
;;; will be different. I don't think we can memoise HugSQL, at least not without
|
||||
;;; hacking the library (might be worth doing that and contributing a patch).
|
||||
;;; So the solution may be to an intervening namespace 'cache', which has one
|
||||
;;; memoised function for each hugsql query.
|
||||
|
||||
(defn file-header [application]
|
||||
(list
|
||||
'ns
|
||||
|
@ -65,21 +71,25 @@
|
|||
(defn generate-handler-body
|
||||
"Generate and return the function body for the handler for this `query`."
|
||||
[query]
|
||||
(list
|
||||
[{:keys ['params 'form-params]}]
|
||||
(list 'let
|
||||
(vector
|
||||
'result
|
||||
(list
|
||||
(let [action (list
|
||||
(symbol (str "db/" (:name query)))
|
||||
'db/*db*
|
||||
(list 'support/massage-params
|
||||
'params 'form-params (key-names (:entity query)))))
|
||||
'params
|
||||
'form-params
|
||||
(key-names (:entity query))))]
|
||||
(list
|
||||
[{:keys ['params 'form-params]}]
|
||||
(case
|
||||
(:type query)
|
||||
(:delete-1 :update-1)
|
||||
'(response/found "/")
|
||||
(list 'response/ok 'result)))))
|
||||
(list
|
||||
action
|
||||
'(response/found "/"))
|
||||
(list
|
||||
'let
|
||||
(vector 'result action)
|
||||
(list 'response/ok 'result))))))
|
||||
|
||||
|
||||
(defn generate-handler-src
|
||||
|
|
|
@ -461,7 +461,7 @@
|
|||
#(and
|
||||
(entity? %)
|
||||
(= (:name (:attrs %)) (:entity (:attrs property)))))
|
||||
link-table-name (link-table-name e1 e2)]
|
||||
link-table-name (link-table-name property e1 e2)]
|
||||
(if
|
||||
;; we haven't already emitted this one...
|
||||
(not (@emitted-link-tables link-table-name))
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
([field-or-property form entity application]
|
||||
(prompt field-or-property))
|
||||
([field-or-property]
|
||||
(capitalise
|
||||
(or
|
||||
(first
|
||||
(children
|
||||
|
@ -154,7 +155,7 @@
|
|||
(= (:tag %) :prompt)
|
||||
(= (:locale :attrs %) *locale*))))
|
||||
(:name (:attrs field-or-property))
|
||||
(:property (:attrs field-or-property)))))
|
||||
(:property (:attrs field-or-property))))))
|
||||
|
||||
|
||||
(defn csrf-widget
|
||||
|
|
Loading…
Reference in a new issue