Commit cb38ff56 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Modified createTable to not create IDENTITY colums for child tables

parent 976bb410
......@@ -21,7 +21,7 @@ namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Index,Doctrine\DBAL\Schema\Table;
/**
* The MsSqlPlatform provides the behavior, features and SQL dialect of the
......@@ -150,6 +150,34 @@ DROP DATABASE ' . $name . ';';
/**
* @override
*/
public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
{
$sql = parent::getCreateTableSQL($table, $createFlags);
$primary = array();
foreach ($table->getIndexes() AS $index) {
/* @var $index Index */
if ($index->isPrimary()) {
$primary = $index->getColumns();
}
}
if (count($primary) === 1) {
foreach ($table->getForeignKeys() AS $definition) {
$columns = $definition->getLocalColumns();
if (count($columns) === 1 && in_array($columns[0], $primary)) {
$sql[0] = str_replace(' IDENTITY', '', $sql[0]);
}
}
}
return $sql;
}
/**
* @override
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = array())
{
......
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