MariaDB 10.0 JSON type with symfony 4

僤鯓⒐⒋嵵緔 提交于 2019-12-05 20:59:40

The problem is that Doctrine is expecting MariaDB 10.2+, but there have been problems getting the latest MariaDB versions into repos (Arch is still at 10.1).

The solution is here: https://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration

Just configure server_version in config/packages/doctrine.yml to:

doctrine:
dbal:
    # configure these for your database server
    driver: 'pdo_mysql'
    server_version: 'mariadb-10.1.34'
    ...

Just replace the version with your version number which you can get with

$ mysql --version
* @ORM\Column(name="roles", type="string")
private $usuarioRoles;

public function getRoles(): array {
        $roles = explode(",",$this->usuarioRoles);
        // guarantee every user at least has ROLE_USER
        $roles[] = 'ROLE_USER';
        return array_unique($roles);
}

public function setRoles(array $roles): self {
        $this->usuarioRol = implode(",",$roles);
        return $this;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!