Skip to content

Commit

Permalink
feat(GfuKiQDV): unnecessary 'ALTER TABLE' without instructions in the…
Browse files Browse the repository at this point in the history
… end of SQL

This leads to exception in Mysqli driver
  • Loading branch information
misha-rollun committed Jun 24, 2024
1 parent 2e6580b commit 0a0acbb
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/DataStore/src/TableGateway/TableManagerMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ public function getTableConfig($tableConfig)
*/
protected function create($tableName, $tableConfig = null)
{
$tableConfig = is_null($tableConfig) ? $tableConfig = $tableName : $tableConfig;
$tableConfig = is_null($tableConfig) ? $tableName : $tableConfig;
$createTable = $this->createCreateTable($tableName, $this->getTableConfig($tableConfig));
$sql = $this->getCreateTableSql($createTable, $tableName);
$sql = $this->getCreateTableSql($createTable);

return $this->db->query($sql, Adapter\Adapter::QUERY_MODE_EXECUTE);
}
Expand Down Expand Up @@ -452,7 +452,7 @@ protected function createCreateTable(string $tableName, array $tableConfig): Cre
return $createTable;
}

protected function getCreateTableSql(CreateTable $createTable, string $tableName): string
protected function getCreateTableSql(CreateTable $createTable): string
{
$createTableDecorator = new Sql\Platform\Mysql\Ddl\CreateTableDecorator();
$mySqlPlatformDbAdapter = new Adapter\Platform\Mysql();
Expand All @@ -463,11 +463,7 @@ protected function getCreateTableSql(CreateTable $createTable, string $tableName
$sqlCreateTable = $createTableDecorator->setSubject($createTable)
->getSqlString($mySqlPlatformDbAdapter);

$mySqlPlatformSql = new Sql\Platform\Mysql\Mysql();
$sql = new Sql\Sql($this->db, null, $mySqlPlatformSql);
$sqlAlterTable = $sql->buildSqlString(new AlterTable($tableName));

return "{$sqlCreateTable};" . PHP_EOL . "{$sqlAlterTable};";
return "$sqlCreateTable;" . PHP_EOL;
}

/**
Expand Down

0 comments on commit 0a0acbb

Please sign in to comment.