1
0
mirror of synced 2025-01-07 09:37:11 +03:00

Merge pull request #752 from doctrine/PgSqlSchemaFix

ORM side fixes.
This commit is contained in:
Guilherme Blanco 2013-08-08 19:43:53 -07:00
commit 7853fb8529
2 changed files with 7 additions and 5 deletions

View File

@ -9,8 +9,10 @@ require_once __DIR__ . '/../../../TestInit.php';
class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
protected function setUp() { protected function setUp()
{
parent::setUp(); parent::setUp();
if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') {
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of postgresql.'); $this->markTestSkipped('The ' . __CLASS__ .' requires the use of postgresql.');
} }
@ -19,6 +21,7 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testPostgresMetadataSequenceIncrementedBy10() public function testPostgresMetadataSequenceIncrementedBy10()
{ {
$address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); $address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
$this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']);
} }
@ -97,7 +100,9 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$sql = $tool->getDropSchemaSQL($classes); $sql = $tool->getDropSchemaSQL($classes);
$this->assertEquals(14, count($sql)); $this->assertEquals(14, count($sql));
$dropSequenceSQLs = 0; $dropSequenceSQLs = 0;
foreach ($sql AS $stmt) { foreach ($sql AS $stmt) {
if (strpos($stmt, "DROP SEQUENCE") === 0) { if (strpos($stmt, "DROP SEQUENCE") === 0) {
$dropSequenceSQLs++; $dropSequenceSQLs++;
@ -115,10 +120,6 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Screen'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Screen'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Avatar'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Avatar'),
); );
try {
$this->_em->getConnection()->exec("CREATE SCHEMA stonewood");
} catch(\Exception $e) {
}
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
$tool->createSchema($classes); $tool->createSchema($classes);

View File

@ -20,6 +20,7 @@ class DDC1360Test extends OrmFunctionalTestCase
)); ));
$this->assertEquals(array( $this->assertEquals(array(
'CREATE SCHEMA "user"',
'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))', 'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))',
'CREATE SEQUENCE "user"."user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', 'CREATE SEQUENCE "user"."user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1',
), $sql); ), $sql);