Skip to content

Commit

Permalink
Prefer the term "constraint" over "fk"
Browse files Browse the repository at this point in the history
  • Loading branch information
HavokInspiration committed Jun 17, 2015
1 parent d485e31 commit c0a96b6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Database/Schema/BaseSchema.php
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schema/MysqlSchema.php
Expand Up @@ -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'])
);
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schema/PostgresSchema.php
Expand Up @@ -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'])
);
Expand Down
10 changes: 5 additions & 5 deletions src/Database/Schema/SqliteSchema.php
Expand Up @@ -29,7 +29,7 @@ class SqliteSchema extends BaseSchema
*
* @var array
*/
protected $_fkIdMap = [];
protected $_constraint = [];

/**
* Convert a column definition to the abstract types.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'])
);
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schema/SqlserverSchema.php
Expand Up @@ -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'])
);
Expand Down

0 comments on commit c0a96b6

Please sign in to comment.