diff --git a/Command/CreateDatabaseDoctrineCommand.php b/Command/CreateDatabaseDoctrineCommand.php index be160e05b..1b8d40484 100644 --- a/Command/CreateDatabaseDoctrineCommand.php +++ b/Command/CreateDatabaseDoctrineCommand.php @@ -52,14 +52,22 @@ protected function execute(InputInterface $input, OutputInterface $output) $ifNotExists = $input->getOption('if-not-exists'); + $driverOptions = []; $params = $connection->getParams(); + + if (isset($params['driverOptions'])) { + $driverOptions = $params['driverOptions'] + } + if (isset($params['master'])) { $params = $params['master']; + $params['driverOptions'] = $driverOptions; } // Since doctrine/dbal 2.11 master has been replaced by primary if (isset($params['primary'])) { $params = $params['primary']; + $params['driverOptions'] = $driverOptions; } // Cannot inject `shard` option in parent::getDoctrineConnection diff --git a/Command/DropDatabaseDoctrineCommand.php b/Command/DropDatabaseDoctrineCommand.php index 6f7935279..4b1485a0a 100644 --- a/Command/DropDatabaseDoctrineCommand.php +++ b/Command/DropDatabaseDoctrineCommand.php @@ -60,15 +60,23 @@ protected function execute(InputInterface $input, OutputInterface $output) $connection = $this->getDoctrineConnection($connectionName); $ifExists = $input->getOption('if-exists'); - + + $driverOptions = []; $params = $connection->getParams(); + + if (isset($params['driverOptions'])) { + $driverOptions = $params['driverOptions'] + } + if (isset($params['master'])) { $params = $params['master']; + $params['driverOptions'] = $driverOptions; } // Since doctrine/dbal 2.11 master has been replaced by primary if (isset($params['primary'])) { $params = $params['primary']; + $params['driverOptions'] = $driverOptions; } if (isset($params['shards'])) { diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index c468ff2b2..b76138093 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -261,6 +261,7 @@ protected function getConnectionOptions($connection) if (! empty($options['slaves'])) { $nonRewrittenKeys = [ 'driver' => true, + 'driverOptions' => true, 'driverClass' => true, 'wrapperClass' => true, 'keepSlave' => true, diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index cbaf8ef5e..703cdb84d 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -126,7 +126,6 @@ public function testDbalLoadSingleMasterSlaveConnection() 'dbname' => 'mysql_db', 'host' => 'localhost', 'unix_socket' => '/path/to/mysqld.sock', - 'driverOptions' => [], ], $param['master'] );