Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
bug fix: calculating item_ids array size correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalnn committed May 16, 2024
1 parent cc1f901 commit 02b32c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion migrations/012_shipments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ DECLARE n_missing_items int;
WHERE id = item_id;
END LOOP;

SELECT NEW.quantity - COUNT(item_ids) INTO n_missing_items;

SELECT NEW.quantity - array_length(item_ids, 1) INTO n_missing_items;
IF n_missing_items > 0 THEN
RAISE NOTICE 'Missing items: %', n_missing_items;
FOR i IN 1..n_missing_items
LOOP
INSERT INTO items (piece_kind, status, warehouse, acc_cost)
Expand Down

0 comments on commit 02b32c8

Please sign in to comment.