-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
Do not cast the order by expression for MySQL drivers as casting a TE… #1977
Conversation
…XT field to TEXT results in a SQL error
This looks like a correct fix, but in the last two weeks this has been changed back and forth.. @Wieter , do you know of a way to make it work on Postgres, without breaking MySQL? |
@bobdenotter this fix seems incorrect to me, as the queries here are built against Doctrine DRM and not SQL. |
My findings were that the line in src/Doctrine/Query/Cast.php was never hit. I had a var_dump just after $backend_driver (before the if condition) followed by an exit(), and I was still getting the exception. Therefore it felt like the CAST in OrderDirective.php was getting passed as-is to MariaDB, and not being filtered out by the condition in Cast.php. My $backend_driver does indeed yield “mysql”. |
My .env was just erased by d2da6b9, it will take a bit more time to get all connections back as I didn't bother to save the dev passwords elsewhere.. :) |
@andysh-uk when I insert in |
@Wieter could there be something in Doctrine that it knows how to render the SQL for CAST against MySQL, that it doesn’t with Postgres, so it calls your function for Postgres but not MySQL? If you can provide me with your IP address I’m more than happy to give you access to my MariaDB dev server, if that helps? If you don’t want to disclose it here, you can send it through my website |
@andysh-uk thanks for the offer, but I managed. My ip address is temporarily super-dynamic as we still have troubles with the ISP ('unlimited' 4G to the rescue..). I was not able to reproduce the error.
I wonder.. what happens with a composer-only fetch and install, through the official release channels. I'll try that later. |
I managed to get the error now and will look into it. #7878 contains the exact steps to reproduce. |
@bobdenotter I think I found the culprit. using composer install creates an I see more is missing from the doctrine config (
|
Thanks @Wieter. Is that why I couldn’t get the line to be hit in src/Doctrine/Query/Cast.php? That would make better sense than my proposed fix in this PR, knowing now that the query I changed is DQL, not pure SQL. |
yes @andysh-uk |
@Wieter that works perfectly, many thanks 😄 I rolled my change back to make sure I was still getting the exception (I was) and then applied your changes to I did double-check that Just FYI, PhpStorm flags the A better option might be to use |
Good to hear it works. Good finding, indeed |
@Wieter thanks, I'll implement and raise a separate PR. |
Fixes #1971 - the CAST to TEXT causes an error on MySQL.
This follows similar logic implemented in src/Doctrine/Query/Cast.php.
Getting the backend driver name (e.g. mysql) is a long chain of method calls but I cannot see any other way. It also uses
getDatabasePlatform()->getName()
instead of thegetDriver()->getName()
call inCast.php
as the docblock on that method suggests it is deprecated (but no alternative suggested.)