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

[DDC-481] Fixed.

parent dc3844e1
......@@ -277,9 +277,9 @@ class ClassMetadataFactory
} else {
$this->_completeIdGeneratorMapping($class);
}
if ($parent && $parent->isInheritanceTypeSingleTable()) {
$class->setTableName($parent->getTableName());
$class->setPrimaryTable($parent->table);
}
$class->setParentClasses($visited);
......
......@@ -903,8 +903,8 @@ class ClassMetadataInfo
/**
* Sets the name of the primary table the class is mapped to.
*
* @param string $tableName The table name.
* @deprecated
* @param string $tableName The table name.
* @deprecated Use {@link setPrimaryTable}.
*/
public function setTableName($tableName)
{
......@@ -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:
*
* name => <tableName>
* schema => <schemaName>
* catalog => <catalogName>
* name => <tableName> (optional, defaults to class name)
* indexes => array of indexes (optional)
* 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
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -31,14 +29,11 @@ require __DIR__ . '/DoctrineAnnotations.php';
/**
* 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
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class AnnotationDriver implements Driver
{
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
......@@ -62,13 +62,16 @@ class XmlDriver extends AbstractFileDriver
}
// Evaluate <entity...> attributes
$table = array();
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'])) {
$metadata->table['schema'] = (string)$xmlRoot['schema'];
}
}*/
if (isset($xmlRoot['inheritance-type'])) {
$inheritanceType = (string)$xmlRoot['inheritance-type'];
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -27,14 +25,11 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo,
/**
* 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
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class YamlDriver extends AbstractFileDriver
{
......@@ -61,13 +56,16 @@ class YamlDriver extends AbstractFileDriver
}
// Evaluate root level properties
$table = array();
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'])) {
$metadata->table['schema'] = $element['schema'];
}
}*/
if (isset($element['inheritanceType'])) {
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
......
......@@ -26,6 +26,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
// Self-made metadata
$cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1');
$cm1->setPrimaryTable(array('name' => '`group`'));
// Add a mapped field
$cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
// Add a mapped field
......@@ -54,6 +55,8 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
// Go
$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->assertTrue($cm1->hasField('name'));
$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