.}!ldZddlZddlZddlZddlmZddlmZddlmZddlm 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.Gd+d,e#Z/dZd-Z0d.Z1d/Z2Gd0d1e$Z3Gd2d3e4Z5Gd4d5e4Z6Gd6d7e3Z7Gd8d9e7Z8Gd:d;e7Z9Gd<d=e9Z:Gd>d?e9Z;Gd@dAee5e6e9Z<GdBdCe4Z=GdDdEe7Z>GdFdGee7Z?GdHdIe$Z@GdJdKe=ee7ZAGdLdMeAZBGdNdOeBZCGdPdQe5e6eBZDGdRdSee&ZEGdTdUe)ZFGdVdWeAZGGdXdYe ZHdS)[ztThe :class:`_expression.FromClause` class of SQL expression elements, representing SQL tables and derived rowsets. N) attrgetter) Visitable) operators)type_api) Annotated) _from_objects) _generative)ColumnCollection) ColumnSet) Executable) Generative) Immutable)_anonymous_label)_clause_element_as_expr)_clone)_cloned_difference_cloned_intersection)_document_text_coercion)_expand_cloned_interpret_as_column_or_from)&_literal_and_labels_as_label_reference_literal_as_label_reference_literal_as_text)_no_text_coercion)_select_iterables)and_) BindParameter) ClauseElement) ClauseList)Grouping)literal_column)True_)UnaryExpression)exc) inspection)utilctj|d}|)t|tjrt | |jS#t$r3}tjtj d|Yd}~dSd}~wwxYw)NF)raiseerrzFROM expression expectedreplace_context) r+inspect isinstancer, string_typesr selectableAttributeErrorraise_r* ArgumentError)elementinsperrs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/sqlalchemy/sql/selectable.py_interpret_as_fromr<8s  g 6 6 6D | gt0 1 1 ' g & & &       8 9 93           sA B(BBct|}t|tr|j}t|ts|}|SN)r<r2Aliasoriginal SelectBaseselectr8s r;_interpret_as_selectrDEsO ))G'5!!#" gz * *#.."" Nc$eZdZedZdS)_OffsetLimitParamc|jSr>)effective_valueselfs r;_limit_offset_valuez%_OffsetLimitParam._limit_offset_valueOs ##rEN)__name__ __module__ __qualname__propertyrLrEr;rGrGNs- $$X$$$rErGc|dSt|dr|St|tr|St j|}t |||dS)zConvert 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. N__clause_element__T)type_unique)hasattrrSr2rr,asintrG)r8namerTvalues r;_offset_or_limit_clauserZTsrt . / /H))+++ GY ' 'H 7## uE$GGGGrEc|dS |j}tj|S#t$r6}tjt jd|z|Yd}~dSd}~wwxYw)zConvert 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. Nz@This SELECT structure does not use a simple integer value for %sr/)rLr,rWr5r6r* CompileError)clauseattrnamerYr:s r;_offset_or_limit_clause_asintr_fs~t !*z%         ')12              s! A!+AA!c@t|i||S)zReturn an :class:`_expression.Alias` object derived from a :class:`_expression.Select`. :param alias: the alias name :param \*args, \**kwargs: all other arguments are delivered to the :func:`_expression.select` function. )Selectalias)rbargskwargss r;subqueryre~s% 4 "6 " " ( ( / //rEc0eZdZdZdZdZedZdS) Selectablez!Mark a class as being selectable.r4Tc|Sr>rQrJs r;r4zSelectable.selectables rEN)rMrNrO__doc____visit_name__ is_selectablerPr4rQrEr;rgrgs=++!NM XrErgcVeZdZdZeeddddZddZdS) HasPrefixesrQexprz+:meth:`_expression.HasPrefixes.prefix_with`z*:paramref:`.HasPrefixes.prefix_with.*expr`c|dd}|r*tjdd|z|||dS)aAdd 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:`_expression.HasPrefixes.prefix_with`. :param \*expr: textual or :class:`_expression.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. dialectNUnsupported argument(s): %s,)popr*r7join_setup_prefixesrKrnkwrps r; prefix_withzHasPrefixes.prefix_withseB&&D))  #- <  T7+++++rENcX|jtfd|Dz|_dS)Nc6g|]}t|dfST)allow_coercion_to_textr.0prps r; z/HasPrefixes._setup_prefixes..;   "!DAAA7K   rE) _prefixestuple)rKprefixesrps `r;ruzHasPrefixes._setup_prefixesG%    !   + +  rEr>)rMrNrOrr rrxrurQrEr;rmrmsjI54 , , [ ,D      rErmcVeZdZdZeeddddZddZdS) HasSuffixesrQrnz+:meth:`_expression.HasSuffixes.suffix_with`z*:paramref:`.HasSuffixes.suffix_with.*expr`c|dd}|r*tjdd|z|||dS)aAdd 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:`_expression.HasSuffixes.suffix_with`. :param \*expr: textual or :class:`_expression.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. rpNrqrr)rsr*r7rt_setup_suffixesrvs r; suffix_withzHasSuffixes.suffix_withsd8&&D))  #- <  T7+++++rENcX|jtfd|Dz|_dS)Nc6g|]}t|dfSr{rr}s r;rz/HasSuffixes._setup_suffixes..rrE) _suffixesr)rKsuffixesrps `r;rzHasSuffixes._setup_suffixesrrEr>)rMrNrOrr rrrrQrEr;rrsiI54 ,, [ ,:      rErceZdZdZdZdZgZdZdZdZ dZ dZ dZ dZ ejdgZejdd ejd d$d Zd$d Zd%d Zd&dZd&dZd$dZd'dZdZdZejddZdZd(dZedZ dZ!edZ"edZ#edZ$ee%ddZ&ee%dZ'd Z(ed!Z)d"Z*d#Z+dS)) FromClauseaERepresent an element that can be used within the ``FROM`` clause of a ``SELECT`` statement. The most common forms of :class:`_expression.FromClause` are the :class:`_schema.Table` and the :func:`_expression.select` constructs. Key features common to all :class:`_expression.FromClause` objects include: * a :attr:`.c` collection, which provides per-name access to a collection of :class:`_expression.ColumnElement` objects. * a :attr:`.primary_key` attribute, which is a collection of all those :class:`_expression.ColumnElement` objects that indicate the ``primary_key`` flag. * Methods to generate various derivations of a "from" clause, including :meth:`_expression.FromClause.alias`, :meth:`_expression.FromClause.join`, :meth:`_expression.FromClause.select`. fromclauseFNc|Sr>rQ)rKeffective_schemamap_s r;_translate_schemazFromClause._translate_schema'srE_columnsz1.1zThe :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.messagesqlalchemy.sql.functionsc |jrt|jd}nt|jd}t|j|dg|fd|gi|S)zReturn a SELECT COUNT generated against this :class:`_expression.FromClause`. .. seealso:: :class:`_functions.count` r tbl_row_countfrom_obj) primary_keylistcolumnsrafunccountlabel)rK functions whereclauseparamscols r;rzFromClause.count,s$   (t'((+CCt|$$Q'C ^ ! !# & & , ,_ = = >   V     rEc t|g|fi|S)zReturn a SELECT of this :class:`_expression.FromClause`. .. seealso:: :func:`_expression.select` - general purpose method which allows for arbitrary column lists. rarKrrs r;rBzFromClause.selectIstfk44V444rEc(t|||||S)aReturn a :class:`_expression.Join` from this :class:`_expression.FromClause` to another :class:`_expression.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:`_expression.FromClause` object such as a :class:`_schema.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:`_expression.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:`_expression.join` - standalone function :class:`_expression.Join` - the type of object produced Join)rKrightonclauseisouterfulls r;rtzFromClause.joinUsXD%7D999rEc(t|||d|S)a Return a :class:`_expression.Join` from this :class:`_expression.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:`_expression.FromClause` object such as a :class:`_schema.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:`_expression.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:`_expression.FromClause.join` :class:`_expression.Join` Tr)rKrrrs r; outerjoinzFromClause.outerjoinsXD%4666rEc8t||S)asReturn an alias of this :class:`_expression.FromClause`. E.g.:: a2 = some_table.alias('a2') The above code creates an :class:`_expression.Alias` object which can be used as a FROM clause in any SELECT statement. .. seealso:: :ref:`core_tutorial_aliases` :func:`_expression.alias` )r? _constructrKrXflats r;rbzFromClause.aliass&d+++rEc8t||S)aMReturn a LATERAL alias of this :class:`_expression.FromClause`. The return value is the :class:`_expression.Lateral` construct also provided by the top-level :func:`_expression.lateral` function. .. versionadded:: 1.1 .. seealso:: :ref:`lateral_selects` - overview of usage. )LateralrrKrXs r;lateralzFromClause.laterals!!$---rEc<t||||S)avReturn a TABLESAMPLE alias of this :class:`_expression.FromClause`. The return value is the :class:`_expression.TableSample` construct also provided by the top-level :func:`_expression.tablesample` function. .. versionadded:: 1.1 .. seealso:: :func:`_expression.tablesample` - usage guidelines and parameters ) TableSampler)rKsamplingrXseeds r; tablesamplezFromClause.tablesamples%%dHdDAAArEc||jvS)zReturn ``True`` if this :class:`_expression.FromClause` is 'derived' from the given ``FromClause``. An example would be an Alias of a Table is derived from that Table. ) _cloned_setrKrs r;is_derived_fromzFromClause.is_derived_fromsT---rEc@|j|jS)zReturn ``True`` if this :class:`_expression.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. )r intersectionrKothers r;_is_lexical_equivalentz!FromClause._is_lexical_equivalents,,U->???rEsqlalchemy.sql.utilcR|||S)zReplace all occurrences of FromClause 'old' with the given Alias object, returning a copy of this :class:`_expression.FromClause`. ) ClauseAdaptertraverse)rKsqlutiloldrbs r;replace_selectablezFromClause.replace_selectables&$$U++44T:::rEc||d}|,||vr(||D]}||d}|r|cS |S)zzReturn corresponding_column for the given column, or if None search for a match in the given dictionary. T)require_embedded)corresponding_column)rKcolumn equivalentsrequivncs r;correspond_on_equivalentsz$FromClause.correspond_on_equivalentssr '''FF ;3+--$S)  ..ut.LLIII rEcxd}|jrSd\}}j}|jj}|D]}t t |j} || } | r|r || |r||| }}Ot| t|kr|| }}t| |krtj tj fd| D} tj tj fd| D} | | kr|| }}|S)aXGiven a :class:`_expression.ColumnElement`, return the exported :class:`_expression.ColumnElement` object from this :class:`expression.Selectable` which corresponds to that original :class:`~sqlalchemy.schema.Column` via a common ancestor column. :param column: the target :class:`_expression.ColumnElement` to be matched :param require_embedded: only return corresponding columns for the given :class:`_expression.ColumnElement`, if the given :class:`_expression.ColumnElement` is actually present within a sub-element of this :class:`_expression.FromClause`. Normally the column will match if it merely shares a common ancestor with one of the exported columns of this :class:`_expression.FromClause`. c||D]5}tt|g|sdS6dS)NFT) differencesetrr)expanded_proxy_set target_setts r;embeddedz1FromClause.corresponding_column..embedded'sb**+=>> ! !>1#..//<<&!!55!4rENNNcpg|]2}||jdd3Sweightrshares_lineage _annotationsgetr~scrs r;rz3FromClause.corresponding_column..WO "!0088O//!<<rEcpg|]2}||jdd3Srrrs r;rz3FromClause.corresponding_column.._rrE) ccontains_column proxy_set _all_columnsrrrlenr,reduceoperatoradd_uncached_proxy_set) rKrrrr intersectrcolsrri col_distance c_distances ` r;rzFromClause.corresponding_columns,    6 ! !& ) ) M#Y% v"1 .1 .A!$^AK%@%@!A!A ''(:;;A. .$. .8. ;;. .;&'CCVVc)nn,,&'CC)^^$(; &)&=&=&?&?$$L"& &'&;&;&=&=""J"L00)*AY rEc>t|d|jjdzS)z|A brief description of this :class:`_expression.FromClause`. Used primarily for error message formatting. rXz object)getattr __class__rMrJs r; descriptionzFromClause.descriptionis tVT^%NFFNFrF),rMrNrOrirjnamed_with_column _hide_froms_is_join _is_select_is_from_container _is_lateral_textualschemarr,!group_expirable_memoized_propertyr deprecated dependenciesrrBrtrrbrrrrrrrrPrrrrr rr_select_iterablerr rrrQrEr;rrs("NKHJKHF   @? MMT_ #T122   32 * 5 5 5 5,:,:,:,:\,7,7,7,7\,,,,* . . . .BBBB . . .@@@T,--;;.-;   VVVVpJJXJ666 ,,,$   !!!  9 :   A x 9 5 566"""++X+   rErceZdZdZdZdZddZeddZe ddZ e d Z d Z dd Z ejd d ZdZefdZdZdZeejd d dZeddZeejd dZedZddZe dZejd ddZe dZe dZdS)!raRepresent a ``JOIN`` construct between two :class:`_expression.FromClause` elements. The public constructor function for :class:`_expression.Join` is the module-level :func:`_expression.join()` function, as well as the :meth:`_expression.FromClause.join` method of any :class:`_expression.FromClause` (e.g. such as :class:`_schema.Table`). .. seealso:: :func:`_expression.join` :meth:`_expression.FromClause.join` rtTNFct||_t||_|&||j|j|_n||_||_||_dS)zConstruct a new :class:`_expression.Join`. The usual entrypoint here is the :func:`_expression.join` function or the :meth:`_expression.FromClause.join` method of any :class:`_expression.FromClause` object. N)r<left self_groupr_match_primariesrrr)rKr$rrrrs r;__init__z Join.__init__sj't,, '..99;;   11$)TZHHDMM$DM  rEc"||||d|S)aReturn an ``OUTER JOIN`` clause element. The returned object is an instance of :class:`_expression.Join`. Similar functionality is also available via the :meth:`_expression.FromClause.outerjoin` method on any :class:`_expression.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:`_expression.FromClause.join` or :meth:`_expression.FromClause.outerjoin` methods on the resulting :class:`_expression.Join` object. TrrrQ)clsr$rrrs r;_create_outerjoinzJoin._create_outerjoins0s4$TBBBBrEc ||||||S)a8Produce a :class:`_expression.Join` object, given two :class:`_expression.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:`_expression.FromClause` object (e.g. such as a :class:`_schema.Table`) using the :meth:`_expression.FromClause.join` method. :param left: The left side of the join. :param right: the right side of the join; this is any :class:`_expression.FromClause` object such as a :class:`_schema.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:`_expression.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:`_expression.FromClause.join` - method form, based on a given left side. :class:`_expression.Join` - the type of object produced. rQ)r*r$rrrrs r; _create_joinzJoin._create_joinshs4'4888rEcd|jjt|j|jjt|jfzS)Nz Join object on %s(%d) and %s(%d))r$ridrrJs r;rzJoin.descriptionTs:1 I ! tyMM J " tzNN 5   rEcr||up3|j|p|j|Sr>)r$rrrs r;rzJoin.is_derived_from]s? $  6y((44 6z))*55 rEc t|Sr> FromGroupingrKagainsts r;r%zJoin.self_groupdD!!!rErcd|jjDd|jjDz}|j|d|D|j|jd|D|j tj d|DdS)Ncg|]}|SrQrQr~rs r;rz4Join._populate_column_collection..is0001000rEcg|]}|SrQrQr9s r;rz4Join._populate_column_collection..is%4 4 4 A4 4 4 rEc3(K|] }|j |VdSr>)rr9s r; z3Join._populate_column_collection..os)55qq}5555555rEc3(K|] }|j|fVdSr>)_labelr~rs r;r<z3Join._populate_column_collection..rs)BB3cj#.BBBBBBrEcg|] }|j SrQ)r r?s r;rz4Join._populate_column_collection..tsBBB3c.BBBrE) r$rrrextendreduce_columnsrrupdater  itertoolschain)rKrrs r;rz Join._populate_column_collectiongs00di/0004 4 z)4 4 4     " "55G555t}     BB'BBBBBB   OBB'BBB C     rEc&|j|}||j|}|X|jrQ||j|j<|j|j|jr|j ||SdSr>) r$rrr rr>r rCrrrKrrs r;rzJoin._refresh_for_new_columnwsi//77 ;*44V<)rr$rrrKclonerws r;_copy_internalszJoin._copy_internalssi E$)**r** U4:,,,, dm22r22 rEc *|j|j|jfSr>)r$rrrKrds r; get_childrenzJoin.get_childrensy$*dm33rEcpt|tr|j}nd}||||S)N)a_subset)r2rr_join_condition)rKr$r left_rights r;r&zJoin._match_primariess= dD ! ! JJJ##D%*#EEErE)0.9zThe :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.)ignore_nonexistent_tablesc|||||}t|dkr|||||t|dkrAt|trd}nd}t jd|jd|jd|dt| dD}t|dkr|dSt|S) aCreate 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". rrzI Perhaps you meant to convert the right side to a subquery using alias()?z2Can't find any foreign key relationships between '' and 'z'.c g|] \}}||k SrQrQ)r~xys r;rz(Join._join_condition..s CCCTQaCCCrE) _joincond_scan_left_rightr_joincond_trim_constraintsr2r3r*NoForeignKeysErrorrrvaluesr!) r*abrTrPconsider_as_foreign_keys constraintshintcrits r;rQzJoin._join_conditionsV33 x4   {  a    * *1k#;    {  q !\** . ((===!---7  DCT+*<*<*>*>%?%?%BCCC t99>>7N; rEct|tr|j}nd}|||||}t |S)N)r_r`rPra)r2rrr[bool)r*r$rrarRrbs r; _can_joinzJoin._can_joinsX dD ! ! JJJ33%= 4  K   rEc tjt}||fD]d}|t|jdD]}| |j|vr ||} nE#tj$r3} d| |D} | j | vrYd} ~ bd} ~ wwxYw| '||j  | |jf||urt|jdD]}| |j|vr ||} nE#tj$r3} d| |D} | j | vrYd} ~ bd} ~ wwxYw| '||j  | |jf|rnf|S)Nc|jjSr>parent_creation_orderfks r;z0Join._joincond_scan_left_right..s ry/HrErch|] }|j SrQrXr~rs r; z1Join._joincond_scan_left_right..s"N"N"Na16"N"N"NrEc|jjSr>rjrms r;roz0Join._joincond_scan_left_right.. s bi6OrEch|] }|j SrQrrrss r;rtz1Join._joincond_scan_left_right..s&O&O&O!qv&O&O&OrE) collections defaultdictrsortedr rk get_referentr*NoReferenceError find_tables table_name constraintappend) r*sql_utilr_rPr`rarbr$rnrnrte table_namess r;r[zJoin._joincond_scan_left_rights "-d33 qM+ + D|$H$H H H-8 )AAA!//$//CC+!!!"N"N83G3G3M3M"N"N"NK+55  !? .55sBI6FGGG1}} %+O+OLLB1<I-EEE % ooa00/%%%&O&Ox7K7KA7N7N&O&O&O ?k99!$HHHH %#BM2993 :JKKK  s0 A  B"/)BB"9DE)E  Ec|rDt|D]4}td|jDt|kr||=5t|dkr]td|D}t|dkrt|d}|||i}t|dkr%t jd|jd|jddS)Nc3$K|] }|jV dSr>)rkr~fs r;r<z2Join._joincond_trim_constraints..*s$88Aqx888888rErc34K|]}t|VdSr>)r)r~rds r;r<z2Join._joincond_trim_constraints..2s(FFtFFFFFFrErzCan't determine join between 'rWz'; tables have more than one foreign key constraint relationship between them. Please specify the 'onclause' of this join explicitly.)rrelementsrr^r*AmbiguousForeignKeysErrorr)r*r_r`rbraconstdedupers r;r\zJoin._joincond_trim_constraints!s $ +k** + +8888888C,==$E* {  a  FF1C1C1E1EFFFFFF6{{a;''*"K$45 {  q // '(mmmQ]]] D  ! rEc @|j|jg}t||fd|gi|S)aSCreate a :class:`_expression.Select` from this :class:`_expression.Join`. The equivalent long-hand form, given a :class:`_expression.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. r)r$rra)rKrrdcollists r;rBz Join.select@s1(9dj)g{FFdVFvFFFrEc2|jjp |jjSr>)r$bindrrJs r;rz Join.bindXsy~00rEc|r| Jd|jd|jd}}||||}||||j|j|j S| dd|S)aReturn an alias of this :class:`_expression.Join`. The default behavior here is to first produce a SELECT construct from this :class:`_expression.Join`, then to produce an :class:`_expression.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:`_expression.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:`_expression.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:`_expression.Alias` represents the names of the individual columns using a ``_`` scheme:: j.c.table_a_id j.c.table_b_a_id :meth:`_expression.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:`_expression.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:`_expression.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:`_expression.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` Nz"Can't send name argument with flatT)rr)F) use_labels correlate) r$rbrrrErtrrrrrB)rKrrXrleft_aright_aadapters r;rbz Join.alias\sR  M<.s& G G GmAFAG,, G G GrE)rDrErrJs r;rzJoin._hide_fromss% G Gd6F G G G  rEcV|g|jjz|jjz|jjzSr>)rr r$rrJs r;r zJoin._from_objectss7Fm) *i% &j& ' rErrr>)FNN) rMrNrOrirjrr' classmethodr+r-rPrrr%r,r rrrrKrNr&deprecated_paramsrQrgr[r\rBrrbrr rQrEr;rrs$NH&CCC[C2=B393939[39j  X    """"T,--   .-     %+3333 444FFFT# #(!% <<<[<| ! ! ![ !T,--11.-[1f[<GGGG011X1T,--yMyMyM.-yMv  X   X   rErceZdZdZdZdZdZdZedZ eddZ dd Z dfd Z e d Zd Zd ZdZdZefdZddZe dZe dZxZS)r?aRepresents 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:`_expression.FromClause.alias` method available on all :class:`_expression.FromClause` subclasses. rbTc td|jjd|jjd|jjd)NzThe zC class is not intended to be constructed directly. Please use the z() standalone function or the z8() method available from appropriate selectable objects.)NotImplementedErrorrrMlower)rKargrws r;r'zAlias.__init__s`!! ''''--////'--////    rEcJ||}|j|i||Sr>)__new___init)r*rrwobjs r;rzAlias._constructs/kk# 3" rENFcJt|||S)a Return an :class:`_expression.Alias` object. An :class:`_expression.Alias` represents any :class:`_expression.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:`_expression.FromClause.alias` method available on all :class:`_expression.FromClause` subclasses. In terms of a SELECT object as generated from the :func:`_expression.select` function, the :meth:`_expression.SelectBase.alias` method returns an :class:`_expression.Alias` or similar object which represents a named, parenthesized subquery. When an :class:`_expression.Alias` is created from a :class:`_schema.Table` object, this has the effect of the table being rendered as ``tablename AS aliasname`` in a SELECT statement. For :func:`_expression.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:`_expression.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:`_expression.Join` - see :meth:`_expression.Join.alias` for details. .. versionadded:: 0.9.0 )rXr)r<rb)r*r4rXrs r;_factoryzAlias._factorys&b"*--33D3IIIrEcb|}t|tr|j}t|t||_|j|_|jr |j|_||_|E|jjrt|jdd}tdt||pdfz}||_ dS)NrXz %%(%d %s)sanon) r2r?r8r@supports_execution_execution_optionsrrrr/rX)rKr4rXbaseselectables r;rz Alias._initAs#// 4+3N// 4& "0"C  " H&4&GD #! <}. <t}fd;;#LBtHHdnf3M$MNND rEct|trBt|jtr(|jrt |St t||S)Nr5) r2CompoundSelectr@ra_needs_parens_for_groupingr3superr?r%)rKr5rs r;r%zAlias.self_groupPsr w / / &4=&11 & 88:: &  %% %UD!!,,W,===rEc^tjr|jS|jddSNasciibackslashreplacer,py3krXencoderJs r;rzAlias.descriptionZ. 9 A9 9##G-?@@ @rEc |jS#t$r6}tjtd|jz|Yd}~dSd}~wwxYw)Nz)Element %s does not support 'as_scalar()'r/)r8 as_scalarr5r,r6)rKr:s r;rzAlias.as_scalaras <))++ +    K$&*l3!$            s A+AAcL||jvrdS|j|S)NT)rr8rrs r;rzAlias.is_derived_fromms+ ) ) )4|++J777rEcX|jjjD]}||dSr>)r8rr _make_proxy)rKrs r;rz!Alias._populate_column_collectionrs8<'4 " "C OOD ! ! ! ! " "rEcz|j|}||jsdS||SdSr>)r8rr rrGs r;rzAlias._refresh_for_new_columnvsCl226:: ?' -tt,,,4rEc t|jtrdS|||jfi||_|j}t|tr|j}t|t||_dSr>)r2r8 TableClauserr?r@)rKrJrwrs r;rKzAlias._copy_internalss dlK 0 0  F uT\00R00 // 4+3N// 4& rEc+<K|r|jD]}|V|jVdSr>)rr8)rKcolumn_collectionsrwrs r;rNzAlias.get_childrens>  V  lrEc|gSr>rQrJs r;r zAlias._from_objects v rEc|jjSr>)r8rrJs r;rz Alias.binds |  rErr>T)rMrNrOrirjrrr'rrrrr%rPrrrrrrrKrNr r __classcell__rs@r;r?r?sz  N    [ 0J0J0J[0Jd    >>>>>>AAXA   888 """%+ ' ' ' ' X!!X!!!!!rEr?c2eZdZdZdZdZeddZdS)raRepresent a LATERAL subquery. This object is constructed from the :func:`_expression.lateral` module level function as well as the :meth:`_expression.FromClause.lateral` method available on all :class:`_expression.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. rTNcHt||S)aReturn a :class:`_expression.Lateral` object. :class:`_expression.Lateral` is an :class:`_expression.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. rr)r<r)r*r4rXs r;rzLateral._factorys#*"*--5545@@@rEr>)rMrNrOrirjrrrrQrEr;rrsN$NKAAA[AAArErcreZdZdZdZeddZdfd Zej ddZ xZ S) radRepresent a TABLESAMPLE clause. This object is constructed from the :func:`_expression.tablesample` module level function as well as the :meth:`_expression.FromClause.tablesample` method available on all :class:`_expression.FromClause` subclasses. .. versionadded:: 1.1 .. seealso:: :func:`_expression.tablesample` rNcLt||||S)aReturn a :class:`_expression.TableSample` object. :class:`_expression.TableSample` is an :class:`_expression.Alias` subclass that represents a table with the TABLESAMPLE clause applied to it. :func:`_expression.tablesample` is also available from the :class:`_expression.FromClause` class via the :meth:`_expression.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. )rXr)r<r)r*r4rrXrs r;rzTableSample._factorys1X"*--99 4d:   rEcx||_||_tt|||dSNrr)rrrrr)rKr4rrXrrs r;rzTableSample._init s:    k4  &&z&=====rErct|j|jr|jS|j|jSr>)r2rFunctionrsystem)rKrs r; _get_methodzTableSample._get_methods9 dmY%7 8 8 8= >((77 7rEr) rMrNrOrirjrrrr,r rrrs@r;rrs  #N- - - [- ^>>>>>> T122883288888rErceZdZdZdZed dZdddeddffd Ze ffd Z e j dd Z d d Zd Zd ZxZS)CTEzRepresent a Common Table Expression. The :class:`_expression.CTE` object is obtained using the :meth:`_expression.SelectBase.cte` method from any selectable. See that method for complete examples. cteNFcJt|||S)zReturn a new :class:`_expression.CTE`, or Common Table Expression instance. Please see :meth:`_expression.HasCTE.cte` for detail on CTE usage. rX recursive)r<r)r*r4rXrs r;rz CTE._factory$s."*--112   rEc||_||_||_|r||_|r||_t t |||dSr)r _cte_alias _restatesrrrrr) rKr4rXrrrrrrs r;rz CTE._init0sa#$"  '&DN  '&DN c4z55555rEc tt|jfi|j|jfi|_t fd|jD|_dS)Nc"g|] }|fi SrQrQ)r~elemrJrws r;rz'CTE._copy_internals..Hs+ : : :4UU4  2   : : :rE)rrrKr frozensetr)rKrJrwrs ``r;rKzCTE._copy_internalsCs~(c4(55"555 ? &#eDO::r::DO" : : : : :4> : : :  rEsqlalchemy.sql.dmlct|j|jr&|jjD]}||dS|jjjD]}||dSr>)r2r8 UpdateBase _returningrrr)rKdmlrs r;rzCTE._populate_column_collectionKs dlCN 3 3 &|. & &%%%% & &|+8 & &%%%% & &rEcjt|j||j||j|jS)a1Return an :class:`_expression.Alias` of this :class:`_expression.CTE`. This method is a CTE-specific specialization of the :meth:`_expression.FromClause.alias` method. .. seealso:: :ref:`core_tutorial_aliases` :func:`_expression.alias` )rXrrrr)rrr@rrrrs r;rbz CTE.aliasTs9~~ Mnnn    rEct|j||j|j|j|g|j|jSN)rXrrrr) rrr@unionrXrrrrrs r;rz CTE.unionksY~~ M   & &nn**D622nn    rEct|j||j|j|j|g|j|j Sr) rrr@ union_allrXrrrrrrs r;rz CTE.union_allusY~~ M # #E * *nn**D622nn    rEr)rMrNrOrirjrrrrrrKr,r rrbrrrrs@r;rrsN    [  )++666666&%+      T+,,&&-,&    .          rErceZdZdZddZdS)HasCTEzTMixin that declares a class to include CTE support. .. versionadded:: 1.1 NFc<t|||S)aReturn a new :class:`_expression.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. .. versionchanged:: 1.1 Added support for UPDATE/INSERT/DELETE as CTE, CTEs added to UPDATE/INSERT/DELETE. SQLAlchemy detects :class:`_expression.CTE` objects, which are treated similarly to :class:`_expression.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. For special prefixes such as PostgreSQL "MATERIALIZED" and "NOT MATERIALIZED", the :meth:`_expression.CTE.prefix_with` method may be used to establish these. .. versionchanged:: 1.3.13 Added support for prefixes. In particular - MATERIALIZED and NOT MATERIALIZED. :param name: name given to the common table expression. Like :meth:`_expression.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:`_expression.HasCTE.cte`. r)rr)rKrXrs r;rz HasCTE.ctesN~~d~CCCrEr)rMrNrOrirrQrEr;rrs> gDgDgDgDgDgDrErceZdZdZdZdZdZedZedZ edZ dZ d Z ed Z d Zefd Zed ZdZdZdZdS)r3z%Represent a grouping of a FROM clausegroupingc||_dSr>rCrKr8s r;r'zFromGrouping.__init__6s  rEcdSr>rQrJs r;rzFromGrouping._init_collections9 rEc|jjSr>)r8rrJs r;rzFromGrouping.columns<s |##rEc|jjSr>)r8rrJs r;rzFromGrouping.primary_key@ |''rEc|jjSr>)r8r rJs r;r zFromGrouping.foreign_keysDs |((rEc6|j|Sr>)r8rrs r;rzFromGrouping.is_derived_fromHs|++G444rEc @t|jjdi|S)NrQ)r3r8rb)rKrws r;rbzFromGrouping.aliasKs&.DL.4444555rEc|jjSr>)r8rrJs r;rzFromGrouping._hide_fromsNrrEc |jfSr>rCrMs r;rNzFromGrouping.get_childrenRs  rEc ,||jfi||_dSr>rCrIs r;rKzFromGrouping._copy_internalsUs!uT\00R00 rEc|jjSr>)r8r rJs r;r zFromGrouping._from_objectsXs |))rEc,t|j|Sr>)rr8)rKattrs r; __getattr__zFromGrouping.__getattr__\st|T***rEcd|jiSNr8rCrJs r; __getstate__zFromGrouping.__getstate___s4<((rEc |d|_dSrrC)rKstates r; __setstate__zFromGrouping.__setstate__bsY' rEN)rMrNrOrirjr'rrPrrr rrbrrNrrKr rrrrQrEr;r3r31s7//N   $$X$((X())X)555666((X(%+1111**X*+++)))(((((rEr3ceZdZdZdZdZdZ dZ fdZdZ e j dZ d Z dd Ze jd dd Ze jd  dd Ze jd ddZedZxZS)ra-Represents a minimal "table" construct. This is a lightweight table object that has only a name, a collection of columns, which are typically produced by the :func:`_expression.column` function, and a schema:: from sqlalchemy import table, column user = table("user", column("id"), column("name"), column("description"), ) The :class:`_expression.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:`_schema.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. tableTFNctt||x|_|_t |_t|_t|_ |D]}| || dd}|||_ |r$tjdt!|zdS)aProduce a new :class:`_expression.TableClause`. The object returned is an instance of :class:`_expression.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. :param schema: The schema name for this table. .. versionadded:: 1.3.18 :func:`_expression.table` can now accept a ``schema`` argument. rNrq)rrr'rXfullnamer rr rrr  append_columnrsrr*r7r)rKrXrrwrrrs r;r'zTableClause.__init__s0 k4  ))+++$(( DM(** $;;EE " "A   q ! ! ! !$''   DK  N#$ADHH$LMM M N NrEcdSr>rQrJs r;rzTableClause._init_collectionsrrEc^tjr|jS|jddSrrrJs r;rzTableClause.descriptionrrEc |j}|2||ur.tjd|jdt |d|||j|j<||_dS)Nzcolumn object 'z' already assigned to table r)rr*r7rrr)rKrexistings r;r zTableClause.append_columnsl7  HD$8$8##555'(M8DDDF  ! aerEc ,|rd|jDSgS)Ncg|]}|SrQrQr9s r;rz,TableClause.get_children..s&&&!A&&&rE)rrKrrds r;rNzTableClause.get_childrens%  &&tv&&& &IrErc $|j|f||d|S)zGenerate an :func:`_expression.insert` construct against this :class:`_expression.TableClause`. E.g.:: table.insert().values(name='foo') See :func:`_expression.insert` for argument and usage information. )r^inline)Insert)rKrr^rrds r;insertzTableClause.inserts%sz$GvfGGGGGrEc &|j|f|||d|S)aGenerate an :func:`_expression.update` construct against this :class:`_expression.TableClause`. E.g.:: table.update().where(table.c.id==7).values(name='foo') See :func:`_expression.update` for argument and usage information. )rr^r)Update)rKrrr^rrds r;rCzTableClause.updates:sz  #       rEc |j||fi|S)zGenerate a :func:`_expression.delete` construct against this :class:`_expression.TableClause`. E.g.:: table.delete().where(table.c.id==7) See :func:`_expression.delete` for argument and usage information. )Delete)rKrrrds r;deletezTableClause.deletes sz$ 66v666rEc|gSr>rQrJs r;r zTableClause._from_objectsrrErr)NNFr>)rMrNrOrirjrimplicit_returning_autoincrement_columnr'rr,memoized_propertyrr rNr rrCrrPr rrs@r;rrfsn:N=!>$N$N$N$N$NL    AAA    T+,, H H H-, HT+,,9>   -, ,T+,, 7 7 7-, 7XrErcbeZdZedZedZdZdZe fdZ d dZ dS) ForUpdateArgc|dvrdSdx}}|dkrd}n/|dkrd}n&|dkrdx}}n|durtjd|zt|| S) aParse the for_update argument of :func:`_expression.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). rNFnowaitTread read_nowaitzUnknown for_update argument: %rr$r#)r*r7r!)rKrr#r$s r;parse_legacy_selectz ForUpdateArg.parse_legacy_select s, -  4 (??FF F]]DD M ! ! D66 __#$E$KLL Lf5555rEcX|jr |jsdS|jr |jrdS|jrdSdS)Nr$r%r#Tr&rJs r;legacy_for_update_valuez$ForUpdateArg.legacy_for_update_value1sF 9 T[ 6 Y 4;  = [ 84rEct|toM|j|jko=|j|jko-|j|jko|j|jko |j|juSr>)r2r!r#r$ skip_locked key_shareofrs r;__eq__zForUpdateArg.__eq__<sq ul + + $  + $ di' $!T%55 $4>1  $ DG#  rEc t|Sr>)r/rJs r;__hash__zForUpdateArg.__hash__Fs $xxrEc N|jfd|jD|_dSdS)Nc"g|] }|fi SrQrQ)r~rrJrws r;rz0ForUpdateArg._copy_internals..Ks+;;;CuuS''B'';;;rE)r-rIs ``r;rKzForUpdateArg._copy_internalsIs8 7 ;;;;;47;;;DGGG  rEFNc||_||_||_||_|%dt j|D|_dSd|_dS)z{Represents arguments specified to :meth:`_expression.Select.for_update`. .. versionadded:: 0.9.0 Nc,g|]}t|SrQr)r~rs r;rz)ForUpdateArg.__init__..as.7;,T22rE)r#r$r+r,r,to_listr-rKr#r$r-r+r,s r;r'zForUpdateArg.__init__Msa  &" >?C|B?O?ODGGGDGGGrEFFNFF) rMrNrOrr'rPr)r.r0rrKr'rQrEr;r!r! s"6"6["6HX   %+<<<<    rEr!ceZdZdZdZdZeejdddZ dZ e d Z d S) rAzBase class for SELECT statements. This includes :class:`_expression.Select`, :class:`_selectable.CompoundSelect` and :class:`.TextAsFrom`. c t|S)aLReturn 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`. ) ScalarSelectrJs r;rzSelectBase.as_scalarssD!!!rEcP||S)zReturn a 'scalar' representation of this selectable, embedded as a subquery with a label. .. seealso:: :meth:`_expression.SelectBase.as_scalar`. )rrrs r;rzSelectBase.labels"~~%%d+++rE0.6zThe :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.rcH|jddi|_dS)zQReturn a new selectable with the 'autocommit' flag set to True. autocommitTN)rrrJs r;r>zSelectBase.autocommits-#'"9"?"? 4 # # rEc|j|j}|j|_||S)zWOverride the default _generate() method to also clear out exported collections.)rrrcopyr)rKss r; _generatezSelectBase._generatesG N " "4> 2 2]''))  rEc|gSr>rQrJs r;r zSelectBase._from_objectsrrEN) rMrNrOrirrr r,rr>rBrPr rQrEr;rArAhs " " " , , ,T_ 8  [ XrErAceZdZdZeZeZdZdZdZ ddZ e dZ e j dZ e ddZedZe d Ze d Ze d Ze d Zed ZedZedZedZdZdZe dZefdZdS)GenerativeSelectaZBase class for SELECT statements where additional elements can be added. This serves as the base for :class:`_expression.Select` and :class:`_selectable.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:`_expression.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:`_expression.GenerativeSelect` was added to provide functionality specific to :class:`_expression.Select` and :class:`_selectable.CompoundSelect` while allowing :class:`_expression.SelectBase` to be used for other SELECT-like objects, e.g. :class:`.TextAsFrom`. NFc ||_|durt||_|5t jd|jd|i|_|t||_ |t||_ ||_ |(tt j |dti|_|*tt j |dt i|_dSdS)NFzThe select.autocommit parameter is deprecated and will be removed in a future release. Please refer to the Select.execution_options.autocommit` parameter.r>r)rr!r'_for_update_argr,warn_deprecatedrrrZ _limit_clause_offset_clause_bindr$r5r_order_by_clauser_group_by_clause) rKr for_updatelimitoffsetorder_bygroup_byrr>s r;r'zGenerativeSelect.__init__s% U " "#/#C#CJ#O#OD  !  B    '+&=&C&Cz*''D #  !8!?!?D   "9&"A"AD   $.h''%!G%%D !  $.h''%!<%%D ! ! ! rEc,|j |jjSdS)z@Provide legacy dialect support for the ``for_update`` attribute.N)rGr)rJs r;rNzGenerativeSelect.for_updates   +'? ?4rEcDt||_dSr>)r!r'rG)rKrYs r;rNzGenerativeSelect.for_updates+??FFrEc8t||||||_dS)aSpecify a ``FOR UPDATE`` clause for this :class:`_expression.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:`_schema.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 )r#r$r-r+r,N)r!rGr6s r;with_for_updatez GenerativeSelect.with_for_updates1t ,#    rEcd|_dS)aReturn 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. TN)rrJs r; apply_labelszGenerativeSelect.apply_labels? srEc,t|jdS)zGet 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. rO)r_rIrJs r;_limitzGenerativeSelect._limitL s-T-?IIIrEc6t|jtS)zqTrue if the LIMIT clause is a simple integer, False if it is not present or is a SQL expression. )r2rIrGrJs r;_simple_int_limitz"GenerativeSelect._simple_int_limitV s $,.?@@@rEc6t|jtS)zrTrue if the OFFSET clause is a simple integer, False if it is not present or is a SQL expression. )r2rJrGrJs r;_simple_int_offsetz#GenerativeSelect._simple_int_offset] s $-/@AAArEc,t|jdS)zGet 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. rP)r_rJrJs r;_offsetzGenerativeSelect._offsetd s-T-@(KKKrEc.t||_dS)a1Return 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:`_expression.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)rZrI)rKrOs r;rOzGenerativeSelect.limitn s$5U;;rEc.t||_dS)a8Return 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:`_expression.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)rZrJ)rKrPs r;rPzGenerativeSelect.offset s(6f==rEc|j|dS)aReturn 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 \*clauses: a series of :class:`_expression.ColumnElement` constructs which will be used to generate an ORDER BY clause. .. seealso:: :ref:`core_tutorial_ordering` N)append_order_byrKclausess r;rQzGenerativeSelect.order_by s& g&&&&rEc|j|dS)aReturn 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 \*clauses: a series of :class:`_expression.ColumnElement` constructs which will be used to generate an GROUP BY clause. .. seealso:: :ref:`core_tutorial_ordering` N)append_group_byres r;rRzGenerativeSelect.group_by s( g&&&&rEct|dkr|dt|_dSt|dd$t |jt |z}t|dt i|_dS)aAppend 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:`_expression.GenerativeSelect.order_by` method is preferred, as it provides standard :term:`method chaining`. .. seealso:: :meth:`_expression.GenerativeSelect.order_by` rrNrLr)rr$rLrrrres r;rdz GenerativeSelect.append_order_by s w<<1  !3$.LLD ! ! !t/66Bt455W E$.%!G%%D ! ! !rEct|dkr|dt|_dSt|dd$t |jt |z}t|dt i|_dS)aAppend 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:`_expression.GenerativeSelect.group_by` method is preferred, as it provides standard :term:`method chaining`. .. seealso:: :meth:`_expression.GenerativeSelect.group_by` rrNrMr)rr$rMrrrres r;rhz GenerativeSelect.append_group_by s w<<1  !3$.LLD ! ! !t/66Bt455W E$.%+F%%D ! ! !rEctr>)rrJs r;_label_resolve_dictz$GenerativeSelect._label_resolve_dict s!###rEc r|j||jfi||_|j||jfi||_dSdSr>)rIrJrIs r;rKz GenerativeSelect._copy_internals s\   )!&t'9!@!@R!@!@D    *"'%(;"B"Br"B"BD    + *rE)FFNNNNNNr7)rMrNrOrir$rLrMrIrJrGr'rPrNsetterr rVrXrZr\r^r`rOrPrQrRrdrhrlrrKrQrEr;rErEs<("z||!z||MNO ((((TXGGG   ? ? ? [? B  [ JJXJAAXA BBXB LLXL<<[<&>>[>*''['(''['*2.$$X$%+CCCCCCrErEceZdZdZdZejdZejdZejdZ ejdZ ejdZ ejdZ d Z d Zed Zed Zed ZedZedZedZedZdZddZdZdZdZeffd ZddZdZ dZ!ee e!Z xZ"S)raXForms the basis of ``UNION``, ``UNION ALL``, and other SELECT-based set operations. .. seealso:: :func:`_expression.union` :func:`_expression.union_all` :func:`_expression.intersect` :func:`_expression.intersect_all` :func:`_expression.except` :func:`_expression.except_all` compound_selectUNIONz UNION ALLEXCEPTz EXCEPT ALL INTERSECTz INTERSECT ALLTc D|dd|_||_g|_d}t |D]\}}t |}|st |jj}ntt |jj|krWtj ddt |jdjj|dzt |jjfz|j | |tj|fi|dS)NrFz}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %drrr)rs_auto_correlatekeywordselects enumeraterrrrr*r7rr%rEr')rKrvrwrdnumcolsnrAs r;r'zCompoundSelect.__init__ s(%zz+u==  g&& < rpr9s r;r<z5CompoundSelect._label_resolve_dict..? s(,,!%,,,,,,rE)dictr)rKds r;rlz"CompoundSelect._label_resolve_dict= s+ ,,TV,,, , ,!QwrEc6ttjg|Ri|S)aReturn a ``UNION`` of multiple selectables. The returned object is an instance of :class:`_selectable.CompoundSelect`. A similar :func:`union()` method is available on all :class:`_expression.FromClause` subclasses. :param \*selects: a list of :class:`_expression.Select` instances. :param \**kwargs: available keyword arguments are the same as those of :func:`select`. )rrqr*rwrds r; _create_unionzCompoundSelect._create_unionB s%$n2GWGGGGGGrEc6ttjg|Ri|S)aReturn a ``UNION ALL`` of multiple selectables. The returned object is an instance of :class:`_selectable.CompoundSelect`. A similar :func:`union_all()` method is available on all :class:`_expression.FromClause` subclasses. :param \*selects: a list of :class:`_expression.Select` instances. :param \**kwargs: available keyword arguments are the same as those of :func:`select`. )r UNION_ALLrs r;_create_union_allz CompoundSelect._create_union_allV s%$n6KKKKFKKKrEc6ttjg|Ri|S)a]Return an ``EXCEPT`` of multiple selectables. The returned object is an instance of :class:`_selectable.CompoundSelect`. :param \*selects: a list of :class:`_expression.Select` instances. :param \**kwargs: available keyword arguments are the same as those of :func:`select`. )rrrrs r;_create_exceptzCompoundSelect._create_exceptj s%n3HgHHHHHHrEc6ttjg|Ri|S)aaReturn an ``EXCEPT ALL`` of multiple selectables. The returned object is an instance of :class:`_selectable.CompoundSelect`. :param \*selects: a list of :class:`_expression.Select` instances. :param \**kwargs: available keyword arguments are the same as those of :func:`select`. )r EXCEPT_ALLrs r;_create_except_allz!CompoundSelect._create_except_all{ s%n7L'LLLVLLLrEc6ttjg|Ri|S)a`Return an ``INTERSECT`` of multiple selectables. The returned object is an instance of :class:`_selectable.CompoundSelect`. :param \*selects: a list of :class:`_expression.Select` instances. :param \**kwargs: available keyword arguments are the same as those of :func:`select`. )rrsrs r;_create_intersectz CompoundSelect._create_intersect s%n6KKKKFKKKrEc6ttjg|Ri|S)adReturn an ``INTERSECT ALL`` of multiple selectables. The returned object is an instance of :class:`_selectable.CompoundSelect`. :param \*selects: a list of :class:`_expression.Select` instances. :param \**kwargs: available keyword arguments are the same as those of :func:`select`. )r INTERSECT_ALLrs r;_create_intersect_allz$CompoundSelect._create_intersect_all s%n:OWOOOOOOrEc@|jdSNr)rw _scalar_typerJs r;rzCompoundSelect._scalar_type s|A++---rENc t|Sr>r2r4s r;r%zCompoundSelect.self_group r6rEcJ|jD]}||rdSdSNTF)rwr)rKrrAs r;rzCompoundSelect.is_derived_from s:  A  ,, tt urEctd|jDD]f}|d||jr |djnd|jr |djnd}dt |D|_gdS)Nc&g|]}|jjSrQ)rr)r~rAs r;rz>CompoundSelect._populate_column_collection.. sAAAq!#*AAArEr)rXrcHg|]\}}|d|dzi Sr) _annotate)r~rrs r;rz>CompoundSelect._populate_column_collection.. s>39Aq Xq1u-..rE)ziprwrrr> _key_labelrx_proxies)rKrproxys r;rz*CompoundSelect._populate_column_collection sAADLAAAB  DG'''+@T!W^^D*./CDG&&t(E=Ft__ENN/  rEcp|jD]}|||jsdStd)NzUCompoundSelect constructs don't support addition of columns to underlying selectables)rwrr r)rKrrAs r;rz&CompoundSelect._refresh_for_new_column sQ . .A % %f - - - -# 4!    rEc Btt|jfi|fd|jD|_t |dr|`dD]8}t||&t||t||fi9dS)Nc"g|] }|fi SrQrQ)r~rArJrws r;rz2CompoundSelect._copy_internals.. s'===1a2===rE_col_map)rLrMrG) rrrKrrwrVrrsetattr)rKrJrwrrs `` r;rKzCompoundSelect._copy_internals s3nd##3E@@R@@@ ===== === 4 $ $    F FD tT"".dEE'$*=*=$D$D$D$DEEE  F FrEc z|rt|jpg|j|jgzt|jzSr>)rrrLrMrwrs r;rNzCompoundSelect.get_children sA  0DLL 6B$d&;< =4<   ! rEcP|jr|jS|jD]}|j}|r|cSdSr>)rKrwr)rKrAes r;rzCompoundSelect.bind sI : :   AA  4rEc||_dSr>rKrKrs r; _set_bindzCompoundSelect._set_bind  rEr>r)#rMrNrOrirjr,symbolrqrrrrrsrrr'rPrlrrrrrrrrr%rrrrrKrNrrrrs@r;rr s,('N DK E K((I T[ " "F\**J K((IDK00M222>XHH[H&LL[L&II[I MM[M LL[L PP[P ..."""" 8    %+ F F F F F F     8D) $ $DDDDDrErc eZdZdZdZdZdZejZ dZ dZ dZ dZ dZejZdZejdd  d6d Zed Z d7d Zd ZedZd8dZed8dZedZejdZedZedZ dZ!e"ffd Z#d9dZ$edZ%ej&dd9dZ'edZ(edZ)edZ*edZ+ed Z,ed!Z-ed"Z.d#Z/d$Z0d%Z1d&Z2d'Z3d(Z4ed)Z5d*Z6d+Z7d,Z8d:d-Z9d.Z:d/Z;d0Zd3Z?d4Z@d5ZAee@eAZ@xZBS);raz"Represents a ``SELECT`` statement.rBrQFNT)r<aGThe :paramref:`_expression.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.)rSzThe :paramref:`_expression.select.for_update` parameter is deprecated and will be removed in a future release. Please refer to the :meth:`_expression.Select.with_for_update` to specify the structure of the ``FOR UPDATE`` clause.)r>rNc  ||_|dur/|durd|_n#dtj|D|_|6tjdtj|D|_ntj|_ t |} n?#t$r2} tjtj d| Yd} ~ nd} ~ wwxYw| rkg|_ |D]`} t| } t| tr | t j} |j | ang|_ |3t'|t j|_nd|_|3t'|t j|_nd|_|r|||r||t3j|fi| dS) aConstruct a new :class:`_expression.Select`. Similar functionality is also available via the :meth:`_expression.FromClause.select` method on any :class:`_expression.FromClause`. All arguments which accept :class:`_expression.ClauseElement` arguments also accept string arguments, which will be converted as appropriate into either :func:`_expression.text` or :func:`_expression.literal_column` constructs. .. seealso:: :ref:`coretutorial_selecting` - Core Tutorial description of :func:`_expression.select`. :param columns: A list of :class:`_expression.ColumnElement` or :class:`_expression.FromClause` objects which will form the columns clause of the resulting statement. For those objects that are instances of :class:`_expression.FromClause` (typically :class:`_schema.Table` or :class:`_expression.Alias` objects), the :attr:`_expression.FromClause.c` collection is extracted to form a collection of :class:`_expression.ColumnElement` objects. This parameter will also accept :class:`_expression.TextClause` constructs as given, as well as ORM-mapped classes. .. note:: The :paramref:`_expression.select.columns` parameter is not available in the method form of :func:`_expression.select`, e.g. :meth:`_expression.FromClause.select`. .. seealso:: :meth:`_expression.Select.column` :meth:`_expression.Select.with_only_columns` :param whereclause: A :class:`_expression.ClauseElement` expression which will be used to form the ``WHERE`` clause. It is typically preferable to add WHERE criterion to an existing :class:`_expression.Select` using method chaining with :meth:`_expression.Select.where`. .. seealso:: :meth:`_expression.Select.where` :param from_obj: A list of :class:`_expression.ClauseElement` objects which will be added to the ``FROM`` clause of the resulting statement. This is equivalent to calling :meth:`_expression.Select.select_from` using method chaining on an existing :class:`_expression.Select` object. .. seealso:: :meth:`_expression.Select.select_from` - full description of explicit FROM clause specification. :param autocommit: legacy autocommit parameter. :param bind=None: an :class:`_engine.Engine` or :class:`_engine.Connection` instance to which the resulting :class:`_expression.Select` object will be bound. The :class:`_expression.Select` object will otherwise automatically bind to whatever :class:`~.base.Connectable` instances can be located within its contained :class:`_expression.ClauseElement` members. :param correlate=True: indicates that this :class:`_expression.Select` object should have its contained :class:`_expression.FromClause` elements "correlated" to an enclosing :class:`_expression.Select` object. It is typically preferable to specify correlations on an existing :class:`_expression.Select` construct using :meth:`_expression.Select.correlate`. .. seealso:: :meth:`_expression.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:`_expression.Select` object via the :meth:`_expression.Select.distinct` method. .. seealso:: :meth:`_expression.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:`_expression.Select.with_for_update` - improved API for specifying the ``FOR UPDATE`` clause. :param group_by: a list of :class:`_expression.ClauseElement` objects which will comprise the ``GROUP BY`` clause of the resulting select. This parameter is typically specified more naturally using the :meth:`_expression.Select.group_by` method on an existing :class:`_expression.Select`. .. seealso:: :meth:`_expression.Select.group_by` :param having: a :class:`_expression.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:`_expression.Select.having` method on an existing :class:`_expression.Select`. .. seealso:: :meth:`_expression.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:`_expression.Select.limit` method on an existing :class:`_expression.Select`. .. seealso:: :meth:`_expression.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:`_expression.Select.offset` method on an existing :class:`_expression.Select`. .. seealso:: :meth:`_expression.Select.offset` :param order_by: a scalar or list of :class:`_expression.ClauseElement` objects which will comprise the ``ORDER BY`` clause of the resulting select. This parameter is typically specified more naturally using the :meth:`_expression.Select.order_by` method on an existing :class:`_expression.Select`. .. seealso:: :meth:`_expression.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:`_expression.Select` object will use these names as well for targeting column members. This parameter can also be specified on an existing :class:`_expression.Select` object using the :meth:`_expression.Select.apply_labels` method. .. seealso:: :meth:`_expression.Select.apply_labels` FTc,g|]}t|SrQrr~rs r;rz#Select.__init__.. s0"""022"""rENc34K|]}t|VdSr>r<rs r;r<z"Select.__init__.. s<--*+"1%%------rEzDcolumns argument to select() must be a Python list or other iterabler/r)ru _distinctr,r5 OrderedSet _from_objrf TypeErrorr6r*r7 _raw_columnsrr2r:r%rcomma_oprr_asbool _whereclause_havingrurrEr') rKrrrdistincthavingrrrrd cols_presentr:rs r;r'zSelect.__init__ sxn ) 5 4!%""!\(33"""  !_--/3|H/E/E---DNN"_..DN ==LL    K!9!$             # "D  , ,033a..A Y-? @@A!((++++  , !#D   " 0 = = H H!)!I!!D  !%D   +F33>>!)?DLL DL  +   * * *  +   * * *!$11&11111s B C&(CCcg}t}|j}tjt |j|jt |jnd|jD]q}||urtj d|r ||vr||}| |j s| || |j r|S)NrQz-select() construct refers to itself as a FROM)r _from_clonedrDrEr rrrr*InvalidRequestErrorrrrrC)rKfromsseen translateitems r;_fromsz Select._fromsK s uu% O 4, - , $+ , , , N    * *Dt||-C 'TY.. $$T%566 # T""" KK( ) ) ) ) rEcjttjdDrNjr9fdjDfdDjrjrfdDjfdDj rJrHtdkr5fdDtstj d zS) aReturn 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. c6g|]}t|jSrQ)rrrs r;rz-Select._get_display_froms..v s"KKKnQ];;KKKrEc3rK|]1}j||"j|V2dSr>)rr)r~rrKs r;r<z,Select._get_display_froms..} s[  (+BB1EE %a(      rEcg|]}|v| SrQrQ)r~rtoremoves r;rz-Select._get_display_froms.. s#;;;1():):Q):):):rEc Xg|]&}|ttpdv$|'SrQr)r~rexplicit_correlate_fromsr to_correlates r;rz-Select._get_display_froms.. s`   /,!#;#Ar% rENc bg|]+}|ttpdjv)|,Sr)rr_correlate_except)r~rrrrKs r;rz-Select._get_display_froms.. sc   )(7=2* rErc8g|]}|tv|SrQr)r~rrimplicit_correlate_fromss r;rz-Select._get_display_froms.. sI+E3KLLMMMMMrEzSelect statement '%s' returned no FROM clauses due to auto-correlation; specify correlate() to control correlation manually.) rrrDrErrCr _correlaterrurr*r)rKrrrrrs```@@@r;_get_display_fromszSelect._get_display_fromsh s  OKKUKKK L    <      %2243DEE   <;;;;;;E ? ?L       "     ! -         E   ( E QEu:: - #' ' rEc^|jd}t|j}|djSr)rrr!type)rKrrs r;rzSelect._scalar_type s+ #D)**Aw|rEc*|S)z1Return the displayed list of FromClause elements.)rrJs r;rz Select.froms s&&(((rE*c0|d||S)aAdd a statement hint to this :class:`_expression.Select`. This method is similar to :meth:`_expression.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:`_expression.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) with_hint)rKtext dialect_names r;with_statement_hintzSelect.with_statement_hint s.~~dD,777rEcz||xj||ffz c_dS|j||f|i|_dS)aAdd an indexing or other executional context hint for the given selectable to this :class:`_expression.Select`. The text of the hint is rendered in the appropriate location for the database backend in use, relative to the given :class:`_schema.Table` or :class:`_expression.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:`_expression.Select.with_statement_hint` N)_statement_hints_hintsr)rKr4rrs r;rzSelect.with_hint sRF    ! !|T&:%< < ! ! ! !+++j,-G,NOODKKKrEc*tjd)NzvSelect objects don't have a type. Call as_scalar() on this Select object to return a 'scalar' version of this Select.r*rrJs r;rz Select.type s%    rEcB|j}|tt|zS)aReturn a Set of all :class:`_expression.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. )rrr )rKrs r;locate_all_fromszSelect.locate_all_froms s# tM512222rEc*t|jS)zAn iterator of all :class:`_expression.ColumnElement` expressions which would be rendered into the columns clause of the resulting SELECT statement. )r rrJs r; inner_columnszSelect.inner_columns s!!2333rEc@tdt|jD}tdt|jD}|}|D]\}}||||||fS)Nc3RK|]"}|j |jp |jp|j|fV#dSr>)_allow_label_resolve_resolve_labelr>rr9s r;r<z-Select._label_resolve_dict..) sU  %   2 2QUA 6      rEc36K|]}|j |j|fVdSr>)rrr9s r;r<z-Select._label_resolve_dict... sE  % UAJ      rE)r}r rrr@items setdefault)rK with_cols only_froms only_colsrrYs r;rlzSelect._label_resolve_dict' s  &t'899       &tz22     NN$$ $**,, - -JC  e , , , ,*i//rEcz||jvrdS|D]}||rdSdSr)rrr)rKrrs r;rzSelect.is_derived_from9 sW :) ) )4&&((  A  ,, tt urEc tt|jfitfd|j|jDx|_tj fd|jD|_tfd|j D|j |_ |j r>tfd|j D|j |_ fd|j D|_ dD]8}t||&t||t||fi9|dS)Nc3.K|]}||fifVdSr>rQr~rrJrws r;r<z)Select._copy_internals..P sG/ / $%Qa2 / / / / / / rEc3(K|] }|V dSr>rQ)r~r from_cloneds r;r<z)Select._copy_internals..U s8) )  KN) ) ) ) ) ) rEc3*K|] }|fiVdSr>rQrs r;r<z)Select._copy_internals.._ s1FFeeAnnnnFFFFFFrEc3*K|] }|fiVdSr>rQrs r;r<z)Select._copy_internals..f sB))#$a2))))))rEc"g|] }|fi SrQrQ)r~rrJrws r;rz*Select._copy_internals..o s'GGGUU1^^^^GGGrE)rrrLrMrG)rrarKr}rrrrr,rrrrrrrr)rKrJrwrrrs `` @r;rKzSelect._copy_internalsB s+fd+E88R888+// / / / / )-)=)=dk)J)J/ / / + +  K ) ) ) ) $(N) ) )   FFFFFdoFFFFFLL O    ! ,%()))))(,(>)))&&eD*++  "HGGGGT5FGGG  F FDtT"".dEE'$*=*=$D$D$D$DEEE rEc |rt|jpg|jzt|jzd|j|j|j|jfDzS)z=Return child elements as per the ClauseElement specification.cg|]}||Sr>rQrs r;rz'Select.get_children.. s)    =!==rE)rrrrrrrLrMrs r;rNzSelect.get_children~ sy 6D$6$6 <" 4;   %L))      rEc0||dS)aReturn a new :func:`_expression.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:`_expression.Select.with_only_columns` for guidelines on adding /replacing the columns of a :class:`_expression.Select` object. N)r rs r;rz Select.column s 6"""""rErc ||j|jg|jft |jzRd|iS)aReturn a new :func:`_expression.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:`_expression.Select.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. only_synonyms)with_only_columnsrBrrrr)rKrrs r;rBzSelect.reduce_columns se.%% "G "" #%dn(=(==   +     rEc|g}|D][}t|}t|tr |t j}||\||_dS)av Return a new :func:`_expression.select` construct with its columns clause replaced with the given columns. This method is exactly equivalent to as if the original :func:`_expression.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:`_expression.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:`_expression.Select.with_only_columns`. Since the method is essentially equivalent to calling the :func:`_expression.select` construct in the first place with the given columns, the columns passed to :meth:`_expression.Select.with_only_columns` should usually be a subset of those which were passed to the :func:`_expression.select` construct, not those which are available from the ``.c`` collection of that :func:`_expression.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:`_expression.select` construct is essentially being asked to select both from ``table1`` as well as itself. rN) rrr2r:r%rrrr)rKrrcrs r;rzSelect.with_only_columns sL    A,Q//A!\** =LL);L<< IIaLLLLrEc0||dS)zReturn a new :func:`_expression.select` construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any. N)append_whereclauserKrs r;wherez Select.wheres  ,,,,,rEc0||dS)zReturn a new :func:`_expression.select` construct with the given expression added to its HAVING clause, joined to the existing clause via AND, if any. N) append_havingrKrs r;rz Select.havings 6"""""rEc|r@d|D}t|jtr|j|z|_dS||_dSd|_dS)aReturn a new :func:`_expression.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. c,g|]}t|SrQrrs r;rz#Select.distinct...s!AAAq/22AAArETN)r2rr)rKrns r;rzSelect.distinct#s[  "AADAAAD$.$// &!%$!6!%!DNNNrEc0||dS)a Return a new :func:`_expression.select` construct with the given FROM expression(s) 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:`_schema.Table` or other selectable will have no effect. Passing a :class:`_expression.Join` that refers to an already present :class:`_schema.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:`_expression.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) append_fromrs r; select_fromzSelect.select_from6sF $$$$$rEcd|_|r|d d|_dSt|jd|D|_dS)aUReturn a new :class:`_expression.Select` which will correlate the given FROM clauses to that of an enclosing :class:`_expression.Select`. Calling this method turns off the :class:`_expression.Select` object's default behavior of "auto-correlation". Normally, FROM elements which appear in a :class:`_expression.Select` that encloses this one via its :term:`WHERE clause`, ORDER BY, HAVING or :term:`columns clause` will be omitted from this :class:`_expression.Select` object's :term:`FROM clause`. Setting an explicit correlation collection using the :meth:`_expression.Select.correlate` method provides a fixed list of FROM objects that can potentially take place in this process. When :meth:`_expression.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:`_expression.Select` object is, relative to an enclosing :class:`_expression.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:`_expression.Select`. Multi-level correlation ensures that the link between enclosed and enclosing :class:`_expression.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:`_expression.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:`_expression.FromClause` constructs, or other compatible constructs (i.e. ORM-mapped classes) to become part of the correlate collection. .. seealso:: :meth:`_expression.Select.correlate_except` :ref:`correlated_subqueries` FrNrQc34K|]}t|VdSr>rrs r;r<z#Select.correlate..s<99*+"1%%999999rE)rurrrrK fromclausess r;rzSelect.correlate[sjj %  ;q>1 DOOO!$/228899/:999DOOOrEcd|_|r|d d|_dSt|jpdd|D|_dS)aReturn a new :class:`_expression.Select` which will omit the given FROM clauses from the auto-correlation process. Calling :meth:`_expression.Select.correlate_except` turns off the :class:`_expression.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:`_expression.Select` object will correlate all of its FROM entries. :param \*fromclauses: a list of one or more :class:`_expression.FromClause` constructs, or other compatible constructs (i.e. ORM-mapped classes) to become part of the correlate-exception collection. .. seealso:: :meth:`_expression.Select.correlate` :ref:`correlated_subqueries` FrNrQc34K|]}t|VdSr>rrs r;r<z*Select.correlate_except..sDMM*+"1%%MMMMMMrE)rurrrrs r;correlate_exceptzSelect.correlate_exceptsz< %  ;q>1%'D " " "%()?)E2%F%F%L%LMM/:MMM&&D " " "rEcd|_t|jd|D|_dS)aAppend the given correlation expression to this :func:`_expression.select` construct. This is an **in-place** mutation method; the :meth:`_expression.Select.correlate` method is preferred, as it provides standard :term:`method chaining`. Fc34K|]}t|VdSr>rrs r;r<z,Select.append_correlation..s<5 5 &' q ! !5 5 5 5 5 5 rEN)rurrrrs r;append_correlationzSelect.append_correlationsM %do..445 5 +55 5 5   rEc|t|}t|tr |t j}|j|gz|_dS)a-Append the given column expression to the columns clause of this :func:`_expression.select` construct. E.g.:: my_select.append_column(some_table.c.new_column) This is an **in-place** mutation method; the :meth:`_expression.Select.column` method is preferred, as it provides standard :term:`method chaining`. See the documentation for :meth:`_expression.Select.with_only_columns` for guidelines on adding /replacing the columns of a :class:`_expression.Select` object. rN)rrr2r:r%rrrrs r;r zSelect.append_columnsg" -f55 fl + + C&&y/A&BBF -8rEcDt|}|j|fz|_dS)a$Append the given columns clause prefix expression to this :func:`_expression.select` construct. This is an **in-place** mutation method; the :meth:`_expression.Select.prefix_with` method is preferred, as it provides standard :term:`method chaining`. N)rr)rKr]s r; append_prefixzSelect.append_prefixs%"&))6)3rEc|ttj|j||_dS)afAppend the given expression to this :func:`_expression.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:`_expression.Select.where` method is preferred, as it provides standard :term:`method chaining`. N)rr!r'_ifnonerrs r;rzSelect.append_whereclauses;  t/@!A!A;OOrEc|ttj|j||_dS)aiAppend the given expression to this :func:`_expression.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:`_expression.Select.having` method is preferred, as it provides standard :term:`method chaining`. N)rr!r'rrrs r;rzSelect.append_havings7 EM$,77@@ rEc|t|}|j|g|_dS)a'Append the given FromClause expression to this :func:`_expression.select` construct's FROM clause. This is an **in-place** mutation method; the :meth:`_expression.Select.select_from` method is preferred, as it provides standard :term:`method chaining`. N)rr<rrrs r;r zSelect.append_froms@ ' 33 --zl;;rEc|jrEtfdfdtjt |jDSdtjt |jDS)Nc|j|jsd|fS|j}|vr|j}n|||fSr>)r>_render_label_in_columns_clause anon_labelr)rrXnamess r; name_for_colz0Select._columns_plus_names..name_for_col!sN8#1+L# !9$x5==.,s1 QrEcg|]}d|fSr>rQr9s r;rz.Select._columns_plus_names..1s,q rE)rrr, unique_listr r)rKr#r"s @@r;_columns_plus_nameszSelect._columns_plus_namess ? EEE     )*;D)rKrrr our_labels r;rzSelect._refresh_for_new_columnDs+  J44V<)rIrJrfrLrfrJs r;rz!Select._needs_parens_for_groupingTs8  d * 3"$. 3D)122 rEcvt|tr|s|St|S)a@Return a 'grouping' construct as per the :class:`_expression.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. )r2rrr3r4s r;r%zSelect.self_group[s? w / / 3355 KD!!!rEc (tj||fi|S)zaReturn a SQL ``UNION`` of this select() construct against the given selectable. )rrrKrrds r;rz Select.unionks +D%BB6BBBrEc (tj||fi|S)zeReturn a SQL ``UNION ALL`` of this select() construct against the given selectable. )rrr/s r;rzSelect.union_allr /eFFvFFFrEc (tj||fi|S)zbReturn a SQL ``EXCEPT`` of this select() construct against the given selectable. )rrr/s r;except_zSelect.except_ys ,T5CCFCCCrEc (tj||fi|S)zfReturn a SQL ``EXCEPT ALL`` of this select() construct against the given selectable. )rrr/s r; except_allzSelect.except_alls 0uGGGGGrEc (tj||fi|S)zeReturn a SQL ``INTERSECT`` of this select() construct against the given selectable. )rrr/s r;rzSelect.intersectr1rEc (tj||fi|S)ziReturn a SQL ``INTERSECT ALL`` of this select() construct against the given selectable. )rrr/s r; intersect_allzSelect.intersect_alls 3D%JJ6JJJrEc|jr|jS|j}|s|jD]}|j}|r ||_|cSn%t |dj}|r ||_|SdSr)rKrrrr)rKrrrs r;rz Select.binds : :   &  F!"DJHHH  U A#A  trEc||_dSr>rrs r;rzSelect._set_bindrrE)NNNFNTNNr)rrr>)CrMrNrOrirjrrr, immutabledictrrrrrrrArrrr'rPrrrrrr rrmethodrrrlrrrKrNrr rBrrrrr rrrr rrrr r'rrrr%rrr3r5rr8rrrrs@r;rara s,,NII T  ! !FILJ#6JT   ,]2]2]2)(]2~X:GKRRRRh ))X) 88882%P%P%P[%PN  X  3 3 344X4000"%+::::::x    &##[# T,--   .- <LL[L\--[-##[#""["$"%"%["%H::[:x##[#J    9992 4 4 4 P P P A A A < < <2 N N N    """" CCCGGGDDDHHHGGGKKK$ 8D) $ $DDDDDrEracVeZdZgZdZdZdZedZeZ e dZ dZ dS)r:TFcF||_||_dSr>)r8rrrs r;r'zScalarSelect.__init__s  ((** rEc*tjd)NzcScalar Select expression has no columns; use this object directly within a column-level expression.rrJs r;rzScalarSelect.columnss% 0   rEcD|j||_dS)zuApply a WHERE clause to the SELECT statement referred to by this :class:`_expression.ScalarSelect`. N)r8r)rKrds r;rzScalarSelect.wheres |))$// rEc |Sr>rQrMs r;r%zScalarSelect.self_groups rEN) rMrNrOr r_is_implicitly_booleanr'rPrrr rr%rQrEr;r:r:s~M"+++  X  A00[0rEr:cJeZdZdZejZgZdZd dZdZ dZ dZ dZ dS) ExistszRepresent an ``EXISTS`` clause.c@|r+t|dttfr |d}nC|stdgf}t |i|}tj||tj tj ddS)a\Construct a new :class:`_expression.Exists` against an existing :class:`_expression.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_e = exists(s) # an exists is usually used in a where of another select # to produce a WHERE EXISTS (SELECT ... ) select([table.c.col1]).where(s_e) # but can also be used in a select to produce a # SELECT EXISTS (SELECT ... ) query select([s_e]) # 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) rrT)rrTwraps_column_expressionN) r2rAr:r&rarr%r(r'rexistsr BOOLEANTYPE)rKrcrdrAs r;r'zExists.__init__s4  AJtAw\(BCC AQAA 0',,-/'''1133>>@@A  %&$(       rENc t|g|fi|Sr>rrs r;rBz Exists.selectstfk44V444rEcz|}|jj||_|Sr>)rr8rr%rKrrs r;rzExists.correlates3 KKMM*DL*J7BBDD rEcz|}|jj||_|Sr>)rr8rr%rKs r;rzExists.correlate_excepts3 KKMM1DL1:>IIKK rEc|}|j||_|S)zReturn a new :class:`_expression.Exists` construct, applying the given expression to the :meth:`_expression.Select.select_from` method of the select statement contained. )rr8r r%rKr]rs r;r zExists.select_froms9 KKMML,,V44??AA rEc|}|j||_|S)zReturn a new :func:`_expression.exists` construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any. )rr8rr%rNs r;rz Exists.wheres9 KKMML&&v..99;; rEr>) rMrNrOrir(rjr r'rBrrr rrQrEr;rDrDs))$3NM' ' ' R5555    rErDcdeZdZdZdZdZd dZedZe dZ dZ e fd Z d Zd S) TextAsFromadWrap a :class:`_expression.TextClause` construct within a :class:`_expression.SelectBase` interface. This allows the :class:`_expression.TextClause` object to gain a ``.c`` collection and other FROM-like capabilities such as :meth:`_expression.FromClause.alias`, :meth:`_expression.SelectBase.cte`, etc. The :class:`.TextAsFrom` construct is produced via the :meth:`_expression.TextClause.columns` method - see that method for details. .. versionadded:: 0.9.0 .. seealso:: :func:`_expression.text` :meth:`_expression.TextClause.columns` text_as_fromTFc0||_||_||_dSr>)r8 column_args positional)rKrrrUs r;r'zTextAsFrom.__init__<s "$rEc|jjSr>)r8rKrJs r;rKzTextAsFrom._bindAs |!!rEc4|jj|i||_dSr>)r8 bindparams)rKbindsbind_as_valuess r;rXzTextAsFrom.bindparamsEs!.t|.HHH rEcD|jD]}||dSr>)rTr)rKrs r;rz&TextAsFrom._populate_column_collectionIs3!  A MM$      rEc T|||jfi||_dSr>)rr8rIs r;rKzTextAsFrom._copy_internalsMs3 uT\00R00 rEc&|jdjSr)rTrrJs r;rzTextAsFrom._scalar_typeQs"''rENr)rMrNrOrirjrr'rPrKr rXrrrKrrQrEr;rQrQs0$NH%%%% ""X"II[I   %+1111(((((rErQceZdZdZdS)AnnotatedFromClausec@|jtj|||dSr>)rrr')rKr8r^s r;r'zAnnotatedFromClause.__init__Vs&  4&11111rEN)rMrNrOr'rQrEr;r_r_Us#22222rEr_r)IrirwrDrrsqlalchemy.sql.visitorsrrVrr annotationrbaser r r r r rrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r*r+r,r<rDrGrZr_rergobjectrmrrrr?rrrrr3rr!rArErrar:rDrQr_rQrEr;resZ ------!!!!!!""""""&&&&&&------((((((******------$$$$$$222222<<<<<<111111&&&&&&''''''''''''############ $$$$$$%%%%%%    $$$$$ $$$ HHHH$!!!0 0 0 0        1 1 1 1 1 &1 1 1 h, , , , , &, , , ^]]]]]]]]@K K K K K :K K K \q!q!q!q!q!Jq!q!q!h+A+A+A+A+Ae+A+A+A\L8L8L8L8L8%L8L8L8^d d d d d *k;d d d NnDnDnDnDnDVnDnDnDb2(2(2(2(2(:2(2(2(jbbbbb)ZbbbJZZZZZ=ZZZzAAAAAZAAAHOCOCOCOCOCzOCOCOCd G%G%G%G%G%%G%G%G%Tb%b%b%b%b%[+'7b%b%b%J%:x>PPPPP_PPPf3(3(3(3(3(3(3(3(l22222)22222rE