Remove more problem exception handling.
This commit is contained in:
parent
ad0d1bc7e2
commit
4a06ad489f
|
@ -1,4 +1,4 @@
|
||||||
(defproject views "0.4.7"
|
(defproject views "0.4.8"
|
||||||
:description "You underestimate the power of the SQL side"
|
:description "You underestimate the power of the SQL side"
|
||||||
|
|
||||||
:url "https://github.com/diligenceengine/views"
|
:url "https://github.com/diligenceengine/views"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
[views.db.load :as vdbl]
|
[views.db.load :as vdbl]
|
||||||
[views.db.checks :as vc]
|
[views.db.checks :as vc]
|
||||||
[views.db.honeysql :as vh]
|
[views.db.honeysql :as vh]
|
||||||
[views.db.util :refer [safe-map log-exception serialization-error?]]))
|
[views.db.util :refer [log-exception serialization-error?]]))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Terminology and data structures used throughout this code
|
;; Terminology and data structures used throughout this code
|
||||||
|
@ -116,11 +116,11 @@
|
||||||
|
|
||||||
(defn compute-insert-delete-deltas-for-views
|
(defn compute-insert-delete-deltas-for-views
|
||||||
[schema db views table record]
|
[schema db views table record]
|
||||||
(safe-map #(compute-delete-deltas-for-insert schema db % table record) views))
|
(mapv #(compute-delete-deltas-for-insert schema db % table record) views))
|
||||||
|
|
||||||
(defn compute-insert-insert-deltas-for-views
|
(defn compute-insert-insert-deltas-for-views
|
||||||
[schema db views table record]
|
[schema db views table record]
|
||||||
(safe-map #(compute-insert-deltas-for-insert schema db % table record) views))
|
(mapv #(compute-insert-deltas-for-insert schema db % table record) views))
|
||||||
|
|
||||||
(defn compute-deltas-for-insert
|
(defn compute-deltas-for-insert
|
||||||
"This takes a *single* insert and a view, applies the insert and computes
|
"This takes a *single* insert and a view, applies the insert and computes
|
||||||
|
@ -171,16 +171,16 @@
|
||||||
(defn- update-and-append-deltas!
|
(defn- update-and-append-deltas!
|
||||||
"Handles update and calculation of delete (before update) and insert (after update) deltas."
|
"Handles update and calculation of delete (before update) and insert (after update) deltas."
|
||||||
[db views action table pkey]
|
[db views action table pkey]
|
||||||
(let [views-pre (safe-map #(calculate-delete-deltas db %) views)
|
(let [views-pre (mapv #(calculate-delete-deltas db %) views)
|
||||||
pkey-val (get-action-row-key db pkey table action)
|
pkey-val (get-action-row-key db pkey table action)
|
||||||
update (j/execute! db (hsql/format action))]
|
update (j/execute! db (hsql/format action))]
|
||||||
{:views-with-deltas (safe-map #(calculate-insert-deltas db action [:= pkey pkey-val] %) views-pre)
|
{:views-with-deltas (mapv #(calculate-insert-deltas db action [:= pkey pkey-val] %) views-pre)
|
||||||
:result-set update}))
|
:result-set update}))
|
||||||
|
|
||||||
(defn- delete-and-append-deltas!
|
(defn- delete-and-append-deltas!
|
||||||
"Handles deletion and calculation of delete (before update) delta."
|
"Handles deletion and calculation of delete (before update) delta."
|
||||||
[db views action table pkey]
|
[db views action table pkey]
|
||||||
(let [views-pre (safe-map #(calculate-delete-deltas db %) views)]
|
(let [views-pre (mapv #(calculate-delete-deltas db %) views)]
|
||||||
{:views-with-deltas views-pre
|
{:views-with-deltas views-pre
|
||||||
:result-set (j/execute! db (hsql/format action))}))
|
:result-set (j/execute! db (hsql/format action))}))
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
[clojure.tools.logging :refer [debug info warn error]]
|
[clojure.tools.logging :refer [debug info warn error]]
|
||||||
[clojure.java.jdbc :as j]
|
[clojure.java.jdbc :as j]
|
||||||
[honeysql.core :as hsql]
|
[honeysql.core :as hsql]
|
||||||
[views.db.util :refer [safe-map log-exception serialization-error?]]))
|
[views.db.util :refer [log-exception serialization-error?]]))
|
||||||
|
|
||||||
(defn view-query
|
(defn view-query
|
||||||
"Takes db and query-fn (compiled HoneySQL hash-map)
|
"Takes db and query-fn (compiled HoneySQL hash-map)
|
||||||
|
|
|
@ -53,13 +53,3 @@
|
||||||
"e: " e
|
"e: " e
|
||||||
" msg: " (.getMessage e)
|
" msg: " (.getMessage e)
|
||||||
" trace: " (with-out-str (print-stack-trace e)))))
|
" trace: " (with-out-str (print-stack-trace e)))))
|
||||||
|
|
||||||
(defn safe-map
|
|
||||||
"A non-lazy map that skips any results that throw exeptions other than SQL
|
|
||||||
serialization errors."
|
|
||||||
[f items]
|
|
||||||
(reduce #(try (conj %1 (f %2))
|
|
||||||
(catch SQLException e (if (serialization-error? e) (throw e) %1))
|
|
||||||
(catch Exception e %1))
|
|
||||||
[]
|
|
||||||
items))
|
|
||||||
|
|
Loading…
Reference in a new issue