Skip to content
Permalink
Browse files

Prefer the term "constraint" over "fk"

  • Loading branch information...
HavokInspiration committed Jun 16, 2015
1 parent d485e31 commit c0a96b66cb7b8304154f6dc054c37493a2156212
@@ -96,7 +96,7 @@ protected function _convertOnClause($clause)
* @param string|array $references The referenced columns of a foreign key constraint statement
* @return string
*/
protected function _convertFkColumnsReference($references)
protected function _convertConstraintColumns($references)
{
if (is_string($references)) {
return $this->_driver->quoteIdentifier($references);
@@ -422,7 +422,7 @@ protected function _keySql($prefix, $data)
' FOREIGN KEY (%s) REFERENCES %s (%s) ON UPDATE %s ON DELETE %s',
implode(', ', $columns),
$this->_driver->quoteIdentifier($data['references'][0]),
$this->_convertFkColumnsReference($data['references'][1]),
$this->_convertConstraintColumns($data['references'][1]),
$this->_foreignOnClause($data['update']),
$this->_foreignOnClause($data['delete'])
);
@@ -467,7 +467,7 @@ protected function _keySql($prefix, $data)
' FOREIGN KEY (%s) REFERENCES %s (%s) ON UPDATE %s ON DELETE %s DEFERRABLE INITIALLY IMMEDIATE',
implode(', ', $columns),
$this->_driver->quoteIdentifier($data['references'][0]),
$this->_convertFkColumnsReference($data['references'][1]),
$this->_convertConstraintColumns($data['references'][1]),
$this->_foreignOnClause($data['update']),
$this->_foreignOnClause($data['delete'])
);
@@ -29,7 +29,7 @@ class SqliteSchema extends BaseSchema
*
* @var array
*/
protected $_fkIdMap = [];
protected $_constraint = [];
/**
* Convert a column definition to the abstract types.
@@ -227,10 +227,10 @@ public function convertForeignKeyDescription(Table $table, $row)
'delete' => $this->_convertOnClause($delete),
];
if (isset($this->_fkIdMap[$table->name()][$row['id']])) {
$name = $this->_fkIdMap[$table->name()][$row['id']];
if (isset($this->_constraint[$table->name()][$row['id']])) {
$name = $this->_constraint[$table->name()][$row['id']];
} else {
$this->_fkIdMap[$table->name()][$row['id']] = $name;
$this->_constraint[$table->name()][$row['id']] = $name;
}
$table->addConstraint($name, $data);
@@ -335,7 +335,7 @@ public function constraintSql(Table $table, $name)
$clause = sprintf(
' REFERENCES %s (%s) ON UPDATE %s ON DELETE %s',
$this->_driver->quoteIdentifier($data['references'][0]),
$this->_convertFkColumnsReference($data['references'][1]),
$this->_convertConstraintColumns($data['references'][1]),
$this->_foreignOnClause($data['update']),
$this->_foreignOnClause($data['delete'])
);
@@ -419,7 +419,7 @@ protected function _keySql($prefix, $data)
' FOREIGN KEY (%s) REFERENCES %s (%s) ON UPDATE %s ON DELETE %s',
implode(', ', $columns),
$this->_driver->quoteIdentifier($data['references'][0]),
$this->_convertFkColumnsReference($data['references'][1]),
$this->_convertConstraintColumns($data['references'][1]),
$this->_foreignOnClause($data['update']),
$this->_foreignOnClause($data['delete'])
);

0 comments on commit c0a96b6

Please sign in to comment.
You can’t perform that action at this time.