Merge branch 'hotfix/#881-support-schema-on-platform-without-schema-emulation'
Close #881
This commit is contained in:
commit
1d4b96eed0
@ -1129,6 +1129,7 @@ Optional attributes:
|
|||||||
|
|
||||||
- **indexes**: Array of @Index annotations
|
- **indexes**: Array of @Index annotations
|
||||||
- **uniqueConstraints**: Array of @UniqueConstraint annotations.
|
- **uniqueConstraints**: Array of @UniqueConstraint annotations.
|
||||||
|
- **schema**: (>= 2.5) Name of the schema the table lies in.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -1140,6 +1141,7 @@ Example:
|
|||||||
* @Table(name="user",
|
* @Table(name="user",
|
||||||
* uniqueConstraints={@UniqueConstraint(name="user_unique",columns={"username"})},
|
* uniqueConstraints={@UniqueConstraint(name="user_unique",columns={"username"})},
|
||||||
* indexes={@Index(name="user_idx", columns={"email"})}
|
* indexes={@Index(name="user_idx", columns={"email"})}
|
||||||
|
* schema="schema_name"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
class User { }
|
class User { }
|
||||||
|
@ -241,6 +241,7 @@ General Getters
|
|||||||
|
|
||||||
|
|
||||||
- ``getTableName()``
|
- ``getTableName()``
|
||||||
|
- ``getSchemaName()``
|
||||||
- ``getTemporaryIdTableName()``
|
- ``getTemporaryIdTableName()``
|
||||||
|
|
||||||
Identifier Getters
|
Identifier Getters
|
||||||
|
@ -187,7 +187,7 @@ specified as the ``<entity />`` element as a direct child of the
|
|||||||
.. code-block:: xml
|
.. code-block:: xml
|
||||||
|
|
||||||
<doctrine-mapping>
|
<doctrine-mapping>
|
||||||
<entity name="MyProject\User" table="cms_users" repository-class="MyProject\UserRepository">
|
<entity name="MyProject\User" table="cms_users" schema="schema_name" repository-class="MyProject\UserRepository">
|
||||||
<!-- definition here -->
|
<!-- definition here -->
|
||||||
</entity>
|
</entity>
|
||||||
</doctrine-mapping>
|
</doctrine-mapping>
|
||||||
@ -211,6 +211,7 @@ Optional attributes:
|
|||||||
- **read-only** - (>= 2.1) Specifies that this entity is marked as read only and not
|
- **read-only** - (>= 2.1) Specifies that this entity is marked as read only and not
|
||||||
considered for change-tracking. Entities of this type can be persisted
|
considered for change-tracking. Entities of this type can be persisted
|
||||||
and removed though.
|
and removed though.
|
||||||
|
- **schema** - (>= 2.5) The schema the table lies in, for platforms that support schemas
|
||||||
|
|
||||||
Defining Fields
|
Defining Fields
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
|
@ -74,6 +74,7 @@ of several common elements:
|
|||||||
type: entity
|
type: entity
|
||||||
repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository
|
repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository
|
||||||
table: cms_users
|
table: cms_users
|
||||||
|
schema: schema_name # The schema the table lies in, for platforms that support schemas (Optional, >= 2.5)
|
||||||
readOnly: true
|
readOnly: true
|
||||||
indexes:
|
indexes:
|
||||||
name_index:
|
name_index:
|
||||||
|
@ -576,10 +576,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
|||||||
|
|
||||||
// Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
|
// Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
|
||||||
if ($this->targetPlatform->usesSequenceEmulatedIdentityColumns()) {
|
if ($this->targetPlatform->usesSequenceEmulatedIdentityColumns()) {
|
||||||
$columnName = $class->getSingleIdentifierColumnName();
|
$columnName = $class->getSingleIdentifierColumnName();
|
||||||
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
|
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
|
||||||
$sequenceName = $this->targetPlatform->getIdentitySequenceName($class->getTableName(), $columnName);
|
$sequencePrefix = $class->getSequencePrefix($this->targetPlatform);
|
||||||
$definition = array(
|
$sequenceName = $this->targetPlatform->getIdentitySequenceName($sequencePrefix, $columnName);
|
||||||
|
$definition = array(
|
||||||
'sequenceName' => $this->targetPlatform->fixSchemaElementName($sequenceName)
|
'sequenceName' => $this->targetPlatform->fixSchemaElementName($sequenceName)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -608,10 +609,10 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
|||||||
|
|
||||||
if ( ! $definition) {
|
if ( ! $definition) {
|
||||||
$fieldName = $class->getSingleIdentifierFieldName();
|
$fieldName = $class->getSingleIdentifierFieldName();
|
||||||
$columnName = $class->getSingleIdentifierColumnName();
|
$sequenceName = $class->getSequenceName($this->targetPlatform);
|
||||||
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
|
$quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
|
||||||
$sequenceName = $class->getTableName() . '_' . $columnName . '_seq';
|
|
||||||
$definition = array(
|
$definition = array(
|
||||||
'sequenceName' => $this->targetPlatform->fixSchemaElementName($sequenceName),
|
'sequenceName' => $this->targetPlatform->fixSchemaElementName($sequenceName),
|
||||||
'allocationSize' => 1,
|
'allocationSize' => 1,
|
||||||
'initialValue' => 1,
|
'initialValue' => 1,
|
||||||
|
@ -24,6 +24,7 @@ use Doctrine\Instantiator\Instantiator;
|
|||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||||
use Doctrine\Common\ClassLoader;
|
use Doctrine\Common\ClassLoader;
|
||||||
@ -2014,6 +2015,16 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
return $this->table['name'];
|
return $this->table['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets primary table's schema name.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getSchemaName()
|
||||||
|
{
|
||||||
|
return isset($this->table['schema']) ? $this->table['schema'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the table name to use for temporary identifier tables of this class.
|
* Gets the table name to use for temporary identifier tables of this class.
|
||||||
*
|
*
|
||||||
@ -2235,6 +2246,11 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
public function setPrimaryTable(array $table)
|
public function setPrimaryTable(array $table)
|
||||||
{
|
{
|
||||||
if (isset($table['name'])) {
|
if (isset($table['name'])) {
|
||||||
|
// Split schema and table name from a table name like "myschema.mytable"
|
||||||
|
if (strpos($table['name'], '.') !== false) {
|
||||||
|
list($this->table['schema'], $table['name']) = explode('.', $table['name'], 2);
|
||||||
|
}
|
||||||
|
|
||||||
if ($table['name'][0] === '`') {
|
if ($table['name'][0] === '`') {
|
||||||
$table['name'] = trim($table['name'], '`');
|
$table['name'] = trim($table['name'], '`');
|
||||||
$this->table['quoted'] = true;
|
$this->table['quoted'] = true;
|
||||||
@ -2243,6 +2259,10 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
$this->table['name'] = $table['name'];
|
$this->table['name'] = $table['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($table['schema'])) {
|
||||||
|
$this->table['schema'] = $table['schema'];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($table['indexes'])) {
|
if (isset($table['indexes'])) {
|
||||||
$this->table['indexes'] = $table['indexes'];
|
$this->table['indexes'] = $table['indexes'];
|
||||||
}
|
}
|
||||||
@ -3240,4 +3260,47 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
throw MappingException::duplicateFieldMapping($this->name, $fieldName);
|
throw MappingException::duplicateFieldMapping($this->name, $fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the sequence name based on class metadata.
|
||||||
|
*
|
||||||
|
* @param AbstractPlatform $platform
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @todo Sequence names should be computed in DBAL depending on the platform
|
||||||
|
*/
|
||||||
|
public function getSequenceName(AbstractPlatform $platform)
|
||||||
|
{
|
||||||
|
$sequencePrefix = $this->getSequencePrefix($platform);
|
||||||
|
|
||||||
|
$columnName = $this->getSingleIdentifierColumnName();
|
||||||
|
$sequenceName = $sequencePrefix . '_' . $columnName . '_seq';
|
||||||
|
|
||||||
|
return $sequenceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the sequence name prefix based on class metadata.
|
||||||
|
*
|
||||||
|
* @param AbstractPlatform $platform
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @todo Sequence names should be computed in DBAL depending on the platform
|
||||||
|
*/
|
||||||
|
public function getSequencePrefix(AbstractPlatform $platform)
|
||||||
|
{
|
||||||
|
$tableName = $this->getTableName();
|
||||||
|
$sequencePrefix = $tableName;
|
||||||
|
|
||||||
|
// Prepend the schema name to the table name if there is one
|
||||||
|
if ($schemaName = $this->getSchemaName()) {
|
||||||
|
$sequencePrefix = $schemaName . '.' . $tableName;
|
||||||
|
|
||||||
|
if ( ! $platform->supportsSchemas() && $platform->canEmulateSchemas()) {
|
||||||
|
$sequencePrefix = $schemaName . '__' . $tableName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sequencePrefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,24 @@ class DefaultQuoteStrategy implements QuoteStrategy
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @todo Table names should be computed in DBAL depending on the platform
|
||||||
*/
|
*/
|
||||||
public function getTableName(ClassMetadata $class, AbstractPlatform $platform)
|
public function getTableName(ClassMetadata $class, AbstractPlatform $platform)
|
||||||
{
|
{
|
||||||
return isset($class->table['quoted'])
|
$tableName = $class->table['name'];
|
||||||
? $platform->quoteIdentifier($class->table['name'])
|
|
||||||
: $class->table['name'];
|
if ( ! empty($class->table['schema'])) {
|
||||||
|
$tableName = $class->table['schema'] . '.' . $class->table['name'];
|
||||||
|
|
||||||
|
if ( ! $platform->supportsSchemas() && $platform->canEmulateSchemas()) {
|
||||||
|
$tableName = $class->table['schema'] . '__' . $class->table['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($class->table['quoted'])
|
||||||
|
? $platform->quoteIdentifier($tableName)
|
||||||
|
: $tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,9 +93,9 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
|||||||
|
|
||||||
// Evaluate Table annotation
|
// Evaluate Table annotation
|
||||||
if (isset($classAnnotations['Doctrine\ORM\Mapping\Table'])) {
|
if (isset($classAnnotations['Doctrine\ORM\Mapping\Table'])) {
|
||||||
$tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table'];
|
$tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table'];
|
||||||
$primaryTable = array(
|
$primaryTable = array(
|
||||||
'name' => $tableAnnot->name,
|
'name' => $tableAnnot->name,
|
||||||
'schema' => $tableAnnot->schema
|
'schema' => $tableAnnot->schema
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -76,12 +76,17 @@ class XmlDriver extends FileDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate <entity...> attributes
|
// Evaluate <entity...> attributes
|
||||||
$table = array();
|
$primaryTable = array();
|
||||||
|
|
||||||
if (isset($xmlRoot['table'])) {
|
if (isset($xmlRoot['table'])) {
|
||||||
$table['name'] = (string)$xmlRoot['table'];
|
$primaryTable['name'] = (string) $xmlRoot['table'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata->setPrimaryTable($table);
|
if (isset($xmlRoot['schema'])) {
|
||||||
|
$primaryTable['schema'] = (string) $xmlRoot['schema'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$metadata->setPrimaryTable($primaryTable);
|
||||||
|
|
||||||
// Evaluate second level cache
|
// Evaluate second level cache
|
||||||
if (isset($xmlRoot->cache)) {
|
if (isset($xmlRoot->cache)) {
|
||||||
@ -150,11 +155,6 @@ class XmlDriver extends FileDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not implemented specially anyway. use table = schema.table
|
|
||||||
if (isset($xmlRoot['schema'])) {
|
|
||||||
$metadata->table['schema'] = (string)$xmlRoot['schema'];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (isset($xmlRoot['inheritance-type'])) {
|
if (isset($xmlRoot['inheritance-type'])) {
|
||||||
$inheritanceType = (string)$xmlRoot['inheritance-type'];
|
$inheritanceType = (string)$xmlRoot['inheritance-type'];
|
||||||
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
|
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
|
||||||
|
@ -73,10 +73,14 @@ class YamlDriver extends FileDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate root level properties
|
// Evaluate root level properties
|
||||||
$table = array();
|
$primaryTable = array();
|
||||||
|
|
||||||
if (isset($element['table'])) {
|
if (isset($element['table'])) {
|
||||||
$table['name'] = $element['table'];
|
$primaryTable['name'] = $element['table'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($element['schema'])) {
|
||||||
|
$primaryTable['schema'] = $element['schema'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate second level cache
|
// Evaluate second level cache
|
||||||
@ -84,7 +88,7 @@ class YamlDriver extends FileDriver
|
|||||||
$metadata->enableCache($this->cacheToArray($element['cache']));
|
$metadata->enableCache($this->cacheToArray($element['cache']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata->setPrimaryTable($table);
|
$metadata->setPrimaryTable($primaryTable);
|
||||||
|
|
||||||
// Evaluate named queries
|
// Evaluate named queries
|
||||||
if (isset($element['namedQueries'])) {
|
if (isset($element['namedQueries'])) {
|
||||||
@ -163,11 +167,6 @@ class YamlDriver extends FileDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not implemented specially anyway. use table = schema.table
|
|
||||||
if (isset($element['schema'])) {
|
|
||||||
$metadata->table['schema'] = $element['schema'];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (isset($element['inheritanceType'])) {
|
if (isset($element['inheritanceType'])) {
|
||||||
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
|
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
|
||||||
|
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\Models\DDC2825;
|
||||||
|
|
||||||
|
/** @Entity @Table(name="explicit_table", schema="explicit_schema") */
|
||||||
|
class ExplicitSchemaAndTable
|
||||||
|
{
|
||||||
|
const CLASSNAME = __CLASS__;
|
||||||
|
|
||||||
|
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
|
||||||
|
public $id;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\Models\DDC2825;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quoted column name to check that sequence names are
|
||||||
|
* correctly handled
|
||||||
|
*
|
||||||
|
* @Entity @Table(name="implicit_schema.implicit_table")
|
||||||
|
*/
|
||||||
|
class SchemaAndTableInTableName
|
||||||
|
{
|
||||||
|
const CLASSNAME = __CLASS__;
|
||||||
|
|
||||||
|
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
|
||||||
|
public $id;
|
||||||
|
}
|
112
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php
Normal file
112
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Tools\ToolsException;
|
||||||
|
use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable;
|
||||||
|
use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class makes tests on the correct use of a database schema when entities are stored
|
||||||
|
*
|
||||||
|
* @group DDC-2825
|
||||||
|
*/
|
||||||
|
class DDC2825Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function setup()
|
||||||
|
{
|
||||||
|
parent::setup();
|
||||||
|
|
||||||
|
$platform = $this->_em->getConnection()->getDatabasePlatform();
|
||||||
|
|
||||||
|
if ( ! $platform->supportsSchemas() && ! $platform->canEmulateSchemas()) {
|
||||||
|
$this->markTestSkipped("This test is only useful for databases that support schemas or can emulate them.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getTestedClasses
|
||||||
|
*
|
||||||
|
* @param string $className
|
||||||
|
* @param string $expectedSchemaName
|
||||||
|
* @param string $expectedTableName
|
||||||
|
*/
|
||||||
|
public function testClassSchemaMappingsValidity($className, $expectedSchemaName, $expectedTableName)
|
||||||
|
{
|
||||||
|
$classMetadata = $this->_em->getClassMetadata($className);
|
||||||
|
$platform = $this->_em->getConnection()->getDatabasePlatform();
|
||||||
|
$quotedTableName = $this->_em->getConfiguration()->getQuoteStrategy()->getTableName($classMetadata, $platform);
|
||||||
|
|
||||||
|
// Check if table name and schema properties are defined in the class metadata
|
||||||
|
$this->assertEquals($expectedTableName, $classMetadata->table['name']);
|
||||||
|
$this->assertEquals($expectedSchemaName, $classMetadata->table['schema']);
|
||||||
|
|
||||||
|
if ($this->_em->getConnection()->getDatabasePlatform()->supportsSchemas()) {
|
||||||
|
$fullTableName = sprintf('%s.%s', $expectedSchemaName, $expectedTableName);
|
||||||
|
} else {
|
||||||
|
$fullTableName = sprintf('%s__%s', $expectedSchemaName, $expectedTableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($fullTableName, $quotedTableName);
|
||||||
|
|
||||||
|
// Checks sequence name validity
|
||||||
|
$this->assertEquals(
|
||||||
|
$fullTableName . '_' . $classMetadata->getSingleIdentifierColumnName() . '_seq',
|
||||||
|
$classMetadata->getSequenceName($platform)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getTestedClasses
|
||||||
|
*
|
||||||
|
* @param string $className
|
||||||
|
*/
|
||||||
|
public function testPersistenceOfEntityWithSchemaMapping($className)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->_schemaTool->createSchema(array($this->_em->getClassMetadata($className)));
|
||||||
|
} catch (ToolsException $e) {
|
||||||
|
// table already exists
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_em->persist(new $className());
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$this->assertCount(1, $this->_em->getRepository($className)->findAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider
|
||||||
|
*
|
||||||
|
* @return string[][]
|
||||||
|
*/
|
||||||
|
public function getTestedClasses()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(ExplicitSchemaAndTable::CLASSNAME, 'explicit_schema', 'explicit_table'),
|
||||||
|
array(SchemaAndTableInTableName::CLASSNAME, 'implicit_schema', 'implicit_table'),
|
||||||
|
array(DDC2825ClassWithImplicitlyDefinedSchemaAndQuotedTableName::CLASSNAME, 'myschema', 'order'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Entity
|
||||||
|
* @Table(name="myschema.order")
|
||||||
|
*/
|
||||||
|
class DDC2825ClassWithImplicitlyDefinedSchemaAndQuotedTableName
|
||||||
|
{
|
||||||
|
const CLASSNAME = __CLASS__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Id @GeneratedValue
|
||||||
|
* @Column(type="integer")
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
}
|
@ -9,6 +9,8 @@ use Doctrine\Tests\Models\Company\CompanyFlexContract;
|
|||||||
use Doctrine\Tests\Models\Cache\City;
|
use Doctrine\Tests\Models\Cache\City;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||||
|
use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable;
|
||||||
|
use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName;
|
||||||
|
|
||||||
abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||||
{
|
{
|
||||||
@ -932,6 +934,32 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']);
|
$this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']);
|
||||||
$this->assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']);
|
$this->assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-2825
|
||||||
|
* @group 881
|
||||||
|
*/
|
||||||
|
public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty()
|
||||||
|
{
|
||||||
|
/* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */
|
||||||
|
$metadata = $this->createClassMetadataFactory()->getMetadataFor(ExplicitSchemaAndTable::CLASSNAME);
|
||||||
|
|
||||||
|
$this->assertSame('explicit_schema', $metadata->getSchemaName());
|
||||||
|
$this->assertSame('explicit_table', $metadata->getTableName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-2825
|
||||||
|
* @group 881
|
||||||
|
*/
|
||||||
|
public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotationProperty()
|
||||||
|
{
|
||||||
|
/* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */
|
||||||
|
$metadata = $this->createClassMetadataFactory()->getMetadataFor(SchemaAndTableInTableName::CLASSNAME);
|
||||||
|
|
||||||
|
$this->assertSame('implicit_schema', $metadata->getSchemaName());
|
||||||
|
$this->assertSame('implicit_table', $metadata->getTableName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Mapping;
|
|||||||
|
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
use Doctrine\ORM\Events;
|
use Doctrine\ORM\Events;
|
||||||
|
use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable;
|
||||||
|
use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName;
|
||||||
|
|
||||||
class AnnotationDriverTest extends AbstractMappingDriverTest
|
class AnnotationDriverTest extends AbstractMappingDriverTest
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Mapping;
|
namespace Doctrine\Tests\ORM\Mapping;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata,
|
use Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver;
|
||||||
Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver,
|
|
||||||
Doctrine\ORM\Tools\Export\ClassMetadataExporter;
|
|
||||||
|
|
||||||
class StaticPHPMappingDriverTest extends AbstractMappingDriverTest
|
class StaticPHPMappingDriverTest extends AbstractMappingDriverTest
|
||||||
{
|
{
|
||||||
@ -23,4 +21,22 @@ class StaticPHPMappingDriverTest extends AbstractMappingDriverTest
|
|||||||
{
|
{
|
||||||
$this->createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class');
|
$this->createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-2825
|
||||||
|
* @group 881
|
||||||
|
*/
|
||||||
|
public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-2825
|
||||||
|
* @group 881
|
||||||
|
*/
|
||||||
|
public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotationProperty()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
|
|
||||||
|
/* @var $metadata ClassMetadata */
|
||||||
|
|
||||||
|
$metadata->setPrimaryTable(array(
|
||||||
|
'name' => 'explicit_table',
|
||||||
|
'schema' => 'explicit_schema',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'id' => true,
|
||||||
|
'fieldName' => 'id',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO);
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
|
|
||||||
|
/* @var $metadata ClassMetadata */
|
||||||
|
|
||||||
|
$metadata->setPrimaryTable(array(
|
||||||
|
'name' => 'implicit_schema.implicit_table',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'id' => true,
|
||||||
|
'fieldName' => 'id',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO);
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<doctrine-mapping
|
||||||
|
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||||
|
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd"
|
||||||
|
>
|
||||||
|
<entity name="Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable" table="explicit_table" schema="explicit_schema">
|
||||||
|
<id name="id" column="id">
|
||||||
|
<generator strategy="AUTO"/>
|
||||||
|
</id>
|
||||||
|
</entity>
|
||||||
|
</doctrine-mapping>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<doctrine-mapping
|
||||||
|
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||||
|
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd"
|
||||||
|
>
|
||||||
|
<entity name="Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName" table="implicit_schema.implicit_table">
|
||||||
|
<id name="id" column="id">
|
||||||
|
<generator strategy="AUTO"/>
|
||||||
|
</id>
|
||||||
|
</entity>
|
||||||
|
</doctrine-mapping>
|
@ -0,0 +1,8 @@
|
|||||||
|
Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable:
|
||||||
|
type: entity
|
||||||
|
table: explicit_table
|
||||||
|
schema: explicit_schema
|
||||||
|
id:
|
||||||
|
id:
|
||||||
|
generator:
|
||||||
|
strategy: AUTO
|
@ -0,0 +1,7 @@
|
|||||||
|
Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName:
|
||||||
|
type: entity
|
||||||
|
table: implicit_schema.implicit_table
|
||||||
|
id:
|
||||||
|
id:
|
||||||
|
generator:
|
||||||
|
strategy: AUTO
|
Loading…
x
Reference in New Issue
Block a user