Skip to content

Commit

Permalink
Merge remote-tracking branch 'github-bantu/ticket/10774' into develop…
Browse files Browse the repository at this point in the history
…-olympus

* github-bantu/ticket/10774:
  [ticket/10774] Correctly specify index name when creating unique index on MySQL.
  [ticket/10774] Add unit tests for UNIQUE index existence and creation.
  • Loading branch information
naderman committed Apr 9, 2012
2 parents 156ae40 + ef8160e commit ef297ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpBB/includes/db/db_tools.php
Expand Up @@ -2115,7 +2115,7 @@ function sql_create_unique_index($table_name, $index_name, $column)

case 'mysql_40':
case 'mysql_41':
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX (' . implode(', ', $column) . ')';
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')';
break;

case 'mssql':
Expand Down
11 changes: 11 additions & 0 deletions tests/dbal/db_tools_test.php
Expand Up @@ -354,9 +354,20 @@ public function test_index_exists()
$this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_simple'));
}

public function test_unique_index_exists()
{
$this->assertTrue($this->tools->sql_unique_index_exists('prefix_table_name', 'i_uniq'));
}

public function test_create_index_against_index_exists()
{
$this->tools->sql_create_index('prefix_table_name', 'fookey', array('c_timestamp', 'c_decimal'));
$this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'fookey'));
}

public function test_create_unique_index_against_unique_index_exists()
{
$this->tools->sql_create_unique_index('prefix_table_name', 'i_uniq_ts_id', array('c_timestamp', 'c_id'));
$this->assertTrue($this->tools->sql_unique_index_exists('prefix_table_name', 'i_uniq_ts_id'));
}
}

0 comments on commit ef297ec

Please sign in to comment.