1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +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: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>

View file

@ -101,7 +101,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
if ($tableAnnot->indexes !== null) { if ($tableAnnot->indexes !== null) {
foreach ($tableAnnot->indexes as $indexAnnot) { foreach ($tableAnnot->indexes as $indexAnnot) {
$index = array('columns' => $indexAnnot->columns); $index = array(
'columns' => $indexAnnot->columns,
'flags' => $indexAnnot->flags
);
if ( ! empty($indexAnnot->name)) { if ( ! empty($indexAnnot->name)) {
$primaryTable['indexes'][$indexAnnot->name] = $index; $primaryTable['indexes'][$indexAnnot->name] = $index;

View file

@ -196,14 +196,22 @@ class XmlDriver extends FileDriver
$metadata->table['indexes'] = array(); $metadata->table['indexes'] = array();
foreach ($xmlRoot->indexes->index as $index) { foreach ($xmlRoot->indexes->index as $index) {
$columns = explode(',', (string)$index['columns']); $columns = explode(',', (string)$index['columns']);
if(!isset($index['flags'])) {
$flags = array();
} else {
$flags = explode(',', (string)$index['flags']);
}
if (isset($index['name'])) { if (isset($index['name'])) {
$metadata->table['indexes'][(string)$index['name']] = array( $metadata->table['indexes'][(string)$index['name']] = array(
'columns' => $columns 'columns' => $columns,
'flags' => $flags
); );
} else { } else {
$metadata->table['indexes'][] = array( $metadata->table['indexes'][] = array(
'columns' => $columns 'columns' => $columns,
'flags' => $flags
); );
} }
} }

View file

@ -213,8 +213,19 @@ class YamlDriver extends FileDriver
$columns = $index['columns']; $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( $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> * @var array<string>
*/ */
public $columns; public $columns;
/**
* @var array<string>
*/
public $flags;
} }

View file

@ -264,7 +264,12 @@ 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']);
} }
} }