I found an issue related to regex replacement function
private function rewrite_regexp()
{
$pattern = '/\s([^\s]*)\s*regexp\s*(\'.*?\')/im';
$this->_query = preg_replace($pattern, ' regexpp(\1, \2)', $this->_query);
}
To reproduce the problem, here is an example
Query:
SELECT name FROM sqlite_master WHERE type='table' AND (name REGEXP '^wpda_' OR name REGEXP '^wbk_services' OR name REGEXP '^wbk_days_on_off' OR name REGEXP '^wbk_locked_time_slots' OR name REGEXP '^wbk_appointments' OR name REGEXP '^wbk_cancelled_appointments' OR name REGEXP '^wbk_email_templates' OR name REGEXP '^wbk_service_categories' OR name REGEXP '^wbk_gg_calendars' OR name REGEXP '^wbk_coupons')
After replacement (wrong SQL syntax) - double braces around first regexpp call
Query:
SELECT name FROM sqlite_master WHERE type='table' AND regexpp((name, '^wpda_') OR regexpp(name, '^wbk_services') OR regexpp(name, '^wbk_days_on_off') OR regexpp(name, '^wbk_locked_time_slots') OR regexpp(name, '^wbk_appointments') OR regexpp(name, '^wbk_cancelled_appointments') OR regexpp(name, '^wbk_email_templates') OR regexpp(name, '^wbk_service_categories') OR regexpp(name, '^wbk_gg_calendars') OR regexpp(name, '^wbk_coupons'))
Solution is to change the regex to:
private function rewrite_regexp()
{
$pattern = '/([a-z0-9_$]+)\s+regexp\s+(\'.*?\')/im';
$this->_query = preg_replace($pattern, ' regexpp(\1, \2)', $this->_query);
}
I found an issue related to regex replacement function
To reproduce the problem, here is an example
Query:
After replacement (wrong SQL syntax) - double braces around first
regexppcallQuery:
Solution is to change the regex to: