mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 06:46:11 +02:00
✨ Allow future dates on get-by-params method.
This commit is contained in:
parent
1232f93f1a
commit
8c223b9fb8
1 changed files with 8 additions and 2 deletions
|
@ -221,14 +221,20 @@
|
||||||
(sql/delete table params opts)
|
(sql/delete table params opts)
|
||||||
(assoc opts :return-keys true))))
|
(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
|
(defn get-by-params
|
||||||
([ds table params]
|
([ds table params]
|
||||||
(get-by-params ds table params nil))
|
(get-by-params ds table params nil))
|
||||||
([ds table params {:keys [uncheked] :or {uncheked false} :as opts}]
|
([ds table params {:keys [uncheked] :or {uncheked false} :as opts}]
|
||||||
(let [res (exec-one! ds (sql/select table params opts))]
|
(let [res (exec-one! ds (sql/select table params opts))]
|
||||||
(when (and (not uncheked)
|
(when (and (not uncheked) (or (not res) (is-deleted? res)))
|
||||||
(or (:deleted-at res) (not res)))
|
|
||||||
(ex/raise :type :not-found
|
(ex/raise :type :not-found
|
||||||
|
:table table
|
||||||
:hint "database object not found"))
|
:hint "database object not found"))
|
||||||
res)))
|
res)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue