import testbase
schema = None

__all__ = 'Table', 'Column',

table_options = {}

def Table(*args, **kw):
    """A schema.Table wrapper/hook for dialect-specific tweaks."""

    global schema
    if schema is None:
        from sqlalchemy import schema
        
    test_opts = dict([(k,kw.pop(k)) for k in kw.keys()
                      if k.startswith('test_')])

    kw.update(table_options)

    if testbase.db.name == 'mysql':
        if 'mysql_engine' not in kw and 'mysql_type' not in kw:
            if 'test_needs_fk' in test_opts or 'test_needs_acid' in test_opts:
                kw['mysql_engine'] = 'InnoDB'

    return schema.Table(*args, **kw)

def Column(*args, **kw):
    """A schema.Column wrapper/hook for dialect-specific tweaks."""

    global schema
    if schema is None:
        from sqlalchemy import schema

    # TODO: a Column that creates a Sequence automatically for PK columns,
    # which would help Oracle tests
    return schema.Column(*args, **kw)

@@ -9,16 +9,44 @@
 estbase%0A
+from testlib import testing%0A
 schema =
@@ -277,17 +277,9 @@
 ema%0A
-        
 %0A
+
     
@@ -588,16 +588,16 @@
 t_opts:%0A
-
         
@@ -635,16 +635,1067 @@
 nnoDB'%0A%0A
+    # Apply some default cascading rules for self-referential foreign keys.%0A    # MySQL InnoDB has some issues around seleting self-refs too.%0A    if testing.against('firebird'):%0A        table_name = args%5B0%5D%0A        unpack = (testing.config.db.dialect.%0A                  identifier_preparer.unformat_identifiers)%0A%0A        # Only going after ForeignKeys in Columns.  May need to%0A        # expand to ForeignKeyConstraint too.%0A        fks = %5Bfk%0A               for col in args if isinstance(col, schema.Column)%0A               for fk in col.args if isinstance(fk, schema.ForeignKey)%5D%0A%0A        for fk in fks:%0A            # root around in raw spec%0A            ref = fk._colspec%0A            if isinstance(ref, schema.Column):%0A                name = ref.table.name%0A            else:%0A                name = unpack(ref)%5B-2%5D%0A            print name, table_name%0A            if name == table_name:%0A                if fk.ondelete is None:%0A                    fk.ondelete = 'CASCADE'%0A                if fk.onupdate is None:%0A                    fk.onupdate = 'CASCADE'%0A%0A
     retu

Apply default cascade rules for firebird self-ref ForeignKeys.