[Dbix-class] Round-tripping bugs in MySQL and MariaDB

Dave Lambley dave at lambley.me.uk
Fri Apr 2 23:29:14 GMT 2021


Hello,

The database I've been working with exposes two cases where a schema cannot be round-tripped through DBIx::Class::Schema::Loader. I have fixes for both which have been sitting around for some time. Is there anything I can do to help get these fixes released?


1) "current_timestamp" defaults cannot be parsed in MariaDB.
https://github.com/dbsrgits/dbix-class-schema-loader/pull/24 https://github.com/dbsrgits/dbix-class-schema-loader/pull/24 (Based on ASHMEMA's PR from a year ago.)
https://rt.cpan.org/Ticket/Display.html?id=134064

MariaDB changed their output format five years ago. DBIx::Class::Schema::Loader needs to be updated to cope.


2) SQL::Translator generates an invalid CREATE TABLE.
https://github.com/dbsrgits/sql-translator/pull/121
https://rt.cpan.org/Ticket/Display.html?id=134065

When a table has a foreign key, SQL::Translator automatically adds an INDEX for the field. If you already have a UNIQUE KEY named after this field, you end up with two indices with the same name. MySQL and MariaDB won't accept this.

The change I have prevents the additional INDEX being created if one already exists by virtue of being on the left hand side of a UNIQUE KEY.

We *could* omit the additional index entirely when generating output for recent MariaDBs (and maybe MySQL) as it implicitly creates the index if necessary. However, it seems desirable to avoid version specific behaviour.

Cheers,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20210403/9b019707/attachment.html>


More information about the DBIx-Class mailing list