[2.0] Fixed DDC-103 - Platform::getAlterTableSql() should return an array on all platforms, added doc-blocks on all methods and fixed some.
This commit is contained in:
parent
140f597e3b
commit
79f4fcb3c4
@ -645,15 +645,16 @@ abstract class AbstractPlatform
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sql for altering an existing table.
|
||||
* (this method is implemented by the drivers)
|
||||
* Gets the sql statements for altering an existing table.
|
||||
*
|
||||
* The method returns an array of sql statements, since some platforms need several statements.
|
||||
*
|
||||
* @param string $name name of the table that is intended to be changed.
|
||||
* @param array $changes associative array that contains the details of each type *
|
||||
* @param boolean $check indicates whether the function should just check if the DBMS driver
|
||||
* can perform the requested table alterations if the value is true or
|
||||
* actually perform them otherwise.
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function getAlterTableSql($name, array $changes, $check = false)
|
||||
{
|
||||
|
@ -88,6 +88,18 @@ class MsSqlPlatform extends AbstractPlatform
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sql statements for altering an existing table.
|
||||
*
|
||||
* The method returns an array of sql statements, since some platforms need several statements.
|
||||
*
|
||||
* @param string $name name of the table that is intended to be changed.
|
||||
* @param array $changes associative array that contains the details of each type *
|
||||
* @param boolean $check indicates whether the function should just check if the DBMS driver
|
||||
* can perform the requested table alterations if the value is true or
|
||||
* actually perform them otherwise.
|
||||
* @return array
|
||||
*/
|
||||
public function getAlterTableSql($name, array $changes, $check = false)
|
||||
{
|
||||
foreach ($changes as $changeName => $change) {
|
||||
@ -165,7 +177,7 @@ class MsSqlPlatform extends AbstractPlatform
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'ALTER TABLE ' . $name . ' ' . $query;
|
||||
return array('ALTER TABLE ' . $name . ' ' . $query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -655,7 +655,7 @@ class MySqlPlatform extends AbstractPlatform
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'ALTER TABLE ' . $name . ' ' . $query;
|
||||
return array('ALTER TABLE ' . $name . ' ' . $query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,6 +392,18 @@ END;';
|
||||
return 'DROP USER ' . $database . ' CASCADE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sql statements for altering an existing table.
|
||||
*
|
||||
* The method returns an array of sql statements, since some platforms need several statements.
|
||||
*
|
||||
* @param string $name name of the table that is intended to be changed.
|
||||
* @param array $changes associative array that contains the details of each type *
|
||||
* @param boolean $check indicates whether the function should just check if the DBMS driver
|
||||
* can perform the requested table alterations if the value is true or
|
||||
* actually perform them otherwise.
|
||||
* @return array
|
||||
*/
|
||||
public function getAlterTableSql($name, array $changes, $check = false)
|
||||
{
|
||||
if ( ! $name) {
|
||||
|
@ -656,7 +656,7 @@ class SchemaTool
|
||||
$joinColumn['type'] = Type::getType($joinColumn['type']);
|
||||
$changes['add'][$name] = $joinColumn;
|
||||
}
|
||||
$sql[] = $this->_platform->getAlterTableSql($tableName, $changes);
|
||||
$sql = array_merge($sql, $this->_platform->getAlterTableSql($tableName, $changes));
|
||||
}
|
||||
|
||||
// Update existent columns
|
||||
@ -670,7 +670,7 @@ class SchemaTool
|
||||
);
|
||||
}
|
||||
|
||||
$sql[] = $this->_platform->getAlterTableSql($tableName, $changes);
|
||||
$sql = array_merge($sql, $this->_platform->getAlterTableSql($tableName, $changes));
|
||||
}
|
||||
|
||||
// Drop any remaining columns
|
||||
@ -682,7 +682,7 @@ class SchemaTool
|
||||
$changes['remove'][$column['name']] = $column;
|
||||
}
|
||||
|
||||
$sql[] = $this->_platform->getAlterTableSql($tableName, $changes);
|
||||
$sql = array_merge($sql, $this->_platform->getAlterTableSql($tableName, $changes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,10 +50,11 @@ class MsSqlPlatformTest extends \Doctrine\Tests\DbalTestCase
|
||||
'unsigned' => 1
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
$this->assertEquals(
|
||||
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL',
|
||||
$this->_platform->getAlterTableSql('mytable', $changes)
|
||||
$sql[0]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,11 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase
|
||||
'unsigned' => 1
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
$this->assertEquals(
|
||||
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL',
|
||||
$this->_platform->getAlterTableSql('mytable', $changes)
|
||||
$sql[0]
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user