Commit b4d9505b authored by Marius Meißner's avatar Marius Meißner

DBAL-#1234: Fixed bug that primary key is missing + added tests

parent e0169b2a
...@@ -443,7 +443,7 @@ class OraclePlatform extends AbstractPlatform ...@@ -443,7 +443,7 @@ class OraclePlatform extends AbstractPlatform
( (
SELECT ucon.constraint_type SELECT ucon.constraint_type
FROM user_constraints ucon FROM user_constraints ucon
WHERE ucon.constraint_name = uind_col.index_name WHERE ucon.index_name = uind_col.index_name
) AS is_primary ) AS is_primary
FROM user_ind_columns uind_col FROM user_ind_columns uind_col
WHERE uind_col.table_name = " . $table . " WHERE uind_col.table_name = " . $table . "
......
...@@ -232,6 +232,29 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -232,6 +232,29 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertCount(7, $columns); $this->assertCount(7, $columns);
} }
/**
* @group DBAL-1234
*/
public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName()
{
$table = new Table('list_table_indexes_pk_id_test');
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', ['notnull' => true]);
$table->addUniqueIndex(['id'], 'id_unique_index');
$this->_sm->dropAndCreateTable($table);
// Adding a primary key on already indexed columns
// Oracle will reuse the unique index, which cause a constraint name differing from the index name
$this->_sm->createConstraint(new Schema\Index('id_pk_id_index', ['id'], true, true), 'list_table_indexes_pk_id_test');
$tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_pk_id_test');
$this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
$this->assertEquals(['id'], array_map('strtolower', $tableIndexes['primary']->getColumns()));
$this->assertTrue($tableIndexes['primary']->isUnique());
$this->assertTrue($tableIndexes['primary']->isPrimary());
}
/** /**
* @group DBAL-2555 * @group DBAL-2555
*/ */
......
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