Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/rda_task_3_transactions.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions task.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
-- Use our database
USE ShopDB;

-- Some data should be created outside the transaction (here)

-- Start the transaction
START TRANSACTION;

-- And some data should be created inside the transaction
USE ShopDB;

INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per checklist item #18 and the previous review, the Orders table insert is still executed before the transaction rather than after COMMIT;. The tests expect the order creation to happen outside and after the transactional block that handles OrderItems and Products, so you should move this statement below COMMIT;.

SET @OrderID = LAST_INSERT_ID();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LAST_INSERT_ID() here depends on the order row inserted above, but both are currently before START TRANSACTION;. According to the requirements, the order creation and retrieval of its ID should happen after the transaction that inserts into OrderItems and updates Products has been committed, so this statement should also be moved to follow COMMIT;.

START TRANSACTION;
INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (@OrderID, 1, 1);
UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1;
COMMIT;
Loading