ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c@sdZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z d efd YZ dee fdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZde fdYZdefdYZd efd!YZd"efd#YZd$efd%YZd&efd'YZd(efd)YZd*efd+YZd,efd-YZd.efd/YZd0efd1YZd2efd3YZ d4efd5YZ!d6e!fd7YZ"d8e!fd9YZ#d<d<d:Z%d<d<d;Z&d<S(=sq Provides the hierarchy of DDL-defining schema items as well as routines to invoke them for a create/drop call. i(t_bind_or_error(t _generative(t Executable(t SchemaVisitor(t ClauseElementi(tevent(texc(tutil(t topologicalt _DDLCompilescBseZdZRS(cKs|j|||S(sNReturn a compiler appropriate for this ClauseElement, given a Dialect.(t ddl_compiler(tselftdialecttkw((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt _compilers(t__name__t __module__R(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR st DDLElementcBseZdZejjied6ZdZdZ dZ dZ dZ dddZ ejdddZedZeddddZd Zd Zd Zd Zd ZdZeeeZdZRS(sBase class for DDL expression constructs. This class is the base for the general purpose :class:`.DDL` class, as well as the various create/drop clause constructs such as :class:`.CreateTable`, :class:`.DropTable`, :class:`.AddConstraint`, etc. :class:`.DDLElement` integrates closely with SQLAlchemy events, introduced in :ref:`event_toplevel`. An instance of one is itself an event receiving callable:: event.listen( users, 'after_create', AddConstraint(constraint).execute_if(dialect='postgresql') ) .. seealso:: :class:`.DDL` :class:`.DDLEvents` :ref:`event_toplevel` :ref:`schema_ddl_sequences` t autocommitcCs|j|||S(N(t _execute_ddl(R t connectiont multiparamstparams((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt_execute_on_connectionGscCsZ|dkrt|}n|j||rC|j|j|S|jjjddS(s Execute this DDL immediately. Executes the DDL statement in isolation using the supplied :class:`.Connectable` or :class:`.Connectable` assigned to the ``.bind`` property, if not supplied. If the DDL has a conditional ``on`` criteria, it will be invoked with None as the event. :param bind: Optional, an ``Engine`` or ``Connection``. If not supplied, a valid :class:`.Connectable` must be present in the ``.bind`` property. :param target: Optional, defaults to None. The target SchemaItem for the execute call. Will be passed to the ``on`` callable if any, and may also provide string expansion data for the statement. See ``execute_at`` for more information. s(DDL execution skipped, criteria not met.N(tNoneRt_should_executetexecutetagainsttenginetloggertinfo(R tbindttarget((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRJs  s0.7sThe :meth:`.DDLElement.execute_at` method is deprecated and will be removed in a future release. Please use the :class:`.DDLEvents` listener interface in conjunction with the :meth:`.DDLElement.execute_if` method.cs9fd}tj|djdd|dS(sQLink execution of this DDL to the DDL lifecycle of a SchemaItem. Links this ``DDLElement`` to a ``Table`` or ``MetaData`` instance, executing it when that schema item is created or dropped. The DDL statement will be executed using the same Connection and transactional context as the Table create/drop itself. The ``.bind`` property of this statement is ignored. :param event: One of the events defined in the schema item's ``.ddl_events``; e.g. 'before-create', 'after-create', 'before-drop' or 'after-drop' :param target: The Table or MetaData instance for which this DDLElement will be associated with. A DDLElement instance can be linked to any number of schema items. ``execute_at`` builds on the ``append_ddl_listener`` interface of :class:`.MetaData` and :class:`.Table` objects. Caveat: Creating or dropping a Table in isolation will also trigger any DDL set to ``execute_at`` that Table's MetaData. This may change in a future release. cs2j|||r.|jj|SdS(N(t_should_execute_deprecatedRR(R RR (t event_nameR (sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt call_eventstt-t_N(Rtlistentreplace(R R"R R#((R"R sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt execute_aths#cCs ||_dS(s9Return a copy of this DDL against a specific schema item.N(R (R R ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRscCs||_||_||_dS(sReturn a callable that will execute this DDLElement conditionally. Used to provide a wrapper for event listening:: event.listen( metadata, 'before_create', DDL("my_ddl").execute_if(dialect='postgresql') ) :param dialect: May be a string, tuple or a callable predicate. If a string, it will be compared to the name of the executing database dialect:: DDL('something').execute_if(dialect='postgresql') If a tuple, specifies multiple dialect names:: DDL('something').execute_if(dialect=('postgresql', 'mysql')) :param callable\_: A callable, which will be invoked with four positional arguments as well as optional keyword arguments: :ddl: This DDL element. :target: The :class:`.Table` or :class:`.MetaData` object which is the target of this event. May be None if the DDL is executed explicitly. :bind: The :class:`.Connection` being used for DDL execution :tables: Optional keyword argument - a list of Table objects which are to be created/ dropped within a MetaData.create_all() or drop_all() method call. :state: Optional keyword argument - will be the ``state`` argument passed to this function. :checkfirst: Keyword argument, will be True if the 'checkfirst' flag was set during the call to ``create()``, ``create_all()``, ``drop()``, ``drop_all()``. If the callable returns a true value, the DDL statement will be executed. :param state: any value which will be passed to the callable\_ as the ``state`` keyword argument. .. seealso:: :class:`.DDLEvents` :ref:`event_toplevel` N(R t callable_tstate(R R R*R+((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt execute_ifsA  cKs|jdk r,|jd||| r,tSt|jtjr]|j|jj krtSn7t|jt t t fr|jj |jkrtSn|j dk r|j |||d|j| rtStS(NR+(tonRR!tFalset isinstanceR Rt string_typesRtnamettupletlisttsetR*R+tTrue(R R RR ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRscKs|jdkrtSt|jtjr;|j|jjkSt|jtt t fri|jj|jkS|j|||||SdS(N( R-RR5R/RR0RR1R2R3R4(R RR RR ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR!scKs/|j|||r+|j|j|SdS(s"Execute the DDL as a ddl_listener.N(RRR(R R RR ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt__call__scCs_|dk r[t|tjtttf r[tj| r[tj dt |j ndS(NsjExpected the name of a database dialect, a tuple of names, or a callable for 'on' criteria, got type '%s'.( RR/RR0R2R3R4tcallableRt ArgumentErrorttypeR(R R-((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt _check_ddl_ons   cCs|jr|jSdS(N(t_bind(R ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR s cCs ||_dS(N(R;(R R((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt _set_bindscCs+|jj|j}|jj|_|S(N(t __class__t__new__t__dict__tcopy(R ts((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt _generatesN(RRt__doc__Rt_execution_optionstunionR5RR R-R R*RRRt deprecatedR)RRR,RR!R6R:RR<tpropertyRB(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR s.  )D    tDDLcBsAeZdZdZejddddddZdZRS( s1A literal DDL statement. Specifies literal SQL DDL to be executed by the database. DDL objects function as DDL event listeners, and can be subscribed to those events listed in :class:`.DDLEvents`, using either :class:`.Table` or :class:`.MetaData` objects as targets. Basic templating support allows a single DDL instance to handle repetitive tasks for multiple tables. Examples:: from sqlalchemy import event, DDL tbl = Table('users', metadata, Column('uid', Integer)) event.listen(tbl, 'before_create', DDL('DROP TRIGGER users_trigger')) spow = DDL('ALTER TABLE %(table)s SET secretpowers TRUE') event.listen(tbl, 'after_create', spow.execute_if(dialect='somedb')) drop_spow = DDL('ALTER TABLE users SET secretpowers FALSE') connection.execute(drop_spow) When operating on Table events, the following ``statement`` string substitutions are available:: %(table)s - the Table name, with any required quoting applied %(schema)s - the schema name, with any required quoting applied %(fullname)s - the Table name including schema, quoted if needed The DDL's "context", if any, will be combined with the standard substitutions noted above. Keys present in the context will override the standard substitutions. tddlR-s0.7sThe :paramref:`.DDL.on` parameter is deprecated and will be removed in a future release. Please refer to :meth:`.DDLElement.execute_if`.cCsct|tjs(tjd|n||_|p:i|_|j|||_||_ dS(s)Create a DDL statement. :param statement: A string or unicode string to be executed. Statements will be processed with Python's string formatting operator. See the ``context`` argument and the ``execute_at`` method. A literal '%' in a statement must be escaped as '%%'. SQL bind parameters are not available in DDL statements. :param on: Optional filtering criteria. May be a string, tuple or a callable predicate. If a string, it will be compared to the name of the executing database dialect:: DDL('something', on='postgresql') If a tuple, specifies multiple dialect names:: DDL('something', on=('postgresql', 'mysql')) If a callable, it will be invoked with four positional arguments as well as optional keyword arguments: :ddl: This DDL element. :event: The name of the event that has triggered this DDL, such as 'after-create' Will be None if the DDL is executed explicitly. :target: The ``Table`` or ``MetaData`` object which is the target of this event. May be None if the DDL is executed explicitly. :connection: The ``Connection`` being used for DDL execution :tables: Optional keyword argument - a list of Table objects which are to be created/ dropped within a MetaData.create_all() or drop_all() method call. If the callable returns a true value, the DDL statement will be executed. :param context: Optional dictionary, defaults to None. These values will be available for use in string substitutions on the DDL statement. :param bind: Optional. A :class:`.Connectable`, used by default when ``execute()`` is invoked without a bind argument. .. seealso:: :class:`.DDLEvents` :ref:`event_toplevel` s4Expected a string or unicode SQL statement, got '%r'N( R/RR0RR8t statementtcontextR:R-R;(R RJR-RKR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt__init__@sK    c Csndt|jt|djt|jggdD].}t||r4d|t||f^q4fS(Ns <%s@%s; %s>s, R-RKs%s=%r(R-RK(R9RtidtjointreprRJtgetattr(R tkey((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt__repr__s   (s0.7sThe :paramref:`.DDL.on` parameter is deprecated and will be removed in a future release. Please refer to :meth:`.DDLElement.execute_if`.N( RRRCt__visit_name__Rtdeprecated_paramsRRLRR(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRHs! Pt_CreateDropBasecBs&eZdZdddZdZRS(sBase class for DDL constructs that represent CREATE and DROP or equivalents. The common theme of _CreateDropBase is a single ``element`` attribute which refers to the element to be created or dropped. cCs,||_|j|||_||_dS(N(telementR:R-R(R RVR-R((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs   cCstS(sAllow disable of _create_rule using a callable. Pass to _create_rule using util.portable_instancemethod(self._create_rule_disable) to retain serializability. (R.(R tcompiler((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt_create_rule_disablesN(RRRCRRLRX(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRUst CreateSchemacBs eZdZdZddZRS(scRepresent a CREATE SCHEMA statement. The argument here is the string name of the schema. t create_schemacKs&||_tt|j||dS(s.Create a new :class:`.CreateSchema` construct.N(tquotetsuperRYRL(R R1R[R ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs N(RRRCRSRRL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRYst DropSchemacBs#eZdZdZdedZRS(saRepresent a DROP SCHEMA statement. The argument here is the string name of the schema. t drop_schemacKs/||_||_tt|j||dS(s,Create a new :class:`.DropSchema` construct.N(R[tcascadeR\R]RL(R R1R[R_R ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs  N(RRRCRSRR.RL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR]st CreateTablecBs&eZdZdZddddZRS(s#Represent a CREATE TABLE statement.t create_tablecCsTtt|j|d|d|g|jD]}t|^q,|_||_dS(sLCreate a :class:`.CreateTable` construct. :param element: a :class:`.Table` that's the subject of the CREATE :param on: See the description for 'on' in :class:`.DDL`. :param bind: See the description for 'bind' in :class:`.DDL`. :param include_foreign_key_constraints: optional sequence of :class:`.ForeignKeyConstraint` objects that will be included inline within the CREATE construct; if omitted, all foreign key constraints that do not specify use_alter=True are included. .. versionadded:: 1.0.0 R-RN(R\R`RLtcolumnst CreateColumntinclude_foreign_key_constraints(R RVR-RRdtcolumn((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs"%N(RRRCRSRRL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR`st _DropViewcBseZdZdZRS(sSemi-public 'DROP VIEW' construct. Used by the test suite for dialect-agnostic drops of views. This object will eventually be part of a public "view" API. t drop_view(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRfsRccBseZdZdZdZRS(s\Represent a :class:`.Column` as rendered in a CREATE TABLE statement, via the :class:`.CreateTable` construct. This is provided to support custom column DDL within the generation of CREATE TABLE statements, by using the compiler extension documented in :ref:`sqlalchemy.ext.compiler_toplevel` to extend :class:`.CreateColumn`. Typical integration is to examine the incoming :class:`.Column` object, and to redirect compilation if a particular flag or condition is found:: from sqlalchemy import schema from sqlalchemy.ext.compiler import compiles @compiles(schema.CreateColumn) def compile(element, compiler, **kw): column = element.element if "special" not in column.info: return compiler.visit_create_column(element, **kw) text = "%s SPECIAL DIRECTIVE %s" % ( column.name, compiler.type_compiler.process(column.type) ) default = compiler.get_column_default_string(column) if default is not None: text += " DEFAULT " + default if not column.nullable: text += " NOT NULL" if column.constraints: text += " ".join( compiler.process(const) for const in column.constraints) return text The above construct can be applied to a :class:`.Table` as follows:: from sqlalchemy import Table, Metadata, Column, Integer, String from sqlalchemy import schema metadata = MetaData() table = Table('mytable', MetaData(), Column('x', Integer, info={"special":True}, primary_key=True), Column('y', String(50)), Column('z', String(20), info={"special":True}) ) metadata.create_all(conn) Above, the directives we've added to the :attr:`.Column.info` collection will be detected by our custom compilation scheme:: CREATE TABLE mytable ( x SPECIAL DIRECTIVE INTEGER NOT NULL, y VARCHAR(50), z SPECIAL DIRECTIVE VARCHAR(20), PRIMARY KEY (x) ) The :class:`.CreateColumn` construct can also be used to skip certain columns when producing a ``CREATE TABLE``. This is accomplished by creating a compilation rule that conditionally returns ``None``. This is essentially how to produce the same effect as using the ``system=True`` argument on :class:`.Column`, which marks a column as an implicitly-present "system" column. For example, suppose we wish to produce a :class:`.Table` which skips rendering of the PostgreSQL ``xmin`` column against the PostgreSQL backend, but on other backends does render it, in anticipation of a triggered rule. A conditional compilation rule could skip this name only on PostgreSQL:: from sqlalchemy.schema import CreateColumn @compiles(CreateColumn, "postgresql") def skip_xmin(element, compiler, **kw): if element.element.name == 'xmin': return None else: return compiler.visit_create_column(element, **kw) my_table = Table('mytable', metadata, Column('id', Integer, primary_key=True), Column('xmin', Integer) ) Above, a :class:`.CreateTable` construct will generate a ``CREATE TABLE`` which only includes the ``id`` column in the string; the ``xmin`` column will be omitted, but only against the PostgreSQL backend. t create_columncCs ||_dS(N(RV(R RV((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLns(RRRCRSRL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRc sat DropTablecBseZdZdZRS(s!Represent a DROP TABLE statement.t drop_table(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRirstCreateSequencecBseZdZdZRS(s&Represent a CREATE SEQUENCE statement.tcreate_sequence(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRkxst DropSequencecBseZdZdZRS(s$Represent a DROP SEQUENCE statement.t drop_sequence(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRm~st CreateIndexcBseZdZdZRS(s#Represent a CREATE INDEX statement.t create_index(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRost DropIndexcBseZdZdZRS(s!Represent a DROP INDEX statement.t drop_index(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRqst AddConstraintcBseZdZdZdZRS(s2Represent an ALTER TABLE ADD CONSTRAINT statement.tadd_constraintcOs5tt|j|||tj|j|_dS(N(R\RsRLRtportable_instancemethodRXt _create_rule(R RVtargsR ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs(RRRCRSRL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRsstDropConstraintcBs eZdZdZedZRS(s3Represent an ALTER TABLE DROP CONSTRAINT statement.tdrop_constraintcKs;||_tt|j||tj|j|_dS(N(R_R\RxRLRRuRXRv(R RVR_R ((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs (RRRCRSR.RL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRxstSetTableCommentcBseZdZdZRS(s*Represent a COMMENT ON TABLE IS statement.tset_table_comment(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRzstDropTableCommentcBseZdZdZRS(sfRepresent a COMMENT ON TABLE '' statement. Note this varies a lot across database backends. tdrop_table_comment(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR|stSetColumnCommentcBseZdZdZRS(s+Represent a COMMENT ON COLUMN IS statement.tset_column_comment(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyR~stDropColumnCommentcBseZdZdZRS(s0Represent a COMMENT ON COLUMN IS NULL statement.tdrop_column_comment(RRRCRS(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRstDDLBasecBseZdZRS(cCs ||_dS(N(R(R R((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs(RRRL(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRstSchemaGeneratorcBsbeZeddZdZdZdZededZdZ edZ dZ RS( cKsMtt|j||||_||_|j|_||_i|_dS(N( R\RRLt checkfirstttablestidentifier_preparertpreparerR tmemo(R R RRRtkwargs((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLs     cCsh|jj|j|jj|}|r>|jj|n|j pg|jj|j|jd| S(Ntschema(R tvalidate_identifierR1Rtschema_for_objectRt has_table(R ttableteffective_schema((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt_can_create_tables cCs_|jj|}|jjo^|jj s5|j o^|j p^|jj|j|jd| S(NR( RRR tsupports_sequencestsequences_optionaltoptionalRt has_sequenceR1(R tsequenceR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt_can_create_sequences    c Cs|jdk r|j}nt|jj}tg|D]}|j|r:|^q:}g|jjD]*}|jdkrn|j|rn|^qn}g|D]\}}|dk r|^q}|j j ||j d|d|j d|x!|D]} |j | dtqWx`|D]X\} } | dk rY|j | dtd| dtqx| D]} |j | q`WqW|j j||j d|d|j d|dS(NRRt _ddl_runnert create_okRdt_is_metadata_operation(RRR3tvaluestsort_tables_and_constraintsRt _sequencesReRtdispatcht before_createRRttraverse_singleR5t after_create( R tmetadataRttt collectionRAtseq_colltfkstevent_collectiontseqRtfkcstfkc((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pytvisit_metadatas@ +*+          c Cs| r|j| rdS|jj||jd|jd|d|x3|jD](}|jdk rP|j|jqPqPW|j j sd}n|jj t |d|t |drx!|jD]}|j|qWn|j jr`|j j r`|jdk r!|jj t|nx<|jD].}|jdk r+|jj t|q+q+Wn|jj||jd|jd|d|dS(NRRRRdtindexes(RRRRRRbtdefaultRRR tsupports_alterRR`thasattrRtsupports_commentstinline_commentstcommentRzR~R(R RRRdRRetindex((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt visit_tables@           cCs*|jjsdS|jjt|dS(N(R RRRRs(R t constraint((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pytvisit_foreign_key_constraintSs cCs5| r|j| rdS|jjt|dS(N(RRRRk(R RR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pytvisit_sequenceXscCs|jjt|dS(N(RRRo(R R((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt visit_index]sN( RRR.RRLRRRRRRR(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRs 3 3  t SchemaDroppercBs_eZeddZdZdZdZdZeedZ dZ edZ RS( cKsMtt|j||||_||_|j|_||_i|_dS(N( R\RRLRRRRR R(R R RRRR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRLbs     c sjdk rj}nt|jj}ySg|D]}j|r:|^q:}ttt|dfd}Wntjk r]}j j st j ddj tg|jD]}|j^qg|D]}|d f^q}q^t jtj|jd|j|jdddj tg|jD]}|j^q:nXg|jjD]*}|jdkrnj|rn|^qn}g|D]\}} |dk r|^q} |jj|jd| d jd xZ|D]R\} } | dk r/j| d td tqx| D]} j| q6WqWx!|D]}j|d tqXW|jj|jd| d jd dS(Nt filter_fncs$jj s|jdkr tSdS(N(R RR1RR.(R(R (sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pytxs s4Can't sort tables for DROP; an unresolvable foreign key dependency exists between tables: %s, and backend does not support ALTER. To restore at least a partial sort, apply use_alter=True to ForeignKey and ForeignKeyConstraint objects involved in the cycle to mark these as known cycles that will be ignored.s, itmsgsCan't sort tables for DROP; an unresolvable foreign key dependency exists between tables: %s. Please ensure that the ForeignKey and ForeignKeyConstraint objects involved in the cycle have names so that they can be dropped using DROP CONSTRAINT.RRRtdrop_okR((RRR3Rt_can_drop_tabletreversedRRtCircularDependencyErrorR RRtwarnRNtsortedtcyclestfullnametraise_from_causeRwtedgesRRet_can_drop_sequenceRt before_dropRRRR5t after_drop(R RRRtunsorted_tablesRterr2RARRRRRRR((R sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRls` ( 0"  1*+         cCsg|jj|j|jj|}|r>|jj|n|j pf|jj|j|jd|S(NR(R RR1RRRR(R RR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRs cCs^|jj|}|jjo]|jj s5|j o]|j p]|jj|j|jd|S(NR( RRR RRRRRR1(R RR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRs    cCs|jjt|dS(N(RRRq(R R((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRsc Cs| r|j| rdS|jj||jd|jd|d||jjt|x3|jD](}|jdk rf|j |jqfqfW|jj ||jd|jd|d|dS(NRRR( RRRRRRRiRbRRRR(R RRRRe((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRs$      cCs*|jjsdS|jjt|dS(N(R RRRRx(R R((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRs cCs5| r|j| rdS|jjt|dS(N(RRRRm(R RR((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRsN( RRR.RRLRRRRRRR(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRas Z  cs_dk rfd}nd}gt|d|d|D]\}}|dk r=|^q=S(s]sort a collection of :class:`.Table` objects based on dependency. This is a dependency-ordered sort which will emit :class:`.Table` objects such that they will follow their dependent :class:`.Table` objects. Tables are dependent on another based on the presence of :class:`.ForeignKeyConstraint` objects as well as explicit dependencies added by :meth:`.Table.add_is_dependent_on`. .. warning:: The :func:`.sort_tables` function cannot by itself accommodate automatic resolution of dependency cycles between tables, which are usually caused by mutually dependent foreign key constraints. To resolve these cycles, either the :paramref:`.ForeignKeyConstraint.use_alter` parameter may be applied to those constraints, or use the :func:`.sql.sort_tables_and_constraints` function which will break out foreign key constraints involved in cycles separately. :param tables: a sequence of :class:`.Table` objects. :param skip_fn: optional callable which will be passed a :class:`.ForeignKey` object; if it returns True, this constraint will not be considered as a dependency. Note this is **different** from the same parameter in :func:`.sort_tables_and_constraints`, which is instead passed the owning :class:`.ForeignKeyConstraint` object. :param extra_dependencies: a sequence of 2-tuples of tables which will also be considered as dependent on each other. .. seealso:: :func:`.sort_tables_and_constraints` :meth:`.MetaData.sorted_tables` - uses this function to sort cs,x%|jD]}|r tSq WdSdS(N(telementsR5R(Rtfk(tskip_fn(sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt_skip_fn4s Rtextra_dependenciesN(RR(RRRRRR((RsE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt sort_tables s) c sTt}t}|dk r.|j|nt}x|D]xjD]}|jtkrv|j|qNn|r||}|tkr|j|qNqn|j}|k rN|j|fqNqNW|jfdjDq>Wy+t t j |j ||dt} Wnt jk r} x| jD]} | |krG| dgjD]*}|dks||tk rm|^qm} |j| x<| D]1}|j}|k r|j|fqqWqGqGWt t j |j ||dt} nXg| D]jj|f^qdt |fgS(ssort a collection of :class:`.Table` / :class:`.ForeignKeyConstraint` objects. This is a dependency-ordered sort which will emit tuples of ``(Table, [ForeignKeyConstraint, ...])`` such that each :class:`.Table` follows its dependent :class:`.Table` objects. Remaining :class:`.ForeignKeyConstraint` objects that are separate due to dependency rules not satisfied by the sort are emitted afterwards as ``(None, [ForeignKeyConstraint ...])``. Tables are dependent on another based on the presence of :class:`.ForeignKeyConstraint` objects, explicit dependencies added by :meth:`.Table.add_is_dependent_on`, as well as dependencies stated here using the :paramref:`~.sort_tables_and_constraints.skip_fn` and/or :paramref:`~.sort_tables_and_constraints.extra_dependencies` parameters. :param tables: a sequence of :class:`.Table` objects. :param filter_fn: optional callable which will be passed a :class:`.ForeignKeyConstraint` object, and returns a value based on whether this constraint should definitely be included or excluded as an inline constraint, or neither. If it returns False, the constraint will definitely be included as a dependency that cannot be subject to ALTER; if True, it will **only** be included as an ALTER result at the end. Returning None means the constraint is included in the table-based result unless it is detected as part of a dependency cycle. :param extra_dependencies: a sequence of 2-tuples of tables which will also be considered as dependent on each other. .. versionadded:: 1.0.0 .. seealso:: :func:`.sort_tables` c3s|]}|fVqdS(N((t.0tparent(R(sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pys stdeterministic_orderiN(R4Rtupdatetforeign_key_constraintst use_alterR5taddtreferred_tablet_extra_dependenciesR3RtsortRERRRR.tdiscardt difference( RRRtfixed_dependenciestmutable_dependenciestremaining_fkcsRtfilteredt dependent_ontcandidate_sortterrtedget can_remove((RsE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyRGs\+                *    ! %N('RCtbaseRRRRRRR$RRRRR RRHRURYR]R`RfRcRiRkRmRoRqRsRxRzR|R~RRRRRRR(((sE/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.pyt sD i   ?