autogen_context, op.constraint_name),
'table_name': _ident(op.table_name),
'type': op.constraint_type,
- 'schema': (", schema='%s'" % _ident(op.schema))
+ 'schema': (", schema=%r" % _ident(op.schema))
if op.schema else '',
}
return text
--- /dev/null
+.. change::
+ :tags: bug, autogenerate
+
+ The "op.drop_constraint()" directive will now render using ``repr()`` for
+ the schema name, in the same way that "schema" renders for all the other op
+ directives. Pull request courtesy Denis Kataev.
"schema='CamelSchema', type_='unique')"
)
+ def test_drop_unique_constraint_schema_reprobj(self):
+ """
+ autogenerate.render._drop_constraint using schema
+ """
+ class SomeObj(str):
+ def __repr__(self):
+ return "foo.camel_schema"
+
+ op_obj = ops.DropConstraintOp(
+ "uq_test_code", "test", type_="unique",
+ schema=SomeObj("CamelSchema")
+ )
+ eq_ignore_whitespace(
+ autogenerate.render_op_text(self.autogen_context, op_obj),
+ "op.drop_constraint('uq_test_code', 'test', "
+ "schema=foo.camel_schema, type_='unique')"
+ )
+
def test_add_fk_constraint(self):
m = MetaData()
Table('a', m, Column('id', Integer, primary_key=True))