mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-29 12:43:15 +01:00
[ticket/15055] Only drop dependent PK indexes and fix more tests for mssql
PHPBB3-15055
This commit is contained in:
parent
f4381a20d4
commit
400fc0f73d
@ -706,7 +706,8 @@ class mssql extends tools
|
||||
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
|
||||
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name
|
||||
WHERE tc.TABLE_NAME = '{$table_name}'
|
||||
AND tc.CONSTRAINT_TYPE = 'Primary Key'";
|
||||
AND tc.CONSTRAINT_TYPE = 'Primary Key'
|
||||
AND ccu.COLUMN_NAME = '{$column_name}'";
|
||||
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
|
@ -462,7 +462,10 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||
// Index name has > 30 chars - that should not be possible.
|
||||
$too_long_index_name = str_repeat('i', 31);
|
||||
$this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name));
|
||||
$this->setExpectedTriggerError(E_USER_ERROR);
|
||||
if (strpos($this->tools->sql_layer, 'mssql') === false)
|
||||
{
|
||||
$this->setExpectedTriggerError(E_USER_ERROR);
|
||||
}
|
||||
$this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp'));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_groups">
|
||||
<column>group_id</column>
|
||||
<column>group_name</column>
|
||||
<column>group_desc</column>
|
||||
<row>
|
||||
<value>10</value>
|
||||
<value>foobar_group</value>
|
||||
<value>test123</value>
|
||||
</row>
|
||||
|
@ -515,35 +515,44 @@
|
||||
</table>
|
||||
<table name="phpbb_privmsgs_folder">
|
||||
<column>user_id</column>
|
||||
<column>folder_id</column>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_privmsgs_rules">
|
||||
<column>user_id</column>
|
||||
<column>rule_string</column>
|
||||
<column>rule_id</column>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value></value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value></value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_drafts">
|
||||
<column>user_id</column>
|
||||
<column>draft_message</column>
|
||||
<column>draft_id</column>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value></value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value></value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
||||
|
@ -29,6 +29,7 @@
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_notifications">
|
||||
<column>notification_id</column>
|
||||
<column>notification_type_id</column>
|
||||
<column>user_id</column>
|
||||
<column>item_id</column>
|
||||
@ -36,6 +37,7 @@
|
||||
<column>notification_read</column>
|
||||
<column>notification_data</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
|
@ -21,6 +21,7 @@
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_notifications">
|
||||
<column>notification_id</column>
|
||||
<column>notification_type_id</column>
|
||||
<column>user_id</column>
|
||||
<column>item_id</column>
|
||||
@ -28,6 +29,7 @@
|
||||
<column>notification_read</column>
|
||||
<column>notification_data</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
@ -36,6 +38,7 @@
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>8</value>
|
||||
<value>1</value>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_notifications">
|
||||
<column>notification_id</column>
|
||||
<column>notification_type_id</column>
|
||||
<column>user_id</column>
|
||||
<column>item_id</column>
|
||||
@ -8,6 +9,7 @@
|
||||
<column>notification_read</column>
|
||||
<column>notification_data</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>6</value>
|
||||
<value>1</value>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_notifications">
|
||||
<column>notification_id</column>
|
||||
<column>notification_type_id</column>
|
||||
<column>user_id</column>
|
||||
<column>item_id</column>
|
||||
@ -8,6 +9,7 @@
|
||||
<column>notification_read</column>
|
||||
<column>notification_data</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
|
@ -21,6 +21,7 @@
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_notifications">
|
||||
<column>notification_id</column>
|
||||
<column>notification_type_id</column>
|
||||
<column>user_id</column>
|
||||
<column>item_id</column>
|
||||
@ -28,6 +29,7 @@
|
||||
<column>notification_read</column>
|
||||
<column>notification_data</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>8</value>
|
||||
<value>1</value>
|
||||
|
@ -108,7 +108,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
|
||||
$types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test');
|
||||
foreach ($types as $id => $type)
|
||||
{
|
||||
$this->db->sql_query('INSERT INTO phpbb_notification_types ' .
|
||||
$this->getConnection()->createQueryTable('insertNotification', 'INSERT INTO phpbb_notification_types ' .
|
||||
$this->db->sql_build_array('INSERT', array(
|
||||
'notification_type_id' => ($id + 1),
|
||||
'notification_type_name' => $type,
|
||||
|
@ -1,25 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
<column>post_username</column>
|
||||
<column>post_subject</column>
|
||||
<column>post_text</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>foo</value>
|
||||
<value>foo</value>
|
||||
<value>foo</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>bar</value>
|
||||
<value>bar</value>
|
||||
<value>bar</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>commonword</value>
|
||||
<value>commonword</value>
|
||||
<value>commonword</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>baaz</value>
|
||||
<value>baaz</value>
|
||||
<value>baaz</value>
|
||||
|
@ -151,6 +151,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
$db = $this->new_dbal();
|
||||
foreach ($this->fixture_xml_data as $key => $value)
|
||||
{
|
||||
/** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */
|
||||
$tableMetaData = $value->getTableMetaData();
|
||||
$columns = $tableMetaData->getColumns();
|
||||
$primaryKeys = $tableMetaData->getPrimaryKeys();
|
||||
|
||||
$sql = "SELECT COLUMN_NAME AS identity_column
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE COLUMNPROPERTY(object_id(TABLE_SCHEMA + '.' + TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1
|
||||
@ -159,8 +164,15 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
$result = $db->sql_query($sql);
|
||||
$identity_columns = $db->sql_fetchrowset($result);
|
||||
$has_default_identity = false;
|
||||
$add_primary_keys = false;
|
||||
foreach ($identity_columns as $column)
|
||||
{
|
||||
if (in_array($column['identity_column'], $columns) && !in_array($column['identity_column'], $primaryKeys))
|
||||
{
|
||||
$primaryKeys[] = $column['identity_column'];
|
||||
$add_primary_keys = true;
|
||||
}
|
||||
|
||||
if ($column['identity_column'] === 'mssqlindex')
|
||||
{
|
||||
$has_default_identity = true;
|
||||
@ -168,18 +180,22 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
}
|
||||
}
|
||||
|
||||
if ($has_default_identity)
|
||||
if ($has_default_identity || $add_primary_keys)
|
||||
{
|
||||
/** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */
|
||||
$tableMetaData = $value->getTableMetaData();
|
||||
$columns = $tableMetaData->getColumns();
|
||||
$columns[] = 'mssqlindex';
|
||||
$newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $tableMetaData->getPrimaryKeys());
|
||||
if ($has_default_identity)
|
||||
{
|
||||
$columns[] = 'mssqlindex';
|
||||
}
|
||||
|
||||
$newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $primaryKeys);
|
||||
$newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData);
|
||||
for ($i = 0; $i < $value->getRowCount(); $i++)
|
||||
{
|
||||
$dataRow = $value->getRow($i);
|
||||
$dataRow['mssqlindex'] = $i + 1;
|
||||
if ($has_default_identity)
|
||||
{
|
||||
$dataRow['mssqlindex'] = $i + 1;
|
||||
}
|
||||
$newTable->addRow($dataRow);
|
||||
}
|
||||
$newXmlData->addTable($newTable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user