Commit 7e0266c9 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #299 from deeky666/fix-sql-server-composite-foreign-keys

Fix list SQL Server composite foreign keys
parents eef9d760 1cb7827a
......@@ -109,6 +109,34 @@ class SQLServerSchemaManager extends AbstractSchemaManager
return $column;
}
/**
* {@inheritdoc}
*/
protected function _getPortableTableForeignKeysList($tableForeignKeys)
{
$foreignKeys = array();
foreach ($tableForeignKeys as $tableForeignKey) {
if ( ! isset($foreignKeys[$tableForeignKey['ForeignKey']])) {
$foreignKeys[$tableForeignKey['ForeignKey']] = array(
'local_columns' => array($tableForeignKey['ColumnName']),
'foreign_table' => $tableForeignKey['ReferenceTableName'],
'foreign_columns' => array($tableForeignKey['ReferenceColumnName']),
'name' => $tableForeignKey['ForeignKey'],
'options' => array(
'onUpdate' => str_replace('_', ' ', $tableForeignKey['update_referential_action_desc']),
'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc'])
)
);
} else {
$foreignKeys[$tableForeignKey['ForeignKey']]['local_columns'][] = $tableForeignKey['ColumnName'];
$foreignKeys[$tableForeignKey['ForeignKey']]['foreign_columns'][] = $tableForeignKey['ReferenceColumnName'];
}
}
return parent::_getPortableTableForeignKeysList($foreignKeys);
}
/**
* @override
*/
......@@ -167,19 +195,16 @@ class SQLServerSchemaManager extends AbstractSchemaManager
}
/**
* @override
* {@inheritdoc}
*/
public function _getPortableTableForeignKeyDefinition($tableForeignKey)
protected function _getPortableTableForeignKeyDefinition($tableForeignKey)
{
return new ForeignKeyConstraint(
(array) $tableForeignKey['ColumnName'],
$tableForeignKey['ReferenceTableName'],
(array) $tableForeignKey['ReferenceColumnName'],
$tableForeignKey['ForeignKey'],
array(
'onUpdate' => str_replace('_', ' ', $tableForeignKey['update_referential_action_desc']),
'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc']),
)
$tableForeignKey['local_columns'],
$tableForeignKey['foreign_table'],
$tableForeignKey['foreign_columns'],
$tableForeignKey['name'],
$tableForeignKey['options']
);
}
......
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