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

MySQL AbstractSchemaManager::createDatabase missing charset and collation #2441

Open
fredw opened this issue Jul 6, 2016 · 0 comments
Open

Comments

@fredw
Copy link

fredw commented Jul 6, 2016

I need to create a new database on MySQL, but the AbstractSchemaManager doesn't respect my ORM entity manager charset param:

$em = Doctrine\ORM\EntityManager::create(
    [
        'driver' => 'pdo_mysql',
        'host' => getenv('DATABASE_HOST'),
        'port' => getenv('DATABASE_PORT'),
        'user' => getenv('DATABASE_USER'),
        'password' => getenv('DATABASE_PASSWORD'),
        'dbname' => getenv('DATABASE_DATABASE'),
        'charset' => 'utf8',
    ],
    $config
);
$params = $em->getConnection()->getParams();
$connection = DriverManager::getConnection($params);
$connection->getSchemaManager()->createDatabase($params['dbname']);

I took a look at the sources and I saw that there isn't parameter on this AbstractSchemaManager::createDatabase:
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L428
And consequently on MySqlPlatform::getCreateDatabaseSQL there isn't a parameter to inform the charset and collection:
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L384

I don't have a very thorough knowledge of doctrine\dbal, but wouldn't be ideal be a way to specify the charset and collation following the MySQL create database standards?

CREATE DATABASE mydb
   DEFAULT CHARACTER SET utf8
   DEFAULT COLLATE utf8_general_ci;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants