.. changelog::
:version: 0.8.2
+ .. change::
+ :tags: bug, mysql
+ :tickets: 2721
+
+ The ``deferrable`` keyword argument on :class:`.ForeignKey` and
+ :class:`.ForeignKeyConstraint` will not render the ``DEFERRABLE`` keyword
+ on the MySQL dialect. For a long time we left this in place because
+ a non-deferrable foreign key would act very differently than a deferrable
+ one, but some environments just disable FKs on MySQL, so we'll be less
+ opinionated here.
+
.. change::
:tags: bug, ext, orm
:tickets: 2730
(self.preparer.format_table(constraint.table),
qual, const)
+ def define_constraint_deferrability(self, constraint):
+ return ""
class MySQLTypeCompiler(compiler.GenericTypeCompiler):
def _extend_numeric(self, type_, spec):
"PRIMARY KEY (data) USING btree)",
dialect=mysql.dialect())
+ def test_skip_deferrable_kw(self):
+ m = MetaData()
+ t1 = Table('t1', m, Column('id', Integer, primary_key=True))
+ t2 = Table('t2', m, Column('id', Integer,
+ ForeignKey('t1.id', deferrable=True),
+ primary_key=True))
+
+ self.assert_compile(
+ schema.CreateTable(t2),
+ "CREATE TABLE t2 (id INTEGER NOT NULL, "
+ "PRIMARY KEY (id), FOREIGN KEY(id) REFERENCES t1 (id))"
+ )
+
class DialectTest(fixtures.TestBase):
__only_on__ = 'mysql'