Laravel-ide-helper: Problem generating model helpers, as database has MySQL 5.7 JSON/JSONB column types

Created on 23 Dec 2015  路  9Comments  路  Source: barryvdh/laravel-ide-helper

php artisan ide-helper:models
Exception: Unknown database type json requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

I have upgraded to Laravle 5.2 to use Schema builder with $table->json(...) ability.

DBAL from version 2.5 has support for new json field types in Doctrine\DBAL\Platforms\MySQL57Platform class which extends default MySqlPlatform class.

Most helpful comment

Actually

'custom_db_types' => array(
        'mysql'=> [
            'json'=>'json_array'
        ]
    ),

works just as well :smile:

All 9 comments

@ddctd143 Did you figure out a solution for this?

I found this pull request on DBAL, which indicates that MySQL 5.7.8 is the specific version that JSON became available in, but the PR has not been merged yet, so this might be an upstream problem that we have to wait for...

https://github.com/doctrine/dbal/pull/2266

I'm with same issue, anyone knows a way to ignore this error and generate ide-helper:model ?

Couldn't in theory require our own version of dbal with that pull request merged? And then set the repo in the composer.json of this lib? So far in my testing dbal with that pull request seems to work fine.

Has this been fixed? I'm getting the same error message using Laravel 5.2, Mysql 5.7.13 and php 7.0.*

No.
It will be fixed when this https://github.com/doctrine/dbal/pull/2266 PR gets merged into doctrine/dbal main branch.

I have added the following in config/ide-helper.php and seemed to ignore the error:

'custom_db_types' => array(
    'mysql' => [
        'json' => 'text',
    ],
),

In _ide_helper_models.php, the json field come out as array:

/**
 * @property array $data
 */

Actually

'custom_db_types' => array(
        'mysql'=> [
            'json'=>'json_array'
        ]
    ),

works just as well :smile:

@barryvdh the correct solution is the last comment (to use custom_db_types), IMHO issue can be closed :}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

beniaminorossini picture beniaminorossini  路  5Comments

anik786 picture anik786  路  3Comments

kickthemooon picture kickthemooon  路  3Comments

andrew-svirin picture andrew-svirin  路  4Comments

Newbie012 picture Newbie012  路  4Comments