def test_autoincrement(self):
    meta = MetaData(testing.db)
    try:
        Table('ai_1', meta, Column('int_y', Integer, primary_key=True, autoincrement=True), Column('int_n', Integer, DefaultClause('0'), primary_key=True), mysql_engine='MyISAM')
        Table('ai_2', meta, Column('int_y', Integer, primary_key=True, autoincrement=True), Column('int_n', Integer, DefaultClause('0'), primary_key=True), mysql_engine='MyISAM')
        Table('ai_3', meta, Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), Column('int_y', Integer, primary_key=True, autoincrement=True), mysql_engine='MyISAM')
        Table('ai_4', meta, Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), Column('int_n2', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), mysql_engine='MyISAM')
        Table('ai_5', meta, Column('int_y', Integer, primary_key=True, autoincrement=True), Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), mysql_engine='MyISAM')
        Table('ai_6', meta, Column('o1', String(1), DefaultClause('x'), primary_key=True), Column('int_y', Integer, primary_key=True, autoincrement=True), mysql_engine='MyISAM')
        Table('ai_7', meta, Column('o1', String(1), DefaultClause('x'), primary_key=True), Column('o2', String(1), DefaultClause('x'), primary_key=True), Column('int_y', Integer, primary_key=True, autoincrement=True), mysql_engine='MyISAM')
        Table('ai_8', meta, Column('o1', String(1), DefaultClause('x'), primary_key=True), Column('o2', String(1), DefaultClause('x'), primary_key=True), mysql_engine='MyISAM')
        meta.create_all()
        table_names = ['ai_1', 'ai_2', 'ai_3', 'ai_4', 'ai_5', 'ai_6', 'ai_7', 'ai_8']
        mr = MetaData(testing.db)
        mr.reflect(only=table_names)
        for tbl in [mr.tables[name] for name in table_names]:
            for c in tbl.c:
                if c.name.startswith('int_y'):
                    assert c.autoincrement
                elif c.name.startswith('int_n'):
                    assert (not c.autoincrement)
            tbl.insert().execute()
            if ('int_y' in tbl.c):
                assert (select([tbl.c.int_y]).scalar() == 1)
                assert (list(tbl.select().execute().first()).count(1) == 1)
            else:
                assert (1 not in list(tbl.select().execute().first()))
    finally:
        meta.drop_all()
def test_autoincrement(self):
    meta = MetaData(testing.db)
    try:
        Table('ai_1', meta, Column('int_y', Integer, primary_key=True, autoincrement=True), Column('int_n', Integer, DefaultClause('0'), primary_key=True), mysql_engine='MyISAM')
        Table('ai_2', meta, Column('int_y', Integer, primary_key=True, autoincrement=True), Column('int_n', Integer, DefaultClause('0'), primary_key=True), mysql_engine='MyISAM')
        Table('ai_3', meta, Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), Column('int_y', Integer, primary_key=True, autoincrement=True), mysql_engine='MyISAM')
        Table('ai_4', meta, Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), Column('int_n2', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), mysql_engine='MyISAM')
        Table('ai_5', meta, Column('int_y', Integer, primary_key=True, autoincrement=True), Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), mysql_engine='MyISAM')
        Table('ai_6', meta, Column('o1', String(1), DefaultClause('x'), primary_key=True), Column('int_y', Integer, primary_key=True, autoincrement=True), mysql_engine='MyISAM')
        Table('ai_7', meta, Column('o1', String(1), DefaultClause('x'), primary_key=True), Column('o2', String(1), DefaultClause('x'), primary_key=True), Column('int_y', Integer, primary_key=True, autoincrement=True), mysql_engine='MyISAM')
        Table('ai_8', meta, Column('o1', String(1), DefaultClause('x'), primary_key=True), Column('o2', String(1), DefaultClause('x'), primary_key=True), mysql_engine='MyISAM')
        meta.create_all()
        table_names = ['ai_1', 'ai_2', 'ai_3', 'ai_4', 'ai_5', 'ai_6', 'ai_7', 'ai_8']
        mr = MetaData(testing.db)
        mr.reflect(only=table_names)
        for tbl in [mr.tables[name] for name in table_names]:
            for c in tbl.c:
                if c.name.startswith('int_y'):
                    assert c.autoincrement
                elif c.name.startswith('int_n'):
                    assert (not c.autoincrement)
            tbl.insert().execute()
            if ('int_y' in tbl.c):
                assert (select([tbl.c.int_y]).scalar() == 1)
                assert (list(tbl.select().execute().first()).count(1) == 1)
            else:
                assert (1 not in list(tbl.select().execute().first()))
    finally:
        meta.drop_all()