Fixed issue where the "modified_name" of :class:`.AlterColumnOp` would not
be considered when rendering op directives for autogenerate. While
autogenerate cannot detect changes in column name, this would nonetheless
impact approaches that made use of this attribute in rewriter recipes. Pull
request courtesy lenvk.
Fixes: #1635
Closes: #1636
Pull-request: https://github.com/sqlalchemy/alembic/pull/1636
Pull-request-sha:
dd103354dcf9cd8db30c66a9a4d3879e4f1c5499
Change-Id: I3e4976a3e703ecd8d69ec208b2d225a8bf6a8251
type_ = op.modify_type
nullable = op.modify_nullable
comment = op.modify_comment
+ newname = op.modify_name
autoincrement = op.kw.get("autoincrement", None)
existing_type = op.existing_type
existing_nullable = op.existing_nullable
rendered = _render_server_default(server_default, autogen_context)
text += ",\n%sserver_default=%s" % (indent, rendered)
+ if newname is not None:
+ text += ",\n%snew_column_name=%r" % (indent, newname)
if type_ is not None:
text += ",\n%stype_=%s" % (indent, _repr_type(type_, autogen_context))
if nullable is not None:
--- /dev/null
+.. change::
+ :tags: bug, autogenerate
+ :tickets: 1635
+
+ Fixed issue where the "modified_name" of :class:`.AlterColumnOp` would not
+ be considered when rendering op directives for autogenerate. While
+ autogenerate cannot detect changes in column name, this would nonetheless
+ impact approaches that made use of this attribute in rewriter recipes. Pull
+ request courtesy lenvk.
{"from mypackage import MySpecialType"},
)
+ def test_render_modify_name(self):
+ op_obj = ops.AlterColumnOp(
+ "sometable",
+ "somecolumn",
+ modify_name="newcolumnname",
+ )
+ eq_ignore_whitespace(
+ autogenerate.render_op_text(self.autogen_context, op_obj),
+ "op.alter_column('sometable', 'somecolumn', "
+ "new_column_name='newcolumnname')",
+ )
+
def test_render_modify_type(self):
op_obj = ops.AlterColumnOp(
"sometable",