diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php index 41138248745b4b098ed528470afb4939ceaf63bf..1ae0504180217f585e94c3fd94e444d6f5167b04 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php @@ -330,7 +330,14 @@ 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') { + } elseif ( + isset($columnConfiguration['type'], $columnConfiguration['renderType']) + && $columnConfiguration['type'] === 'select' + && ( + $columnConfiguration['renderType'] !== 'selectSingle' + || (isset($columnConfiguration['maxitems']) && $columnConfiguration['maxitems'] > 1) + ) + ) { $columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY); } else { $columnMap->setTypeOfRelation(ColumnMap::RELATION_NONE); diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php index f6922c2189b90d60f7cf8102a2156380771aea0e..977ffa92a203be51e3237ddfb47958ed0dfeb737 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php @@ -150,6 +150,30 @@ class DataMapFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData); } + /** + * @test + */ + public function setRelationsDetectsSelectRenderTypeSingleAsNonRelational() + { + $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('foo', 'foo'); + $columnConfiguration = [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['One', 1], + ['Two', 2], + ['Three', 3], + ], + ]; + $propertyMetaData = []; + $mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false); + $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation'); + $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation'); + $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation'); + $actualColumnMap = $mockDataMapFactory->_callRef('setRelations', $columnMap, $columnConfiguration, $propertyMetaData); + $this->assertSame($columnMap::RELATION_NONE, $actualColumnMap->getTypeOfRelation()); + } + /** * @test */