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

retrieve version from query. #2539

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ private function getDatabasePlatformVersion()
return $this->_conn->getServerVersion();
}

if ($this->_conn instanceof \PDO && $this->_conn->getAttribute(PDO::ATTR_DRIVER_NAME)==='mysql') {
try {
return $this->_conn->query('select version()')->fetchColumn();
} catch (\PDOException $e) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather have a failure here, since it's mysql, and yet something is going horribly wrong. This catch block should go away.

Copy link
Author

Choose a reason for hiding this comment

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

It makes sense to make tests for my own code. My problem was that when wrapping a PDO Connection of MySql , getDatabasePlatformVersion returns null. Looking more into the code I see there is a requiresQueryForServerVersion mechanism but for PDO this method return false.

I'll dig more into this problem.

Copy link
Member

Choose a reason for hiding this comment

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

What you just described is what should be formalized into a test case.

//version query not supported
}
}
// Unable to detect platform version.
return null;
}
Expand Down