[BUGFIX] Cannot use contain with multivalued static enumeration column 87/27787/4
authorXavier Perseguers <xavier@typo3.org>
Sat, 1 Mar 2014 10:17:21 +0000 (11:17 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 4 Mar 2014 16:11:11 +0000 (17:11 +0100)
When a column is defined as a multivalued static enumeration:
'somecolumn' => array(
    'exclude' => 0,
    'label' => 'Some label',
    'config' => array(
        'type' => 'select',
        'items' => array(
            array('Option 1', 1),
            array('Option 2', 2),
            array('Option 3', 3),
            array('Option 4', 4),
        ),
        'size' => 4,
        'maxitems' => 4,
        'eval' => ''
    ),
),
it is not possible to query the domain model using operation "contains":
$value = 2;
$query->matching(
    $query->contains('somecolumn', $value)
);

Releases: 6.2, 6.1
Fixes: #56205
Change-Id: If898db7f355ad931d1c8b55febc2f59f19b0f38b
Reviewed-on: https://review.typo3.org/27787
Reviewed-by: Alexander Opitz
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Froemken
Tested-by: Stefan Froemken
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php

index 1857811..443de0f 100644 (file)
@@ -302,6 +302,8 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface {
                                $columnMap = $this->setOneToManyRelation($columnMap, $columnConfiguration);
                        } elseif (isset($propertyMetaData['type']) && strpbrk($propertyMetaData['type'], '_\\') !== FALSE) {
                                $columnMap = $this->setOneToOneRelation($columnMap, $columnConfiguration);
+                       } elseif (isset($columnConfiguration['type']) && $columnConfiguration['type'] === 'select' && isset($columnConfiguration['maxitems']) && $columnConfiguration['maxitems'] > 1) {
+                               $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY);
                        } else {
                                $columnMap->setTypeOfRelation(ColumnMap::RELATION_NONE);
                        }