Ñò ‰„[Jc @sÂddklZlZlZlZlZddklZlZl Z ddk l Z d„Z d„Z eeeed„Zd„Zed„Zd efd „ƒYZhZdd klZxreiiƒeieigD]QZeeeƒo;eeeiƒo(d eifeƒUd eidUqÜqÜWdd„Z!d„Z"dd„Z#d„Z$dded„Z%dd„Z&defd„ƒYZ'de i(fd„ƒYZ)de)fd„ƒYZ*dS(iÿÿÿÿ(texctschemat topologicaltutiltsql(t expressiont operatorstvisitors(tchaincsftˆƒ‰g‰‡‡fd†}x/ˆD]'}ti|htd6h|d6ƒq+WtiˆˆƒS(sLsort a collection of Table objects in order of their foreign-key dependency.csO|iodS|ii}|ˆjo#|ii}ˆi||fƒndS(N(t use_altertcolumnttabletparenttappend(tfkeyt parent_tablet child_table(ttuplesttables(s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytvisit_foreign_key s     tschema_visitort foreign_key(tlistRttraversetTrueRtsort(RRR ((RRs7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyt sort_tabless %cCsftti|ƒƒ}xJt|ƒD]8\}}x)|D]!}|i|ƒo ||fSq5Wq"WdSdS(s³Given a list of FROM clauses and a selectable, return the first index and element from the list of clauses which can be joined against the selectable. returns None, None if no match is found. e.g.:: clause1 = table1.join(table2) clause2 = table4.join(table5) join_to = table2.join(table3) find_join_source([clause1, clause2], join_to) == clause1 N(NN(RRt _from_objectst enumeratetis_derived_fromtNone(tclausestjoin_tot selectablestitfts((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytfind_join_sources cs®g‰h}‡fd†}|o||d<|dCan't find any foreign key relationships between '%s' and '%s'is®Can't determine join between '%s' and '%s'; tables have more than one foreign key constraint relationship between them. Please specify the 'onclause' of this join explicitly.N(tsett foreign_keyst get_referentRtNoReferencedTableErrorR R R6t constrainttlent ArgumentErrort descriptionRtand_(tatbtignore_nonexistent_tablestcritt constraintstfkR7((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytjoin_conditionWsH      t AnnotatedcBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s§clones a ClauseElement and applies an 'annotations' dictionary. Unlike regular clones, this clone also mimics __hash__() and __cmp__() of the original element so that it takes its place in hashed collections. A reference to the original element is maintained, for the important reason of keeping its hash value current. When GC'ed, the hash value may be reused, causing conflicts. cGs|pti|ƒS|\}}yt|i}WnItj o=titd|iit|ifhƒ}t|iR„R6RRRt ColumnSetRƒ( RˆRtkwRFR7RIRYtfk_colR‰R/((R‡Rˆs7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytreduce_columnss4     "cs]ˆoˆotidƒ‚n‡‡‡‡fd†}g‰ti|hh|d6ƒˆS(s9traverse an expression and locate binary criterion pairs.sSCan only specify one of 'consider_as_foreign_keys' or 'consider_as_referenced_keys'csCˆ o|itij odSt|itiƒ pt|itiƒ odSˆo¤|iˆjo@|i|ijp|iˆjoˆi|i|ifƒq?|iˆjo@|i|ijp|iˆjoˆi|i|ifƒq?nBˆo¤|iˆjo@|i|ijp|iˆjoˆi|i|ifƒq?|iˆjo@|i|ijp|iˆjoˆi|i|ifƒq?n—t|it i ƒo€t|it i ƒoj|ii |iƒoˆi|i|ifƒq?|ii |iƒoˆi|i|ifƒq?ndS(N( RRR‚RWRyRt ColumnElementRzR RtColumnt references(R…(tpairst any_operatortconsider_as_foreign_keystconsider_as_referenced_keys(s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR‰Ss&.33!33!,R…(RRARR(RR”R•R“R‰((R’R“R”R•s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytcriterion_as_pairsMs cs9ˆdjo tƒ‰n‡fd†}ti|ihh|d6ƒg}t|itiƒot |iˆƒ}nt |ii ƒ}t|i tiƒot |i ˆƒ}nt |i i ƒ}tƒ}xa||D]U}|ˆjo5|i |jo!|i|ƒ|i|i ƒq1qÜ|i|ƒqÜW|S(skReturn a list of uniquely named columns. The column list of the given Join will be narrowed down to a list of all equivalently-named, equated columns folded into one column, where 'equated' means they are equated to each other in the ON clause of this join. This function is used by Join.select(fold_equivalents=True). Deprecated. This function is used for a certain kind of "polymorphic_union" which is designed to achieve joined table inheritance where the base table has no "discriminator" column; [ticket:1131] will provide a better way to achieve this. csT|itijo=|ii|iijo$ˆi|iƒˆi|iƒndS(N(RRR‚RytnameRzR6(R…(tequivs(s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR‰€s,R…N(RR;RRRxRWRyRRvtfolded_equivalentsRRˆRzR—R R6(R*R˜R‰tcollistRyRztusedRY((R˜s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR™ms(      t AliasedRowcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sWrap a RowProxy with a translation map. This object allows a set of keys to be translated to those present in a RowProxy. cCs6t|tƒo|i|_n ||_||_dS(N(RWRœtrowtmap(R^RRž((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR_Ÿs cCs|i||ijS(N(RžR(R^tkey((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyt __contains__¨scCs ||jS(N((R^RŸ((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pythas_key«scCs|i|i|S(N(RRž(R^RŸ((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyt __getitem__®scCs |iiƒS(N(Rtkeys(R^((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR£±s(RRRkRlR_R R¡R¢R£(((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyRœ˜s    RtcBs8eZdZdddd„Zeid„Zd„ZRS(s9Clones and modifies clauses based on column correspondence. E.g.:: table1 = Table('sometable', metadata, Column('col1', Integer), Column('col2', Integer) ) table2 = Table('someothertable', metadata, Column('col1', Integer), Column('col2', Integer) ) condition = table1.c.col1 == table2.c.col1 make an alias of table1:: s = table1.alias('foo') calling ``ClauseAdapter(s).traverse(condition)`` converts condition to read:: s.c.col1 == table2.c.col1 cCsRhtd6|gd6|_||_||_||_ti|phƒ|_dS(NR-R{(R.t__traverse_options__t selectabletincludeRpRt column_dictt equivalents(R^R¥R¨R¦Rp((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR_Ïs    cCs|ii|d|ƒ}| ol||ijo\||joOxL|i|D]9}|i|d|d|i|gƒƒ}|o|SqKWn|S(Ntrequire_embeddedt_seen(R¥tcorresponding_columnR¨t_corresponding_columntunion(R^R7R©Rªtnewcoltequiv((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR¬Ös%' cCs˜t|tiƒo|ii|ƒo|iSnt|tiƒpdS|io||ijodS|io||ijodS|i |t ƒS(N( RWRRXR¥RRRR¦RpR¬R(R^R7((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytreplaceàs N( RRRkRlRR_Rt EMPTY_SETR¬R°(((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyRtµs t ColumnAdaptercBskeZdZddddd„Zd„ZeiZei Z d„Z d„Z d„Z d„Zd„ZRS( sExtends ClauseAdapter with extra utility functions. Provides the ability to "wrap" this ClauseAdapter around another, a columns dictionary which returns cached, adapted elements given an original, and an adapted_row() factory. cCsJti|||||ƒ|o|i|ƒnti|iƒ|_dS(N(RtR_RRtpopulate_column_dictt _locate_colRˆ(R^R¥R¨tchain_toR¦Rp((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR_øscCs‘|ii|iƒ}|iiƒ|_|i|i|iƒ|_|i|i|iƒ|_|i|i|iƒ|_ti |iƒ|_ |S(N( RORMRZR[t_wrapR´t adapt_clauset adapt_listRR³Rˆ(R^R}tac((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytwrapþscs‡‡fd†}|S(Ncsˆ|ƒ}ˆ|ƒS(N((R7(twrappedtlocal(s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pytlocate s ((R^R¼R»R½((R»R¼s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR¶ scCsV|i|tƒ}|p9|i|ƒ}t|tiƒo|idƒ}qRn|S(N(R¬R.R·RWRt_LabeltlabelR(R^R7RY((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR´s cCst||iƒS(N(RœRˆ(R^R((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyt adapted_rowscCs|iiƒ}|d=|S(NRˆ(RZR[(R^td((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyt __getstate__scCs)|ii|ƒti|iƒ|_dS(N(RZR`Rt PopulateDictR´Rˆ(R^tstate((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyt __setstate__"sN(RRRkRlRR_RºRtRR·tcopy_and_processR¸R¶R´RÀRÂRÅ(((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyR²ïs     (+t sqlalchemyRRRRRtsqlalchemy.sqlRRRt itertoolsRRR%R.R5R:RJRLRKRNRZRVRtTableRSRWRQt issubclasst ClauseElementRRtlocalsRRrRsR€RŽR–R™RœtReplacingCloningVisitorRtR²(((s7/usr/lib/python2.6/site-packages/sqlalchemy/sql/util.pyts2(   8F #   5 +: