0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Allow future dates on get-by-params method.

This commit is contained in:
Andrey Antukh 2021-06-07 10:56:21 +02:00
parent 1232f93f1a
commit 8c223b9fb8

View file

@ -221,14 +221,20 @@
(sql/delete table params opts)
(assoc opts :return-keys true))))
(defn- is-deleted?
[{:keys [deleted-at]}]
(and (dt/instant? deleted-at)
(< (inst-ms deleted-at)
(inst-ms (dt/now)))))
(defn get-by-params
([ds table params]
(get-by-params ds table params nil))
([ds table params {:keys [uncheked] :or {uncheked false} :as opts}]
(let [res (exec-one! ds (sql/select table params opts))]
(when (and (not uncheked)
(or (:deleted-at res) (not res)))
(when (and (not uncheked) (or (not res) (is-deleted? res)))
(ex/raise :type :not-found
:table table
:hint "database object not found"))
res)))