ENUM type in model

In a project we want to use ENUM type properties in some models. Adding them worked fine:

/**
 * @var string
 * @ORM\Column(type="string", columnDefinition="ENUM('database', 'email', 'note')")
 */
protected $type;

The migration generated also looks fine:

$this->addSql("CREATE TABLE my_package_domain_model_activity (persistence_object_identifier VARCHAR(40) NOT NULL, [some other properties], action ENUM('add', 'update'), INDEX IDX_D7144FA081398E09 (customer), PRIMARY KEY(persistence_object_identifier)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");

But the problem is that after creating and executing this migration I get this error:

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

  Type: Doctrine\DBAL\DBALException
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatfo
		rm.php
  Line: 423

I first thought that this was because I added more ENUM types, but then I found out that the problems are the ENUM type fields from the migration above.

So in short: It was possible to define an enum property, create a migration for it and create this field in the DB using migrationexecute. But from that point this field is considered unsupported.

I found a related discussion in https://forum.typo3.org/index.php/t/210173/ but have the same issues.

Does anyone have experience with ENUM properties? Should we rather not use those at all or is there a solution?

(Tested in Flow 3.1 and also after updating to 3.2.)

Hi,

this sounds rather like some doctrine issue. What I could find was https://github.com/doctrine/doctrine2/issues/1885

Apart from that I’d suggest you to read
http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/cookbook/mysql-enums.html
You can use the setting TYPO3.Flow.persistence.doctrine.dbal.mappingTypes to map the enum type to text in Flow.

But maybe you also might want to take a look here:
http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

Regards,
Alexander