Commits

Mike Bayer committed 97b7227

Autogenerate will include "autoincrement=False"
in the rendered table metadata
if this flag was set to false on the source
:class:`.Column` object.
#94

Comments (0)

Files changed (3)

alembic/autogenerate.py

                     _render_server_default(
                             column.server_default, autogen_context
                     )))
+    if not column.autoincrement:
+        opts.append(("autoincrement", column.autoincrement))
+
     if column.nullable is not None:
         opts.append(("nullable", column.nullable))
 

docs/build/changelog.rst

     :released:
 
     .. change::
+        :tags: bug
+        :tickets: 94
+
+      Autogenerate will include "autoincrement=False"
+      in the rendered table metadata
+      if this flag was set to false on the source
+      :class:`.Column` object.
+
+    .. change::
         :tags: feature
         :tickets: 66
 

tests/test_autogenerate.py

             "    sa.Column('id', mysql.INTEGER(display_width=11), "
                 "nullable=False),\n"
             "    sa.Column('value', mysql.TINYINT(display_width=1), "
-            "nullable=True),\n"
+            "autoincrement=False, nullable=True),\n"
             "    sa.PrimaryKeyConstraint('id')\n    )\n"
             "    op.drop_table('sometable')\n"
             "    ### end Alembic commands ###"
     op.drop_column('order', 'user_id', schema='%(schema)s')
     op.drop_column('address', 'street', schema='%(schema)s')
     op.create_table('extra',
-    sa.Column('x', sa.CHAR(length=1), nullable=True),
-    sa.Column('uid', sa.INTEGER(), nullable=True),
+    sa.Column('x', sa.CHAR(length=1), autoincrement=False, nullable=True),
+    sa.Column('uid', sa.INTEGER(), autoincrement=False, nullable=True),
     sa.ForeignKeyConstraint(['uid'], ['%(schema)s.user.id'], name='extra_uid_fkey'),
     sa.PrimaryKeyConstraint(),
     schema='%(schema)s'
                 'nullable=False)'
         )
 
+    def test_render_col_autoinc_false_mysql(self):
+        c = Column('some_key', Integer, primary_key=True, autoincrement=False)
+        Table('some_table', MetaData(), c)
+        result = autogenerate._render_column(
+                    c, self.autogen_context
+                )
+        eq_(
+            result,
+            'sa.Column(\'some_key\', sa.Integer(), '
+                'autoincrement=False, '
+                'nullable=False)'
+        )
+
+
     def test_render_modify_type(self):
         eq_ignore_whitespace(
             autogenerate._modify_col(