Added index flags test
This commit is contained in:
parent
b3a2988d2c
commit
32ed32cf56
@ -103,8 +103,11 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
foreach ($tableAnnot->indexes as $indexAnnot) {
|
||||
$index = array(
|
||||
'columns' => $indexAnnot->columns,
|
||||
'flags' => $indexAnnot->flags
|
||||
);
|
||||
|
||||
if( ! empty($indexAnnot->flags)) {
|
||||
$index['flags'] = $indexAnnot->flags;
|
||||
}
|
||||
|
||||
if ( ! empty($indexAnnot->name)) {
|
||||
$primaryTable['indexes'][$indexAnnot->name] = $index;
|
||||
|
@ -194,25 +194,21 @@ class XmlDriver extends FileDriver
|
||||
// Evaluate <indexes...>
|
||||
if (isset($xmlRoot->indexes)) {
|
||||
$metadata->table['indexes'] = array();
|
||||
foreach ($xmlRoot->indexes->index as $index) {
|
||||
$columns = explode(',', (string)$index['columns']);
|
||||
foreach ($xmlRoot->indexes->index as $indexXml) {
|
||||
$columns = explode(',', (string)$indexXml['columns']);
|
||||
|
||||
if( ! isset($index['flags'])) {
|
||||
$flags = array();
|
||||
} else {
|
||||
$flags = explode(',', (string)$index['flags']);
|
||||
$index = array(
|
||||
'columns' => $columns
|
||||
);
|
||||
|
||||
if( isset($indexXml['flags'])) {
|
||||
$index['flags'] = explode(',', (string)$indexXml['flags']);
|
||||
}
|
||||
|
||||
if (isset($index['name'])) {
|
||||
$metadata->table['indexes'][(string)$index['name']] = array(
|
||||
'columns' => $columns,
|
||||
'flags' => $flags
|
||||
);
|
||||
if (isset($indexXml['name'])) {
|
||||
$metadata->table['indexes'][(string)$indexXml['name']] = $index;
|
||||
} else {
|
||||
$metadata->table['indexes'][] = array(
|
||||
'columns' => $columns,
|
||||
'flags' => $flags
|
||||
);
|
||||
$metadata->table['indexes'][] = $index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,31 +201,32 @@ class YamlDriver extends FileDriver
|
||||
|
||||
// Evaluate indexes
|
||||
if (isset($element['indexes'])) {
|
||||
foreach ($element['indexes'] as $name => $index) {
|
||||
if ( ! isset($index['name'])) {
|
||||
$index['name'] = $name;
|
||||
foreach ($element['indexes'] as $name => $indexYml) {
|
||||
if ( ! isset($indexYml['name'])) {
|
||||
$indexYml['name'] = $name;
|
||||
}
|
||||
|
||||
if (is_string($index['columns'])) {
|
||||
$columns = explode(',', $index['columns']);
|
||||
if (is_string($indexYml['columns'])) {
|
||||
$columns = explode(',', $indexYml['columns']);
|
||||
$columns = array_map('trim', $columns);
|
||||
} else {
|
||||
$columns = $index['columns'];
|
||||
$columns = $indexYml['columns'];
|
||||
}
|
||||
|
||||
if( ! isset($index['flags'])) {
|
||||
$flags = array();
|
||||
} elseif (is_string($index['flags'])) {
|
||||
$flags = explode(',', $index['flags']);
|
||||
$flags = array_map('trim', $flags);
|
||||
} else {
|
||||
$flags = $index['flags'];
|
||||
}
|
||||
|
||||
$metadata->table['indexes'][$index['name']] = array(
|
||||
'columns' => $columns,
|
||||
'flags' => $flags
|
||||
|
||||
$index = array(
|
||||
'columns' => $columns
|
||||
);
|
||||
|
||||
if(isset($indexYml['flags'])) {
|
||||
if (is_string($indexYml['flags'])) {
|
||||
$flags = explode(',', $indexYml['flags']);
|
||||
$index['flags'] = array_map('trim', $flags);
|
||||
} else {
|
||||
$index['flags'] = $indexYml['flags'];
|
||||
}
|
||||
}
|
||||
|
||||
$metadata->table['indexes'][$indexYml['name']] = $index;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,18 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
return $class;
|
||||
}
|
||||
|
||||
public function testEntityIndexFlags()
|
||||
{
|
||||
$class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Comment');
|
||||
|
||||
$this->assertEquals(array(
|
||||
0 => array(
|
||||
'columns' => array('content'),
|
||||
'flags' => array('fulltext')
|
||||
)
|
||||
), $class->table['indexes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testEntityTableNameAndInheritance
|
||||
* @param ClassMetadata $class
|
||||
@ -1266,3 +1278,15 @@ class DDC807SubClasse2 {}
|
||||
class Address {}
|
||||
class Phonenumber {}
|
||||
class Group {}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(indexes={@Index(columns={"content"}, flags={"fulltext"})})
|
||||
*/
|
||||
class Comment
|
||||
{
|
||||
/**
|
||||
* @Column(type="text")
|
||||
*/
|
||||
private $content;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
|
||||
$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
|
||||
$metadata->setPrimaryTable(array(
|
||||
'indexes' => array(
|
||||
array('columns' => array('content'), 'flags' => array('fulltext'))
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'content',
|
||||
'type' => 'text',
|
||||
'scale' => 0,
|
||||
'length' => NULL,
|
||||
'unique' => false,
|
||||
'nullable' => false,
|
||||
'precision' => 0,
|
||||
'columnName' => 'content',
|
||||
));
|
@ -0,0 +1,18 @@
|
||||
<?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
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\ORM\Mapping\Comment">
|
||||
|
||||
<indexes>
|
||||
<index columns="content" flags="fulltext"/>
|
||||
</indexes>
|
||||
|
||||
<field name="content" type="text"/>
|
||||
|
||||
</entity>
|
||||
|
||||
</doctrine-mapping>
|
@ -0,0 +1,9 @@
|
||||
Doctrine\Tests\ORM\Mapping\Comment:
|
||||
type: entity
|
||||
fields:
|
||||
content:
|
||||
type: text
|
||||
indexes:
|
||||
0:
|
||||
columns: content
|
||||
flags: fulltext
|
Loading…
x
Reference in New Issue
Block a user