Commit 0e273a9c authored by Guilherme Blanco's avatar Guilherme Blanco

Normalized parameter name across platforms

parent 14dbd406
......@@ -489,18 +489,20 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
protected function _getCreateTableSQL($name, array $columns, array $options = [])
{
$indexes = [];
if (isset($options['indexes'])) {
$indexes = $options['indexes'];
}
$options['indexes'] = [];
$sqls = parent::_getCreateTableSQL($tableName, $columns, $options);
$sqls = parent::_getCreateTableSQL($name, $columns, $options);
foreach ($indexes as $definition) {
$sqls[] = $this->getCreateIndexSQL($definition, $tableName);
$sqls[] = $this->getCreateIndexSQL($definition, $name);
}
return $sqls;
......
......@@ -418,20 +418,20 @@ SQL
/**
* {@inheritDoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
protected function _getCreateTableSQL($name, array $columns, array $options = [])
{
$queryFields = $this->getColumnDeclarationListSQL($columns);
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
foreach ($options['uniqueConstraints'] as $name => $definition) {
$queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition);
foreach ($options['uniqueConstraints'] as $constraintName => $definition) {
$queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($constraintName, $definition);
}
}
// add all indexes
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $name => $definition) {
$queryFields .= ', ' . $this->getIndexDeclarationSQL($name, $definition);
foreach ($options['indexes'] as $indexName => $definition) {
$queryFields .= ', ' . $this->getIndexDeclarationSQL($indexName, $definition);
}
}
......@@ -447,7 +447,7 @@ SQL
$query .= 'TEMPORARY ';
}
$query .= 'TABLE ' . $tableName . ' (' . $queryFields . ') ';
$query .= 'TABLE ' . $name . ' (' . $queryFields . ') ';
$query .= $this->buildTableOptions($options);
$query .= $this->buildPartitionOptions($options);
......@@ -461,7 +461,7 @@ SQL
// Propagate foreign key constraints only for InnoDB.
if (isset($options['foreignKeys']) && $engine === 'INNODB') {
foreach ((array) $options['foreignKeys'] as $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
$sql[] = $this->getCreateForeignKeySQL($definition, $name);
}
}
......
......@@ -380,13 +380,13 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
protected function _getCreateTableSQL($name, array $columns, array $options = [])
{
$indexes = $options['indexes'] ?? [];
$options['indexes'] = [];
$sql = parent::_getCreateTableSQL($tableName, $columns, $options);
$sql = parent::_getCreateTableSQL($name, $columns, $options);
foreach ($columns as $name => $column) {
foreach ($columns as $columnName => $column) {
if (isset($column['sequence'])) {
$sql[] = $this->getCreateSequenceSQL($column['sequence']);
}
......@@ -396,12 +396,12 @@ class OraclePlatform extends AbstractPlatform
continue;
}
$sql = array_merge($sql, $this->getCreateAutoincrementSql($name, $tableName));
$sql = array_merge($sql, $this->getCreateAutoincrementSql($columnName, $name));
}
if (isset($indexes) && ! empty($indexes)) {
foreach ($indexes as $index) {
$sql[] = $this->getCreateIndexSQL($index, $tableName);
$sql[] = $this->getCreateIndexSQL($index, $name);
}
}
......
......@@ -776,7 +776,7 @@ SQL
/**
* {@inheritDoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
protected function _getCreateTableSQL($name, array $columns, array $options = [])
{
$queryFields = $this->getColumnDeclarationListSQL($columns);
......@@ -785,19 +785,19 @@ SQL
$queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
}
$query = 'CREATE TABLE ' . $tableName . ' (' . $queryFields . ')';
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
$sql = [$query];
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index) {
$sql[] = $this->getCreateIndexSQL($index, $tableName);
$sql[] = $this->getCreateIndexSQL($index, $name);
}
}
if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] as $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
$sql[] = $this->getCreateForeignKeySQL($definition, $name);
}
}
......
......@@ -1292,21 +1292,21 @@ SQL
/**
* {@inheritdoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
protected function _getCreateTableSQL($name, array $columns, array $options = [])
{
$columnListSql = $this->getColumnDeclarationListSQL($columns);
$indexSql = [];
if (! empty($options['uniqueConstraints'])) {
foreach ((array) $options['uniqueConstraints'] as $name => $definition) {
$columnListSql .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition);
foreach ((array) $options['uniqueConstraints'] as $constraintName => $definition) {
$columnListSql .= ', ' . $this->getUniqueConstraintDeclarationSQL($constraintName, $definition);
}
}
if (! empty($options['indexes'])) {
/** @var Index $index */
foreach ((array) $options['indexes'] as $index) {
$indexSql[] = $this->getCreateIndexSQL($index, $tableName);
$indexSql[] = $this->getCreateIndexSQL($index, $name);
}
}
......@@ -1326,7 +1326,7 @@ SQL
}
}
$query = 'CREATE TABLE ' . $tableName . ' (' . $columnListSql;
$query = 'CREATE TABLE ' . $name . ' (' . $columnListSql;
$check = $this->getCheckDeclarationSQL($columns);
if (! empty($check)) {
......
......@@ -303,14 +303,14 @@ SQL
/**
* {@inheritDoc}
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = [])
protected function _getCreateTableSQL($name, array $columns, array $options = [])
{
$defaultConstraintsSql = [];
$commentsSql = [];
$tableComment = $options['comment'] ?? null;
if ($tableComment !== null) {
$commentsSql[] = $this->getCommentOnTableSQL($tableName, $tableComment);
$commentsSql[] = $this->getCommentOnTableSQL($name, $tableComment);
}
// @todo does other code breaks because of this?
......@@ -322,22 +322,22 @@ SQL
// Build default constraints SQL statements.
if (isset($column['default'])) {
$defaultConstraintsSql[] = 'ALTER TABLE ' . $tableName .
' ADD' . $this->getDefaultConstraintDeclarationSQL($tableName, $column);
$defaultConstraintsSql[] = 'ALTER TABLE ' . $name .
' ADD' . $this->getDefaultConstraintDeclarationSQL($name, $column);
}
if (empty($column['comment']) && ! is_numeric($column['comment'])) {
continue;
}
$commentsSql[] = $this->getCreateColumnCommentSQL($tableName, $column['name'], $column['comment']);
$commentsSql[] = $this->getCreateColumnCommentSQL($name, $column['name'], $column['comment']);
}
$columnListSql = $this->getColumnDeclarationListSQL($columns);
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
foreach ($options['uniqueConstraints'] as $name => $definition) {
$columnListSql .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition);
foreach ($options['uniqueConstraints'] as $constraintName => $definition) {
$columnListSql .= ', ' . $this->getUniqueConstraintDeclarationSQL($constraintName, $definition);
}
}
......@@ -349,25 +349,26 @@ SQL
$columnListSql .= ', PRIMARY KEY' . $flags . ' (' . implode(', ', array_unique(array_values($options['primary']))) . ')';
}
$query = 'CREATE TABLE ' . $tableName . ' (' . $columnListSql;
$query = 'CREATE TABLE ' . $name . ' (' . $columnListSql;
$check = $this->getCheckDeclarationSQL($columns);
if (! empty($check)) {
$query .= ', ' . $check;
}
$query .= ')';
$sql = [$query];
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index) {
$sql[] = $this->getCreateIndexSQL($index, $tableName);
$sql[] = $this->getCreateIndexSQL($index, $name);
}
}
if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] as $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
$sql[] = $this->getCreateForeignKeySQL($definition, $name);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment