ÿØÿà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@sdZddlZddlZddlZddlmZddlmZddlmZddlm Z ddl m Z dd l m Z dd l mZdd l mZdd l mZdd l mZddl mZddl mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$dd lm%Z%dd!lm&Z&dd"lm'Z'dd#lm(Z(dd$lm)Z)d%d&lm*Z*d%d'lm+Z+d%d(lm,Z,d)Z-d*Z.d+e#fd,YZ/e0e0d-Z1d.Z2d/Z3d0e$fd1YZ4d2e5fd3YZ6d4e5fd5YZ7d6e4fd7YZ8d8e8fd9YZ9d:e8fd;YZ:d<e:fd=YZ;d>e:fd?YZ<d@ee7e:fdAYZ=dBe5fdCYZ>dDe8fdEYZ?dFee8fdGYZ@dHe$fdIYZAdJe>ee8fdKYZBdLeBfdMYZCdNeCfdOYZDdPe6e7eCfdQYZEdRee&fdSYZFdTe)fdUYZGdVeBfdWYZHdXe fdYYZIdS(ZsiThe :class:`.FromClause` class of SQL expression elements, representing SQL tables and derived rowsets. iN(t attrgetter(t Visitablei(t operators(ttype_api(t Annotated(t _from_objects(t _generative(tColumnCollection(t ColumnSet(t Executable(t Generative(t Immutable(t_anonymous_label(t_clause_element_as_expr(t_clone(t_cloned_difference(t_cloned_intersection(t_document_text_coercion(t_expand_cloned(t_interpret_as_column_or_from(t&_literal_and_labels_as_label_reference(t_literal_as_label_reference(t_literal_as_text(t_no_text_coercion(t_select_iterables(tand_(t BindParameter(t ClauseElement(t ClauseList(tGrouping(tliteral_column(tTrue_(tUnaryExpressioni(texc(t inspection(tutilcCsutj|dt}|dkrCt|tjrCt|qCny |jSWn t k rpt j dnXdS(NtraiseerrsFROM expression expected( R"tinspecttFalsetNonet isinstanceR#t string_typesRt selectabletAttributeErrorR!t ArgumentError(telementtinsp((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_interpret_as_from7s   cCsIt|}t|tr'|j}nt|tsE|j}n|S(N(R/R(tAliastoriginalt SelectBasetselect(R-((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_interpret_as_selectBs   t_OffsetLimitParamcBseZedZRS(cCs|jS(N(teffective_value(tself((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_limit_offset_valueLs(t__name__t __module__tpropertyR8(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR5KscCsh|dkrdSt|dr)|jSt|tr<|Stj|}t||d|dtSdS(sConvert the given value to an "offset or limit" clause. This handles incoming integers and converts to an expression; if an expression is already given, it is passed through. t__clause_element__ttype_tuniqueN( R'thasattrR<R(RR#tasintR5tTrue(R-tnameR=tvalue((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_offset_or_limit_clauseQs  cCsU|dkrdSy |j}Wn$tk rCtjd|nXtj|SdS(sConvert the "offset or limit" clause of a select construct to an integer. This is only possible if the value is stored as a simple bound parameter. Otherwise, a compilation error is raised. s@This SELECT structure does not use a simple integer value for %sN(R'R8R+R!t CompileErrorR#R@(tclausetattrnameRC((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_offset_or_limit_clause_asintcs   cOst||j|S(sReturn an :class:`.Alias` object derived from a :class:`.Select`. name alias name \*args, \**kwargs all other arguments are delivered to the :func:`select` function. (tSelecttalias(RJtargstkwargs((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytsubqueryxs t SelectablecBs)eZdZdZeZedZRS(s mark a class as being selectableR*cCs|S(N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR*s(R9R:t__doc__t__visit_name__RAt is_selectableR;R*(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRNst HasPrefixescBs;eZdZeeddddZddZRS(texprs :meth:`.HasPrefixes.prefix_with`s*:paramref:`.HasPrefixes.prefix_with.*expr`cOsK|jdd}|r7tjddj|n|j||dS(sAdd one or more expressions following the statement keyword, i.e. SELECT, INSERT, UPDATE, or DELETE. Generative. This is used to support backend-specific prefix keywords such as those provided by MySQL. E.g.:: stmt = table.insert().prefix_with("LOW_PRIORITY", dialect="mysql") # MySQL 5.7 optimizer hints stmt = select([table]).prefix_with( "/*+ BKA(t1) */", dialect="mysql") Multiple prefixes can be specified by multiple calls to :meth:`.prefix_with`. :param \*expr: textual or :class:`.ClauseElement` construct which will be rendered following the INSERT, UPDATE, or DELETE keyword. :param \**kw: A single keyword 'dialect' is accepted. This is an optional string dialect name which will limit rendering of this prefix to only that dialect. tdialectsUnsupported argument(s): %st,N(tpopR'R!R,tjoint_setup_prefixes(R7RStkwRT((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt prefix_withs cCs?|jtg|D]}t|dt|f^q|_dS(Ntallow_coercion_to_text(t _prefixesttupleRRA(R7tprefixesRTtp((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRXs (N(R9R:R\RRRZR'RX(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRRs#t HasSuffixescBs;eZdZeeddddZddZRS(RSs :meth:`.HasSuffixes.suffix_with`s*:paramref:`.HasSuffixes.suffix_with.*expr`cOsK|jdd}|r7tjddj|n|j||dS(sAdd one or more expressions following the statement as a whole. This is used to support backend-specific suffix keywords on certain constructs. E.g.:: stmt = select([col1, col2]).cte().suffix_with( "cycle empno set y_cycle to 1 default 0", dialect="oracle") Multiple suffixes can be specified by multiple calls to :meth:`.suffix_with`. :param \*expr: textual or :class:`.ClauseElement` construct which will be rendered following the target clause. :param \**kw: A single keyword 'dialect' is accepted. This is an optional string dialect name which will limit rendering of this suffix to only that dialect. RTsUnsupported argument(s): %sRUN(RVR'R!R,RWt_setup_suffixes(R7RSRYRT((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt suffix_withs cCs?|jtg|D]}t|dt|f^q|_dS(NR[(t _suffixesR]RRA(R7tsuffixesRTR_((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRas (N(R9R:RcRRRbR'Ra(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR`st FromClausecBseZdZdZeZgZeZeZeZ eZ eZ d!Z dZejdgZejdddejdd!dZd!d Zd!eed Zd!ed Zd!ed Zd!d Zd!d!dZdZdZejddZdZedZe dZ!dZ"edZ#edZ$edZ%e e&dddZ'e e&dZ(dZ)e dZ*dZ+d Z,RS("sRepresent an element that can be used within the ``FROM`` clause of a ``SELECT`` statement. The most common forms of :class:`.FromClause` are the :class:`.Table` and the :func:`.select` constructs. Key features common to all :class:`.FromClause` objects include: * a :attr:`.c` collection, which provides per-name access to a collection of :class:`.ColumnElement` objects. * a :attr:`.primary_key` attribute, which is a collection of all those :class:`.ColumnElement` objects that indicate the ``primary_key`` flag. * Methods to generate various derivations of a "from" clause, including :meth:`.FromClause.alias`, :meth:`.FromClause.join`, :meth:`.FromClause.select`. t fromclausecCs|S(N((R7teffective_schematmap_((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_translate_schemast_columnss1.1tmessagesThe :meth:`.FromClause.count` method is deprecated, and will be removed in a future release. Please use the :class:`.functions.count` function available from the :attr:`.func` namespace.ssqlalchemy.sql.functionscKsc|jrt|jd}nt|jd}t|jj|jdg|d|g|S(sreturn a SELECT COUNT generated against this :class:`.FromClause`. .. seealso:: :class:`.functions.count` it tbl_row_counttfrom_obj(t primary_keytlisttcolumnsRItfunctcounttlabel(R7t functionst whereclausetparamstcol((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRr$s cKst|g||S(sreturn a SELECT of this :class:`.FromClause`. .. seealso:: :func:`~.sql.expression.select` - general purpose method which allows for arbitrary column lists. (RI(R7RuRv((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR3As cCst|||||S(s Return a :class:`.Join` from this :class:`.FromClause` to another :class:`FromClause`. E.g.:: from sqlalchemy import join j = user_table.join(address_table, user_table.c.id == address_table.c.user_id) stmt = select([user_table]).select_from(j) would emit SQL along the lines of:: SELECT user.id, user.name FROM user JOIN address ON user.id = address.user_id :param right: the right side of the join; this is any :class:`.FromClause` object such as a :class:`.Table` object, and may also be a selectable-compatible object such as an ORM-mapped class. :param onclause: a SQL expression representing the ON clause of the join. If left at ``None``, :meth:`.FromClause.join` will attempt to join the two tables based on a foreign key relationship. :param isouter: if True, render a LEFT OUTER JOIN, instead of JOIN. :param full: if True, render a FULL OUTER JOIN, instead of LEFT OUTER JOIN. Implies :paramref:`.FromClause.join.isouter`. .. versionadded:: 1.1 .. seealso:: :func:`.join` - standalone function :class:`.Join` - the type of object produced (tJoin(R7trighttonclausetisoutertfull((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRWMs)cCst|||t|S(sReturn a :class:`.Join` from this :class:`.FromClause` to another :class:`FromClause`, with the "isouter" flag set to True. E.g.:: from sqlalchemy import outerjoin j = user_table.outerjoin(address_table, user_table.c.id == address_table.c.user_id) The above is equivalent to:: j = user_table.join( address_table, user_table.c.id == address_table.c.user_id, isouter=True) :param right: the right side of the join; this is any :class:`.FromClause` object such as a :class:`.Table` object, and may also be a selectable-compatible object such as an ORM-mapped class. :param onclause: a SQL expression representing the ON clause of the join. If left at ``None``, :meth:`.FromClause.join` will attempt to join the two tables based on a foreign key relationship. :param full: if True, render a FULL OUTER JOIN, instead of LEFT OUTER JOIN. .. versionadded:: 1.1 .. seealso:: :meth:`.FromClause.join` :class:`.Join` (RxRA(R7RyRzR|((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt outerjoinxs)cCstj||S(sVreturn an alias of this :class:`.FromClause`. E.g.:: a2 = some_table.alias('a2') The above code creates an :class:`.Alias` object which can be used as a FROM clause in any SELECT statement. .. seealso:: :ref:`core_tutorial_aliases` :func:`~.expression.alias` (R0t _construct(R7RBtflat((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRJscCstj||S(s8Return a LATERAL alias of this :class:`.FromClause`. The return value is the :class:`.Lateral` construct also provided by the top-level :func:`~.expression.lateral` function. .. versionadded:: 1.1 .. seealso:: :ref:`lateral_selects` - overview of usage. (tLateralR~(R7RB((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytlaterals cCstj||||S(sZReturn a TABLESAMPLE alias of this :class:`.FromClause`. The return value is the :class:`.TableSample` construct also provided by the top-level :func:`~.expression.tablesample` function. .. versionadded:: 1.1 .. seealso:: :func:`~.expression.tablesample` - usage guidelines and parameters (t TableSampleR~(R7tsamplingRBtseed((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt tablesamples cCs ||jkS(sReturn True if this FromClause is 'derived' from the given FromClause. An example would be an Alias of a Table is derived from that Table. (t _cloned_set(R7Rf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytis_derived_froms cCs|jj|jS(sReturn True if this FromClause and the other represent the same lexical identity. This tests if either one is a copy of the other, or if they are the same via annotation identity. (Rt intersection(R7tother((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_is_lexical_equivalentsssqlalchemy.sql.utilcCs|j|j|S(sreplace all occurrences of FromClause 'old' with the given Alias object, returning a copy of this :class:`.FromClause`. (t ClauseAdapterttraverse(R7tsqlutiltoldRJ((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytreplace_selectablescCsh|j|dt}|dkrd||krdx4||D]%}|j|dt}|r8|Sq8Wn|S(szReturn corresponding_column for the given column, or if None search for a match in the given dictionary. trequire_embeddedN(tcorresponding_columnRAR'(R7tcolumnt equivalentsRwtequivtnc((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytcorrespond_on_equivalentss cCsd}|jj|r|Sd\}}|j}|jj}xX|D]P}tt|j} |j| } | rG| s|| |rG|dkr|| }}qt| t|kr|| }}q| |krt j t j g|j D]*} | j|r| jjdd^q} t j t j g|j D]*} | j|rB| jjdd^qB} | | kr|| }}qqqGqGW|S(sGiven a :class:`.ColumnElement`, return the exported :class:`.ColumnElement` object from this :class:`.Selectable` which corresponds to that original :class:`~sqlalchemy.schema.Column` via a common ancestor column. :param column: the target :class:`.ColumnElement` to be matched :param require_embedded: only return corresponding columns for the given :class:`.ColumnElement`, if the given :class:`.ColumnElement` is actually present within a sub-element of this :class:`.FromClause`. Normally the column will match if it merely shares a common ancestor with one of the exported columns of this :class:`.FromClause`. cSs@x9|j|D](}tt|gj|stSqWtS(N(t differencetsetRRR&RA(texpanded_proxy_sett target_settt((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytembeddeds  tweightiN(NN(tctcontains_columnR't proxy_sett _all_columnsRRRtlenR#treducetoperatortaddt_uncached_proxy_settshares_lineaget _annotationstget(R7RRRRwt intersectRtcolsRRtitsct col_distancet c_distance((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs<       -- cCst|d|jjdS(sga brief description of this FromClause. Used primarily for error message formatting. RBs object(tgetattrt __class__R9(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt descriptionUscCs|jj|dS(s8delete memoized collections when a FromClause is cloned.N(t_memoized_propertytexpire_instance(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_reset_exported^scCs3d|jkr&|j|jn|jjS(skA named-based collection of :class:`.ColumnElement` objects maintained by this :class:`.FromClause`. The :attr:`.columns`, or :attr:`.c` collection, is the gateway to the construction of SQL expressions using table-bound or other selectable-bound columns:: select([mytable]).where(mytable.c.somecolumn == 5) Rj(t__dict__t_init_collectionst_populate_column_collectionRjt as_immutable(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRpcs   cCs|j|j|jS(sbReturn the collection of Column objects which comprise the primary key of this FromClause.(RRRn(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRnus  cCs|j|j|jS(sUReturn the collection of ForeignKey objects which this FromClause references.(RRt foreign_keys(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR~s  Rptdocs,An alias for the :attr:`.columns` attribute.cCsgd|jkstd|jks*td|jks?tt|_t|_t|_dS(NRjRnR(RtAssertionErrorRRjRRnRR(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs   cCs d|jkS(NRj(R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_cols_populatedscCsdS(sCalled on subclasses to establish the .c collection. Each implementation has a different way of establishing this collection. N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRtcCsA|js dS|j|jkr9|j|j|kr9|SdSdS(sMGiven a column added to the .c collection of an underlying selectable, produce the local version of that column, assuming this selectable ultimately should proxy this column. this is used to "ping" a derived selectable to add a new column to its .c. collection when a Column has been added to one of the Table objects it ultimtely derives from. If the given selectable hasn't populated its .c. collection yet, it should at least pass on the message to the contained selectables, but it will return None. This method is currently used by Declarative to allow Table columns to be added to a partially constructed inheritance mapping that may have already produced joins. The method isn't public right now, as the full span of implications and/or caveats aren't yet clear. It's also possible that this functionality could be invoked by default via an event, which would require that selectables maintain a weak referencing collection of all derivations. N(RR'tkeyRp(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_refresh_for_new_columns  (N(-R9R:RORPR&tnamed_with_columnt _hide_fromst_is_joint _is_selectt_is_from_containert _is_lateralt_textualR'tschemaRiR#t!group_expirable_memoized_propertyRt deprecatedt dependenciesRrR3RWR}RJRRRRRRRR;RRRpRnRRRt_select_iterableRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyResR   ++   T       RxcBsmeZdZdZeZdeedZe dedZ e deedZ e dZ dZddZejdd Zd Zed Zd Zd Ze ejddedddZe ddZe dZe dZddZe dZejddedZe dZ e dZ!RS(swrepresent a ``JOIN`` construct between two :class:`.FromClause` elements. The public constructor function for :class:`.Join` is the module-level :func:`.join()` function, as well as the :meth:`.FromClause.join` method of any :class:`.FromClause` (e.g. such as :class:`.Table`). .. seealso:: :func:`.join` :meth:`.FromClause.join` RWcCsmt||_t|j|_|dkrN|j|j|j|_n ||_||_||_dS(sConstruct a new :class:`.Join`. The usual entrypoint here is the :func:`~.expression.join` function or the :meth:`.FromClause.join` method of any :class:`.FromClause` object. N( R/tleftt self_groupRyR't_match_primariesRzR{R|(R7RRyRzR{R|((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt__init__s   cCs||||dtd|S(sReturn an ``OUTER JOIN`` clause element. The returned object is an instance of :class:`.Join`. Similar functionality is also available via the :meth:`~.FromClause.outerjoin()` method on any :class:`.FromClause`. :param left: The left side of the join. :param right: The right side of the join. :param onclause: Optional criterion for the ``ON`` clause, is derived from foreign key relationships established between left and right otherwise. To chain joins together, use the :meth:`.FromClause.join` or :meth:`.FromClause.outerjoin` methods on the resulting :class:`.Join` object. R{R|(RA(tclsRRyRzR|((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_create_outerjoinscCs||||||S(sProduce a :class:`.Join` object, given two :class:`.FromClause` expressions. E.g.:: j = join(user_table, address_table, user_table.c.id == address_table.c.user_id) stmt = select([user_table]).select_from(j) would emit SQL along the lines of:: SELECT user.id, user.name FROM user JOIN address ON user.id = address.user_id Similar functionality is available given any :class:`.FromClause` object (e.g. such as a :class:`.Table`) using the :meth:`.FromClause.join` method. :param left: The left side of the join. :param right: the right side of the join; this is any :class:`.FromClause` object such as a :class:`.Table` object, and may also be a selectable-compatible object such as an ORM-mapped class. :param onclause: a SQL expression representing the ON clause of the join. If left at ``None``, :meth:`.FromClause.join` will attempt to join the two tables based on a foreign key relationship. :param isouter: if True, render a LEFT OUTER JOIN, instead of JOIN. :param full: if True, render a FULL OUTER JOIN, instead of JOIN. .. versionadded:: 1.1 .. seealso:: :meth:`.FromClause.join` - method form, based on a given left side :class:`.Join` - the type of object produced ((RRRyRzR{R|((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt _create_joins/cCs2d|jjt|j|jjt|jfS(Ns Join object on %s(%d) and %s(%d)(RRtidRy(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR4s    cCs.||kp-|jj|p-|jj|S(N(RRRy(R7Rf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR=s cCs t|S(N(t FromGrouping(R7tagainst((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRDsssqlalchemy.sql.utilcCsg|jjD] }|^q g|jjD] }|^q)}|jj|jd|D|j|jjd|D|j jt j g|D]}|j ^qdS(Ncss|]}|jr|VqdS(N(Rn(t.0R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys Oscss|]}|j|fVqdS(N(t_label(RRw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys Rs( RRpRyRntextendtreduce_columnsRzRjtupdateRt itertoolstchain(R7RRRpRw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRGs   cCs|jj|}|dkr3|jj|}n|dk r|jr||j|j<|jj|j|j r|j j |n|SndS(N( RRR'RyRRjRRRRnR(R7RRw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRWs    cKsM|j||j||_||j||_||j||_dS(N(RRRyRz(R7tcloneRY((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_copy_internalsds cKs|j|j|jfS(N(RRyRz(R7RL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt get_childrenjscCs7t|tr|j}nd}|j||d|S(Nta_subset(R(RxRyR't_join_condition(R7RRyt left_right((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRms tignore_nonexistent_tabless0.9sThe :paramref:`.join_condition.ignore_nonexistent_tables` parameter is deprecated and will be removed in a future release. Tables outside of the two tables being handled are no longer considered.c Cs|j||||}t|dkrC|j||||nt|dkrt|trmd}nd}tjd|j|j|fngt|j dD]\}} || k^q} t| dkr| dSt | SdS(screate a join condition between two tables or selectables. e.g.:: join_condition(tablea, tableb) would produce an expression along the lines of:: tablea.c.id==tableb.c.tablea_id The join is determined based on the foreign key relationships between the two selectables. If there are multiple ways to join, or no way to join, an error is raised. :param ignore_nonexistent_tables: unused - tables outside of the two tables being handled are not considered. :param a_subset: An optional expression that is a sub-component of ``a``. An attempt will be made to join to just this sub-component first before looking at the full ``a`` construct, and if found will be successful even if there are other ways to join to ``a``. This allows the "right side" of a join to be passed thereby providing a "natural join". iisI Perhaps you meant to convert the right side to a subquery using alias()?RsACan't find any foreign key relationships between '%s' and '%s'.%sN( t_joincond_scan_left_rightRt_joincond_trim_constraintsR(RR!tNoForeignKeysErrorRRotvaluesR( RtatbRRtconsider_as_foreign_keyst constraintsthinttxtytcrit((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRts + 5c CsOt|tr|j}nd}|jd|d|d|d|}t|S(NRRRR(R(RxRyR'Rtbool(RRRyRRR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt _can_joins   c Cstjt}x||fD]}|dkr4qnxt|jddD]}|dk rt|j|krtqMny|j|}Wn1tj k r} | j |j krMqqMnX|dk rM||j j ||jfqMqMW||k rxt|jddD]}|dk r7|j|kr7qny|j|}Wn1tj k r}} | j |j krq~qnX|dk r||j j ||jfqqWn|rPqqW|S(NRcSs |jjS(N(tparentt_creation_order(tfk((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytRcSs |jjS(N(RR(R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRR(t collectionst defaultdictRoR'tsortedRRt get_referentR!tNoReferenceErrort table_nameRBt constrainttappend( RRRRRRRRRwtnrte((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRsD   $   'cCs|rOxFt|D]5}td|jDt|kr||=qqWnt|dkrtd|jD}t|dkrt|d}i|||6}qnt|dkrtjd|j|jfndS(Ncss|]}|jVqdS(N(R(Rtf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sicss|]}t|VqdS(N(R](RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sisCan'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.(RoRtelementsRRR!tAmbiguousForeignKeysErrorR(RRRRRtconsttdedupeR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs cKs+|j|jg}t||d|g|S(s"Create a :class:`.Select` from this :class:`.Join`. The equivalent long-hand form, given a :class:`.Join` object ``j``, is:: from sqlalchemy import select j = select([j.left, j.right], **kw).\ where(whereclause).\ select_from(j) :param whereclause: the WHERE criterion that will be sent to the :func:`select()` function :param \**kwargs: all other kwargs are sent to the underlying :func:`select()` function. Rm(RRyRI(R7RuRLtcollist((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR3scCs|jjp|jjS(N(RtbindRy(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR3scCs|r|dkstd|jjdt|jjdt}}|j|j|j|}|j||j |j d|j d|j S|j dtdtj|SdS(sbreturn an alias of this :class:`.Join`. The default behavior here is to first produce a SELECT construct from this :class:`.Join`, then to produce an :class:`.Alias` from that. So given a join of the form:: j = table_a.join(table_b, table_a.c.id == table_b.c.a_id) The JOIN by itself would look like:: table_a JOIN table_b ON table_a.id = table_b.a_id Whereas the alias of the above, ``j.alias()``, would in a SELECT context look like:: (SELECT table_a.id AS table_a_id, table_b.id AS table_b_id, table_b.a_id AS table_b_a_id FROM table_a JOIN table_b ON table_a.id = table_b.a_id) AS anon_1 The equivalent long-hand form, given a :class:`.Join` object ``j``, is:: from sqlalchemy import select, alias j = alias( select([j.left, j.right]).\ select_from(j).\ with_labels(True).\ correlate(False), name=name ) The selectable produced by :meth:`.Join.alias` features the same columns as that of the two individual selectables presented under a single name - the individual columns are "auto-labeled", meaning the ``.c.`` collection of the resulting :class:`.Alias` represents the names of the individual columns using a ``_`` scheme:: j.c.table_a_id j.c.table_b_a_id :meth:`.Join.alias` also features an alternate option for aliasing joins which produces no enclosing SELECT and does not normally apply labels to the column names. The ``flat=True`` option will call :meth:`.FromClause.alias` against the left and right sides individually. Using this option, no new ``SELECT`` is produced; we instead, from a construct as below:: j = table_a.join(table_b, table_a.c.id == table_b.c.a_id) j = j.alias(flat=True) we get a result like this:: table_a AS table_a_1 JOIN table_b AS table_b_1 ON table_a_1.id = table_b_1.a_id The ``flat=True`` argument is also propagated to the contained selectables, so that a composite join such as:: j = table_a.join( table_b.join(table_c, table_b.c.id == table_c.c.b_id), table_b.c.a_id == table_a.c.id ).alias(flat=True) Will produce an expression like:: table_a AS table_a_1 JOIN ( table_b AS table_b_1 JOIN table_c AS table_c_1 ON table_b_1.id = table_c_1.b_id ) ON table_a_1.id = table_b_1.a_id The standalone :func:`~.expression.alias` function as well as the base :meth:`.FromClause.alias` method also support the ``flat=True`` argument as a no-op, so that the argument can be passed to the ``alias()`` method of any selectable. .. versionadded:: 0.9.0 Added the ``flat=True`` option to create "aliases" of joins without enclosing inside of a SELECT subquery. :param name: name given to the alias. :param flat: if True, produce an alias of the left and right sides of this :class:`.Join` and return the join of those two selectables. This produces join expression that does not include an enclosing SELECT. .. versionadded:: 0.9.0 .. seealso:: :ref:`core_tutorial_aliases` :func:`~.expression.alias` s"Can't send name argument with flatRR{R|t use_labelst correlateN(R'RRRJRARyRRRWRRzR{R|R3R&(R7RRBRtleft_atright_atadapter((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRJ7se  cCs2tjg|jD]}t|j|j^qS(N(RRRRRRy(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCs%|g|jj|jj|jjS(N(RzRRRy(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRsN(s0.9sThe :paramref:`.join_condition.ignore_nonexistent_tables` parameter is deprecated and will be removed in a future release. Tables outside of the two tables being handled are no longer considered.("R9R:RORPRARR'R&Rt classmethodRRR;RRRR#RRRRRRRtdeprecated_paramsRRRRR3RRJRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRxsB/       82  wR0cBseZdZdZeZeZdZedZ ede dZ ddZ ddZedZdZd Zd Zd Zed Zed ZedZedZRS(sRepresents an table or selectable alias (AS). Represents an alias, as typically applied to any table or sub-select within a SQL statement using the ``AS`` keyword (or without the keyword on certain databases such as Oracle). This object is constructed from the :func:`~.expression.alias` module level function as well as the :meth:`.FromClause.alias` method available on all :class:`.FromClause` subclasses. RJcOs;td|jj|jjj|jjjfdS(NsThe %s class is not intended to be constructed directly. Please use the %s() standalone function or the %s() method available from appropriate selectable objects.(tNotImplementedErrorRR9tlower(R7targRY((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs  cOs#|j|}|j|||S(N(t__new__t_init(RRRYtobj((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR~scCst|jd|d|S(sMReturn an :class:`.Alias` object. An :class:`.Alias` represents any :class:`.FromClause` with an alternate name assigned within SQL, typically using the ``AS`` clause when generated, e.g. ``SELECT * FROM table AS aliasname``. Similar functionality is available via the :meth:`~.FromClause.alias` method available on all :class:`.FromClause` subclasses. In terms of a SELECT object as generated from the :func:`.select` function, the :meth:`.SelectBase.alias` method returns an :class:`.Alias` or similar object which represents a named, parenthesized subquery. When an :class:`.Alias` is created from a :class:`.Table` object, this has the effect of the table being rendered as ``tablename AS aliasname`` in a SELECT statement. For :func:`.select` objects, the effect is that of creating a named subquery, i.e. ``(select ...) AS aliasname``. The ``name`` parameter is optional, and provides the name to use in the rendered SQL. If blank, an "anonymous" name will be deterministically generated at compile time. Deterministic means the name is guaranteed to be unique against other constructs used in the same statement, and will also be the same name for each successive compilation of the same statement object. :param selectable: any :class:`.FromClause` subclass, such as a table, select statement, etc. :param name: string name to be assigned as the alias. If ``None``, a name will be deterministically generated at compile time. :param flat: Will be passed through to if the given selectable is an instance of :class:`.Join` - see :meth:`.Join.alias` for details. .. versionadded:: 0.9.0 RBR(R/RJ(RR*RBR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_factorys,cCs|}xt|tr$|j}q W||_|j|_|jrR|j|_n||_|dkr|jjrt|jdd}nt dt ||pdf}n||_ dS(NRBs %%(%d %s)stanon( R(R0R-R1tsupports_executiont_execution_optionsR'RRR RRB(R7R*RBtbaseselectable((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs       %cCsSt|tr:t|jtr:|jjr:t|Stt|jd|S(NR( R(tCompoundSelectR1RIt_needs_parens_for_groupingRtsuperR0R(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR!s  cCs'tjr|jS|jjddSdS(Ntasciitbackslashreplace(R#tpy3kRBtencode(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR+s cCs<y|jjSWn$tk r7td|jnXdS(Ns)Element %s does not support 'as_scalar()'(R-t as_scalarR+(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR 2s  cCs#||jkrtS|jj|S(N(RRAR-R(R7Rf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR:scCs+x$|jjjD]}|j|qWdS(N(R-RpRt _make_proxy(R7Rw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR?scCsC|jj|}|dk r;|js+dS|j|SndSdS(N(R-RR'RR!(R7RRw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRCs   cKsjt|jtrdS|j||j||_|j}xt|tr\|j}qAW||_dS(N(R(R-t TableClauseRR0R1(R7RRYR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRMs   cks.|r"x|jD] }|VqWn|jVdS(N(RR-(R7tcolumn_collectionsRYR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRZs cCs|gS(N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR`scCs |jjS(N(R-R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRdsN(R9R:RORPRARRRR R~R'R&RRRR;RR RRRRRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR0s&  -      RcBs,eZdZdZeZeddZRS(sRepresent a LATERAL subquery. This object is constructed from the :func:`~.expression.lateral` module level function as well as the :meth:`.FromClause.lateral` method available on all :class:`.FromClause` subclasses. While LATERAL is part of the SQL standard, currently only more recent PostgreSQL versions provide support for this keyword. .. versionadded:: 1.1 .. seealso:: :ref:`lateral_selects` - overview of usage. RcCst|jd|S(sfReturn a :class:`.Lateral` object. :class:`.Lateral` is an :class:`.Alias` subclass that represents a subquery with the LATERAL keyword applied to it. The special behavior of a LATERAL subquery is that it appears in the FROM clause of an enclosing SELECT, but may correlate to other FROM clauses of that SELECT. It is a special case of subquery only supported by a small number of backends, currently more recent PostgreSQL versions. .. versionadded:: 1.1 .. seealso:: :ref:`lateral_selects` - overview of usage. RB(R/R(RR*RB((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR~sN( R9R:RORPRARR R'R(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRis RcBsPeZdZdZedddZdddZej ddZ RS(sLRepresent a TABLESAMPLE clause. This object is constructed from the :func:`~.expression.tablesample` module level function as well as the :meth:`.FromClause.tablesample` method available on all :class:`.FromClause` subclasses. .. versionadded:: 1.1 .. seealso:: :func:`~.expression.tablesample` RcCst|j|d|d|S(seReturn a :class:`.TableSample` object. :class:`.TableSample` is an :class:`.Alias` subclass that represents a table with the TABLESAMPLE clause applied to it. :func:`~.expression.tablesample` is also available from the :class:`.FromClause` class via the :meth:`.FromClause.tablesample` method. The TABLESAMPLE clause allows selecting a randomly selected approximate percentage of rows from a table. It supports multiple sampling methods, most commonly BERNOULLI and SYSTEM. e.g.:: from sqlalchemy import func selectable = people.tablesample( func.bernoulli(1), name='alias', seed=func.random()) stmt = select([selectable.c.people_id]) Assuming ``people`` with a column ``people_id``, the above statement would render as:: SELECT alias.people_id FROM people AS alias TABLESAMPLE bernoulli(:bernoulli_1) REPEATABLE (random()) .. versionadded:: 1.1 :param sampling: a ``float`` percentage between 0 and 100 or :class:`.functions.Function`. :param name: optional alias name :param seed: any real-valued SQL expression. When specified, the REPEATABLE sub-clause is also rendered. RBR(R/R(RR*RRBR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs* cCs2||_||_tt|j|d|dS(NRB(RRRRR(R7R*RRBR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs  ssqlalchemy.sql.functionscCs3t|j|jr|jS|jj|jSdS(N(R(RtFunctionRqtsystem(R7Rt((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt _get_methodsN( R9R:RORPR R'RRR#RR&(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs  -tCTEcBseZdZdZed edZd ed ed dZ e dZ e j ddZd edZdZd ZRS( sRepresent a Common Table Expression. The :class:`.CTE` object is obtained using the :meth:`.SelectBase.cte` method from any selectable. See that method for complete examples. tctecCst|jd|d|S(sReturn a new :class:`.CTE`, or Common Table Expression instance. Please see :meth:`.HasCte.cte` for detail on CTE usage. RBt recursive(R/R((RR*RBR)((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCsM||_||_||_|r-||_ntt|j|d|dS(NRB(R)t _cte_aliast _restatesRcRR'R(R7R*RBR)R*R+Rc((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs    cKsrtt|j|||jdk r@||j||_ntg|jD]}|||^qM|_dS(N(RR'RR*R't frozensetR+(R7RRYtelem((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs ssqlalchemy.sql.dmlcCsgt|j|jr<xK|jjD]}|j|q"Wn'x$|jjjD]}|j|qLWdS(N(R(R-t UpdateBaset _returningR!RpR(R7tdmlRw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs c Cs.tj|jd|d|jd|d|jS(s Return an :class:`.Alias` of this :class:`.CTE`. This method is a CTE-specific specialization of the :class:`.FromClause.alias` method. .. seealso:: :ref:`core_tutorial_aliases` :func:`~.expression.alias` RBR)R*Rc(R'R~R1R)Rc(R7RBR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRJs   c CsItj|jj|d|jd|jd|jj|gd|jS(NRBR)R+Rc(R'R~R1tunionRBR)R+Rc(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR1-s   c CsItj|jj|d|jd|jd|jj|gd|jS(NRBR)R+Rc( R'R~R1t union_allRBR)R+R1Rc(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR26s   N(R9R:RORPR R'R&RR,RRRR#RRRJR1R2(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR's    tHasCTEcBseZdZdedZRS(sTMixin that declares a class to include CTE support. .. versionadded:: 1.1 cCstj|d|d|S(sReturn a new :class:`.CTE`, or Common Table Expression instance. Common table expressions are a SQL standard whereby SELECT statements can draw upon secondary statements specified along with the primary statement, using a clause called "WITH". Special semantics regarding UNION can also be employed to allow "recursive" queries, where a SELECT statement can draw upon the set of rows that have previously been selected. CTEs can also be applied to DML constructs UPDATE, INSERT and DELETE on some databases, both as a source of CTE rows when combined with RETURNING, as well as a consumer of CTE rows. SQLAlchemy detects :class:`.CTE` objects, which are treated similarly to :class:`.Alias` objects, as special elements to be delivered to the FROM clause of the statement as well as to a WITH clause at the top of the statement. .. versionchanged:: 1.1 Added support for UPDATE/INSERT/DELETE as CTE, CTEs added to UPDATE/INSERT/DELETE. :param name: name given to the common table expression. Like :meth:`._FromClause.alias`, the name can be left as ``None`` in which case an anonymous symbol will be used at query compile time. :param recursive: if ``True``, will render ``WITH RECURSIVE``. A recursive common table expression is intended to be used in conjunction with UNION ALL in order to derive rows from those already selected. The following examples include two from PostgreSQL's documentation at http://www.postgresql.org/docs/current/static/queries-with.html, as well as additional examples. Example 1, non recursive:: from sqlalchemy import (Table, Column, String, Integer, MetaData, select, func) metadata = MetaData() orders = Table('orders', metadata, Column('region', String), Column('amount', Integer), Column('product', String), Column('quantity', Integer) ) regional_sales = select([ orders.c.region, func.sum(orders.c.amount).label('total_sales') ]).group_by(orders.c.region).cte("regional_sales") top_regions = select([regional_sales.c.region]).\ where( regional_sales.c.total_sales > select([ func.sum(regional_sales.c.total_sales)/10 ]) ).cte("top_regions") statement = select([ orders.c.region, orders.c.product, func.sum(orders.c.quantity).label("product_units"), func.sum(orders.c.amount).label("product_sales") ]).where(orders.c.region.in_( select([top_regions.c.region]) )).group_by(orders.c.region, orders.c.product) result = conn.execute(statement).fetchall() Example 2, WITH RECURSIVE:: from sqlalchemy import (Table, Column, String, Integer, MetaData, select, func) metadata = MetaData() parts = Table('parts', metadata, Column('part', String), Column('sub_part', String), Column('quantity', Integer), ) included_parts = select([ parts.c.sub_part, parts.c.part, parts.c.quantity]).\ where(parts.c.part=='our part').\ cte(recursive=True) incl_alias = included_parts.alias() parts_alias = parts.alias() included_parts = included_parts.union_all( select([ parts_alias.c.sub_part, parts_alias.c.part, parts_alias.c.quantity ]). where(parts_alias.c.part==incl_alias.c.sub_part) ) statement = select([ included_parts.c.sub_part, func.sum(included_parts.c.quantity). label('total_quantity') ]).\ group_by(included_parts.c.sub_part) result = conn.execute(statement).fetchall() Example 3, an upsert using UPDATE and INSERT with CTEs:: from datetime import date from sqlalchemy import (MetaData, Table, Column, Integer, Date, select, literal, and_, exists) metadata = MetaData() visitors = Table('visitors', metadata, Column('product_id', Integer, primary_key=True), Column('date', Date, primary_key=True), Column('count', Integer), ) # add 5 visitors for the product_id == 1 product_id = 1 day = date.today() count = 5 update_cte = ( visitors.update() .where(and_(visitors.c.product_id == product_id, visitors.c.date == day)) .values(count=visitors.c.count + count) .returning(literal(1)) .cte('update_cte') ) upsert = visitors.insert().from_select( [visitors.c.product_id, visitors.c.date, visitors.c.count], select([literal(product_id), literal(day), literal(count)]) .where(~exists(update_cte.select())) ) connection.execute(upsert) .. seealso:: :meth:`.orm.query.Query.cte` - ORM version of :meth:`.HasCTE.cte`. RBR)(R'R~(R7RBR)((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR(GsN(R9R:ROR'R&R((((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR3@sRcBseZdZdZdZdZedZedZedZ dZ dZ ed Z d Z ed Zed Zd ZdZdZRS(s%Represent a grouping of a FROM clausetgroupingcCs ||_dS(N(R-(R7R-((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCsdS(N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCs |jjS(N(R-Rp(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRpscCs |jjS(N(R-Rn(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRnscCs |jjS(N(R-R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCs|jj|S(N(R-R(R7R-((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscKst|jj|S(N(RR-RJ(R7RY((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRJscCs |jjS(N(R-R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscKs |jfS(N(R-(R7RL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR scKs||j||_dS(N(R-(R7RRY((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR scCs |jjS(N(R-R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCst|j|S(N(RR-(R7tattr((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt __getattr__scCsi|jd6S(NR-(R-(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt __getstate__scCs|d|_dS(NR-(R-(R7tstate((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt __setstate__s(R9R:RORPRRR;RpRnRRRJRRRRRR6R7R9(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs         R"cBseZdZdZeZeZd Z dZ dZ e j dZdZedZe jdd edZe jdd d ed Ze jdd d Zed ZRS( sRepresents a minimal "table" construct. This is a lightweight table object that has only a name and a collection of columns, which are typically produced by the :func:`.expression.column` function:: from sqlalchemy import table, column user = table("user", column("id"), column("name"), column("description"), ) The :class:`.TableClause` construct serves as the base for the more commonly used :class:`~.schema.Table` object, providing the usual set of :class:`~.expression.FromClause` services including the ``.c.`` collection and statement generation methods. It does **not** provide all the additional schema-level services of :class:`~.schema.Table`, including constraints, references to other tables, or support for :class:`.MetaData`-level services. It's useful on its own as an ad-hoc construct used to generate quick SQL statements when a more fully fledged :class:`~.schema.Table` is not on hand. ttablecGsitt|j||_|_t|_t|_t |_ x|D]}|j |qNWdS(sIProduce a new :class:`.TableClause`. The object returned is an instance of :class:`.TableClause`, which represents the "syntactical" portion of the schema-level :class:`~.schema.Table` object. It may be used to construct lightweight table constructs. .. versionchanged:: 1.0.0 :func:`.expression.table` can now be imported from the plain ``sqlalchemy`` namespace like any other SQL element. :param name: Name of the table. :param columns: A collection of :func:`.expression.column` constructs. N( RR"RRBtfullnameRRjRRnRRt append_column(R7RBRpR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyREs    cCsdS(N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR_scCs'tjr|jS|jjddSdS(NRR(R#RRBR(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRbs cCs||j|j<||_dS(N(RjRR:(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR<iscKs(|r g|jD] }|^qSgSdS(N(R(R7R#RLR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRmsssqlalchemy.sql.dmlcKs|j|d|d||S(sGenerate an :func:`.insert` construct against this :class:`.TableClause`. E.g.:: table.insert().values(name='foo') See :func:`.insert` for argument and usage information. Rtinline(tInsert(R7R0RR=RL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytinsertss c Ks"|j|d|d|d||S(sGenerate an :func:`.update` construct against this :class:`.TableClause`. E.g.:: table.update().where(table.c.id==7).values(name='foo') See :func:`.update` for argument and usage information. RuRR=(tUpdate(R7R0RuRR=RL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs cKs|j|||S(sGenerate a :func:`.delete` construct against this :class:`.TableClause`. E.g.:: table.delete().where(table.c.id==7) See :func:`.delete` for argument and usage information. (tDelete(R7R0RuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytdeletes cCs|gS(N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRsN(R9R:RORPRARR&timplicit_returningR't_autoincrement_columnRRR#tmemoized_propertyRR<RRR?RRBR;R(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR"s"       t ForUpdateArgcBs\eZedZedZdZdZedZ e e de e dZ RS(cCs|dtfkrdSt}}|dkr5t}nP|dkrJt}n;|dkrct}}n"|tk rtjd|ntd|d|S(sParse the for_update argument of :func:`.select`. :param mode: Defines the lockmode to use. ``None`` - translates to no lockmode ``'update'`` - translates to ``FOR UPDATE`` (standard SQL, supported by most dialects) ``'nowait'`` - translates to ``FOR UPDATE NOWAIT`` (supported by Oracle, PostgreSQL 8.1 upwards) ``'read'`` - translates to ``LOCK IN SHARE MODE`` (for MySQL), and ``FOR SHARE`` (for PostgreSQL) ``'read_nowait'`` - translates to ``FOR SHARE NOWAIT`` (supported by PostgreSQL). ``FOR SHARE`` and ``FOR SHARE NOWAIT`` (PostgreSQL). tnowaittreadt read_nowaitsUnknown for_update argument: %rN(R'R&RAR!R,RF(R7RRGRH((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytparse_legacy_selects        cCsB|jr|j rdS|jr-|jr-dS|jr:dStSdS(NRHRIRG(RHRGRA(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytlegacy_for_update_values cCsgt|tof|j|jkof|j|jkof|j|jkof|j|jkof|j|jkS(N(R(RFRGRHt skip_lockedt key_sharetof(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt__eq__s cCs t|S(N(R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt__hash__scKs>|jdk r:g|jD]}|||^q|_ndS(N(RNR'(R7RRYRw((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCsk||_||_||_||_|dk r^gtj|D]}t|^q@|_n d|_dS(shRepresents arguments specified to :meth:`.Select.for_update`. .. versionadded:: 0.9.0 N( RGRHRLRMR'R#tto_listRRN(R7RGRHRNRLRMR-((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs     .N( R9R:R RJR;RKRORPRRR&R'R(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRFs%  R2cBs\eZdZdZdZeejddddZdZ e dZ RS( sBase class for SELECT statements. This includes :class:`.Select`, :class:`.CompoundSelect` and :class:`.TextAsFrom`. cCs t|S(sLreturn a 'scalar' representation of this selectable, which can be used as a column expression. Typically, a select statement which has only one column in its columns clause is eligible to be used as a scalar expression. The returned object is an instance of :class:`ScalarSelect`. (t ScalarSelect(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s cCs|jj|S(sreturn a 'scalar' representation of this selectable, embedded as a subquery with a label. .. seealso:: :meth:`~.SelectBase.as_scalar`. (R Rs(R7RB((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs s s0.6RksThe :meth:`.SelectBase.autocommit` method is deprecated, and will be removed in a future release. Please use the the :paramref:`.Connection.execution_options.autocommit` parameter in conjunction with the :meth:`.Executable.execution_options` method.cCs |jjitd6|_dS(sPreturn a new selectable with the 'autocommit' flag set to True. t autocommitN(RR1RA(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRS+s cCs5|jj|j}|jj|_|j|S(sWOverride the default _generate() method to also clear out exported collections.(RRRtcopyR(R7ts((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt _generate=s cCs|gS(N((R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRFs( R9R:ROR RsRR#RRSRVR;R(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR2 s  tGenerativeSelectc BsFeZdZeZeZdZdZdZ e e dddddddZ e dZ e jdZ ee e de e dZedZe dZe dZe dZe d Zed Zed Zed Zed ZdZdZe dZedZRS(sBase class for SELECT statements where additional elements can be added. This serves as the base for :class:`.Select` and :class:`.CompoundSelect` where elements such as ORDER BY, GROUP BY can be added and column rendering can be controlled. Compare to :class:`.TextAsFrom`, which, while it subclasses :class:`.SelectBase` and is also a SELECT construct, represents a fixed textual string which cannot be altered at this level, only wrapped as a subquery. .. versionadded:: 0.9.0 :class:`.GenerativeSelect` was added to provide functionality specific to :class:`.Select` and :class:`.CompoundSelect` while allowing :class:`.SelectBase` to be used for other SELECT-like objects, e.g. :class:`.TextAsFrom`. c Cs||_|tk r*tj||_n|dk rbtjd|jj i|d6|_n|dk rt ||_ n|dk rt ||_ n||_ |dk rtdttj||_n|dk rtdttj||_ndS(NsThe select.autocommit parameter is deprecated and will be removed in a future release. Please refer to the Select.execution_options.autocommit` parameter.RSR(RR&RFRJt_for_update_argR'R#twarn_deprecatedRR1RDt _limit_clauset_offset_clauset_bindRRRQt_order_by_clauseRt_group_by_clause( R7Rt for_updatetlimittoffsettorder_bytgroup_byRRS((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRcs&         cCs!|jdk r|jjSdSdS(sIProvide legacy dialect support for the ``for_update`` attribute. N(RXR'RK(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR_s cCstj||_dS(N(RFRJRX(R7RC((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR_sc Cs.td|d|d|d|d||_dS(sSpecify a ``FOR UPDATE`` clause for this :class:`.GenerativeSelect`. E.g.:: stmt = select([table]).with_for_update(nowait=True) On a database like PostgreSQL or Oracle, the above would render a statement like:: SELECT table.a, table.b FROM table FOR UPDATE NOWAIT on other backends, the ``nowait`` option is ignored and instead would produce:: SELECT table.a, table.b FROM table FOR UPDATE When called with no arguments, the statement will render with the suffix ``FOR UPDATE``. Additional arguments can then be provided which allow for common database-specific variants. :param nowait: boolean; will render ``FOR UPDATE NOWAIT`` on Oracle and PostgreSQL dialects. :param read: boolean; will render ``LOCK IN SHARE MODE`` on MySQL, ``FOR SHARE`` on PostgreSQL. On PostgreSQL, when combined with ``nowait``, will render ``FOR SHARE NOWAIT``. :param of: SQL expression or list of SQL expression elements (typically :class:`.Column` objects or a compatible expression) which will render into a ``FOR UPDATE OF`` clause; supported by PostgreSQL and Oracle. May render as a table or as a column depending on backend. :param skip_locked: boolean, will render ``FOR UPDATE SKIP LOCKED`` on Oracle and PostgreSQL dialects or ``FOR SHARE SKIP LOCKED`` if ``read=True`` is also specified. .. versionadded:: 1.1.0 :param key_share: boolean, will render ``FOR NO KEY UPDATE``, or if combined with ``read=True`` will render ``FOR KEY SHARE``, on the PostgreSQL dialect. .. versionadded:: 1.1.0 RGRHRNRLRMN(RFRX(R7RGRHRNRLRM((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytwith_for_updates 8cCs t|_dS(sreturn a new selectable with the 'use_labels' flag set to True. This will result in column expressions being generated using labels against their table name, such as "SELECT somecolumn AS tablename_somecolumn". This allows selectables which contain multiple FROM clauses to produce a unique set of column names regardless of name conflicts among the individual FROM clauses. N(RAR(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt apply_labelss cCst|jdS(sGet an integer value for the limit. This should only be used by code that cannot support a limit as a BindParameter or other custom clause as it will throw an exception if the limit isn't currently set to an integer. R`(RHRZ(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_limitscCst|jtS(sqTrue if the LIMIT clause is a simple integer, False if it is not present or is a SQL expression. (R(RZR5(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_simple_int_limitscCst|jtS(srTrue if the OFFSET clause is a simple integer, False if it is not present or is a SQL expression. (R(R[R5(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_simple_int_offsetscCst|jdS(sGet an integer value for the offset. This should only be used by code that cannot support an offset as a BindParameter or other custom clause as it will throw an exception if the offset isn't currently set to an integer. Ra(RHR[(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_offsetscCst||_dS(s&return a new selectable with the given LIMIT criterion applied. This is a numerical value which usually renders as a ``LIMIT`` expression in the resulting select. Backends that don't support ``LIMIT`` will attempt to provide similar functionality. .. versionchanged:: 1.0.0 - :meth:`.Select.limit` can now accept arbitrary SQL expressions as well as integer values. :param limit: an integer LIMIT parameter, or a SQL expression that provides an integer result. N(RDRZ(R7R`((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR` scCst||_dS(s-return a new selectable with the given OFFSET criterion applied. This is a numeric value which usually renders as an ``OFFSET`` expression in the resulting select. Backends that don't support ``OFFSET`` will attempt to provide similar functionality. .. versionchanged:: 1.0.0 - :meth:`.Select.offset` can now accept arbitrary SQL expressions as well as integer values. :param offset: an integer OFFSET parameter, or a SQL expression that provides an integer result. N(RDR[(R7Ra((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRa scGs|j|dS(s{return a new selectable with the given list of ORDER BY criterion applied. e.g.:: stmt = select([table]).order_by(table.c.id, table.c.name) :param \*order_by: a series of :class:`.ColumnElement` constructs which will be used to generate an ORDER BY clause. .. seealso:: :ref:`core_tutorial_ordering` N(tappend_order_by(R7tclauses((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRb3 scGs|j|dS(sreturn a new selectable with the given list of GROUP BY criterion applied. e.g.:: stmt = select([table.c.name, func.max(table.c.stat)]).\ group_by(table.c.name) :param \*group_by: a series of :class:`.ColumnElement` constructs which will be used to generate an GROUP BY clause. .. seealso:: :ref:`core_tutorial_ordering` N(tappend_group_by(R7Rk((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRcG scGs~t|dkr1|ddkr1t|_nIt|dddk ret|jt|}ntdt||_dS(sAppend the given ORDER BY criterion applied to this selectable. The criterion will be appended to any pre-existing ORDER BY criterion. This is an **in-place** mutation method; the :meth:`~.GenerativeSelect.order_by` method is preferred, as it provides standard :term:`method chaining`. .. seealso:: :meth:`.GenerativeSelect.order_by` iiR]RN(RR'RR]RRoR(R7Rk((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRj\ s "cGs~t|dkr1|ddkr1t|_nIt|dddk ret|jt|}ntdt||_dS(sAppend the given GROUP BY criterion applied to this selectable. The criterion will be appended to any pre-existing GROUP BY criterion. This is an **in-place** mutation method; the :meth:`~.GenerativeSelect.group_by` method is preferred, as it provides standard :term:`method chaining`. .. seealso:: :meth:`.GenerativeSelect.group_by` iiR^RN(RR'RR^RRoR(R7Rk((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRlt s "cCs tdS(N(R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_label_resolve_dict scKsR|jdk r'||j||_n|jdk rN||j||_ndS(N(RZR'R[(R7RRY((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR sN(R9R:RORR]R^R'RZR[RXR&RR;R_tsetterRRdReRfRgRhRiR`RaRbRcRjRlRmRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRWKsF   ! 9     RcBsOeZdZdZejdZejdZejdZejdZ ejdZ ejdZ e Z dZed Zed Zed Zed Zed ZedZedZdZddZdZdZdZedZe dZ dZ!dZ"ee!e"Z!RS(sForms the basis of ``UNION``, ``UNION ALL``, and other SELECT-based set operations. .. seealso:: :func:`.union` :func:`.union_all` :func:`.intersect` :func:`.intersect_all` :func:`.except` :func:`.except_all` tcompound_selecttUNIONs UNION ALLtEXCEPTs EXCEPT ALLt INTERSECTs INTERSECT ALLcOs|jdt|_||_g|_d}xt|D]\}}t|}|smt|j j }n]t|j j |krt j ddt|jdj j |dt|j j fn|jj |jd|q:Wtj||dS(NRs}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %diiR(RVR&t_auto_correlatetkeywordtselectsR't enumerateR RRRR!R,RRRWR(R7RtRuRLtnumcolstnRU((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s"    cCs&td|jD}|||fS(Ncss|]}|j|fVqdS(N(R(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys s(tdictR(R7td((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRm scOsttj||S(sReturn a ``UNION`` of multiple selectables. The returned object is an instance of :class:`.CompoundSelect`. A similar :func:`union()` method is available on all :class:`.FromClause` subclasses. \*selects a list of :class:`.Select` instances. \**kwargs available keyword arguments are the same as those of :func:`select`. (RRp(RRuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt _create_union scOsttj||S(sReturn a ``UNION ALL`` of multiple selectables. The returned object is an instance of :class:`.CompoundSelect`. A similar :func:`union_all()` method is available on all :class:`.FromClause` subclasses. \*selects a list of :class:`.Select` instances. \**kwargs available keyword arguments are the same as those of :func:`select`. (Rt UNION_ALL(RRuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_create_union_all scOsttj||S(s7Return an ``EXCEPT`` of multiple selectables. The returned object is an instance of :class:`.CompoundSelect`. \*selects a list of :class:`.Select` instances. \**kwargs available keyword arguments are the same as those of :func:`select`. (RRq(RRuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_create_except scOsttj||S(s;Return an ``EXCEPT ALL`` of multiple selectables. The returned object is an instance of :class:`.CompoundSelect`. \*selects a list of :class:`.Select` instances. \**kwargs available keyword arguments are the same as those of :func:`select`. (Rt EXCEPT_ALL(RRuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_create_except_all scOsttj||S(s:Return an ``INTERSECT`` of multiple selectables. The returned object is an instance of :class:`.CompoundSelect`. \*selects a list of :class:`.Select` instances. \**kwargs available keyword arguments are the same as those of :func:`select`. (RRr(RRuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_create_intersect$ scOsttj||S(s>Return an ``INTERSECT ALL`` of multiple selectables. The returned object is an instance of :class:`.CompoundSelect`. \*selects a list of :class:`.Select` instances. \**kwargs available keyword arguments are the same as those of :func:`select`. (Rt INTERSECT_ALL(RRuRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_create_intersect_all5 scCs|jdjS(Ni(Rut _scalar_type(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRF scCs t|S(N(R(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRI scCs+x$|jD]}|j|r tSq WtS(N(RuRRAR&(R7RfRU((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRL scCsxtg|jD]}|jj^qD]}|dj|d|jrU|djndd|jrq|djnd}gt |D]&\}}|j i|dd6^q|_ q)WdS(NiRBRiR( tzipRuRRR!RRR't _key_labelRvt _annotatet_proxies(R7RURtproxyRR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRR s /  cCs>x|jD]}|j|q W|js.dStddS(NsUCompoundSelect constructs don't support addition of columns to underlying selectables(RuRRR'R(R7RRU((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRn s  cKstt|j|||jg|jD]}|||^q-|_t|drc|`nxHdD]@}t||dk rjt |||t|||qjqjWdS(Nt_col_mapR]R^RX(R]R^RX( RRRRRuR?RRR'tsetattr(R7RRYRUR5((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR{ s (  cKs6|rt|jpg|j|jgt|jS(N(RoRR]R^Ru(R7R#RL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR scCs?|jr|jSx(|jD]}|j}|r|SqWdSdS(N(R\RuRR'(R7RUte((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s  cCs ||_dS(N(R\(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt _set_bind sN(#R9R:RORPR#tsymbolRpR|RqRRrRRARRR;RmR R{R}R~RRRRR'RRRRRRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s6        RIc BseZdZdZd4Zd5ZejZd6Z e Z d7Z d8Zd7ZejZeZejdd9dd:d7d7d7e d7ed7d7dZed Zd7d7d Zd Zed Zd dZed dZedZejdZ edZ!edZ"dZ#e$dZ%edZ&edZ'ej(dedZ)edZ*edZ+edZ,edZ-edZ.edZ/ed Z0d!Z1d"Z2d#Z3d$Z4d%Z5d&Z6ed'Z7d(Z8d)Z9d*Z:d7d+Z;d,Z<d-Z=d.Z>d/Z?d0Z@d1ZAd2ZBd3ZCeeBeCZBRS(;s(Represents a ``SELECT`` statement. R3RSs0.6s<The :paramref:`.select.autocommit` parameter is deprecated and will be removed in a future release. Please refer to the :paramref:`.Connection.execution_options.autocommit` parameter in conjunction with the the :meth:`.Executable.execution_options` method in order to affect the autocommit behavior for a statement.R_s0.9sThe :paramref:`.select.for_update` parameter is deprecated and will be removed in a future release. Please refer to the :meth:`.Select.with_for_update` to specify the structure of the ``FOR UPDATE`` clause.c Ks||_|tk r[|tkr-t|_q[gtj|D]} t| ^q=|_n|dk rtjdtj|D|_ ntj|_ yt |} Wn t k rt j dnX| r7g|_x]|D]I} t| } t| tr | jdtj} n|jj| qWn g|_|dk rmt|jdtj|_n d|_|dk rt|jdtj|_n d|_|r|j|n|r|j|ntj|| dS(sConstruct a new :class:`.Select`. Similar functionality is also available via the :meth:`.FromClause.select` method on any :class:`.FromClause`. All arguments which accept :class:`.ClauseElement` arguments also accept string arguments, which will be converted as appropriate into either :func:`text()` or :func:`literal_column()` constructs. .. seealso:: :ref:`coretutorial_selecting` - Core Tutorial description of :func:`.select`. :param columns: A list of :class:`.ColumnElement` or :class:`.FromClause` objects which will form the columns clause of the resulting statement. For those objects that are instances of :class:`.FromClause` (typically :class:`.Table` or :class:`.Alias` objects), the :attr:`.FromClause.c` collection is extracted to form a collection of :class:`.ColumnElement` objects. This parameter will also accept :class:`.Text` constructs as given, as well as ORM-mapped classes. .. note:: The :paramref:`.select.columns` parameter is not available in the method form of :func:`.select`, e.g. :meth:`.FromClause.select`. .. seealso:: :meth:`.Select.column` :meth:`.Select.with_only_columns` :param whereclause: A :class:`.ClauseElement` expression which will be used to form the ``WHERE`` clause. It is typically preferable to add WHERE criterion to an existing :class:`.Select` using method chaining with :meth:`.Select.where`. .. seealso:: :meth:`.Select.where` :param from_obj: A list of :class:`.ClauseElement` objects which will be added to the ``FROM`` clause of the resulting statement. This is equivalent to calling :meth:`.Select.select_from` using method chaining on an existing :class:`.Select` object. .. seealso:: :meth:`.Select.select_from` - full description of explicit FROM clause specification. :param autocommit: legacy autocommit parameter. :param bind=None: an :class:`~.Engine` or :class:`~.Connection` instance to which the resulting :class:`.Select` object will be bound. The :class:`.Select` object will otherwise automatically bind to whatever :class:`~.base.Connectable` instances can be located within its contained :class:`.ClauseElement` members. :param correlate=True: indicates that this :class:`.Select` object should have its contained :class:`.FromClause` elements "correlated" to an enclosing :class:`.Select` object. It is typically preferable to specify correlations on an existing :class:`.Select` construct using :meth:`.Select.correlate`. .. seealso:: :meth:`.Select.correlate` - full description of correlation. :param distinct=False: when ``True``, applies a ``DISTINCT`` qualifier to the columns clause of the resulting statement. The boolean argument may also be a column expression or list of column expressions - this is a special calling form which is understood by the PostgreSQL dialect to render the ``DISTINCT ON ()`` syntax. ``distinct`` is also available on an existing :class:`.Select` object via the :meth:`~.Select.distinct` method. .. seealso:: :meth:`.Select.distinct` :param for_update=False: when ``True``, applies ``FOR UPDATE`` to the end of the resulting statement. ``for_update`` accepts various string values interpreted by specific backends, including: * ``"read"`` - on MySQL, translates to ``LOCK IN SHARE MODE``; on PostgreSQL, translates to ``FOR SHARE``. * ``"nowait"`` - on PostgreSQL and Oracle, translates to ``FOR UPDATE NOWAIT``. * ``"read_nowait"`` - on PostgreSQL, translates to ``FOR SHARE NOWAIT``. .. seealso:: :meth:`.Select.with_for_update` - improved API for specifying the ``FOR UPDATE`` clause. :param group_by: a list of :class:`.ClauseElement` objects which will comprise the ``GROUP BY`` clause of the resulting select. This parameter is typically specified more naturally using the :meth:`.Select.group_by` method on an existing :class:`.Select`. .. seealso:: :meth:`.Select.group_by` :param having: a :class:`.ClauseElement` that will comprise the ``HAVING`` clause of the resulting select when ``GROUP BY`` is used. This parameter is typically specified more naturally using the :meth:`.Select.having` method on an existing :class:`.Select`. .. seealso:: :meth:`.Select.having` :param limit=None: a numerical value which usually renders as a ``LIMIT`` expression in the resulting select. Backends that don't support ``LIMIT`` will attempt to provide similar functionality. This parameter is typically specified more naturally using the :meth:`.Select.limit` method on an existing :class:`.Select`. .. seealso:: :meth:`.Select.limit` :param offset=None: a numeric value which usually renders as an ``OFFSET`` expression in the resulting select. Backends that don't support ``OFFSET`` will attempt to provide similar functionality. This parameter is typically specified more naturally using the :meth:`.Select.offset` method on an existing :class:`.Select`. .. seealso:: :meth:`.Select.offset` :param order_by: a scalar or list of :class:`.ClauseElement` objects which will comprise the ``ORDER BY`` clause of the resulting select. This parameter is typically specified more naturally using the :meth:`.Select.order_by` method on an existing :class:`.Select`. .. seealso:: :meth:`.Select.order_by` :param use_labels=False: when ``True``, the statement will be generated using labels for each column in the columns clause, which qualify each column with its parent table's (or aliases) name so that name conflicts between columns in different tables don't occur. The format of the label is _. The "c" collection of the resulting :class:`.Select` object will use these names as well for targeting column members. This parameter can also be specified on an existing :class:`.Select` object using the :meth:`.Select.apply_labels` method. .. seealso:: :meth:`.Select.apply_labels` css|]}t|VqdS(N(R/(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys ssDcolumns argument to select() must be a Python list or other iterableRN(RsR&RAt _distinctR#RQRR't OrderedSett _from_objRt TypeErrorR!R,t _raw_columnsRR(RRRRtcomma_opRt_asboolt _whereclauset_havingRXRaRWR( R7RpRuRmtdistinctthavingRR^RdRLRt cols_presentR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR sF    . "          cCsg}t}|j}xtjt|j|jdk rKt|jnd|jD]u}||kr|t j dn|r||kr||}n|j |j s|j |n|j|j qXW|S(Ns-select() construct refers to itself as a FROM((Rt _from_clonedRRRRRR'RR!tInvalidRequestErrorRRRR(R7tfromstseent translatetitem((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_froms s"       csj}ttjg|D]}t|j^q}|rjru|jfd|jjDng|D]}||kr||^q|}nj rj }|rg|D]0}|t t ||pd|kr|^q}qnj dk rJg|D]3}|t t ||p)dj kr|^q}njr|rt|dkrg|D]!}|t ||krr|^qr}t|stjdqn|S(sReturn the full list of 'from' clauses to be displayed. Takes into account a set of existing froms which may be rendered in the FROM clause of enclosing selects; this Select may want to leave those absent if it is automatically correlating. c3s2|](}j|j|rj|VqdS(N(RR(RR(R7(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sisSelect statement '%s' returned no FROM clauses due to auto-correlation; specify correlate() to control correlation manually.(N((RRRRRRRRRt _correlateRt_correlate_exceptR'RRsRR!R(R7texplicit_correlate_fromstimplicit_correlate_fromsRRttoremovet to_correlate((R7sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_get_display_froms sN .  (       cCs'|jd}t|j}|djS(Ni(RRoRttype(R7R-R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR3 s cCs |jS(s1Return the displayed list of FromClause elements.(R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR8 st*cCs|jd||S(sadd a statement hint to this :class:`.Select`. This method is similar to :meth:`.Select.with_hint` except that it does not require an individual table, and instead applies to the statement as a whole. Hints here are specific to the backend database and may include directives such as isolation levels, file directives, fetch directives, etc. .. versionadded:: 1.0.0 .. seealso:: :meth:`.Select.with_hint` :meth:.`.Select.prefix_with` - generic SELECT prefixing which also can suit some database-specific HINT syntaxes such as MySQL optimizer hints N(t with_hintR'(R7ttextt dialect_name((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytwith_statement_hint> scCsM|dkr'|j||ff7_n"|jji|||f6|_dS(sAdd an indexing or other executional context hint for the given selectable to this :class:`.Select`. The text of the hint is rendered in the appropriate location for the database backend in use, relative to the given :class:`.Table` or :class:`.Alias` passed as the ``selectable`` argument. The dialect implementation typically uses Python string substitution syntax with the token ``%(name)s`` to render the name of the table or alias. E.g. when using Oracle, the following:: select([mytable]).\ with_hint(mytable, "index(%(name)s ix_mytable)") Would render SQL as:: select /*+ index(mytable ix_mytable) */ ... from mytable The ``dialect_name`` option will limit the rendering of a particular hint to a particular backend. Such as, to add hints for both Oracle and Sybase simultaneously:: select([mytable]).\ with_hint(mytable, "index(%(name)s ix_mytable)", 'oracle').\ with_hint(mytable, "WITH INDEX ix_mytable", 'sybase') .. seealso:: :meth:`.Select.with_statement_hint` N(R't_statement_hintst_hintsR1(R7R*RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRV s" cCstjddS(NsvSelect objects don't have a type. Call as_scalar() on this Select object to return a 'scalar' version of this Select.(R!R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR} scCs|j}|tt|S(sreturn a Set of all FromClause elements referenced by this Select. This set is a superset of that returned by the ``froms`` property, which is specifically for those FromClause elements that would actually be rendered. (RRoR(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytlocate_all_froms s cCs t|jS(san iterator of all ColumnElement expressions which would be rendered into the columns clause of the resulting SELECT statement. (RR(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt inner_columns scCstdt|jD}tdt|jD}|j}x*|jD]\}}|j||qWW|||fS(Ncss9|]/}|jr|jp*|jp*|j|fVqdS(N(t_allow_label_resolvet_resolve_labelRR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys scss'|]}|jr|j|fVqdS(N(RR(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys s(RyRRRRTtitemst setdefault(R7t with_colst only_fromst only_colsRRC((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRm s cCsA||jkrtSx'|jD]}|j|r tSq WtS(N(RRARRR&(R7RfR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s c s\tt|jtfd|jj|jD|_tj fd|jD|_t fd|j Dj|j |_ |j rt fd|j Dj|j |_ ng|j D]}|^q|_ xHd D]@}t||dk r t||t||q q W|jdS( Nc3s$|]}||fVqdS(N((RR(RRY(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sc3s|]}|VqdS(N((RR(t from_cloned(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sc3s|]}|VqdS(N((RR(R(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sc3s|]}|VqdS(N((RR(R(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sRRR]R^RX(RRR]R^RX(RRIRRyRR1RRR#RRRRRRR'RR(R7RRYRR5((RRRYsL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s* 2  ( )cKsh|rt|jpg|jt|jg|j|j|j|jfD]}|dk rK|^qKS(s=return child elements as per the ClauseElement specification.N( RoRpRRRRR]R^R'(R7R#RLR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s,cCs|j|dS(sxreturn a new select() construct with the given column expression added to its columns clause. E.g.:: my_select = my_select.column(table.c.new_column) See the documentation for :meth:`.Select.with_only_columns` for guidelines on adding /replacing the columns of a :class:`.Select` object. N(R<(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR sssqlalchemy.sql.utilcCs5|j|j|jd||jft|jS(sReturn a new :func`.select` construct with redundantly named, equivalently-valued columns removed from the columns clause. "Redundant" here means two columns where one refers to the other either based on foreign key, or via a simple equality comparison in the WHERE clause of the statement. The primary purpose of this method is to automatically construct a select statement with all uniquely-named columns, without the need to use table-qualified labels as :meth:`.apply_labels` does. When columns are omitted based on foreign key, the referred-to column is the one that's kept. When columns are omitted based on WHERE equivalence, the first column in the columns clause is the one that's kept. :param only_synonyms: when True, limit the removal of columns to those which have the same name as the equivalent. Otherwise, all columns that are equivalent to another are removed. t only_synonyms(twith_only_columnsRRRR]R(R7RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s  cCsn|jg}xN|D]F}t|}t|trP|jdtj}n|j|qW||_dS(s Return a new :func:`.select` construct with its columns clause replaced with the given columns. This method is exactly equivalent to as if the original :func:`.select` had been called with the given columns clause. I.e. a statement:: s = select([table1.c.a, table1.c.b]) s = s.with_only_columns([table1.c.b]) should be exactly equivalent to:: s = select([table1.c.b]) This means that FROM clauses which are only derived from the column list will be discarded if the new column list no longer contains that FROM:: >>> table1 = table('t1', column('a'), column('b')) >>> table2 = table('t2', column('a'), column('b')) >>> s1 = select([table1.c.a, table2.c.b]) >>> print s1 SELECT t1.a, t2.b FROM t1, t2 >>> s2 = s1.with_only_columns([table2.c.b]) >>> print s2 SELECT t2.b FROM t1 The preferred way to maintain a specific FROM clause in the construct, assuming it won't be represented anywhere else (i.e. not in the WHERE clause, etc.) is to set it using :meth:`.Select.select_from`:: >>> s1 = select([table1.c.a, table2.c.b]).\ ... select_from(table1.join(table2, ... table1.c.a==table2.c.a)) >>> s2 = s1.with_only_columns([table2.c.b]) >>> print s2 SELECT t2.b FROM t1 JOIN t2 ON t1.a=t2.a Care should also be taken to use the correct set of column objects passed to :meth:`.Select.with_only_columns`. Since the method is essentially equivalent to calling the :func:`.select` construct in the first place with the given columns, the columns passed to :meth:`.Select.with_only_columns` should usually be a subset of those which were passed to the :func:`.select` construct, not those which are available from the ``.c`` collection of that :func:`.select`. That is:: s = select([table1.c.a, table1.c.b]).select_from(table1) s = s.with_only_columns([table1.c.b]) and **not**:: # usually incorrect s = s.with_only_columns([s.c.b]) The latter would produce the SQL:: SELECT b FROM (SELECT t1.a AS a, t1.b AS b FROM t1), t1 Since the :func:`.select` construct is essentially being asked to select both from ``table1`` as well as itself. RN( RRR(RRRRRRR(R7RptrcR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR2 sE   cCs|j|dS(sreturn a new select() construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any. N(tappend_whereclause(R7Ru((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytwhere scCs|j|dS(sreturn a new select() construct with the given expression added to its HAVING clause, joined to the existing clause via AND, if any. N(t append_having(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR scGsc|rVg|D]}t|^q }t|jtrJ|j||_q_||_n t|_dS(s Return a new select() construct which will apply DISTINCT to its columns clause. :param \*expr: optional column expressions. When present, the PostgreSQL dialect will render a ``DISTINCT ON (>)`` construct. N(RR(RRoRA(R7RSR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s  cCs|j|dS(sreturn a new :func:`.select` construct with the given FROM expression merged into its list of FROM objects. E.g.:: table1 = table('t1', column('a')) table2 = table('t2', column('b')) s = select([table1.c.a]).\ select_from( table1.join(table2, table1.c.a==table2.c.b) ) The "from" list is a unique set on the identity of each element, so adding an already present :class:`.Table` or other selectable will have no effect. Passing a :class:`.Join` that refers to an already present :class:`.Table` or other selectable will have the effect of concealing the presence of that selectable as an individual element in the rendered FROM list, instead rendering it into a JOIN clause. While the typical purpose of :meth:`.Select.select_from` is to replace the default, derived FROM clause with a join, it can also be called with individual table elements, multiple times if desired, in the case that the FROM clause cannot be fully derived from the columns clause:: select([func.count('*')]).select_from(table1) N(t append_from(R7Rf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt select_from s cGsTt|_|r+|ddkr+d|_n%t|jjd|D|_dS(sdreturn a new :class:`.Select` which will correlate the given FROM clauses to that of an enclosing :class:`.Select`. Calling this method turns off the :class:`.Select` object's default behavior of "auto-correlation". Normally, FROM elements which appear in a :class:`.Select` that encloses this one via its :term:`WHERE clause`, ORDER BY, HAVING or :term:`columns clause` will be omitted from this :class:`.Select` object's :term:`FROM clause`. Setting an explicit correlation collection using the :meth:`.Select.correlate` method provides a fixed list of FROM objects that can potentially take place in this process. When :meth:`.Select.correlate` is used to apply specific FROM clauses for correlation, the FROM elements become candidates for correlation regardless of how deeply nested this :class:`.Select` object is, relative to an enclosing :class:`.Select` which refers to the same FROM object. This is in contrast to the behavior of "auto-correlation" which only correlates to an immediate enclosing :class:`.Select`. Multi-level correlation ensures that the link between enclosed and enclosing :class:`.Select` is always via at least one WHERE/ORDER BY/HAVING/columns clause in order for correlation to take place. If ``None`` is passed, the :class:`.Select` object will correlate none of its FROM entries, and all will render unconditionally in the local FROM clause. :param \*fromclauses: a list of one or more :class:`.FromClause` constructs, or other compatible constructs (i.e. ORM-mapped classes) to become part of the correlate collection. .. seealso:: :meth:`.Select.correlate_except` :ref:`correlated_subqueries` icss|]}t|VqdS(N(R/(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sN((R&RsR'RRR1(R7t fromclauses((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s )  cGsZt|_|r+|ddkr+d|_n+t|jp:djd|D|_dS(sreturn a new :class:`.Select` which will omit the given FROM clauses from the auto-correlation process. Calling :meth:`.Select.correlate_except` turns off the :class:`.Select` object's default behavior of "auto-correlation" for the given FROM elements. An element specified here will unconditionally appear in the FROM list, while all other FROM elements remain subject to normal auto-correlation behaviors. If ``None`` is passed, the :class:`.Select` object will correlate all of its FROM entries. :param \*fromclauses: a list of one or more :class:`.FromClause` constructs, or other compatible constructs (i.e. ORM-mapped classes) to become part of the correlate-exception collection. .. seealso:: :meth:`.Select.correlate` :ref:`correlated_subqueries` icss|]}t|VqdS(N(R/(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys sN(((R&RsR'RRR1(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytcorrelate_except s   cCs2t|_t|jjd|D|_dS(sappend the given correlation expression to this select() construct. This is an **in-place** mutation method; the :meth:`~.Select.correlate` method is preferred, as it provides standard :term:`method chaining`. css|]}t|VqdS(N(R/(RR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pys &sN(R&RsRRR1(R7Rf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytappend_correlations cCsT|jt|}t|tr=|jdtj}n|j|g|_dS(sappend the given column expression to the columns clause of this select() construct. E.g.:: my_select.append_column(some_table.c.new_column) This is an **in-place** mutation method; the :meth:`~.Select.column` method is preferred, as it provides standard :term:`method chaining`. See the documentation for :meth:`.Select.with_only_columns` for guidelines on adding /replacing the columns of a :class:`.Select` object. RN(RRR(RRRRRR(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR<)s   cCs#t|}|j|f|_dS(sappend the given columns clause prefix expression to this select() construct. This is an **in-place** mutation method; the :meth:`~.Select.prefix_with` method is preferred, as it provides standard :term:`method chaining`. N(RR\(R7RF((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt append_prefixBs cCs,|jttj|j||_dS(sJappend the given expression to this select() construct's WHERE criterion. The expression will be joined to existing WHERE criterion via AND. This is an **in-place** mutation method; the :meth:`~.Select.where` method is preferred, as it provides standard :term:`method chaining`. N(RRRt_ifnoneR(R7Ru((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRNs cCs,|jttj|j||_dS(sMappend the given expression to this select() construct's HAVING criterion. The expression will be joined to existing HAVING criterion via AND. This is an **in-place** mutation method; the :meth:`~.Select.having` method is preferred, as it provides standard :term:`method chaining`. N(RRRRR(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR]s cCs2|jt|}|jj|g|_dS(s append the given FromClause expression to this select() construct's FROM clause. This is an **in-place** mutation method; the :meth:`~.Select.select_from` method is preferred, as it provides standard :term:`method chaining`. N(RR/RR1(R7Rf((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRks  cs|jrPtfd}gtjt|jD]}||^q:Sgtjt|jD]}d|f^qiSdS(Ncs[|jdks|j r#d|fS|j}|krD|j}n j|||fS(N(RR't_render_label_in_columns_clauset anon_labelR(RRB(tnames(sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt name_for_col}s     (RRR#t unique_listRRR'(R7RR((RsL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt_columns_plus_namesxs   ,c Csx|jD]\}}t|ds+q n|dkr@d}nB|jr||j}|dk r||jkr|j}qnd}|j|d|d|dtq WdS(NR!RRBtname_is_truncatable( RR?R'RRRRR!RA(R7RBRR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs    c Csx|jD]}|j|}|dk r ||jkr|jr|jrU|jn|j}||jkr|j |d|jr|j ndd|jr|jnddt SndSq WdS(NRBRR( RRR'RRRRRRR!RRA(R7RRfRwt our_label((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs  cCs.|jdk p-|jdk p-t|jjS(N(RZR'R[RR]Rk(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCs*t|tr |j r |St|S(s+return a 'grouping' construct as per the ClauseElement specification. This produces an element that can be embedded in an expression. Note that this method is called automatically as needed when constructing expressions and should not require explicit use. (R(RRR(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs  cKstj|||S(sSreturn a SQL UNION of this select() construct against the given selectable.(RR{(R7RRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR1scKstj|||S(sareturn a SQL UNION ALL of this select() construct against the given selectable. (RR}(R7RRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR2scKstj|||S(sTreturn a SQL EXCEPT of this select() construct against the given selectable.(RR~(R7RRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pytexcept_scKstj|||S(sbreturn a SQL EXCEPT ALL of this select() construct against the given selectable. (RR(R7RRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt except_allscKstj|||S(sareturn a SQL INTERSECT of this select() construct against the given selectable. (RR(R7RRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscKstj|||S(sereturn a SQL INTERSECT ALL of this select() construct against the given selectable. (RR(R7RRL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt intersect_allscCs||jr|jS|j}|sRxV|jD]"}|j}|r)||_|Sq)Wn&t|dj}|rx||_|SdS(Ni(R\RRRRoR'(R7RRR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs      cCs ||_dS(N(R\(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs(((N((s0.6s<The :paramref:`.select.autocommit` parameter is deprecated and will be removed in a future release. Please refer to the :paramref:`.Connection.execution_options.autocommit` parameter in conjunction with the the :meth:`.Executable.execution_options` method in order to affect the autocommit behavior for a statement.(s0.9sThe :paramref:`.select.for_update` parameter is deprecated and will be removed in a future release. Please refer to the :meth:`.Select.with_for_update` to specify the structure of the ``FOR UPDATE`` clause.(DR9R:RORPR\RcR#t immutabledictRRR&RR'RRRR2RRARR RR;RRRRRRRRtmethodRRRmRRRRRRRRRRRRRRRR<RRRRRRRRRR1R2RRRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRI s   S  &   <  N "1#                 RRcBsPeZgZeZeZdZedZ e Z e dZ dZ RS(cCs||_|j|_dS(N(R-RR(R7R-((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR s cCstjddS(NscScalar Select expression has no columns; use this object directly within a column-level expression.(R!R(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRpscCs|jj||_dS(sjApply a WHERE clause to the SELECT statement referred to by this :class:`.ScalarSelect`. N(R-R(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscKs|S(N((R7RL((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR"s(R9R:RRARR&t_is_implicitly_booleanRR;RpRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRRs tExistscBsVeZdZejZgZdZddZdZ dZ dZ dZ RS(s%Represent an ``EXISTS`` clause. c Os|r,t|dttfr,|d}n6|sGtdgf}nt||jj}tj||dt j dt j dt dS(sConstruct a new :class:`.Exists` against an existing :class:`.Select` object. Calling styles are of the following forms:: # use on an existing select() s = select([table.c.col1]).where(table.c.col2==5) s = exists(s) # construct a select() at once exists(['*'], **select_arguments).where(criterion) # columns argument is optional, generates "EXISTS (SELECT *)" # by default. exists().where(table.c.col2==5) iRRR=twraps_column_expressionN(R(R2RRRRIR RR RRtexistsRt BOOLEANTYPERA(R7RKRLRU((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR.s   cKst|g||S(N(RI(R7RuRv((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR3OscGs+|j}|jj|j|_|S(N(RR-RR(R7RfR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRRs cGs+|j}|jj|j|_|S(N(RR-RR(R7RfR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRWs cCs+|j}|jj|j|_|S(sreturn a new :class:`.Exists` construct, applying the given expression to the :meth:`.Select.select_from` method of the select statement contained. (RR-RR(R7RFR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR\s cCs+|j}|jj|j|_|S(sreturn a new exists() construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any. (RR-RR(R7RFR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRfs N( R9R:ROR RPRRR'R3RRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR&s  !    t TextAsFromcBsbeZdZdZeZedZedZ e dZ dZ e dZdZRS(sWrap a :class:`.TextClause` construct within a :class:`.SelectBase` interface. This allows the :class:`.TextClause` object to gain a ``.c`` collection and other FROM-like capabilities such as :meth:`.FromClause.alias`, :meth:`.SelectBase.cte`, etc. The :class:`.TextAsFrom` construct is produced via the :meth:`.TextClause.columns` method - see that method for details. .. versionadded:: 0.9.0 .. seealso:: :func:`.text` :meth:`.TextClause.columns` t text_as_fromcCs||_||_||_dS(N(R-t column_argst positional(R7RRpR((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs  cCs |jjS(N(R-R\(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyR\scOs|jj|||_dS(N(R-t bindparams(R7tbindstbind_as_values((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscCs%x|jD]}|j|q WdS(N(RR!(R7R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRscKs#|j||j||_dS(N(RR-(R7RRY((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs cCs|jdjS(Ni(RR(R7((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs(R9R:RORPRARR&RR;R\RRRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRps   tAnnotatedFromClausecBseZdZRS(cCs|jtj|||dS(N(RRR(R7R-R((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs(R9R:R(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyRs(JRORRRRtsqlalchemy.sql.visitorsRRRRt annotationRtbaseRRRRR R R RR R RRRRRRRRRRRRRRRRRRR R!R"R#R/R4R5R'RDRHRMRNtobjectRRR`ReRxR0RRR'R3RR"RFR2RWRRIRRRRR(((sL/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/selectable.pyt s       3.,L_5\BL kJ2