perf: disable new-db cache for custom queries

related to #4285
This commit is contained in:
Tienson Qin
2022-02-19 14:40:49 +08:00
parent 8c9f2dc266
commit db07341ebe

View File

@@ -157,24 +157,25 @@
(defn- new-db
[cached-result tx-data old-db k]
(try
(let [empty-db (d/empty-db db-schema/schema)
db (or old-db
(when (and (coll? cached-result)
(or (map? (first cached-result))
(empty? cached-result)))
(let [cached-result (util/remove-nils cached-result)]
(-> empty-db
(d/with cached-result)
(:db-after)))))]
(when db
(:db-after (d/with db tx-data))))
(catch js/Error e
(prn "New db: " {:k k
:old-db old-db
:cached-result cached-result})
(js/console.error e)
old-db)))
(when-not (= :custom (second k))
(try
(let [empty-db (d/empty-db db-schema/schema)
db (or old-db
(when (and (coll? cached-result)
(or (map? (first cached-result))
(empty? cached-result)))
(let [cached-result (util/remove-nils cached-result)]
(-> empty-db
(d/with cached-result)
(:db-after)))))]
(when db
(:db-after (d/with db tx-data))))
(catch js/Error e
(prn "New db: " {:k k
:old-db old-db
:cached-result cached-result})
(js/console.error e)
old-db))))
(defn get-query-cached-result
[k]