Skip to content

Solution#201

Open
RodOpsOK wants to merge 2 commits into
mate-academy:mainfrom
RodOpsOK:develop
Open

Solution#201
RodOpsOK wants to merge 2 commits into
mate-academy:mainfrom
RodOpsOK:develop

Conversation

@RodOpsOK

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because one core business rule is not correctly implemented for all relevant cases. Your script correctly creates an order for CustomerID = 1, inserts one OrderItems row with ProductID = 1 and Count = 1, and updates Products.WarehouseAmount inside a transaction, which satisfies the task for this specific instance. However, at the line where you update Products.WarehouseAmount (the UPDATE Products ... SET WarehouseAmount = WarehouseAmount - 1 statement in task.sql), you hardcode the decrement as 1 instead of using the Count value from the inserted OrderItem [CHECKLIST ITEM #6, #7]. This means the logic would be incorrect for any order where Count is not 1, violating the explicit business rule that if an order contains 5 items, the warehouse should be decreased by 5. To fix this, change the UPDATE Products statement so that it subtracts the actual Count from the corresponding OrderItem (for example, by using a variable holding the inserted Count or by joining OrderItems and Products on ProductID and using OrderItems.Count in the calculation). Everything else in your transaction setup looks fine for this task, so once the warehouse decrement is tied to Count, your solution will reflect the intended behavior much more accurately. Keep the good structure you already have; this is a small but important correction to make your solution fully compliant with the business rules.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread task.sql Outdated
Comment on lines +13 to +14
INSERT INTO OrderItems (OrderID, ProductID, Count)
VALUES (LAST_INSERT_ID(), 1, 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here you hardcode Count = 1, which is correct for this particular task instance, but the business rule example (5 items → decrease by 5) implies the warehouse adjustment should be based on the Count value. Consider ensuring that the Products update uses the same quantity as the inserted OrderItem rather than a fixed literal, so the logic matches checklist item #7 more generally.

Comment thread task.sql Outdated
Comment on lines +16 to +17
UPDATE Products
SET WarehouseAmount = WarehouseAmount - 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The warehouse amount is decreased by a hardcoded 1. To align with the business rule that the warehouse should be decreased by the number of items ordered (e.g., 5 items → minus 5), it would be better to subtract the Count of the corresponding OrderItem instead of a fixed 1. This will still work for Count = 1 but also reflects the rule correctly.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am approving your solution because it correctly implements all core functional and transactional requirements for the task. Your task.sql script uses USE ShopDB;, creates a new order for CustomerID = 1 with date 2023-01-01, and then adds product ProductID = 1 with Count = 1 as an order item, all in the expected tables. You correctly separate concerns by inserting the order outside a transaction and then wrapping the OrderItems insert and Products.WarehouseAmount update in a transaction, which matches the requirement to decide what should be transactional. The use of LAST_INSERT_ID() to associate the order item with the newly created order is appropriate, and using @order_count to decrement WarehouseAmount ensures the logic scales correctly for other quantities (e.g., 5 items reduce stock by 5). The CI failure is clearly due to a transient Docker/MySQL image pull issue and not related to your code, so no changes are needed on your side.

Overall, your script is concise, functionally complete, and aligned with the business rules and checklist for this task. Nice work solidifying the transactional logic and fixing the previous decrement issue.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@Losiev Losiev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All tests should pass

Run docker run --name mysql -e MYSQL_ROOT_PASSWORD=P@ssw0rd -v $(pwd):/scripts -d mysql:8.0-debian
Unable to find image 'mysql:8.0-debian' locally
docker: Error response from daemon: received unexpected HTTP status: 500 Internal Server Error

Run 'docker run --help' for more information
Error: Process completed with exit code 125.

@RodOpsOK
RodOpsOK force-pushed the develop branch 2 times, most recently from 5ee3c17 to 5874762 Compare July 10, 2026 14:13

@k5sha k5sha left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me, keep it up! 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants