Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.
jazithedev opened this issue ยท 4 comments
Hello,
I wrote a simple test code:
public function testHandle(): void
{
static::getContainer()->get(DatabaseToolCollection::class)->get()->loadFixtures();
}
The above results in this error message:
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.
Despite having proper entry in doctrine.xml
configuration which should fix the issue:
<doctrine:mapping-type name="enum">
string
</doctrine:mapping-type>
I still receive the error. It's like LiipTestFixturesBundle is not reading the Doctrine config ๐.
Hello,
please share the full error stack.
Did you try removing all the spaces?
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
The Symfony doc doesn't show spaces around string
.
The error may also come from a field declared with type enum
.
According to the following code, MySQL doesn't support enum
columns: https://github.com/doctrine/dbal/blob/a24b89d663d8f261199bc0a91c48016042ebda85/src/Platforms/AbstractMySQLPlatform.php#L1152-L1183
This is the full stack:
Doctrine\DBAL\Exception : Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.
/srv/www/vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:396
/srv/www/vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php:137
/srv/www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:981
/srv/www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:208
/srv/www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:321
/srv/www/vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php:336
/srv/www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:306
/srv/www/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1229
/srv/www/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php:851
/srv/www/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php:836
/srv/www/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:111
/srv/www/tests_integration/Dir/MyClassTest.php:41
Did you try removing all the spaces?
Yes, I tried. Nevertheless, my dev/prod environment is based on that config for quite a while now, and it works ๐
. Also, I'm also running doctrine:fixtures:load
separately, and it also work without any issue. When removing that entry from config, I'm receiving the very same error message when running doctrine:fixtures:load
.
The "enum" fix was done how it is described in Registering custom Mapping Types in the SchemaTool.
The line 111 of ORMDatabaseTool
contains $schemaTool->dropDatabase();
.
It looks like dropping the database results in the error you see.
As a workaround, you can try to keep the database schema during tests: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/caveats.md#damadoctrinetestbundle
I worked! Thank you ๐.