fix collection quantity add/remove to work properly when quality is nil
This commit is contained in:
parent
6265c390ae
commit
cd3cb45213
|
@ -16,6 +16,16 @@
|
||||||
(if-not (first (jdbc/query dt ["select count(*) from lists where id = ? and is_public in (true, ?)" list-id public-only?]))
|
(if-not (first (jdbc/query dt ["select count(*) from lists where id = ? and is_public in (true, ?)" list-id public-only?]))
|
||||||
(throw (new Exception (str "Not authorized to update list:" list-id)))
|
(throw (new Exception (str "Not authorized to update list:" list-id)))
|
||||||
(let [num-updates (first
|
(let [num-updates (first
|
||||||
|
; i love that SQL forces you to use "is null" ...
|
||||||
|
(if (nil? quality)
|
||||||
|
(vexec! view-system dt
|
||||||
|
["update collection
|
||||||
|
set quantity = quantity + ?
|
||||||
|
where card_id = ? and
|
||||||
|
quality is null and
|
||||||
|
foil = ? and
|
||||||
|
list_id = ?"
|
||||||
|
quantity-change card-id foil? list-id])
|
||||||
(vexec! view-system dt
|
(vexec! view-system dt
|
||||||
["update collection
|
["update collection
|
||||||
set quantity = quantity + ?
|
set quantity = quantity + ?
|
||||||
|
@ -23,7 +33,7 @@
|
||||||
quality = ? and
|
quality = ? and
|
||||||
foil = ? and
|
foil = ? and
|
||||||
list_id = ?"
|
list_id = ?"
|
||||||
quantity-change card-id quality foil? list-id]))]
|
quantity-change card-id quality foil? list-id])))]
|
||||||
(if (= 0 num-updates)
|
(if (= 0 num-updates)
|
||||||
(first
|
(first
|
||||||
(vexec! view-system dt
|
(vexec! view-system dt
|
||||||
|
|
Loading…
Reference in a new issue