You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to propose a change to mysql connector strictMode where it returns the wrong server version when using Azure database for mysql. I read some discussions online that this seems to be an issue with PDO::ATTR_SERVER_VERSION and any solution with a mysql proxy. It is nice that you introduced a way to explicitly override the version, but it would be great if we could get the correct server version when deciding to pass certain sql modes. For many of my use cases we have the app deployed to multiple environments. It is not feasible for us to upgrade all the databases at once. I guess we could pass mysql server version as environment variable, but this does not smell right to me.
I was thinking of something like the following to get the correct server version, but I am uncertain how to best start the conversation. Please kindly point me to some documentation I probably missed if I am going about this all wrong.
I did a quick search for strictMode, contribute, version, pull request, ATTR_SERVER_VERSION. I did not find a similar discussion.
#32708 - PR that introduce explicit override as workaround
The following change is what I propose because it provides me the correct server version:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to propose a change to mysql connector strictMode where it returns the wrong server version when using Azure database for mysql. I read some discussions online that this seems to be an issue with PDO::ATTR_SERVER_VERSION and any solution with a mysql proxy. It is nice that you introduced a way to explicitly override the version, but it would be great if we could get the correct server version when deciding to pass certain sql modes. For many of my use cases we have the app deployed to multiple environments. It is not feasible for us to upgrade all the databases at once. I guess we could pass mysql server version as environment variable, but this does not smell right to me.
I was thinking of something like the following to get the correct server version, but I am uncertain how to best start the conversation. Please kindly point me to some documentation I probably missed if I am going about this all wrong.
I did a quick search for strictMode, contribute, version, pull request, ATTR_SERVER_VERSION. I did not find a similar discussion.
#32708 - PR that introduce explicit override as workaround
The following change is what I propose because it provides me the correct server version:
diff --git a/src/Illuminate/Database/Connectors/MySqlConnector.php b/src/Illuminate/Database/Connectors/MySqlConnector.php
index a7640859d7..8affc87e01 100755
--- a/src/Illuminate/Database/Connectors/MySqlConnector.php
+++ b/src/Illuminate/Database/Connectors/MySqlConnector.php
@@ -197,7 +197,7 @@ protected function setCustomModes(PDO $connection, array $config)
*/
protected function strictMode(PDO $connection, $config)
{
- $version = $config['version'] ?? $connection->getAttribute(PDO::ATTR_SERVER_VERSION);
+ $version = $config['version'] ?? $connection->query('select version()')->fetchColumn();
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions