1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

[DBAL-204] Filter namespaced assets if Schemas/Emulation is not supported.

This commit is contained in:
Benjamin Eberlei 2012-01-21 11:29:48 +01:00
parent febfe35c23
commit 0f3abde413
3 changed files with 35 additions and 2 deletions

View file

@ -21,6 +21,8 @@ namespace Doctrine\ORM\Tools;
use Doctrine\ORM\ORMException, use Doctrine\ORM\ORMException,
Doctrine\DBAL\Types\Type, Doctrine\DBAL\Types\Type,
Doctrine\DBAL\Schema\Schema,
Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets,
Doctrine\ORM\EntityManager, Doctrine\ORM\EntityManager,
Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Internal\CommitOrderCalculator, Doctrine\ORM\Internal\CommitOrderCalculator,
@ -127,7 +129,7 @@ class SchemaTool
$sm = $this->_em->getConnection()->getSchemaManager(); $sm = $this->_em->getConnection()->getSchemaManager();
$metadataSchemaConfig = $sm->createSchemaConfig(); $metadataSchemaConfig = $sm->createSchemaConfig();
$metadataSchemaConfig->setExplicitForeignKeyIndexes(false); $metadataSchemaConfig->setExplicitForeignKeyIndexes(false);
$schema = new \Doctrine\DBAL\Schema\Schema(array(), array(), $metadataSchemaConfig); $schema = new Schema(array(), array(), $metadataSchemaConfig);
$evm = $this->_em->getEventManager(); $evm = $this->_em->getEventManager();
@ -252,6 +254,10 @@ class SchemaTool
} }
} }
if ( ! $this->_platform->supportsSchemas() && ! $this->_platform->canEmulateSchemas() ) {
$schema->visit(new RemoveNamespacedAssets());
}
if ($evm->hasListeners(ToolEvents::postGenerateSchema)) { if ($evm->hasListeners(ToolEvents::postGenerateSchema)) {
$evm->dispatchEvent(ToolEvents::postGenerateSchema, new GenerateSchemaEventArgs($this->_em, $schema)); $evm->dispatchEvent(ToolEvents::postGenerateSchema, new GenerateSchemaEventArgs($this->_em, $schema));
} }

@ -1 +1 @@
Subproject commit 29b714b7fe72641d749ae90324a5759853fe09b0 Subproject commit 480b127fb5c35d6fbd70964a228cd63cfe2b7e14

View file

@ -64,4 +64,31 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(1, count($sql)); $this->assertEquals(1, count($sql));
$this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); $this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]);
} }
/**
* @group DBAL-204
*/
public function testGetCreateSchemaSql4()
{
$classes = array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\MysqlSchemaNamespacedEntity')
);
$tool = new SchemaTool($this->_em);
$sql = $tool->getCreateSchemaSql($classes);
$this->assertEquals(0, count($sql));
}
} }
/**
* @Entity
* @Table("namespace.entity")
*/
class MysqlSchemaNamespacedEntity
{
/** @Column(type="integer") @Id @GeneratedValue */
public $id;
}