commit
3a1e24e680
@ -341,6 +341,7 @@
|
|||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute name="name" type="xs:NMTOKEN" use="optional"/>
|
<xs:attribute name="name" type="xs:NMTOKEN" use="optional"/>
|
||||||
<xs:attribute name="columns" type="xs:string" use="required"/>
|
<xs:attribute name="columns" type="xs:string" use="required"/>
|
||||||
|
<xs:attribute name="flags" type="xs:string" use="optional"/>
|
||||||
<xs:anyAttribute namespace="##other"/>
|
<xs:anyAttribute namespace="##other"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|
||||||
|
@ -103,6 +103,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
|||||||
foreach ($tableAnnot->indexes as $indexAnnot) {
|
foreach ($tableAnnot->indexes as $indexAnnot) {
|
||||||
$index = array('columns' => $indexAnnot->columns);
|
$index = array('columns' => $indexAnnot->columns);
|
||||||
|
|
||||||
|
if ( ! empty($indexAnnot->flags)) {
|
||||||
|
$index['flags'] = $indexAnnot->flags;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! empty($indexAnnot->name)) {
|
if ( ! empty($indexAnnot->name)) {
|
||||||
$primaryTable['indexes'][$indexAnnot->name] = $index;
|
$primaryTable['indexes'][$indexAnnot->name] = $index;
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,17 +194,17 @@ class XmlDriver extends FileDriver
|
|||||||
// Evaluate <indexes...>
|
// Evaluate <indexes...>
|
||||||
if (isset($xmlRoot->indexes)) {
|
if (isset($xmlRoot->indexes)) {
|
||||||
$metadata->table['indexes'] = array();
|
$metadata->table['indexes'] = array();
|
||||||
foreach ($xmlRoot->indexes->index as $index) {
|
foreach ($xmlRoot->indexes->index as $indexXml) {
|
||||||
$columns = explode(',', (string)$index['columns']);
|
$index = array('columns' => explode(',', (string) $indexXml['columns']));
|
||||||
|
|
||||||
if (isset($index['name'])) {
|
if (isset($indexXml['flags'])) {
|
||||||
$metadata->table['indexes'][(string)$index['name']] = array(
|
$index['flags'] = explode(',', (string) $indexXml['flags']);
|
||||||
'columns' => $columns
|
}
|
||||||
);
|
|
||||||
|
if (isset($indexXml['name'])) {
|
||||||
|
$metadata->table['indexes'][(string) $indexXml['name']] = $index;
|
||||||
} else {
|
} else {
|
||||||
$metadata->table['indexes'][] = array(
|
$metadata->table['indexes'][] = $index;
|
||||||
'columns' => $columns
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,21 +201,26 @@ class YamlDriver extends FileDriver
|
|||||||
|
|
||||||
// Evaluate indexes
|
// Evaluate indexes
|
||||||
if (isset($element['indexes'])) {
|
if (isset($element['indexes'])) {
|
||||||
foreach ($element['indexes'] as $name => $index) {
|
foreach ($element['indexes'] as $name => $indexYml) {
|
||||||
if ( ! isset($index['name'])) {
|
if ( ! isset($indexYml['name'])) {
|
||||||
$index['name'] = $name;
|
$indexYml['name'] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($index['columns'])) {
|
if (is_string($indexYml['columns'])) {
|
||||||
$columns = explode(',', $index['columns']);
|
$index = array('columns' => array_map('trim', explode(',', $indexYml['columns'])));
|
||||||
$columns = array_map('trim', $columns);
|
|
||||||
} else {
|
} else {
|
||||||
$columns = $index['columns'];
|
$index = array('columns' => $indexYml['columns']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata->table['indexes'][$index['name']] = array(
|
if (isset($indexYml['flags'])) {
|
||||||
'columns' => $columns
|
if (is_string($indexYml['flags'])) {
|
||||||
);
|
$index['flags'] = array_map('trim', explode(',', $indexYml['flags']));
|
||||||
|
} else {
|
||||||
|
$index['flags'] = $indexYml['flags'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$metadata->table['indexes'][$indexYml['name']] = $index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,4 +34,9 @@ final class Index implements Annotation
|
|||||||
* @var array<string>
|
* @var array<string>
|
||||||
*/
|
*/
|
||||||
public $columns;
|
public $columns;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string>
|
||||||
|
*/
|
||||||
|
public $flags;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,11 @@ class SchemaTool
|
|||||||
|
|
||||||
if (isset($class->table['indexes'])) {
|
if (isset($class->table['indexes'])) {
|
||||||
foreach ($class->table['indexes'] as $indexName => $indexData) {
|
foreach ($class->table['indexes'] as $indexName => $indexData) {
|
||||||
$table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName);
|
if( ! isset($indexData['flags'])) {
|
||||||
|
$indexData['flags'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->addIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, (array)$indexData['flags']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,18 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
return $class;
|
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
|
* @depends testEntityTableNameAndInheritance
|
||||||
* @param ClassMetadata $class
|
* @param ClassMetadata $class
|
||||||
@ -1266,3 +1278,36 @@ class DDC807SubClasse2 {}
|
|||||||
class Address {}
|
class Address {}
|
||||||
class Phonenumber {}
|
class Phonenumber {}
|
||||||
class Group {}
|
class Group {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Entity
|
||||||
|
* @Table(indexes={@Index(columns={"content"}, flags={"fulltext"})})
|
||||||
|
*/
|
||||||
|
class Comment
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Column(type="text")
|
||||||
|
*/
|
||||||
|
private $content;
|
||||||
|
|
||||||
|
public static function loadMetadata(ClassMetadataInfo $metadata)
|
||||||
|
{
|
||||||
|
$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,21 @@
|
|||||||
|
<?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