Unverified Commit 642fc86e authored by Simon Podlipsky's avatar Simon Podlipsky Committed by Sergei Morozov

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

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