MySQL doesn't support MATCH, INITIALLY, or DEFERRED

Issue #2841 resolved
Former user created an issue

MySQL does not support foreign key options of MATCH, INITIALLY, or DEFERRED. See:

https://dev.mysql.com/doc/refman/5.5/en/create-table-foreign-keys.html, find for 'Important'

MATCH causes later options such as ON UPDATE and ON DELETE to be silently ignored.

So if a user sets MATCH, INIITALLY, or DEFERRED in their ForeignKeyConstraint object, their schema will differ without any warning.

I therefore propose the MySQL dialect throw a CompileError if those options are specified.

Comments (5)

  1. Mike Bayer repo owner

    So I'm torn between CompileError and warning with or without ignoring it. someone who wants to set up MATCH for other backends would otherwise have to do a conditional DDL here, but if someone actually needs MATCH to be significant probably has to do that anyway.

    how about CompileError on 0.9 and warning on 0.8? it is possible existing applications are relying upon current behavior.

  2. Mike Bayer repo owner

    well yeah, this is a total crapshow. we have a precedent of ignoring "deferrable" already set up in #2721. But the approach in #2721 is really only valid when someone is using SET FOREIGN_KEY_CHECKS=0.

    So i think we need to rethink this entirely. I'd like to invalidate #2721 and give that user an entirely different path for his FK situation. DEFERRABLE and INITIALLY will be let through again, causing MySQL to fail (it fails, I checked). MATCH will totally raise an error. in 0.8, nothing changes but everything warns.

  3. Log in to comment