Commit 59d4e0c8 authored by Roman S. Borschel's avatar Roman S. Borschel

[DDC-481] Fixed.

parent dc3844e1
...@@ -279,7 +279,7 @@ class ClassMetadataFactory ...@@ -279,7 +279,7 @@ class ClassMetadataFactory
} }
if ($parent && $parent->isInheritanceTypeSingleTable()) { if ($parent && $parent->isInheritanceTypeSingleTable()) {
$class->setTableName($parent->getTableName()); $class->setPrimaryTable($parent->table);
} }
$class->setParentClasses($visited); $class->setParentClasses($visited);
......
...@@ -904,7 +904,7 @@ class ClassMetadataInfo ...@@ -904,7 +904,7 @@ class ClassMetadataInfo
* Sets the name of the primary table the class is mapped to. * Sets the name of the primary table the class is mapped to.
* *
* @param string $tableName The table name. * @param string $tableName The table name.
* @deprecated * @deprecated Use {@link setPrimaryTable}.
*/ */
public function setTableName($tableName) public function setTableName($tableName)
{ {
...@@ -912,18 +912,22 @@ class ClassMetadataInfo ...@@ -912,18 +912,22 @@ class ClassMetadataInfo
} }
/** /**
* Sets the primary table definition. The provided array must have the * Sets the primary table definition. The provided array supports the
* following structure: * following structure:
* *
* name => <tableName> * name => <tableName> (optional, defaults to class name)
* schema => <schemaName> * indexes => array of indexes (optional)
* catalog => <catalogName> * uniqueConstraints => array of constraints (optional)
* *
* @param array $primaryTableDefinition * @param array $table
*/ */
public function setPrimaryTable(array $primaryTableDefinition) public function setPrimaryTable(array $table)
{ {
$this->table = $primaryTableDefinition; if (isset($table['name']) && $table['name'][0] == '`') {
$table['name'] = trim($table['name'], '`');
$table['quoted'] = true;
}
$this->table = $table;
} }
/** /**
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -31,10 +29,7 @@ require __DIR__ . '/DoctrineAnnotations.php'; ...@@ -31,10 +29,7 @@ require __DIR__ . '/DoctrineAnnotations.php';
/** /**
* The AnnotationDriver reads the mapping metadata from docblock annotations. * The AnnotationDriver reads the mapping metadata from docblock annotations.
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com> * @author Jonathan H. Wage <jonwage@gmail.com>
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
...@@ -62,13 +62,16 @@ class XmlDriver extends AbstractFileDriver ...@@ -62,13 +62,16 @@ class XmlDriver extends AbstractFileDriver
} }
// Evaluate <entity...> attributes // Evaluate <entity...> attributes
$table = array();
if (isset($xmlRoot['table'])) { if (isset($xmlRoot['table'])) {
$metadata->table['name'] = (string)$xmlRoot['table']; $table['name'] = (string)$xmlRoot['table'];
} }
$metadata->setPrimaryTable($table);
/* not implemented specially anyway. use table = schema.table
if (isset($xmlRoot['schema'])) { if (isset($xmlRoot['schema'])) {
$metadata->table['schema'] = (string)$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'];
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -27,10 +25,7 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo, ...@@ -27,10 +25,7 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo,
/** /**
* The YamlDriver reads the mapping metadata from yaml schema files. * The YamlDriver reads the mapping metadata from yaml schema files.
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com> * @author Jonathan H. Wage <jonwage@gmail.com>
...@@ -61,13 +56,16 @@ class YamlDriver extends AbstractFileDriver ...@@ -61,13 +56,16 @@ class YamlDriver extends AbstractFileDriver
} }
// Evaluate root level properties // Evaluate root level properties
$table = array();
if (isset($element['table'])) { if (isset($element['table'])) {
$metadata->table['name'] = $element['table']; $table['name'] = $element['table'];
} }
$metadata->setPrimaryTable($table);
/* not implemented specially anyway. use table = schema.table
if (isset($element['schema'])) { if (isset($element['schema'])) {
$metadata->table['schema'] = $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'])));
......
...@@ -26,6 +26,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase ...@@ -26,6 +26,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
// Self-made metadata // Self-made metadata
$cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1');
$cm1->setPrimaryTable(array('name' => '`group`'));
// Add a mapped field // Add a mapped field
$cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar')); $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
// Add a mapped field // Add a mapped field
...@@ -54,6 +55,8 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase ...@@ -54,6 +55,8 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
// Go // Go
$cm1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1'); $cm1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1');
$this->assertEquals('group', $cm1->table['name']);
$this->assertTrue($cm1->table['quoted']);
$this->assertEquals(array(), $cm1->parentClasses); $this->assertEquals(array(), $cm1->parentClasses);
$this->assertTrue($cm1->hasField('name')); $this->assertTrue($cm1->hasField('name'));
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType); $this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType);
......
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