Generated HugSQL queries now (all?) working.
This commit is contained in:
parent
e67142db47
commit
8ee91b5372
|
@ -392,13 +392,10 @@
|
|||
|
||||
(defn queries
|
||||
"Generate all standard queries for this `entity` in this `application`; if
|
||||
no entity is specified, generate all queris for the application."
|
||||
no entity is specified, generate all queries for the application."
|
||||
([application entity]
|
||||
(merge
|
||||
(if
|
||||
(link-table? entity)
|
||||
(link-table-queries entity application)
|
||||
{})
|
||||
;; TODO: queries that look through link tables
|
||||
(insert-query entity)
|
||||
(update-query entity)
|
||||
(delete-query entity)
|
||||
|
|
|
@ -47,12 +47,12 @@
|
|||
(f/unparse (f/formatters :basic-date-time) (t/now)))
|
||||
(list
|
||||
:require
|
||||
'[clojure.java.io :as io]
|
||||
'[compojure.core :refer [defroutes GET POST]]
|
||||
'[hugsql.core :as hugsql]
|
||||
'[noir.response :as nresponse]
|
||||
'[noir.util.route :as route]
|
||||
'[compojure.core :refer [defroutes GET POST]]
|
||||
'[ring.util.http-response :as response]
|
||||
'[clojure.java.io :as io]
|
||||
'[hugsql.core :as hugsql]
|
||||
(vector (symbol (str (safe-name (:name (:attrs application))) ".db.core")) :as 'db))))
|
||||
|
||||
|
||||
|
|
|
@ -44,12 +44,12 @@
|
|||
(f/unparse (f/formatters :basic-date-time) (t/now)))
|
||||
(list
|
||||
:require
|
||||
'[clojure.java.io :as io]
|
||||
'[compojure.core :refer [defroutes GET POST]]
|
||||
'[hugsql.core :as hugsql]
|
||||
'[noir.response :as nresponse]
|
||||
'[noir.util.route :as route]
|
||||
'[compojure.core :refer [defroutes GET POST]]
|
||||
'[ring.util.http-response :as response]
|
||||
'[clojure.java.io :as io]
|
||||
'[hugsql.core :as hugsql]
|
||||
(vector (symbol (str (:name (:attrs application)) ".layout")) :as 'l)
|
||||
(vector (symbol (str (:name (:attrs application)) ".db.core")) :as 'db)
|
||||
(vector (symbol (str (:name (:attrs application)) ".routes.manual")) :as 'm))))
|
||||
|
|
|
@ -480,7 +480,7 @@
|
|||
(list-page-control true)]})
|
||||
|
||||
|
||||
(defn- list-to-template
|
||||
(defn list-to-template
|
||||
"Generate a template as specified by this `list` element for this `entity`,
|
||||
taken from this `application`. If `list` is nill, generate a default list
|
||||
template for the entity."
|
||||
|
@ -502,9 +502,9 @@
|
|||
`entity` in this `application`"
|
||||
[entity application]
|
||||
(let
|
||||
[forms (children entity #(= (:tag %) :form))
|
||||
pages (children entity #(= (:tag %) :page))
|
||||
lists (children entity #(= (:tag %) :list))]
|
||||
[forms (children-with-tag entity :form)
|
||||
pages (children-with-tag entity :page)
|
||||
lists (children-with-tag entity :list)]
|
||||
(if
|
||||
(and
|
||||
(= (:tag entity) :entity) ;; it seems to be an ADL entity
|
||||
|
|
|
@ -281,14 +281,6 @@
|
|||
(safe-name string))))))
|
||||
|
||||
|
||||
(defn link-table?
|
||||
"Return true if this `entity` represents a link table."
|
||||
[entity]
|
||||
(let [properties (children entity #(= (:tag %) :property))
|
||||
links (filter #(-> % :attrs :entity) properties)]
|
||||
(= (count properties) (count links))))
|
||||
|
||||
|
||||
(defn read-adl [url]
|
||||
(let [adl (x/parse url)
|
||||
valid? (valid-adl? adl)]
|
||||
|
@ -371,6 +363,14 @@
|
|||
`(filter insertable? (key-properties entity)))
|
||||
|
||||
|
||||
(defn link-table?
|
||||
"Return true if this `entity` represents a link table."
|
||||
[entity]
|
||||
(let [properties (all-properties entity)
|
||||
links (filter #(-> % :attrs :entity) properties)]
|
||||
(= (count properties) (count links))))
|
||||
|
||||
|
||||
(defn key-names [entity]
|
||||
(remove
|
||||
nil?
|
||||
|
|
Loading…
Reference in a new issue