-
-
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
Existing columns not found (at least in mysql) #349
Existing columns not found (at least in mysql) #349
Conversation
…ame was being as database name instead of just the dbname part
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DBAL-570 We use Jira to track the state of pull requests and the versions they got |
@@ -155,6 +155,12 @@ public function listTableColumns($table, $database = null) | |||
$database = $this->_conn->getDatabase(); | |||
} | |||
|
|||
// If an entire DSN is passed extract db name from it | |||
preg_match('/dbname=([^;]*)/', $database, $matches); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you want to pass a DSN to this method when a database name is expected?
Well I don't want to (and thus I don't) but that is what the default value becomes when you not pass a database name to this method, see: $this->_conn->getDatabase(). |
As far as I can see |
Good point @deeky666, Our connection is created in a subsystem of a bigger project which uses PDO. It turned out Doctrine was being fed a PDO dsn string when connection was created like: 'mysql:host=localhost;dbname={dbName}'. The thing is that Doctrine actually works fine with this configuration except for the issue mentioned above. I will split the configuration into separate host and dbname parameters before passing it to doctrine. Thanks |
@lucasvanlierop I'm sure there will be other issues whenever the |
Well that apparently most stuff still works when a dsn is passed, that's why it took me some time to discover what was wrong, I'll close this PR now |
As per user request... |
Existing columns in the database were not found since dsn was being used instead of just the db name part of the dsn.
Two examples where I ran into this
Note that this fix is quite basic it might the case the conversion has to happen earlier on in the code for example by adding a 'getDatabaseName()' method to \Doctrine\DBAL\Connection or maybe just apply it in \Doctrine\DBAL\Platforms\MySqlPlatform::getListTableIndexesSQL()?
Please let me know