Commit 255c396d authored by Steve Müller's avatar Steve Müller

use identity sequence name for generating SQL to drop an autoincrement from a column

parent e03569fa
......@@ -533,14 +533,16 @@ END;';
public function getDropAutoincrementSql($table)
{
$table = $this->normalizeIdentifier($table);
$quotedTableName = $table->getQuotedName($this);
$unquotedTableName = $table->getName();
$autoincrementIdentifierName = $this->getAutoincrementIdentifierName($table);
$identitySequenceName = $this->getIdentitySequenceName(
$table->isQuoted() ? $table->getQuotedName($this) : $table->getName(),
''
);
return array(
'DROP TRIGGER ' . $autoincrementIdentifierName,
$this->getDropSequenceSQL($unquotedTableName . '_SEQ'), // todo: needs to be fixed
$this->getDropConstraintSQL($autoincrementIdentifierName, $quotedTableName),
$this->getDropSequenceSQL($identitySequenceName),
$this->getDropConstraintSQL($autoincrementIdentifierName, $table->getQuotedName($this)),
);
}
......
......@@ -506,4 +506,43 @@ class OraclePlatformTest extends AbstractPlatformTestCase
'ALTER TABLE foo RENAME COLUMN bar TO baz',
);
}
/**
* @dataProvider getReturnsDropAutoincrementSQL
* @group DBAL-831
*/
public function testReturnsDropAutoincrementSQL($table, $expectedSql)
{
$this->assertSame($expectedSql, $this->_platform->getDropAutoincrementSql($table));
}
public function getReturnsDropAutoincrementSQL()
{
return array(
array(
'myTable',
array(
'DROP TRIGGER MYTABLE_AI_PK',
'DROP SEQUENCE MYTABLE_SEQ',
'ALTER TABLE MYTABLE DROP CONSTRAINT MYTABLE_AI_PK',
)
),
array(
'"myTable"',
array(
'DROP TRIGGER "myTable_AI_PK"',
'DROP SEQUENCE "myTable_SEQ"',
'ALTER TABLE "myTable" DROP CONSTRAINT "myTable_AI_PK"',
)
),
array(
'table',
array(
'DROP TRIGGER TABLE_AI_PK',
'DROP SEQUENCE TABLE_SEQ',
'ALTER TABLE "TABLE" DROP CONSTRAINT TABLE_AI_PK',
)
),
);
}
}
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