Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#32540 Throw error when updating stock when auto increment is exceed… #3309

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vovsky
Copy link
Contributor

@vovsky vovsky commented May 3, 2021

Description (*)

In \Magento\Inventory\Model\ResourceModel\SourceItem\SaveMultiple the "INSERT ... ON DUPLICATE KEY UPDATE" statement is used to save records in inventory_source_item table. Since inventory_source_item table has more than one unique/primary key this statement is unsafe (see https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html at the bottom). In this particular case when the auto increment value is reached and new record is being inserted it will update the last record in the table instead of creating new one, no errors is thrown.

Fixed Issues (if relevant)

  1. Fixes API - No error when updating stock when auto increment is exceeded in inventory_source_item  magento2#32540: API - No error when updating stock when auto increment is exceeded in inventory_source_item

Manual testing scenarios (*)

  1. Insert record to inventory_source_item table with max source_item_id 4294967295, e. g:
    INSERT INTO inventory_source_item (source_item_id, source_code, sku, quantity, status) VALUES (4294967295, 'default', 'test', '100.0000', '1');
  2. Create a new product via Magento Admin or API

Expected result: error is thrown.

Actual Result: no error is thrown, stock item is not saved. The item with source_item_id 4294967295 is updated instead.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@vovsky
Copy link
Contributor Author

vovsky commented May 3, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@sidolov sidolov changed the base branch from 1.2-develop to develop November 11, 2021 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API - No error when updating stock when auto increment is exceeded in inventory_source_item
2 participants