-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Doctrine\DBAL\Connection issue with "platform" key of $params array #3194
Comments
As a bug fix, I think the easiest solution would be either to remove the dbal/lib/Doctrine/DBAL/Connection.php Line 234 in 11037b4
or append the platform to the list of returned parameters in: dbal/lib/Doctrine/DBAL/Connection.php Line 261 in 11037b4
As a longer term solution, we should think about getting rid of At a glance, the use cases are:
|
Actually, returning the platform (or any other object like dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php Lines 100 to 105 in 017991a
Unless there's a non-breaking solution proposed for |
Thank you @morozov, |
If I remember correctly, the reason is that since the connection has a defined database, when you try to connect to it to create the database, you get an error saying the database does not exist. So you need to connect without the database configured in order to create the database from the connection. |
hey @jwage |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Summary
I have a Symfony 4.1 project with installed Doctrine packages.
I found an issue, when trying to use my custom database Platform class, which I created to workaround another issue with default MySql Platform class - when you create database it's not adding
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
to create table statement.I created class with just one method:
Then added it to doctrine configuration:
When trying to execute
doctrine:database:create
command it creates database with default character set and collation, but should withutf8mb4
.I performed a debug session with script
\Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand
and found that:execute()
method at line 47$connection = $this->getDoctrineConnection($connectionName);
return correct connection object with correctplatform
property set.$params = $connection->getParams();
and$params
doesn't containplatform
key$tmpConnection = DriverManager::getConnection($params);
returns connection object withoutplatform
property set.Tbh, I don't know why it is necessary to get another
$tmpConnection
instead of using already set$connection
, but new connection object is created without proper platform, as$params
doesn't have keyplatform
.Current behavior
Command
doctrine:database:create
doesn't use configuredplatform_service
object.How to reproduce
Create custom platform class (see above) and configure doctrine dbal to use it via parameter
platform_service
.Execute command
doctrine:database:create
and check created database. It will be created with default character set and collation, instead of enforcedutf8mb4
in custom Platform object.Expected behavior
Any creation of a connection object should respect configured value of
platform_service
.As a possible fix in
\Doctrine\DBAL\Connection::__construct
at line 234:unset($this->_params["platform"]);
after that everything works correctly.
Or, probably method
\Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand::execute
should be refactored if favour of using correct$connection
instead of incorrect$tmpConection
object.The text was updated successfully, but these errors were encountered: