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