Skip to content

Attributes named like mysql reserved keywords will break flat catalog indexing #22113

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

Closed
wants to merge 2 commits into from
Closed

Conversation

ghost
Copy link

@ghost ghost commented Apr 2, 2019

Description (*)

Having a product attribute named condition or some other mysql reserved keyword will result in an error while indexing flat catalog:

Ex:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition 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.condition AND t0.store_id = 0
LEFT JOIN eav_attribute_option_value AS ts ON ts.option_id = et.condition AND ts.store_id = 1
SET et.condition_value = IFNULL(ts.value, t0.value)
WHERE (condition IS NOT NULL)

Fixed Issues (if relevant)

Fixes flat catalog indexing for that scenario

  1. magento/magento2#<issue_number>: Issue title
  2. ...

florinsith added 2 commits April 2, 2019 14:24
… indexing

Having a product attribute named condition or some other mysql reserved keyword will result in an error while indexing flat catalog:

Ex: 

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition 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.condition AND t0.store_id = 0
 LEFT JOIN `eav_attribute_option_value` AS `ts` ON ts.option_id = et.condition AND ts.store_id = 1
SET `et`.`condition_value` = IFNULL(ts.value, t0.value)
WHERE (condition IS NOT NULL)
Attributes named like mysql reserved keywords will break flat catalog…
@m2-assistant
Copy link

m2-assistant bot commented Apr 2, 2019

Hi @florinsith. 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

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Apr 2, 2019

CLA assistant check
All committers have signed the CLA.

@orlangur
Copy link
Contributor

orlangur commented Apr 2, 2019

@florinsith any contribution should be delivered to 2.3-develop first. Is it reproducible there?

@ghost
Copy link
Author

ghost commented Apr 6, 2019

The 2.3-develop code is different and weird but I dont think it has an issue. By looking at the code it should result in something like:

.....
SET et.condition_value = IFNULL(ts.value, t0.value)
WHERE (IFNULL(ts.value, t0.value) IS NOT NULL)
....

As you notice the attribute code is replaced by that ifnull function in the where condition.

So I guess its just the 2.2 branch,

@orlangur
Copy link
Contributor

orlangur commented Apr 6, 2019

@florinsith ok, then corresponding changes needs to be backported from 2.3-develop (as full commits) instead of custom ones applied.

@orlangur
Copy link
Contributor

Closing due to inactivity. Feel free to reach me out anytime later if you wish to continue work on this pull request and it will be reopened.
Thanks for collaboration!

@orlangur orlangur closed this Apr 24, 2019
@m2-assistant
Copy link

m2-assistant bot commented Apr 24, 2019

Hi @florinsith, 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.

@ghost
Copy link
Author

ghost commented Apr 24, 2019

I dont really understand what you mean, I am not familiar with this flow. How would I make the change on 2.3-develop since that has different code?

@orlangur
Copy link
Contributor

@florinsith you need to find commits where fixed logic was introduced for 2.3-develop and cherry-pick them to 2.2-develop.

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.

3 participants