Skip to content

Commit

Permalink
Added compatibility with MySQL 8.0.11 (GA)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopedra committed Apr 22, 2018
1 parent 0c6f474 commit 2f772af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Illuminate/Database/Connectors/MySqlConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function setModes(PDO $connection, array $config)
$this->setCustomModes($connection, $config);
} elseif (isset($config['strict'])) {
if ($config['strict']) {
$connection->prepare($this->strictMode())->execute();
$connection->prepare($this->strictMode($connection))->execute();
} else {
$connection->prepare("set session sql_mode='NO_ENGINE_SUBSTITUTION'")->execute();
}
Expand All @@ -171,10 +171,16 @@ protected function setCustomModes(PDO $connection, array $config)
/**
* Get the query to enable strict mode.
*
* @param \PDO $connection
*
* @return string
*/
protected function strictMode()
protected function strictMode(PDO $connection)
{
if (version_compare($connection->getAttribute(PDO::ATTR_SERVER_VERSION), '8.0.11') >= 0) {
return "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
}

return "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
}
}

0 comments on commit 2f772af

Please sign in to comment.