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

attribute with reserved keyword as internal name causes SQL error #1999

Closed
fritzmg opened this issue Nov 29, 2018 · 1 comment
Closed

attribute with reserved keyword as internal name causes SQL error #1999

fritzmg opened this issue Nov 29, 2018 · 1 comment
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Nov 29, 2018

If you choose an internal name for a variant attribute that is also a reserved keyword of the SQL server, the following error will occur when auto generating variants:

Doctrine\DBAL\Exception\SyntaxErrorException:
An exception occurred while executing 'SELECT * FROM tl_iso_product WHERE pid='44' AND storage='4' AND color='1' AND case='7'':

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '='7'' at line 1

  at vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php:99
  at Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception occurred while executing \'SELECT * FROM tl_iso_product WHERE pid=\'44\' AND storage=\'4\' AND color=\'1\' AND case=\'7\'\':SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'=\'7\'\' at line 1', object(PDOException))
     (vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php:184)
  at Doctrine\DBAL\DBALException::wrapException(object(Driver), object(PDOException), 'An exception occurred while executing \'SELECT * FROM tl_iso_product WHERE pid=\'44\' AND storage=\'4\' AND color=\'1\' AND case=\'7\'\':SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'=\'7\'\' at line 1')
     (vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php:158)
  at Doctrine\DBAL\DBALException::driverExceptionDuringQuery(object(Driver), object(PDOException), 'SELECT * FROM tl_iso_product WHERE pid=\'44\' AND storage=\'4\' AND color=\'1\' AND case=\'7\'', array())
     (vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php:943)
  at Doctrine\DBAL\Connection->executeQuery('SELECT * FROM tl_iso_product WHERE pid=\'44\' AND storage=\'4\' AND color=\'1\' AND case=\'7\'')
     (vendor\contao\core-bundle\src\Resources\contao\library\Contao\Database\Statement.php:276)
  at Contao\Database\Statement->query()
     (vendor\contao\core-bundle\src\Resources\contao\library\Contao\Database\Statement.php:250)
  at Contao\Database\Statement->execute(array('44', 'storage' => '4', 'color' => '1', 'case' => '7'))
     (vendor\isotope\isotope-core\system\modules\isotope\library\Isotope\Backend\Product\VariantGenerator.php:128)
  at Isotope\Backend\Product\VariantGenerator->handle(object(Standard), array('storage' => array('4', '5', '6'), 'color' => array('1', '2', '3', '11'), 'case' => array('7', '8', '9', '10')))
     (vendor\isotope\isotope-core\system\modules\isotope\library\Isotope\Backend\Product\VariantGenerator.php:72)
  at Isotope\Backend\Product\VariantGenerator->generate(object(DC_ProductData))
     (vendor\contao\core-bundle\src\Resources\contao\classes\Backend.php:423)
  at Contao\Backend->getBackendModule('iso_products', null)
     (vendor\contao\core-bundle\src\Resources\contao\controllers\BackendMain.php:163)
  at Contao\BackendMain->run()
     (vendor\contao\core-bundle\src\Controller\BackendController.php:48)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (vendor\symfony\http-kernel\HttpKernel.php:149)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor\symfony\http-kernel\HttpKernel.php:66)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor\symfony\http-kernel\Kernel.php:188)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web\app_dev.php:84)

In this case I have chosen the internal name case for the attribute.

Probably ill advised of me to choose such an internal name 😉, but may be Isotope should escape those or prevent internal names that could be reserved keywords

@aschempp
Copy link
Member

I have added a database keyword validation in 8c3e869. It only works in Contao 4 but I guess we can live with that 😉

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

No branches or pull requests

2 participants