Skip to content

Commit

Permalink
Remove dbname reference from database connection configuration
Browse files Browse the repository at this point in the history
There is still the dbname within the url. Need to get rid of this in CreateDatabaseCommand,
because else it still tries to connect to the server with this dbname, which probably doesn't exists yet.
  • Loading branch information
kingcrunch committed Oct 2, 2015
1 parent 5674222 commit 9e556cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Command/CreateDatabaseDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$name) {
throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
}
unset($params['dbname']);
// 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);
$shouldNotCreateDatabase = $ifNotExists && in_array($name, $tmpConnection->getSchemaManager()->listDatabases());
Expand Down

1 comment on commit 9e556cb

@1ma
Copy link

@1ma 1ma commented on 9e556cb Nov 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kingcrunch This commit breaks the command for a DBAL service configured as an SQLite database as of version 1.6.0 of the bundle. If $params['path'] is unset the program flow enters the if statement at L81 and $name is quoted twice, thus breaking the eventual PDO class instantiation down the line.

On my box, surrounding the if block with a couple of dump($name) yields the following output, and commenting out the conditional block solves the problem:

$ sf doctrine:database:create
"/vagrant/app/database.db3"
""/vagrant/app/database.db3""
Could not create database "/vagrant/app/database.db3" for connection named default
An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file

Since I don't understand what's the rationale behind this commit I'm not confident enough to propose a fix, nevertheless I wanted to bring this to your attention. Thank you.

Please sign in to comment.