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

Wrap WHERE condition in parens #2965

Merged

Conversation

mattdavenport
Copy link
Contributor

When utilizing getProductFlatSelect(), we ran into a bug in Mage_Rule_Model_Condition_Combine::prepareConditionSql() in which the WHERE clause construction did not properly parenthesize the conditions. As an example:

Pre-fix:

FIND_IN_SET('123',`cpf`.`quantity`) OR FIND_IN_SET('1801',`cpf`.`quantity`) AND FIND_IN_SET('7',`ccp`.`category_id`)

Post-fix:

(FIND_IN_SET('123',`cpf`.`quantity`) OR FIND_IN_SET('1801',`cpf`.`quantity`)) AND (FIND_IN_SET('7',`ccp`.`category_id`))

This PR ensures each where clause addition is properly contained and evaluated.

When the Combine condition is utilized (e.g. via getProductFlatSelect),
this commit fixes the logic when using multiple WHERE clauses.
@github-actions github-actions bot added the Component: Rule Relates to Mage_Rule label Jan 17, 2023
@fballiano fballiano merged commit 4836d1f into OpenMage:1.9.4.x Jan 21, 2023
fballiano pushed a commit that referenced this pull request Jan 21, 2023
@fballiano
Copy link
Contributor

merged and cherrypicked to v20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Rule Relates to Mage_Rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants