FriendsOfDoctrine / dbal-clickhouse

Doctrine DBAL driver for ClickHouse database
GNU General Public License v3.0
98 stars 80 forks source link

`php bin/console doctrine:database:create` does not work #35

Open mrpavlikov opened 4 years ago

mrpavlikov commented 4 years ago

Symfony 5.0.2

$ php bin/console doctrine:database:create

throws exception

In Driver.php line 54:
  Connection parameter `dbname` is required                                               

As far as I can see vendor/doctrine/doctrine-bundle/Command/CreateDatabaseDoctrineCommand.php:86 unsets dbname to check whether db exists and connects without driver:

// Need to get rid of _every_ occurrence of dbname from connection configuration and we have already extracted all relevant info from url
unset($params['dbname'], $params['path'], $params['url']);

$tmpConnection = DriverManager::getConnection($params);
$tmpConnection->connect($input->getOption('shard'));
$shouldNotCreateDatabase = $ifNotExists && in_array($name, $tmpConnection->getSchemaManager()->listDatabases());

but \FOD\DBALClickHouse\Driver::connect does not let that.

if (! isset($params['dbname'])) {
     throw new ClickHouseException('Connection parameter `dbname` is required');
}
shadz3rg commented 4 years ago

Also there is some problems with quoted identifiers. Somehow double backticks replaces double-quotes.

Could not create database `metrics` for connection named clickhouse
An exception occurred while executing 'CREATE DATABASE ``metrics``':

Syntax error: failed at position 17: ``metrics``. Expected one of: identifier, IF NOT EXISTS 
IN:CREATE DATABASE ``metrics``