     ;; certname_catalogs, and don't want duplicate joins. I wish this were more
     ;; generic.
     :certnames
-    "INNER JOIN certnames ON certname_catalogs.certname = certnames.name"
-
-    :certname_catalogs
-    ""
-    (count "INNER JOIN certname_catalogs USING(catalog)")))
+    "INNER JOIN certnames ON certname_catalogs.certname = certnames.name"))
 
 (defn query->sql
   "Compile a query into an SQL expression."


(defn build-join-expr
  "Builds an inner join expression between catalog_resources and the given
  `table`. The only acceptable tables are `certnames` and `certname_catalogs`,
  each of which *must* have rows corresponding to the `catalog_resources`
  table. Thus this operation is safe."
  [table]
  (condp = table
    ;; We will always also join to certname_catalogs if we're joining to


         ;; node join.
         [["node" "name"]]
         {:where "certname_catalogs.certname = ?"
          :params [value]}

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

         ;; param joins.
