From ba1be5dc2ecf99bfe7feaf22368c46e42f515bb3 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sun, 5 Aug 2018 17:17:57 +0100 Subject: [PATCH] Create and Update now work. --- src/adl_support/forms_support.clj | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/adl_support/forms_support.clj b/src/adl_support/forms_support.clj index a2d1522..550fd3c 100644 --- a/src/adl_support/forms_support.clj +++ b/src/adl_support/forms_support.clj @@ -92,3 +92,14 @@ "Return true if all the keys in `keys` are present in the map `m`." [m keys] `(clojure.set/subset? (set ~keys) (set (keys ~m)))) + + +(defmacro prepare-insertion-params + "Params for insertion into the database must have keys for all fields in the + insert query, even if the value of some of those keys is nil. Massage these + `params` to have a value for each field in these `fields`." + [params fields] + `(merge + (reduce {} (map #(hash-map (keyword %) nil) ~fields)) + ~params)) +