Installation fails with postgres (SHOW TABLES)
tacman opened this issue · 0 comments
tacman commented
Q | A |
---|---|
Zikula Version | 3.0 |
PHP Version | 8.0.4 |
Expected Behavior
Installation should work with pgsql.
Current Behavior
Installation fails because the command to show tables isn't correct for postgres.
php bin/console zikula:install:start --database_name=zikula --database_user=main --database_password=main --email=admin@example.com --locale=en --no-interaction --database_host=localhost --router:request_context:host=zikula.wip --database_driver=pgsql
Invalid data provided: ERROR: Error! Could not connect to the database. Please check that you have entered the correct database information and try again. SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM"
LINE 1: SHOW TABLES FROM zikula LIKE '%'
^
09:54:49 CRITICAL [console] Error thrown while running command "zikula:install:start --database_name=zikula --database_user=main --database_password=main --email='tacman@gmail.com' --locale=en --no-interaction --database_host=localhost --router:request_context:host='zikula.wip' --database_driver=pgsql". Message: "Errors out of the form's scope - do you have validation constraints on properties not used in the form? (Violations on unused fields: data)" ["exception" => RuntimeException { …},"command" => "zikula:install:start --database_name=zikula --database_user=main --database_password=main --email='tacman@gmail.com' --locale=en --no-interaction --database_host=localhost --router:request_context:host='zikula.wip' --database_driver=pgsql","message" => "Errors out of the form's scope - do you have validation constraints on properties not used in the form? (Violations on unused fields: data)"]
In FormHelper.php line 70:
Errors out of the form's scope - do you have validation constraints on properties not used in the form? (Violations on unused fields: data)
Possible Solution
There is no SHOW TABLES command in postgres. So in
src/Zikula/CoreInstallerBundle/Validator/Constraints/ValidPdoConnectionValidator.php
the validate method as
$sql = in_array($object['database_driver'], ['mysql', 'mysqli'])
? 'SHOW TABLES FROM `' . $dbName . "` LIKE '%'"
: 'SHOW TABLES FROM ' . $dbName . " LIKE '%'";
For example, if I set .env.local
DATABASE_URL="postgresql://main:main@127.0.0.1:5432/zikula?serverVersion=13&charset=utf8"
bin/console doctrine:query:sql "SHOW TABLES FROM zikula"
In AbstractPostgreSQLDriver.php line 73:
An exception occurred while executing 'SHOW TABLES FROM zikula':
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM"
LINE 1: SHOW TABLES FROM zikula
^