1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Added index flags support in annotation, xml & yaml mapping drivers.

This commit is contained in:
Adrian Olek 2014-03-06 23:09:26 +01:00 committed by Marco Pivetta
parent da24133306
commit cc2fb1a070
6 changed files with 39 additions and 6 deletions

View File

@ -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>

View File

@ -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;

View File

@ -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
);
}
}

View File

@ -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
);
}
}

View File

@ -34,4 +34,9 @@ final class Index implements Annotation
* @var array<string>
*/
public $columns;
/**
* @var array<string>
*/
public $flags;
}

View File

@ -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']);
}
}