Skip to content

Fix MySQL syntax error on indexation with certain attribute codes #22559

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

Merged
merged 3 commits into from
May 7, 2019
Merged

Conversation

Beagon
Copy link
Contributor

@Beagon Beagon commented Apr 30, 2019

Description

Fixes an issue where the category flat indexer would throw an MySQL syntax error if an attribute_code was equal to a MySQL function.

If you have a attribute with a code called "group" the following would occur when the catalog flat data indexer tries to run:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group IS NOT NULL)' at line 5, query was: UPDATE `catalog_product_flat_1_tmp_indexer` AS `et` LEFT JOIN `eav_attribute_option_value` AS `t0` ON t0.option_id = et.group AND t0.store_id = 0 LEFT JOIN `eav_attribute_option_value` AS `ts` ON ts.option_id = et.group AND ts.store_id = 1 SET `et`.`group_value` = IFNULL(ts.value, t0.value) WHERE (group IS NOT NULL)

Manual testing scenarios

Before patch:

  1. Create attribute with attribute code group.
  2. Add attribute to attribute set of products.
  3. Run Catalog Flat Data indexer. php bin/magento indexer:reindex catalog_category_flat
  4. See the error appear.

After patch:

  1. Create attribute with attribute code group.
  2. Add attribute to attribute set of products.
  3. Run Catalog Flat Data indexer. php bin/magento indexer:reindex catalog_category_flat
  4. Everything should have been successfully rebuilt.

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 on Travis CI are green)

@m2-assistant
Copy link

m2-assistant bot commented Apr 30, 2019

Hi @Beagon. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.2-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@Beagon Beagon added the Partner: Itonomy PR created by partner Itonomy label Apr 30, 2019
@Beagon Beagon changed the title Fix issue with attribute codes Fix MySQL syntax error on indexation with certain attribute codes Apr 30, 2019
@orlangur orlangur self-assigned this Apr 30, 2019
Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

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

Hi @Beagon, please do the following: #22113 (comment)

@Beagon Beagon requested a review from orlangur April 30, 2019 14:01
@Beagon
Copy link
Contributor Author

Beagon commented Apr 30, 2019

Hi @orlangur,

I've backported the changes from 2.3-dev.

Greetings,

Robin

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

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

Great @Beagon! 👍 Didn't expect it that fast taking into consideration discussion in previous PR)

@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-4860 has been created to process this Pull Request

@VasylShvorak
Copy link
Contributor

✔️ QA passed

@m2-assistant
Copy link

m2-assistant bot commented May 7, 2019

Hi @Beagon, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

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.

6 participants