Skip to content

Commit

Permalink
[DBAL-204] Filter namespaced assets if Schemas/Emulation is not suppo…
Browse files Browse the repository at this point in the history
…rted.
  • Loading branch information
beberlei committed Jan 21, 2012
1 parent febfe35 commit 0f3abde
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/Doctrine/ORM/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

use Doctrine\ORM\ORMException,
Doctrine\DBAL\Types\Type,
Doctrine\DBAL\Schema\Schema,
Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets,
Doctrine\ORM\EntityManager,
Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Internal\CommitOrderCalculator,
Expand Down Expand Up @@ -127,7 +129,7 @@ public function getSchemaFromMetadata(array $classes)
$sm = $this->_em->getConnection()->getSchemaManager();
$metadataSchemaConfig = $sm->createSchemaConfig();
$metadataSchemaConfig->setExplicitForeignKeyIndexes(false);
$schema = new \Doctrine\DBAL\Schema\Schema(array(), array(), $metadataSchemaConfig);
$schema = new Schema(array(), array(), $metadataSchemaConfig);

$evm = $this->_em->getEventManager();

Expand Down Expand Up @@ -252,6 +254,10 @@ public function getSchemaFromMetadata(array $classes)
}
}

if ( ! $this->_platform->supportsSchemas() && ! $this->_platform->canEmulateSchemas() ) {
$schema->visit(new RemoveNamespacedAssets());
}

if ($evm->hasListeners(ToolEvents::postGenerateSchema)) {
$evm->dispatchEvent(ToolEvents::postGenerateSchema, new GenerateSchemaEventArgs($this->_em, $schema));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vendor/doctrine-dbal
Submodule doctrine-dbal updated 105 files
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,31 @@ public function testGetCreateSchemaSql3()
$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]);
}

/**
* @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;
}

0 comments on commit 0f3abde

Please sign in to comment.