symfony-cmf / routing-bundle

Symfony bundle to provide the CMF chain router to handle multiple routers, and the dynamic router to load routes from a database or other sources.
160 stars 78 forks source link

ORM: a new "condition" field needs to be escaped as it's a reserved word (at least in MySQL) #480

Closed dbojdo closed 2 years ago

dbojdo commented 2 years ago

Environment

PHP 8.1

Symfony packages

symfony/symfony 6.0.*

Symfony CMF packages

symfony-cmf/routing        3.0.0 3.0.0 Extends the Symfony routing component for dynamic routes and chaining several routers
symfony-cmf/routing-bundle 3.0.0 3.0.0 Symfony RoutingBundle

Subject

A mapping of "condition" column in src/Resources/config/doctrine-base/Symfony.Component.Routing.Route.orm.xml should quote the column name as "condition" is a reserved name.

Steps to reproduce

Use ORM and try to persist a new Route object using MySQL 8.0

Expected results

The route should be persisted

Actual results

MySQL syntax error Doctrine\DBAL\Exception\SyntaxErrorException(code: 1064): An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition, variable_pattern, staticPrefix, name, position) VALUES ('', 'a:0:{}',' at line 1 at /var/www/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:88) [previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 1064): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition, variable_pattern, staticPrefix, name, position) VALUES ('', 'a:0:{}',' at line 1 at /var/www/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:30)