Open eywolfe opened 3 months ago
That makes sense since PickedItem.query(trx) .findOne({ inventory_uuid: ref('inventory.uuid'), order_uuid: pickedItem.order_uuid, }) .select('quantity')
returns a promise, and objection will not resolve it before calling beforeUpdate
.
I'm trying to write a static
beforeUpdate
hook and noticed that when mypatch
call uses a subquery the value(s) are not included in theinputItems
array.Here is the relevant part of my
beforeUpdate
definition:If I call the function like this then I see
quantity_in_stock
provided ininputItems
:However if I call the function using a subquery in the patch parameter I don't see
quantity_in_stock
ininputItems
:Is there any workaround here other than refactoring to not pass a subquery when calling
patch
? I can do that in this one instance, but it's not maintainable to assume we won't write code like this in the future. I also tried writing anafterUpdate
function instead and ran into the same issue.