Skip to content

Commit

Permalink
Merge pull request doctrine#2715 from dhensby/pulls/fix-2714
Browse files Browse the repository at this point in the history
FIX Sequence::isAutoIncrementsFor now case insensitive
  • Loading branch information
deeky666 committed May 10, 2017
2 parents e98d241 + 106097a commit c48effb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/Sequence.php
Expand Up @@ -149,7 +149,7 @@ public function isAutoIncrementsFor(Table $table)

$sequenceName = $this->getShortestName($table->getNamespaceName());
$tableName = $table->getShortestName($table->getNamespaceName());
$tableSequenceName = sprintf('%s_%s_seq', $tableName, $pkColumns[0]);
$tableSequenceName = sprintf('%s_%s_seq', $tableName, $column->getShortestName($table->getNamespaceName()));

return $tableSequenceName === $sequenceName;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php
Expand Up @@ -24,5 +24,24 @@ public function testIsAutoincrementFor()
$this->assertFalse($sequence2->isAutoIncrementsFor($table));
$this->assertFalse($sequence3->isAutoIncrementsFor($table));
}

public function testIsAutoincrementForCaseInsensitive()
{
$table = new Table('foo');
$table->addColumn('ID', 'integer', array('autoincrement' => true));
$table->setPrimaryKey(array('ID'));

$sequence = new Sequence("foo_id_seq");
$sequence1 = new Sequence("foo_ID_seq");
$sequence2 = new Sequence("bar_id_seq");
$sequence3 = new Sequence("bar_ID_seq");
$sequence4 = new Sequence("other.foo_id_seq");

$this->assertTrue($sequence->isAutoIncrementsFor($table));
$this->assertTrue($sequence1->isAutoIncrementsFor($table));
$this->assertFalse($sequence2->isAutoIncrementsFor($table));
$this->assertFalse($sequence3->isAutoIncrementsFor($table));
$this->assertFalse($sequence4->isAutoIncrementsFor($table));
}
}

0 comments on commit c48effb

Please sign in to comment.