Added index flags support in annotation, xml & yaml mapping drivers.
This commit is contained in:
parent
da24133306
commit
cc2fb1a070
@ -341,6 +341,7 @@
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:NMTOKEN" use="optional"/>
|
||||
<xs:attribute name="columns" type="xs:string" use="required"/>
|
||||
<xs:attribute name="flags" type="xs:string" use="optional"/>
|
||||
<xs:anyAttribute namespace="##other"/>
|
||||
</xs:complexType>
|
||||
|
||||
|
@ -101,7 +101,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
|
||||
if ($tableAnnot->indexes !== null) {
|
||||
foreach ($tableAnnot->indexes as $indexAnnot) {
|
||||
$index = array('columns' => $indexAnnot->columns);
|
||||
$index = array(
|
||||
'columns' => $indexAnnot->columns,
|
||||
'flags' => $indexAnnot->flags
|
||||
);
|
||||
|
||||
if ( ! empty($indexAnnot->name)) {
|
||||
$primaryTable['indexes'][$indexAnnot->name] = $index;
|
||||
|
@ -196,14 +196,22 @@ class XmlDriver extends FileDriver
|
||||
$metadata->table['indexes'] = array();
|
||||
foreach ($xmlRoot->indexes->index as $index) {
|
||||
$columns = explode(',', (string)$index['columns']);
|
||||
|
||||
|
||||
if(!isset($index['flags'])) {
|
||||
$flags = array();
|
||||
} else {
|
||||
$flags = explode(',', (string)$index['flags']);
|
||||
}
|
||||
|
||||
if (isset($index['name'])) {
|
||||
$metadata->table['indexes'][(string)$index['name']] = array(
|
||||
'columns' => $columns
|
||||
'columns' => $columns,
|
||||
'flags' => $flags
|
||||
);
|
||||
} else {
|
||||
$metadata->table['indexes'][] = array(
|
||||
'columns' => $columns
|
||||
'columns' => $columns,
|
||||
'flags' => $flags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -213,8 +213,19 @@ class YamlDriver extends FileDriver
|
||||
$columns = $index['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
|
||||
'columns' => $columns,
|
||||
'flags' => $flags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,9 @@ final class Index implements Annotation
|
||||
* @var array<string>
|
||||
*/
|
||||
public $columns;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
public $flags;
|
||||
}
|
||||
|
@ -264,7 +264,12 @@ class SchemaTool
|
||||
|
||||
if (isset($class->table['indexes'])) {
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user