Merge remote-tracking branch 'bantu/ticket/10327' into develop-olympus

* bantu/ticket/10327:
  [ticket/10327] Use $this->tools instead of creating a new instance of db_tools.
  [ticket/10327] Also change CREATE UNIQUE INDEX to use ALTER TABLE.
This commit is contained in:
Igor Wiedler 2011-10-14 17:50:08 +02:00
commit cafefe9379
2 changed files with 4 additions and 11 deletions

View file

@ -2115,7 +2115,7 @@ class phpbb_db_tools
case 'mysql_40': case 'mysql_40':
case 'mysql_41': case 'mysql_41':
$statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; $statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX (' . implode(', ', $column) . ')';
break; break;
case 'mssql': case 'mssql':

View file

@ -351,19 +351,12 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_index_exists() public function test_index_exists()
{ {
$db_tools = new phpbb_db_tools($this->db); $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_simple'));
$this->assertTrue($db_tools->sql_index_exists('prefix_table_name', 'i_simple'));
} }
public function test_create_index_against_index_exists() public function test_create_index_against_index_exists()
{ {
$db_tools = new phpbb_db_tools($this->db); $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'));
$table_name = 'prefix_table_name';
$index_name = 'fookey';
$db_tools->sql_create_index($table_name, $index_name, array('c_timestamp', 'c_decimal'));
$this->assertTrue($db_tools->sql_index_exists($table_name, $index_name));
} }
} }