Convert Postgres, Oracle and SQL Server increment_by & min_value to int when creating Sequence

parent cc7bec25
......@@ -303,8 +303,8 @@ class OracleSchemaManager extends AbstractSchemaManager
return new Sequence(
$this->getQuotedIdentifierName($sequence['sequence_name']),
$sequence['increment_by'],
$sequence['min_value']
(int) $sequence['increment_by'],
(int) $sequence['min_value']
);
}
......
......@@ -311,7 +311,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$sequence += $data;
}
return new Sequence($sequenceName, $sequence['increment_by'], $sequence['min_value']);
return new Sequence($sequenceName, (int) $sequence['increment_by'], (int) $sequence['min_value']);
}
/**
......
......@@ -76,7 +76,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
*/
protected function _getPortableSequenceDefinition($sequence)
{
return new Sequence($sequence['name'], $sequence['increment'], $sequence['start_value']);
return new Sequence($sequence['name'], (int) $sequence['increment'], (int) $sequence['start_value']);
}
/**
......
......@@ -123,7 +123,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$name = 'dropcreate_sequences_test_seq';
$this->_sm->dropAndCreateSequence(new \Doctrine\DBAL\Schema\Sequence($name, 20, 10));
$this->_sm->dropAndCreateSequence(new Sequence($name, 20, 10));
self::assertTrue($this->hasElementWithName($this->_sm->listSequences(), $name));
}
......@@ -142,11 +142,11 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
public function testListSequences()
{
if(!$this->_conn->getDatabasePlatform()->supportsSequences()) {
$this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.');
if (! $this->_conn->getDatabasePlatform()->supportsSequences()) {
$this->markTestSkipped($this->_conn->getDriver()->getName() . ' does not support sequences.');
}
$sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10);
$sequence = new Sequence('list_sequences_test_seq', 20, 10);
$this->_sm->createSequence($sequence);
$sequences = $this->_sm->listSequences();
......@@ -154,16 +154,18 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
self::assertInternalType('array', $sequences, 'listSequences() should return an array.');
$foundSequence = null;
foreach($sequences as $sequence) {
self::assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $sequence, 'Array elements of listSequences() should be Sequence instances.');
if(strtolower($sequence->getName()) == 'list_sequences_test_seq') {
$foundSequence = $sequence;
foreach ($sequences as $sequence) {
self::assertInstanceOf(Sequence::class, $sequence, 'Array elements of listSequences() should be Sequence instances.');
if (strtolower($sequence->getName()) !== 'list_sequences_test_seq') {
continue;
}
$foundSequence = $sequence;
}
self::assertNotNull($foundSequence, "Sequence with name 'list_sequences_test_seq' was not found.");
self::assertEquals(20, $foundSequence->getAllocationSize(), "Allocation Size is expected to be 20.");
self::assertEquals(10, $foundSequence->getInitialValue(), "Initial Value is expected to be 10.");
self::assertSame(20, $foundSequence->getAllocationSize(), 'Allocation Size is expected to be 20.');
self::assertSame(10, $foundSequence->getInitialValue(), 'Initial Value is expected to be 10.');
}
public function testListDatabases()
......
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