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

retrieve version from query. #2539

wants to merge 2 commits into from

Conversation

catalinux
Copy link

This is needed when you expecially when you get Dbal Connection from a laravel connection

…you get Dbal Connection from a laravel connection
@kimhemsoe
Copy link
Member

kimhemsoe commented Oct 21, 2016

Can you explain the usecase a bit more for those of us whom have never touched laravel?

Also i am guessing "version()" does not exist on all platforms and/or agree on the return format, so your proposed solution is a nogo.

@catalinux
Copy link
Author

Ok. When the connection is native PHP \PDO, it won't detect the version.

@catalinux
Copy link
Author

I could add mysql testing so, I could have

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

@Ocramius
Copy link
Member

Ok. When the connection is native PHP \PDO, it won't detect the version.

If you provide doctrine with a PDO instance on your own, then it should be up to you to also provide the correct platform to the connection, since you may have done a lot of custom stuff on it anyway.

Can you eventually demonstrate the issue with a failing test case? We don't merge anything that is not coming with corresponding test cases, sorry...

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.

@morozov
Copy link
Member

morozov commented Nov 28, 2020

Probably obsolete as of #4115.

@morozov morozov closed this Nov 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants