Reputation: 2962
Running into the above error while attempting to run doctrine:schema:update
in Symfony.
The error is happening in AbstractPlatform (part of \lib\Doctrine\Platforms\AbstractPlatform)
I'm checking and JSON is definitely registered in \lib\Doctrine\DBAL\Types\Type.php
abstract class Type
{
const TARRAY = 'array';
const SIMPLE_ARRAY = 'simple_array';
const JSON_ARRAY = 'json_array';
const JSON = 'json';
...
}
Version of MySQL is 5.7.26 so that should be ok (json is a type here)
I'm just trying to figure out a workaround.
I tried adding
doctrine:
dbal:
types:
enum: json
to doctrine.yaml
but that has had no effect. Does anyone know a workaround? I have no idea where the json file is being called...
Edit: I've come across a similar situation here but the answer is for Laravel: "Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it." while running php artisan migrate command
Does anyone have any idea how to implement this for Symfony?
Upvotes: 3
Views: 4937
Reputation: 1
For me the fix was a composer update
from a minor version to an other so it was a bug in the Doctrine DBAL.
Upvotes: 0
Reputation: 150
make sure your dbal config is pointing at the correct server version:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: utf8mb4
server_version: 5.7
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
engine: InnoDB
Upvotes: 2
Reputation: 2962
For those interested, here's a hackish workaround I came across here https://github.com/doctrine/orm/issues/6540
In AbstractPlatform, I just modified the error check to convert json files into strings. Not ideal, but it got past this error.
public function getDoctrineTypeMapping($dbType)
{
if ($this->doctrineTypeMapping === null) {
$this->initializeAllDoctrineTypeMappings();
}
$dbType = strtolower($dbType);
//inserted hack here
if($dbType == 'json') {
$dbType = 'string';
}
//
if (!isset($this->doctrineTypeMapping[$dbType])) {
throw new \Doctrine\DBAL\DBALException("Unknown database type ".$dbType." requested, " . get_class($this) . " may not support it.");
}
return $this->doctrineTypeMapping[$dbType];
}
Upvotes: 2