Compatibility with PHP 7.3 / MySQL 8
Lumeriol opened this issue · 1 comments
Version: 3.x-dev
Bug Description
Problem is with joining tables in selection. With PHP <= 7.2.10 is everything okay, 7.3 version throw exception Nette\Database\DriverException #42S22. Both code runs on MySQL 8 with same configuration.
Simple queries to single table (without "dot-joining") is okay.
Steps To Reproduce
This code for example:
return $this->db->table($this->repository)
->where([
'product.is_random_offer = ?' => 1,
'product.is_active = ?' => 1,
'is_primary = ?' => 1
])
->order('RAND()')
->limit($count)
->fetchAll();
Generated query on PHP 7.2
SELECT `product_product_category`.`id`, `product_product_category`.`product_id`,
`product_product_category`.`product_category_id`
FROM `product_product_category`
LEFT JOIN `product` ON `product_product_category`.`product_id` = `product`.`id`
WHERE (`product`.`is_random_offer` = 1) AND (`product`.`is_active` = 1) AND (`is_primary` = 1)
ORDER BY RAND()
LIMIT 5
Generated problematic query on PHP 7.3
SELECT *
FROM `product_product_category`
WHERE (`product`.`is_random_offer` = ?) AND (`product`.`is_active` = ?) AND (`is_primary` = ?)
ORDER BY RAND()
LIMIT 5
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'product.is_random_offer' in 'where clause'.
Problematic files:
File: ...\nette\database\src\Database\DriverException.php:27
$e = new static($src->message, 0, $src);
File: ...\database\src\Database\Drivers\MySqlDriver.php:66
return Nette\Database\DriverException::from($e);
etc. in Tracy call stack.
Expected Behavior
I know, that PHP 7.3 is still under development, but now in RC2 version, and compatibility with Nette 3 is not complete, so when it is up to date, you can fix it to be same/similar behavior as in 7.2.
It is caused by incompatibility between PCRE and PCRE 2 used in PHP 7.3… https://bugs.exim.org/show_bug.cgi?id=2332