   for the query. All fact columns are selected, and no order is applied."
   [ops query]
   {:post [valid-jdbc-query? %]}
-  (let [{:keys [where joins params]} (compile-term ops query)
-        join-stmt (build-join-expr :fact joins)
-        sql (format "SELECT %s FROM certname_facts %s WHERE %s" (string/join ", " (map #(str "certname_facts." %) fact-columns)) join-stmt where)]
+  (let [{:keys [where params]} (compile-term ops query)
+        sql (format "SELECT %s FROM certname_facts WHERE %s" (string/join ", " (map #(str "certname_facts." %) fact-columns)) where)]
     (apply vector sql params)))
 
 (defn node-query->sql

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

(def compile-and

;;     {:where "certname_catalogs.certname = ?"
;;      :params ["foo.example.com"]}
;;
;; The `where` key is then inserted into a template query to return
;; the final result as a string of SQL code.
;;
;; The compiled query components can be combined by operators such as `AND` or
