Yii2: Separate MariaDB schema

Created on 5 Jul 2018  路  7Comments  路  Source: yiisoft/yii2

MariaDB is diverging more and more from MySQL.

What steps will reproduce the problem?

Try to use JSON columns with Yii and MariaDB.

What is the expected result?

It should work.

What do you get instead?

It doesn't since MySQL and MariaDB have solved the problem in different ways.

Proposal

  • Create mariadb\Schema and related classes that extend from the MySQL version.
  • When creating a JSON column we must manually add the JSON validation constraint, see this.

Since in MariaDB creating a JSON column results in a LONGTEXT column we need to somehow identify which LONGTEXT columns contain JSON.

  • Create option to detect JSON columns in MariaDB via column comments or name pattern matching.
  • Create option to detect JSON column by parsing constraints via SHOW CREATE TABLE.

Backwards compatibility

Since the DSN remains exactly the same. No one will ever use the MariaDB schema / classes, so any additions to Yii are backwards compatible.
For now I propose not doing any detection and just forcing users to set $driverName = 'mariadb'; if they want to use the new classes.

I'm willing to implement this in 2.X, alternatively I'll implement this privately and will merge it into 3.0 when that gets released.

Any feedback is appreciated.

MySQL db enhancement

Most helpful comment

For 2.0 this can be an extension, we should officiall support mariadb features in 3.0.

All 7 comments

I think the best way is if you'll implement it as extension as we do for 3.0 for MSSQL and Oracle: https://github.com/yiisoft/yii2-oracle

Ah, nice, so for 3.0 all drivers are separate?
I'll implement an extension for both 2.x and 3.x then i guess :)

Not all drivers but the ones core team aren't able to maintain themselves.

When you'll do, feel free to send pull requests that add these to the guide.

See my comment in #16515, MariaDB should be offically supported.

For 2.0 this can be an extension, we should officiall support mariadb features in 3.0.

This issue was moved by samdark to yiisoft/db#8.

Was this page helpful?
0 / 5 - 0 ratings