Commit 2e86ad31 authored by Dries's avatar Dries

- 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
......@@ -316,8 +316,8 @@ public function addField($table, $field, $spec, $keys_new = array()) {
}
$query = 'ALTER TABLE {' . $table . '} ADD ';
$query .= $this->createFieldSql($field, $this->processField($spec));
if (count($keys_new)) {
$query .= ', ADD ' . implode(', ADD ', $this->createKeysSql($keys_new));
if ($keys_sql = $this->createKeysSql($keys_new)) {
$query .= ', ADD ' . implode(', ADD ', $keys_sql);
}
$this->connection->query($query);
if (isset($spec['initial'])) {
......@@ -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));
if (count($keys_new)) {
$sql .= ', ADD ' . implode(', ADD ', $this->createKeysSql($keys_new));
if ($keys_sql = $this->createKeysSql($keys_new)) {
$sql .= ', ADD ' . implode(', ADD ', $keys_sql);
}
$this->connection->query($sql);
}
......
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