 ;; the "compiled" form of the query, and then to turn that into a complete SQL
 ;; query.
 ;;
-;; The compiled form of a query consists of a map with three keys: `where`,
-;; `joins`, and `params`. The `where` key contains SQL for querying that
+;; The compiled form of a query consists of a map with two keys: `where`
+;; and `params`. The `where` key contains SQL for querying that
 ;; particular predicate, written in such a way as to be suitable for placement
 ;; after a `WHERE` clause in the database. `params` contains, naturally, the
 ;; parameters associated with that SQL expression. For instance, a resource

          :params [value]}

         [["node" "active"]]
         {:joins [:certnames]
          :where (format "certnames.deactivated IS %s" (if value "NULL" "NOT NULL"))}

         :else
         (throw (IllegalArgumentException. (str path " is not a queryable object for facts")))))


  (when (empty? terms)
    (throw (IllegalArgumentException. (str op " requires at least one term"))))
  (let [compiled-terms (map #(compile-term ops %) terms)
        params (mapcat :params compiled-terms)
        query  (->> (map :where compiled-terms)
                    (map #(format "(%s)" %))
                    (string/join (format " %s " (string/upper-case op))))]
    {:where  query
     :params params}))

(def compile-and
