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

Installation fails with postgres (SHOW TABLES) #4688

Closed
tacman opened this issue Jul 3, 2021 · 0 comments
Closed

Installation fails with postgres (SHOW TABLES) #4688

tacman opened this issue Jul 3, 2021 · 0 comments
Labels
Milestone

Comments

@tacman
Copy link

tacman commented Jul 3, 2021

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                                          
                      ^                                                    
@tacman tacman added the Bug label Jul 3, 2021
@Guite Guite added this to the 3.1.0 milestone Oct 13, 2021
@Guite Guite closed this as completed in f77868d Oct 13, 2021
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