Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Support json for mysql driver #47

Open
RNACode opened this issue Jul 22, 2020 · 1 comment
Open

Support json for mysql driver #47

RNACode opened this issue Jul 22, 2020 · 1 comment

Comments

@RNACode
Copy link

RNACode commented Jul 22, 2020

What steps will reproduce the problem?

Install cycle/orm and cycle/migrations
Now cycle not full support json type for mysql, because it automatically convert json to text
https://github.com/spiral/database/blob/master/src/Driver/MySQL/Schema/MySQLColumn.php#L88

Example of migration

    public function up(): void
    {
        $this
            ->table(self::$table)
            ->addColumn('id', 'primary')
            ->addColumn('message', 'json')
            ->create();
    }

I've used following hack, but it looks terrible

    public function up(): void
    {
        $tbl = $this
            ->table(self::$table);

        $tbl
            ->addColumn('id', 'primary')
            ->create();

        $schema = $tbl->getSchema();
        $col = $schema->json('message');
        $prop = (new ReflectionClass($col))->getProperty('type');
        $prop->setAccessible(true);
        $prop->setValue($col, 'JSON');

        $schema->save();
    }

What is the expected result?

I've expected json column

What do you get instead?

I've get a text column

Additional info

Q A
Orm version 2.7.15
PHP version 7.3
Operating system Ubuntu
@wolfy-j
Copy link
Member

wolfy-j commented Jul 22, 2020

Hi,

one of the improvements we want to do in a future version is to provide the ability to declare native DB types. Not all databases support the same types equally so we are focusing on the more unified approach vs deep DB support. But only for now, this is already in our plans (we are working on growing the dev team which can help with such improvements).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants