Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,13 @@ protected function addColumnToMappingArray(ORM\Column $columnAnnotation, array $
$mapping['fieldName'] = $fieldName;
}

$mapping['type'] = ($columnAnnotation->type === 'string') ? null : $columnAnnotation->type;
$mapping['type'] = $columnAnnotation->type;
$mapping['scale'] = $columnAnnotation->scale;
$mapping['length'] = $columnAnnotation->length;
$mapping['unique'] = $columnAnnotation->unique;
$mapping['nullable'] = $columnAnnotation->nullable;
$mapping['precision'] = $columnAnnotation->precision;
$mapping['enumType'] = $columnAnnotation->enumType;

if ($columnAnnotation->options) {
$mapping['options'] = $columnAnnotation->options;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Neos\Flow\Tests\Functional\Persistence\FixturesPHP8;

enum EnumForAProperty: string
{
case IS_A = 'A;';
case IS_B = 'B;';
}
13 changes: 13 additions & 0 deletions Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/TestEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class TestEntity
#[ORM\Embedded(class: "Neos\Flow\Tests\Functional\Persistence\FixturesPHP8\TestEmbeddable")]
protected TestEmbeddable $embedded;

#[ORM\Column(type: 'string', enumType: EnumForAProperty::class)]
protected EnumForAProperty $enumForAProperty = EnumForAProperty::IS_A;

/**
* Constructor
*/
Expand Down Expand Up @@ -163,4 +166,14 @@ public function getEmbeddedValueObject(): TestEmbeddedValueObject
{
return $this->embeddedValueObject;
}

public function getEnumForAProperty(): EnumForAProperty
{
return $this->enumForAProperty;
}

public function setEnumForAProperty(EnumForAProperty $enumForAProperty): void
{
$this->enumForAProperty = $enumForAProperty;
}
}
15 changes: 15 additions & 0 deletions Neos.Flow/Tests/Functional/Persistence/PersistenceTestPHP8.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Neos\Flow\Persistence\Doctrine\QueryResult;
use Neos\Flow\Persistence\Exception;
use Neos\Flow\Persistence\Exception\ObjectValidationFailedException;
use Neos\Flow\Tests\Functional\Persistence\FixturesPHP8\EnumForAProperty;
use Neos\Flow\Tests\Functional\Persistence\FixturesPHP8\TestEntity;
use Neos\Flow\Tests\FunctionalTestCase;
use Neos\Utility\ObjectAccess;

Expand Down Expand Up @@ -721,6 +723,19 @@ public function hasUnpersistedChangesReturnsTrueAfterObjectUpdate()
self::assertTrue($this->persistenceManager->hasUnpersistedChanges());
}

public function enumPropertyCanBePersisted()
{
$testEntity = new TestEntity();
$testEntity->setEnumForAProperty(EnumForAProperty::IS_B);
$this->testEntityRepository->add($testEntity);
$this->persistenceManager->persistAll();
$this->persistenceManager->clearState();

/** @var FixturesPHP8\TestEntity $testEntity */
$testEntity = $this->testEntityRepository->findAll()->getFirst();
self::assertEquals(EnumForAProperty::IS_B, $testEntity->getEnumForAProperty());
}

/**
* Helper which inserts example data into the database.
*
Expand Down