<s> from . import exclusions <EOL> from . . import schema , event <EOL> from . import config <EOL> __all__ = '<STR_LIT>' , '<STR_LIT>' , <EOL> table_options = { } <EOL> def Table ( * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> test_opts = dict ( [ ( k , kw . pop ( k ) ) for k in list ( kw ) <EOL> if k . startswith ( '<STR_LIT>' ) ] ) <EOL> kw . update ( table_options ) <EOL> if exclusions . against ( config . _current , '<STR_LIT>' ) : <EOL> if '<STR_LIT>' not in kw and '<STR_LIT>' not in kw : <EOL> if '<STR_LIT>' in test_opts or '<STR_LIT>' in test_opts : <EOL> kw [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> kw [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if exclusions . against ( config . _current , '<STR_LIT>' ) : <EOL> table_name = args [ <NUM_LIT:0> ] <EOL> unpack = ( config . db . dialect . <EOL> identifier_preparer . unformat_identifiers ) <EOL> fks = [ fk <EOL> for col in args if isinstance ( col , schema . Column ) <EOL> for fk in col . foreign_keys ] <EOL> for fk in fks : <EOL> ref = fk . _colspec <EOL> if isinstance ( ref , schema . Column ) : <EOL> name = ref . table . name <EOL> else : <EOL> name = unpack ( ref ) [ <NUM_LIT:0> ] <EOL> if name == table_name : <EOL> if fk . ondelete is None : <EOL> fk . ondelete = '<STR_LIT>' <EOL> if fk . onupdate is None : <EOL> fk . onupdate = '<STR_LIT>' <EOL> return schema . Table ( * args , ** kw ) <EOL> def Column ( * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> test_opts = dict ( [ ( k , kw . pop ( k ) ) for k in list ( kw ) <EOL> if k . startswith ( '<STR_LIT>' ) ] ) <EOL> if not config . requirements . foreign_key_ddl . enabled_for_config ( config ) : <EOL> args = [ arg for arg in args if not isinstance ( arg , schema . ForeignKey ) ] <EOL> col = schema . Column ( * args , ** kw ) <EOL> if '<STR_LIT>' in test_opts and kw . get ( '<STR_LIT:primary_key>' , False ) : <EOL> col . info [ '<STR_LIT>' ] = True <EOL> if exclusions . against ( config . _current , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> def add_seq ( c , tbl ) : <EOL> c . _init_items ( <EOL> schema . Sequence ( _truncate_name ( <EOL> config . db . dialect , tbl . name + '<STR_LIT:_>' + c . name + '<STR_LIT>' ) , <EOL> optional = True ) <EOL> ) <EOL> event . listen ( col , '<STR_LIT>' , add_seq , propagate = True ) <EOL> return col <EOL> def _truncate_name ( dialect , name ) : <EOL> if len ( name ) > dialect . max_identifier_length : <EOL> return name [ <NUM_LIT:0> : max ( dialect . max_identifier_length - <NUM_LIT:6> , <NUM_LIT:0> ) ] + "<STR_LIT:_>" + hex ( hash ( name ) % <NUM_LIT:64> ) [ <NUM_LIT:2> : ] <EOL> else : <EOL> return name </s>
