Commit 8a8c28c4 authored by alexpott's avatar alexpott

Issue #1224892 by iaine, lapistano, LinL, jonvk: Duplicate code in...

Issue #1224892 by iaine, lapistano, LinL, jonvk: Duplicate code in mysql/schema.inc (createKeySql = createKeysSqlHelper)
parent 737f04d8
......@@ -258,16 +258,16 @@ protected function createKeysSql($spec) {
$keys = array();
if (!empty($spec['primary key'])) {
$keys[] = 'PRIMARY KEY (' . $this->createKeysSqlHelper($spec['primary key']) . ')';
$keys[] = 'PRIMARY KEY (' . $this->createKeySql($spec['primary key']) . ')';
}
if (!empty($spec['unique keys'])) {
foreach ($spec['unique keys'] as $key => $fields) {
$keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeysSqlHelper($fields) . ')';
$keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeySql($fields) . ')';
}
}
if (!empty($spec['indexes'])) {
foreach ($spec['indexes'] as $index => $fields) {
$keys[] = 'INDEX `' . $index . '` (' . $this->createKeysSqlHelper($fields) . ')';
$keys[] = 'INDEX `' . $index . '` (' . $this->createKeySql($fields) . ')';
}
}
......@@ -287,19 +287,6 @@ protected function createKeySql($fields) {
return implode(', ', $return);
}
protected function createKeysSqlHelper($fields) {
$return = array();
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = '`' . $field[0] . '`(' . $field[1] . ')';
}
else {
$return[] = '`' . $field . '`';
}
}
return implode(', ', $return);
}
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
......
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