Merge branch 'DDC-631'
This commit is contained in:
commit
4705c1cb03
@ -106,21 +106,25 @@ class XmlDriver extends AbstractFileDriver
|
||||
|
||||
// Evaluate <indexes...>
|
||||
if (isset($xmlRoot->indexes)) {
|
||||
$metadata->table['indexes'] = array();
|
||||
foreach ($xmlRoot->indexes->index as $index) {
|
||||
if (is_string($index['columns'])) {
|
||||
$columns = explode(',', $index['columns']);
|
||||
} else {
|
||||
$columns = $index['columns'];
|
||||
}
|
||||
$columns = explode(',', (string)$index['columns']);
|
||||
|
||||
$metadata->table['indexes'][$index['name']] = array(
|
||||
'columns' => $columns
|
||||
);
|
||||
if (isset($index['name'])) {
|
||||
$metadata->table['indexes'][(string)$index['name']] = array(
|
||||
'columns' => $columns
|
||||
);
|
||||
} else {
|
||||
$metadata->table['indexes'][] = array(
|
||||
'columns' => $columns
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate <unique-constraints..>
|
||||
if (isset($xmlRoot->{'unique-constraints'})) {
|
||||
$metadata->table['uniqueConstraints'] = array();
|
||||
foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $unique) {
|
||||
$columns = explode(',', (string)$unique['columns']);
|
||||
|
||||
|
@ -36,6 +36,21 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testEntityTableNameAndInheritance
|
||||
* @param ClassMetadata $class
|
||||
*/
|
||||
public function testEntityIndexes($class)
|
||||
{
|
||||
$this->assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.');
|
||||
$this->assertEquals(array(
|
||||
'name_idx' => array('columns' => array('name')),
|
||||
0 => array('columns' => array('user_email'))
|
||||
), $class->table['indexes']);
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testEntityTableNameAndInheritance
|
||||
* @param ClassMetadata $class
|
||||
@ -240,7 +255,11 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
/**
|
||||
* @Entity
|
||||
* @HasLifecycleCallbacks
|
||||
* @Table(name="cms_users", uniqueConstraints={@UniqueConstraint(name="search_idx", columns={"name", "user_email"})})
|
||||
* @Table(
|
||||
* name="cms_users",
|
||||
* uniqueConstraints={@UniqueConstraint(name="search_idx", columns={"name", "user_email"})},
|
||||
* indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"})}
|
||||
* )
|
||||
*/
|
||||
class User
|
||||
{
|
||||
@ -411,6 +430,9 @@ class User
|
||||
$metadata->table['uniqueConstraints'] = array(
|
||||
'search_idx' => array('columns' => array('name', 'user_email')),
|
||||
);
|
||||
$metadata->table['indexes'] = array(
|
||||
'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email'))
|
||||
);
|
||||
$metadata->setSequenceGeneratorDefinition(array(
|
||||
'sequenceName' => 'tablename_seq',
|
||||
'allocationSize' => 100,
|
||||
|
@ -106,6 +106,9 @@ $metadata->mapManyToMany(array(
|
||||
$metadata->table['uniqueConstraints'] = array(
|
||||
'search_idx' => array('columns' => array('name', 'user_email')),
|
||||
);
|
||||
$metadata->table['indexes'] = array(
|
||||
'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email'))
|
||||
);
|
||||
$metadata->setSequenceGeneratorDefinition(array(
|
||||
'sequenceName' => 'tablename_seq',
|
||||
'allocationSize' => 100,
|
||||
|
@ -7,6 +7,11 @@
|
||||
|
||||
<entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users">
|
||||
|
||||
<indexes>
|
||||
<index name="name_idx" columns="name"/>
|
||||
<index columns="user_email"/>
|
||||
</indexes>
|
||||
|
||||
<unique-constraints>
|
||||
<unique-constraint columns="name,user_email" name="search_idx" />
|
||||
</unique-constraints>
|
||||
|
@ -59,3 +59,8 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
uniqueConstraints:
|
||||
search_idx:
|
||||
columns: name,user_email
|
||||
indexes:
|
||||
name_idx:
|
||||
columns: name
|
||||
0:
|
||||
columns: user_email
|
Loading…
Reference in New Issue
Block a user