Skip to content
Snippets Groups Projects
Commit 2e86ad31 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #826668 by Damien Tournoud: db_add_field() will not accept 'foreign...

- Patch #826668 by Damien Tournoud: db_add_field() will not accept 'foreign keys' even though it is part of schema api.
parent 1ecf2d13
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -316,8 +316,8 @@ public function addField($table, $field, $spec, $keys_new = array()) { ...@@ -316,8 +316,8 @@ public function addField($table, $field, $spec, $keys_new = array()) {
} }
$query = 'ALTER TABLE {' . $table . '} ADD '; $query = 'ALTER TABLE {' . $table . '} ADD ';
$query .= $this->createFieldSql($field, $this->processField($spec)); $query .= $this->createFieldSql($field, $this->processField($spec));
if (count($keys_new)) { if ($keys_sql = $this->createKeysSql($keys_new)) {
$query .= ', ADD ' . implode(', ADD ', $this->createKeysSql($keys_new)); $query .= ', ADD ' . implode(', ADD ', $keys_sql);
} }
$this->connection->query($query); $this->connection->query($query);
if (isset($spec['initial'])) { if (isset($spec['initial'])) {
...@@ -439,8 +439,8 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array ...@@ -439,8 +439,8 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array
} }
$sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec)); $sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec));
if (count($keys_new)) { if ($keys_sql = $this->createKeysSql($keys_new)) {
$sql .= ', ADD ' . implode(', ADD ', $this->createKeysSql($keys_new)); $sql .= ', ADD ' . implode(', ADD ', $keys_sql);
} }
$this->connection->query($sql); $this->connection->query($sql);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment