   ([conn project-name suite-name]
     (get-suite-by-name conn project-name suite-name identity))
   ([conn project-name suite-name row-fn]
-    (first (j/query conn
-             ["SELECT suite.* FROM suite JOIN project ON project_id = project.id WHERE project.name = ? AND suite.name = ?" project-name suite-name]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn
+      ["SELECT suite.* FROM suite JOIN project ON project_id = project.id WHERE project.name = ? AND suite.name = ?" project-name suite-name]
+      :row-fn row-fn)))
 
 (defn get-suite-by-id
   ([conn project-id suite-id]
     (get-suite-by-id conn project-id suite-id identity))
   ([conn project-id suite-id row-fn]
-    (first (j/query conn
-             ["SELECT suite.* FROM suite JOIN project ON suite.project_id = project.id WHERE suite.id = ? AND project.id = ?" suite-id project-id]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn
+      ["SELECT suite.* FROM suite JOIN project ON suite.project_id = project.id WHERE suite.id = ? AND project.id = ?" suite-id project-id]
+      :row-fn row-fn)))
 
 (defn get-project-by-name
   ([conn project-name]
     (get-project-by-name conn project-name identity))
   ([conn project-name row-fn]
-    (first (j/query conn
-             ["SELECT * FROM project WHERE name = ?" project-name]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn ["SELECT * FROM project WHERE name = ?" project-name] :row-fn row-fn)))
 
 (defn get-project-by-id
   ([conn project-id]
     (get-project-by-id conn project-id identity))
   ([conn project-id row-fn]
-    (first (j/query conn
-             ["SELECT project.* FROM project WHERE id = ?" project-id]
-             :row-fn row-fn
-             :identifiers ident-fn))))
+    (query-single conn ["SELECT project.* FROM project WHERE id = ?" project-id] :row-fn row-fn)))
 
 (defn create-suite-for-project!
   "Creates a new suite with an empty baseline for the given project. Returns the created suite's id."

(defn get-run
  "Returns the data for the given run-id"
  [conn run-id]
  (first
    (j/query conn
      ["SELECT run.*, project.id project_id FROM run
       JOIN suite ON run.suite_id = suite.id JOIN project ON suite.project_id = project.id
       WHERE project.id = suite.project_id AND suite.id = run.suite_id AND run.id = ?" run-id]
      :row-fn format-dates
      :identifiers ident-fn)))

(def ^:private get-suite-runs-sql
  "SELECT run.* FROM run JOIN suite ON suite.id = run.suite_id

  [{h2-id h2-generated-key id :id}]
  (or h2-id id))

(defn- insert-single! [conn table row-map & opts]
  (extract-generated-id (first (apply j/insert! conn table row-map :entities ent-fn opts))))
(defn- update! [conn table set-map where-clause & opts]
  (apply j/update! conn table set-map where-clause :entities ent-fn opts))
(defn- query [conn sql-and-params & opts]
  (apply j/query conn sql-and-params :identifiers ident-fn opts))
(defn- query-single [& args]
  (first (apply query args)))

(defn- format-dates [run-row]
  (-> run-row
