[core] Remove unnecessary parentheses to group conditions
Closed this issue · 0 comments
AniTrend Issue Guidelines
Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.
You may find an answer in issues:
https://github.com/AniTrend/support-query-builder/issues?q=is%3Aissue+is%3Aclosed
Enhancement Information
In the core
module when we use parentheses for criteria (primarily for AND and OR operators) to explicitly specify the order of evaluation for conditions in a WHERE
clause.
Example:
(column_name = 'something' AND column_name LIKE '%pe')
column_name = 'something' AND column_name LIKE '%pe'
👈🏿 Ideal
In most SQL databases, including common ones like MySQL, PostgreSQL, and SQL Server, using parentheses in this context doesn't affect the query's performance. The database query optimiser will understand the logical order of operations and will execute the conditions correctly in both cases.
Additional Context
So, in our example, whether you we parentheses or not, the performance should be the same, and the results will be identical. It's primarily a matter of personal preference and readability, for this sake we'd like to stick to the norm.