 (defn get-all-artists
   "Returns all artists' names from the database."
   [db-con]
-  (let [result (j/query db-con
-                        (sql/format
-                         (sql/build :select :name
-                                    :from :artists
-                                    :order-by [[:name :asc]])))]
-    (map :name result)))
+  (j/query db-con
+           (sql/format
+            (sql/build :select :name
+                       :from :artists
+                       :order-by [[:name :asc]]))
+           {:row-fn #(:name %)}))
 
 (defn get-episodes-with-track
   "Returns track name, artist, episode name and number of the provided track."

      (if-not (= (count ep-name-parts) 2)
        {:status "error"
         :cause "invalid-name"}
        (let [date-str-to-sql-time
              ;; Converts the input date string to a SQL timestamp.
              (fn [date-str]
                (c/to-sql-time (t/plus (t/from-time-zone
                                        (f/parse date-formatter date-str)
                                        (t/time-zone-for-id
                                         (cfg/get-conf-value :time-zone)))
                                       (t/hours 12))))
              episode-id (:ep_id (first (j/insert! db-con
                                                   :episodes
                                                   {:number (Integer/parseInt
                                                             (ep-name-parts 1))
                                                    :name ep-name
                                                    :date (date-str-to-sql-time
                                                           date)})))]
          (if (every? pos? (for [track-json tracklist-json]
                             (insert-episode-track db-con
                                                   episode-id
                                                   track-json)))
            {:status "success"}
            ;; TODO add rollback on failure
            {:status "error"
             :cause "general-error"}))))
    (catch org.postgresql.util.PSQLException pge
      (.printStackTrace pge)
      (if (re-find #"violates unique constraint" (.getMessage pge))

  "Returns all the episodes in the database. Returns episode number, name
  date."
  [db-con]
  (j/query db-con
           (sql/format
            (sql/build :select [:number :name :date]
                       :from :episodes
                       :order-by [[:number :desc]]))
           {:row-fn #(merge % {:date (sql-ts-to-date-str (:date %))})}))

(defn get-episode-basic-data
  "Returns the basic data (name and date) of the episode with
  the provided number."
  [db-con episode-number]
  (first (j/query db-con
                  (sql/format
                   (sql/build :select [:name :date]
                              :from :episodes
                              :where [:= :number (Integer/parseInt
                                                  episode-number)]))
                  {:row-fn #(merge % {:date (sql-ts-to-date-str (:date %))})})))

(defn get-episode-tracks
  "Returns the track name, artist and possible feature of each track in the
