def test_default_reflection(self):
    'Test reflection of column defaults.'
    from sqlalchemy.dialects.mysql import VARCHAR
    def_table = Table('mysql_def', MetaData(testing.db), Column('c1', VARCHAR(10, collation='utf8_unicode_ci'), DefaultClause(''), nullable=False), Column('c2', String(10), DefaultClause('0')), Column('c3', String(10), DefaultClause('abc')), Column('c4', TIMESTAMP, DefaultClause('2009-04-05 12:00:00')), Column('c5', TIMESTAMP), Column('c6', TIMESTAMP, DefaultClause(sql.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))))
    def_table.create()
    try:
        reflected = Table('mysql_def', MetaData(testing.db), autoload=True)
    finally:
        def_table.drop()
    assert (def_table.c.c1.server_default.arg == '')
    assert (def_table.c.c2.server_default.arg == '0')
    assert (def_table.c.c3.server_default.arg == 'abc')
    assert (def_table.c.c4.server_default.arg == '2009-04-05 12:00:00')
    assert (str(reflected.c.c1.server_default.arg) == "''")
    assert (str(reflected.c.c2.server_default.arg) == "'0'")
    assert (str(reflected.c.c3.server_default.arg) == "'abc'")
    assert (str(reflected.c.c4.server_default.arg) == "'2009-04-05 12:00:00'")
    assert (reflected.c.c5.default is None)
    assert (reflected.c.c5.server_default is None)
    assert (reflected.c.c6.default is None)
    assert re.match('CURRENT_TIMESTAMP(\\(\\))? ON UPDATE CURRENT_TIMESTAMP(\\(\\))?', str(reflected.c.c6.server_default.arg).upper())
    reflected.create()
    try:
        reflected2 = Table('mysql_def', MetaData(testing.db), autoload=True)
    finally:
        reflected.drop()
    assert (str(reflected2.c.c1.server_default.arg) == "''")
    assert (str(reflected2.c.c2.server_default.arg) == "'0'")
    assert (str(reflected2.c.c3.server_default.arg) == "'abc'")
    assert (str(reflected2.c.c4.server_default.arg) == "'2009-04-05 12:00:00'")
    assert (reflected.c.c5.default is None)
    assert (reflected.c.c5.server_default is None)
    assert (reflected.c.c6.default is None)
    assert re.match('CURRENT_TIMESTAMP(\\(\\))? ON UPDATE CURRENT_TIMESTAMP(\\(\\))?', str(reflected.c.c6.server_default.arg).upper())
Test reflection of column defaults.
def test_default_reflection(self):
    
    from sqlalchemy.dialects.mysql import VARCHAR
    def_table = Table('mysql_def', MetaData(testing.db), Column('c1', VARCHAR(10, collation='utf8_unicode_ci'), DefaultClause(), nullable=False), Column('c2', String(10), DefaultClause('0')), Column('c3', String(10), DefaultClause('abc')), Column('c4', TIMESTAMP, DefaultClause('2009-04-05 12:00:00')), Column('c5', TIMESTAMP), Column('c6', TIMESTAMP, DefaultClause(sql.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))))
    def_table.create()
    try:
        reflected = Table('mysql_def', MetaData(testing.db), autoload=True)
    finally:
        def_table.drop()
    assert (def_table.c.c1.server_default.arg == )
    assert (def_table.c.c2.server_default.arg == '0')
    assert (def_table.c.c3.server_default.arg == 'abc')
    assert (def_table.c.c4.server_default.arg == '2009-04-05 12:00:00')
    assert (str(reflected.c.c1.server_default.arg) == )
    assert (str(reflected.c.c2.server_default.arg) == "'0'")
    assert (str(reflected.c.c3.server_default.arg) == "'abc'")
    assert (str(reflected.c.c4.server_default.arg) == "'2009-04-05 12:00:00'")
    assert (reflected.c.c5.default is None)
    assert (reflected.c.c5.server_default is None)
    assert (reflected.c.c6.default is None)
    assert re.match('CURRENT_TIMESTAMP(\\(\\))? ON UPDATE CURRENT_TIMESTAMP(\\(\\))?', str(reflected.c.c6.server_default.arg).upper())
    reflected.create()
    try:
        reflected2 = Table('mysql_def', MetaData(testing.db), autoload=True)
    finally:
        reflected.drop()
    assert (str(reflected2.c.c1.server_default.arg) == )
    assert (str(reflected2.c.c2.server_default.arg) == "'0'")
    assert (str(reflected2.c.c3.server_default.arg) == "'abc'")
    assert (str(reflected2.c.c4.server_default.arg) == "'2009-04-05 12:00:00'")
    assert (reflected.c.c5.default is None)
    assert (reflected.c.c5.server_default is None)
    assert (reflected.c.c6.default is None)
    assert re.match('CURRENT_TIMESTAMP(\\(\\))? ON UPDATE CURRENT_TIMESTAMP(\\(\\))?', str(reflected.c.c6.server_default.arg).upper())