SQL error on MySQL8
Permalink Browser Info Environment
I got this error on MySQL8:
I fixed it by wrapping table names with ` to sanitize Groups.
Exception Occurred: /path/to/concrete/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:90 An exception occurred while executing 'RENAME TABLE groups TO groups_tmp;': SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups TO groups_tmp' at line 1 (0)
I fixed it by wrapping table names with ` to sanitize Groups.
public function getFixScriptRows($appendCorrect = false, $lowerToUpper = true) { $names = $this->getDatabaseTableNames(true); $currentTables = $this->getCurrentTables(); $rows = array(); foreach ($names as $tbl) { $migrateTbl = $lowerToUpper ? strtolower($tbl) : $tbl; $tbl = !$lowerToUpper ? strtolower($tbl) : $tbl; if ($appendCorrect || ($key = array_search($migrateTbl, $currentTables)) !== false) { $tmpName = $migrateTbl . "_tmp"; array_push($rows, "RENAME TABLE `" . $migrateTbl . "` TO `" . $tmpName . "`;"); if ($appendCorrect || ($key2 = array_search($tbl, $currentTables)) !== false) { array_push($rows, "DROP TABLE IF EXISTS `" . $tbl . "`;"); unset($currentTables[$key2]); }
Viewing 15 lines of 21 lines. View entire code block.
Type: | Discussion |
---|---|
Status: | New |