L i  dZddlmZddlZddlmZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#dd lm$Z$dd!l%m&Z&dd"l%m'Z'dd#l%m(Z(dd$l%m)Z)dd%l%m*Z*dd&l%m+Z+dd'l%m,Z,dd(l%m-Z-dd)l%m.Z.dd*l/m0Z0dd+l/m1Z1dd,l2m3Z3dd-l2m4Z4dd.l2m5Z5dd/l2m6Z6dd0l2m7Z7dd1l2m8Z8dd2l2m9Z9dd3l2m:Z:dd4l2m;Z;dd5l2mZ>dd8l2m?Z?dd9l2m@Z@dd:l2mAZAdd;l2mBZBddl2mEZEdd?l2mFZFdd@l2mGZGddAl2mHZHddBlmIZIddClJmKZKddDlJmLZLddElJmMZMddFlJmNZNddGlJmOZOddHlJmPZPddIlJmQZQddJlJmRZRddKlJmSZSddLlJmTZTddMlJmUZUddNlJmVZVddOl mWZWddPlXmYZYddQl$mZZZddRl$m[Z[ddSl$m\Z\dTdUlm]Z]dTdVlm^Z^dTdWl^m_Z_dTdXl`maZadTdYl`mbZbdTdZl`mcZceMjZderdd[l%meZedd\l%mfZfdd]l%mgZgdd^l%mhZhdd_l%miZidd`l%mjZjddal%mkZkddbl%mlZlddcl%mmZmdddl%mnZnddel%moZoddfl%mpZpddgl%mqZqddhl%mrZrddil%msZsddjl%mtZtddkl%muZuddll%mvZvddml%mwZxddnl%myZyddol2mzZzddpl2m{Z{ddql2m|Z|ddrlm}Z}ddsl~mZddtlmZddulmZddvlJmZddwlJmZddxlJmZddylJmZddzlJmZdd{lmZdd|lmZdd}lmZdd~lXmZddl#mZddl$mZedeQe dfZe edgeefZGddebZedefZedefZeededfZeeeeede ee ffZeedZGddeLeZGdde!j6eRZGddeDeZGddeee)ZGddeZGddZGddZGddZGdde!jFeZGddeZGddeZee\ZZZZeZGdde!jZeZGddZGddeZGddeeZGddeZGdde!jZeZGddeeZGddeeZGddeZGdde!jZe!jneEeeeZGddeZGddeZGddeZGdde!jxeZGddeZGddeSeZGddeeZGdde!jZeHeZeddee ee ffZGdÄdeNZGdĄde!jeeEeZGdƄde!jeSeQe ZGdȄde!je!je!je!jee1e Zedeˬ˫ZGd̄deSeeeZGd΄deCeeEZeAjddѫGd҄deAZGdԄdeZGdքdeFeee)ZeD]ZeeeӐjeӫeAjddثGdلde^jeAZGdۄdܫZGd݄deje"je$jZGd߄deeeeFeeee) ZGdde!jeEeSeQe(ZGddeVeZGddeeeEZeZ Gdde0Zy)ztThe :class:`_expression.FromClause` class of SQL expression elements, representing SQL tables and derived rowsets. ) annotationsN)Enum) AbstractSet)Any)Callable)cast)Dict)Generic)Iterable)Iterator)List) NamedTuple)NoReturn)Optional)overload)Sequence)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union) cache_key) coercions) operators)roles) traversals)type_api)visitors)_ColumnsClauseArgument)_no_kw)_T)_TP)is_column_element)is_select_statement) is_subquery)is_table)is_text_clause) Annotated)SupportsCloneAnnotations)_clone)_cloned_difference)_cloned_intersection)_entity_namespace_key)_EntityNamespace)_expand_cloned _from_objects) _generative_never_select_column)_NoArg)_select_iterables)CacheableOptions)ColumnCollection) ColumnSet) CompileState)DedupeColumnCollection) DialectKWArgs) Executable) Generative)HasCompileState) HasMemoized) Immutable)_document_text_coercion)_anonymous_label) BindParameter)BooleanClauseList) ClauseElement) ClauseList) ColumnClause) ColumnElement)DQLDMLClauseElement)GroupedElement)literal_column)TableValuedColumn)UnaryExpression) OperatorType)NULLTYPE)_TraverseInternalsType)InternalTraversal)prefix_anon_map)exc)util)!HasMemoized_ro_memoized_attribute)Literal)Protocol)Self)_ColumnExpressionArgument)#_ColumnExpressionOrStrLabelArgument)_FromClauseArgument)_JoinTargetArgument)_LimitOffsetType) _MAYBE_ENTITY) _NOT_ENTITY)_OnClauseArgument)#_SelectStatementForCompoundArgument)_T0)_T1)_T2)_T3)_T4)_T5)_T6)_T7)_TextCoercedExpressionArgument)_TypedColumnClauseArgument)_TypeEngineArgument)_AmbiguousTableNameMap)ExecutableOption)ReadOnlyColumnCollection)_CacheKeyTraversalType) SQLCompiler)Delete)Update)BinaryExpression)KeyedColumnElement)Label) NamedColumn) TextClause)Function) ForeignKey)ForeignKeyConstraint)TableValueType) TypeEngine)_CloneCallableType FromClauser|)ColumnElement[Any]r|cXeZdZejddZejddZy)_JoinTargetProtocolcyNselfs _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/sql/selectable.pyr3z!_JoinTargetProtocol._from_objectss14cyrrrs rentity_namespacez$_JoinTargetProtocol.entity_namespaces47rNreturnList[FromClause]rr0)__name__ __module__ __qualname__rXro_non_memoized_propertyr3rrrrrrs* ""4#4 ""7#7rrColumnElement[bool])_ColumnExpressionArgument[Any]r_rc"eZdZdZeddZy)_OffsetLimitParamTc|jSr)effective_valuers r_limit_offset_valuez%_OffsetLimitParam._limit_offset_values###rNr Optional[int])rrr inherit_cachepropertyrrrrrrsM $$rrceZdZdZdZdZdZdZdZe d dZ e jd dZ d dZ ddZddZe dd Zy ) ReturnsRowsaThe base-most class for Core constructs that have some concept of columns that can represent rows. While the SELECT statement and TABLE are the primary things we think of in this category, DML like INSERT, UPDATE and DELETE can also specify RETURNING which means they can be used in CTEs and other forms, and PostgreSQL has functions that return rows also. .. versionadded:: 1.4 TFc|Srrrs r selectablezReturnsRows.selectables rct)aEA sequence of column expression objects that represents the "selected" columns of this :class:`_expression.ReturnsRows`. This is typically equivalent to .exported_columns except it is delivered in the form of a straight sequence and not keyed :class:`_expression.ColumnCollection`. NotImplementedErrorrs r_all_selected_columnsz!ReturnsRows._all_selected_columnss "##rct)zReturn ``True`` if this :class:`.ReturnsRows` is 'derived' from the given :class:`.FromClause`. An example would be an Alias of a Table is derived from that Table. rr fromclauses ris_derived_fromzReturnsRows.is_derived_from "##rct)z=Populate columns into an :class:`.AliasedReturnsRows` object.rrrcolumns primary_key foreign_keyss r#_generate_fromclause_column_proxiesz/ReturnsRows._generate_fromclause_column_proxiess "##rct)z>reset internal collections for an incoming column being added.rrcolumns r_refresh_for_new_columnz#ReturnsRows._refresh_for_new_columns !##rct)aA :class:`_expression.ColumnCollection` that represents the "exported" columns of this :class:`_expression.ReturnsRows`. The "exported" columns represent the collection of :class:`_expression.ColumnElement` expressions that are rendered by this SQL construct. There are primary varieties which are the "FROM clause columns" of a FROM clause, such as a table, join, or subquery, the "SELECTed columns", which are the columns in the "columns clause" of a SELECT statement, and the RETURNING columns in a DML statement.. .. versionadded:: 1.4 .. seealso:: :attr:`_expression.FromClause.exported_columns` :attr:`_expression.SelectBase.exported_columns` rrs rexported_columnszReturnsRows.exported_columnss 0"##rNrrr_SelectIterablerOptional[FromClause]rbool rrr.ColumnCollection[str, KeyedColumnElement[Any]]rr;rSet[KeyedColumnElement[Any]]rNonerrrr)rz"ReadOnlyColumnCollection[Any, Any])rrr__doc___is_returns_rows_is_from_clause_is_select_base_is_select_statement _is_lateralrrrXrrrrrrrrrrrs OO K  "" $# $$ $ $@ $ $ 3 $  $$$$rrceZdZdZy)ExecutableReturnsRowsz0base for executable statements that return rows.Nrrrrrrrrrs:rrceZdZdZy)TypedReturnsRowsz8base for a typed executable statements that return rows.Nrrrrrr"sBrrceZdZdZdZdZd dZdddZejdd ejd dd Z d dd Z y) Selectablez!Mark a class as being selectable.rTctrrrs rrz"Selectable._refresh_for_new_column- !##rNc0tj||S);Return a LATERAL alias of this :class:`_expression.Selectable`. The return value is the :class:`_expression.Lateral` construct also provided by the top-level :func:`_expression.lateral` function. .. seealso:: :ref:`tutorial_lateral_correlation` - overview of usage. name)Lateral _constructrrs rlateralzSelectable.lateral0s!!$T!22r1.4zThe :meth:`.Selectable.replace_selectable` method is deprecated, and will be removed in a future release. Similar functionality is available via the sqlalchemy.sql.visitors module.)messagesqlalchemy.sql.utilcrtjjj|j |S)zReplace all occurrences of :class:`_expression.FromClause` 'old' with the given :class:`_expression.Alias` object, returning a copy of this :class:`_expression.FromClause`. )rX preloadedsql_util ClauseAdaptertraverse)roldaliass rreplace_selectablezSelectable.replace_selectable=s*~~&&44U;DDTJJrc:|jj||S)aGiven a :class:`_expression.ColumnElement`, return the exported :class:`_expression.ColumnElement` object from the :attr:`_expression.Selectable.exported_columns` collection of this :class:`_expression.Selectable` which corresponds to that original :class:`_expression.ColumnElement` 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.Selectable`. Normally the column will match if it merely shares a common ancestor with one of the exported columns of this :class:`_expression.Selectable`. .. seealso:: :attr:`_expression.Selectable.exported_columns` - the :class:`_expression.ColumnCollection` that is used for the operation. :meth:`_expression.ColumnCollection.corresponding_column` - implementation method. )rcorresponding_column)rrrequire_embeddeds rrzSelectable.corresponding_columnLs$F$$99 $  rrrr Optional[str]rLateralFromClause)rrrAliasrr\F)rzKeyedColumnElement[Any]rrr!Optional[KeyedColumnElement[Any]]) rrrr__visit_name__ is_selectablerrrX deprecatedpreload_modulerrrrrrr&s+!NM$ 3T__ M T./K0 KIN% -% AE% *% rrceZdZUdZded<dej fgZded<ee dddd d  d d Z y ) HasPrefixesr+Tuple[Tuple[DQLDMLClauseElement, str], ...] _prefixesrS _has_prefixes_traverse_internalsprefixesz+:meth:`_expression.HasPrefixes.prefix_with`z.:paramref:`.HasPrefixes.prefix_with.*prefixes`*dialectc |jt|Dcgc](}tjtj ||f*c}z|_|Scc}w)aqAdd 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 \*prefixes: textual or :class:`_expression.ClauseElement` construct which will be rendered following the INSERT, UPDATE, or DELETE keyword. :param dialect: optional string dialect name which will limit rendering of this prefix to only that dialect. )rtuplerexpectrStatementOptionRole)rrrps r prefix_withzHasPrefixes.prefix_with{sXF%" !!%";";Q?I +     -A N)r#_TextCoercedExpressionArgument[Any]rstrrr\) rrrr__annotations__rTdp_prefix_sequencerr4rDrrrrrrtsz=?I:? '::;@$&<58#6##  #  #rrceZdZUdZded<dej fgZded<ee dddd d  d d Z y ) HasSuffixesrr _suffixesrS _has_suffixes_traverse_internalssuffixesz+:meth:`_expression.HasSuffixes.suffix_with`z.:paramref:`.HasSuffixes.suffix_with.*suffixes`rrc |jt|Dcgc](}tjtj ||f*c}z|_|Scc}w)a%Add 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 \*suffixes: textual or :class:`_expression.ClauseElement` construct which will be rendered following the target clause. :param dialect: Optional string dialect name which will limit rendering of this suffix to only that dialect. )r rrrrr)rrrrs r suffix_withzHasSuffixes.suffix_withsXH%" !!%";";Q?I +     rN)rrrrrr\) rrrr rrTr r r4rDrrrrr r sz=?I:? '::;@$&<58$6$$  $  $rr ceZdZUejZded<dZded<dejfdejfgZ ded<e d d dZ e d dd Z dd Zy )HasHintsz/util.immutabledict[Tuple[FromClause, str], str]_hintsrzTuple[Tuple[str, str], ...]_statement_hintsrS_has_hints_traverse_internalsc(|jd||S)aAdd a statement hint to this :class:`_expression.Select` or other selectable object. .. tip:: :meth:`_expression.Select.with_statement_hint` generally adds hints **at the trailing end** of a SELECT statement. To place dialect-specific hints such as optimizer hints at the **front** of the SELECT statement after the SELECT keyword, use the :meth:`_expression.Select.prefix_with` method for an open-ended space, or for table-specific hints the :meth:`_expression.Select.with_hint` may be used, which places hints in a dialect-specific location. 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. .. seealso:: :meth:`_expression.Select.with_hint` :meth:`_expression.Select.prefix_with` - generic SELECT prefixing which also can suit some database-specific HINT syntaxes such as MySQL or Oracle Database optimizer hints N _with_hint)rtext dialect_names rwith_statement_hintzHasHints.with_statement_hintsBtT<88rc(|j|||S)a?Add an indexing or other executional context hint for the given selectable to this :class:`_expression.Select` or other selectable object. .. tip:: The :meth:`_expression.Select.with_hint` method adds hints that are **specific to a single table** to a statement, in a location that is **dialect-specific**. To add generic optimizer hints to the **beginning** of a statement ahead of the SELECT keyword such as for MySQL or Oracle Database, use the :meth:`_expression.Select.prefix_with` method. To add optimizer hints to the **end** of a statement such as for PostgreSQL, use the :meth:`_expression.Select.with_statement_hint` method. 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 Database, the following:: select(mytable).with_hint(mytable, "index(%(name)s ix_mytable)") Would render SQL as: .. sourcecode:: sql 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 Database and MSSql simultaneously:: select(mytable).with_hint( mytable, "index(%(name)s ix_mytable)", "oracle" ).with_hint(mytable, "WITH INDEX ix_mytable", "mssql") .. seealso:: :meth:`_expression.Select.with_statement_hint` :meth:`_expression.Select.prefix_with` - generic SELECT prefixing which also can suit some database-specific HINT syntaxes such as MySQL or Oracle Database optimizer hints rrrrrs r with_hintzHasHints.with_hint stz4>>rc||xj||ffz c_|S|jjtjt j ||f|i|_|Sr)rrunionrrrFromClauseRolers rrzHasHints._with_hintEss    ! !|T&:%< < ! ++++"(()=)=zJ$ DK rN)r)rrrrrr\)rr_rrrrrr\)rzOptional[_FromClauseArgument]rrrrrr\)rrrrX immutabledictrrrrTdp_statement_hint_listdp_table_hint_listrr4rrrrrrrrs ;5716 .EEF $778=!#9  9 9D  9?'9?9? 9?  9?9?v1   rrceZdZUdZdZdZejd%dZde d<de d<d Z d e d < d Z d Z dZ dZd&d Z d' d(dZ d) d*dZ d) d+dZ d, d-dZd.dZd/dZejd0dZ d1dZej d2dZej d2dZej4d2dZd3dZejd4dZej4d5dZej4d6dZd3dZ ejd7dZ!e"d8dZ# d9d Z$d:d!Z%d dd" d;d#Z&e'r d< d=d$Z(y y )>raERepresent 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`. rFcyNrrrs r _hide_fromszFromClause._hide_fromsqsrr _is_clone_ofzColumnCollection[Any, Any]_columnsNrschemaTct|S)a#Return a SELECT of this :class:`_expression.FromClause`. e.g.:: stmt = some_table.select().where(some_table.c.id == 5) .. seealso:: :func:`_expression.select` - general purpose method which allows for arbitrary column lists. Selectrs rselectzFromClause.selectsd|rc t|||||S)aReturn a :class:`_expression.Join` from this :class:`_expression.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: .. sourcecode:: sql 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`. .. seealso:: :func:`_expression.join` - standalone function :class:`_expression.Join` - the type of object produced Join)rrightonclauseisouterfulls rjoinzFromClause.joinsfD%7D99rc t|||d|S)aReturn 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. .. seealso:: :meth:`_expression.FromClause.join` :class:`_expression.Join` Tr1)rr3r4r6s r outerjoinzFromClause.outerjoins^D%466rc0tj||S)atReturn 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:`tutorial_using_aliases` :func:`_expression.alias` r)rrrrflats rrzFromClause.aliass*400rc4tj||||S)aWReturn 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. .. seealso:: :func:`_expression.tablesample` - usage guidelines and parameters )samplingrseed) TableSampler)rr>rr?s r tablesamplezFromClause.tablesamples%"%% 8$T&  rc||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_setrs rrzFromClause.is_derived_from*sT----rc^t|jj|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. )rrC intersectionrothers r_is_lexical_equivalentz!FromClause._is_lexical_equivalent6s&D$$11%2C2CDEErcJt|d|jjdzS)z|A brief description of this :class:`_expression.FromClause`. Used primarily for error message formatting. rz object)getattr __class__rrs r descriptionzFromClause.description@s"tVT^^%<%zAFromClause._generate_fromclause_column_proxies..Ps0(  OO ,  ( !)_populate_separate_keyscrs ` ``rrz.FromClause._generate_fromclause_column_proxiesIs& ''( vv (  rc|jS)aA :class:`_expression.ColumnCollection` that represents the "exported" columns of this :class:`_expression.Selectable`. The "exported" columns for a :class:`_expression.FromClause` object are synonymous with the :attr:`_expression.FromClause.columns` collection. .. versionadded:: 1.4 .. seealso:: :attr:`_expression.Selectable.exported_columns` :attr:`_expression.SelectBase.exported_columns` rXrs rrzFromClause.exported_columnsWs ,vv rc|jS)aA named-based collection of :class:`_expression.ColumnElement` objects maintained by this :class:`_expression.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) :return: a :class:`.ColumnCollection` object. rZrs rrzFromClause.columnsos vv rcrd|jvr|j|jjS)zk A synonym for :attr:`.FromClause.columns` :return: a :class:`.ColumnCollection` r*)__dict___setup_collectionsr* as_readonlyrs rrXz FromClause.cs/ T]] *  # # %}}((**rcLtj5d|jvr*d|jvsJd|jvsJ dddyt}t }t }|j |||||_||_||_ dddy#1swYyxYw)Nr*rr)rrr) rXmini_gilr]r:r;set_populate_column_collectionr*rr)rr*rrs rr^zFromClause._setup_collectionss ]] -T]]*$ 555%666  - -4D3EH#+K9<L  , , ') - %DM*D  ,D + - - -s0B ABB#c|jS)aReturn a namespace used for name-based access in SQL expressions. This is the namespace that is used to resolve "filter_by()" type expressions, such as:: stmt.filter_by(address="some address") It defaults to the ``.c`` collection, however internally it can be overridden using the "entity_namespace" annotation to deliver alternative results. rZrs rrzFromClause.entity_namespaces vv rc:|j|jS)apReturn the iterable collection of :class:`_schema.Column` objects which comprise the primary key of this :class:`_selectable.FromClause`. For a :class:`_schema.Table` object, this collection is represented by the :class:`_schema.PrimaryKeyConstraint` which itself is an iterable collection of :class:`_schema.Column` objects. )r^rrs rrzFromClause.primary_keys !rc:|j|jS)aVReturn the collection of :class:`_schema.ForeignKey` marker objects which this FromClause references. Each :class:`_schema.ForeignKey` is a member of a :class:`_schema.Table`-wide :class:`_schema.ForeignKeyConstraint`. .. seealso:: :attr:`_schema.Table.foreign_key_constraints` )r^rrs rrzFromClause.foreign_keyss !   rcJdD]}|jj|d y)aReset the attributes linked to the ``FromClause.c`` attribute. This collection is separate from all the other memoized things as it has shown to be sensitive to being cleared out in situations where enclosing code, typically in a replacement traversal scenario, has already established strong relationships with the exported columns. The collection is cleared for the case where a table is having a column added to it as well as within a Join during copy internals. )r*rrXrrN)r]pop)rkeys r_reset_column_collectionz#FromClause._reset_column_collections(O )C MM  c4 ( )rc(d|jDS)Nc38K|]}t|r|ywrr5rSrXs rrUz.FromClause._select_iterable..sAa)=a)@AsrZrs r_select_iterablezFromClause._select_iterablesA466AArcd|jvS)Nr*)r]rs r_cols_populatedzFromClause._cols_populatedsT]]**rcy)zCalled on subclasses to establish the .c collection. Each implementation has a different way of establishing this collection. Nrrrrrs rrcz&FromClause._populate_column_collectionrc$|jy)aNGiven 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 ultimately 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)rjrs rrz"FromClause._refresh_for_new_columns2 %%'rrr<c&|j|SNr)rr;s r_anonymous_fromclausez FromClause._anonymous_fromclauseszztz$$rcyrrragainsts r self_groupzFromClause.self_groups(+rrIterable[FromClause]r Select[Any]NFF) r3r_r4)Optional[_ColumnExpressionArgument[bool]]r5rr6rrr2NF)r3r_r4rr6rrr2)rrr<rrNamedFromClauseNN)r>Union[float, Function[Any]]rrr?*Optional[roles.ExpressionElementRole[Any]]rr@r)rGrrrrrrrz6ReadOnlyColumnCollection[str, KeyedColumnElement[Any]])rrrrzIterable[NamedColumn[Any]]rzIterable[ForeignKey]rrrrrrr;rrrrr)rrr<rrrr)r{Optional[OperatorType]rzUnion[FromGrouping, Self]))rrrrrnamed_with_columnrXrr(rr+rr_is_join_use_schema_mapr/r7r9rrArrHrLrrrro_memoized_propertyrXr^rrrrjrnrrprcrrxrr|rrrrrYs("N ""#'&(( FM MOHO&?C 3:"3:<3: 3:  3:  3:p?C /7"/7</7 /7  /7d8=1!1041 14#;?  -  9    * .F ""J#J    @    3     "" ?#. "" ?#"  + +-0 "" #       !! )" ""B#B++  ?    3    (8(,%%$%37% % 59 ,1 , & ,rcReZdZUdZdZded<ejdddZy) rzA :class:`.FromClause` that has a name. Examples include tables, subqueries, CTEs, aliased tables. .. versionadded:: 2.0 Trrzsqlalchemy.sql.sqltypesc6t|tjS)ayReturn a :class:`_sql.TableValuedColumn` object for this :class:`_expression.FromClause`. A :class:`_sql.TableValuedColumn` is a :class:`_sql.ColumnElement` that represents a complete row in a table. Support for this construct is backend dependent, and is supported in various forms by backends such as PostgreSQL, Oracle Database and SQL Server. E.g.: .. sourcecode:: pycon+sql >>> from sqlalchemy import select, column, func, table >>> a = table("a", column("id"), column("x"), column("y")) >>> stmt = select(func.row_to_json(a.table_valued())) >>> print(stmt) {printsql}SELECT row_to_json(a) AS row_to_json_1 FROM a .. versionadded:: 1.4.0b2 .. seealso:: :ref:`tutorial_functions` - in the :ref:`unified_tutorial` )rOr TABLEVALUErs r table_valuedzNamedFromClause.table_valued-s8!x':':;;rNrzTableValuedColumn[Any]) rrrrrrrXrrrrrrr s4 IT23<4.Es6q 6sc38K|]}|j|fywr) _tq_key_label)rSrTs rrUz3Join._populate_column_collection..Hs ( ),S   $( )rXrrrrXr3extendreduce_columnsr4rWupdate itertoolschainr)rrrrsqlutilrXr*rTs rrcz Join._populate_column_collection7s..))>Biikk2J12Jzz||N AN 3    " "6H6   ''( 08(    OO(C3c..C D 3KN Ds C( C- C2 c 0ttjt|jt|j }|Dcic] }|||fi|c} dfd }||d<t |dd|i||jycc}w)Nct|tr.|jvr |jj|}|Syr isinstancerJtablerobjkwnewelem new_fromss rreplacez%Join._copy_internals..replaced;#|,i1G#CII.CCCHrrclonerz/Union[BinaryExpression[Any], ColumnClause[Any]]rrrrr) rbrrr3rr3super_copy_internals_reset_memoizations)rrr all_the_fromsfrrrKs @rrzJoin._copy_internalsOs OOdii(djj)  1>>1Qa2&>  @  /  9 2e2r2   "+?s Bct|||jj||jj|yr)rrrr3rrrKs rrzJoin._refresh_for_new_columnvs4 '/ ))&1 **62rcht|tr |j}nd}|j|||S)N)a_subset)rr2r3_join_condition)rrr3 left_rights rrzJoin._match_primaries{s4 dD !JJ##D%*#EEr)rconsider_as_foreign_keysc|j||||}t|dkDr|j||||t|dk(rGt|trd}nd}t j d|jd|jd|t|jdDcgc] \}}||k( } }}t| dk(r| dSt| Scc}}w)zCreate a join condition between two tables or selectables. See sqlalchemy.sql.util.join_condition() for full docs. rrzI Perhaps you meant to convert the right side to a subquery using alias()?z2Can't find any foreign key relationships between '' and 'z'.) _joincond_scan_left_rightlen_joincond_trim_constraintsrrrWNoForeignKeysErrorrLlistvaluesand_) clsabrr constraintshintxycrits rrzJoin._join_conditions 33 x4  { a   * *1k#;  { q !\*. ((==!--7  &*+*<*<*>%?%BCTQaCC t9>7N;  Ds+C)rct|tr |j}nd}|j||||}t |S)N)rrrr)rr2r3rr)rrr3rrrs r _can_joinzJoin._can_joinsJ dD !JJ33%= 4 K  rcRtjj}tjt j |}tjt j |}tjt}||fD]}|t|jdD]R}||j|vr |j|} | )||j&j)| |jfT||urmt|jdD]R}||j|vr |j|} | )||j&j)| |jfT|s|S|S#tj$rH} |j!|D chc]} | j"ncc} w} } | j$| vrYd} ~ %d} ~ wwxYw#tj$rH} |j!|D chc]} | j"ncc} w} } | j$| vrYd} ~ d} ~ wwxYw)Nc.|jjSrparent_creation_orderfks rz0Join._joincond_scan_left_right..sryy88rric.|jjSrrrs rrz0Join._joincond_scan_left_right..s299#<#<r)rXrrrrrr! collections defaultdictrsortedrr get_referentrWNoReferenceError find_tablesr table_name constraintappend) rrrrrrrrrrTnrtet table_namess rrzJoin._joincond_scan_left_rights>>**   U111 5   U111 5  # #D )  qM- D|8 H -8 )AA!//$/C? .55sBII6FG' H(1} %%<LB 1<II-EE % ooa0#BMM2993 :JK'L(]- \A++!3;3G3G3M"Na166"N"NK"N+5 !*//%7?7K7KA7N&O!qvv&O&O &O??k9!$ %sH3E-$G -GGF' &GG H&H!1H H!!H&c|rDt|D]6}|jDchc]}|jc}t|k7s4||=8t |dkDrI|j Dchc] }t |}}t |dk(rt|d} | || i}t |dk7r0tjd|jd|jdycc}wcc}w)NrrzCan't determine join between 'rz'; tables have more than one foreign key constraint relationship between them. Please specify the 'onclause' of this join explicitly.) relementsrrbrrrrWAmbiguousForeignKeysErrorrL) rrrrrconstrrdeduperis rrzJoin._joincond_trim_constraintss $k* +&+nn5AHH5,:$E*  + { a .9.@.@.BCdeDkCFC6{a;'*"K$45 { q // '(mmQ]] D  !6Ds C'C"c`t|j|jj|S)aCreate a :class:`_expression.Select` from this :class:`_expression.Join`. E.g.:: stmt = table_a.join(table_b, table_a.c.id == table_b.c.a_id) stmt = stmt.select() The above will produce a SQL string resembling: .. sourcecode:: sql SELECT table_a.id, table_a.col, table_b.id, table_b.a_id FROM table_a JOIN table_b ON table_a.id = table_b.a_id )r.rr3 select_fromrs rr/z Join.select4s$$dii,88>>rctjj}|ret|jt t fr|}n:|r6t|jtr|d|jj}n|}t|jt t fr|}n:|r6t|jtr|d|jj}n|}|jj|||jj||}}|j|j|j|}|j||j|j|j |j"S|j%j't(j+dj-|S)N_rur5r6)rXrrrrrr2rrr3rxrrr7rr4r5r6r/set_label_styler correlater) rrr<r left_name right_nameleft_aright_aadapters rrxzJoin._anonymous_fromclauseHsj..)) $))lD%9: Jtyy/B#'&$))..)9 :I $I$**|T&:;! Jtzz?C$(64::??*;!mark a FROM clause as being able to render directly as LATERALNrrrrrrsHrrcXeZdZUdZdZdZded<dejfdejfgZ ded<e d d  dd Z d d dd Z dfd Z ddZej"ddZej"ddZeddZddZef dfd ZeddZxZS)AliasedReturnsRowszLBase class of aliases against tables, subqueries, and other selectables.TFrelementrrSrNrc R|j|}|j|fd|i||S)Nr)__new___init)rrrrrs rrzAliasedReturnsRows._constructs/kk# *.4.2. rcDtjtj|||_||_||_|^t |tr+|jrt|dd}t |trd}tjt||xsd}||_ y)Napply_propagate_attrsranon)rrrReturnsRowsRoler$ _orig_namerrrrJrEsafe_constructrr)rrrs rr'zAliasedReturnsRows._inits ''  ! !:T  "  <:z200z648d$45D#222d8T^VLD rcZt|||jj|yr)rrr$rs rrz*AliasedReturnsRows._refresh_for_new_columns" '/ ,,V4rcB|jj||||yNrPr$rrrs rrcz.AliasedReturnsRows._populate_column_collections$ 88 '{ 9 rc@|j}t|try|S)Nanon_1)rrrErs rrLzAliasedReturnsRows.descriptionsyy d, - rc.|jjSr)r$implicit_returningrs rr6z%AliasedReturnsRows.implicit_returnings||...rc|jS)z9Legacy for dialects that are referring to Alias.original.r$rs roriginalzAliasedReturnsRows.originals||rcV||jvry|jj|SNT)rCr$rrs rrz"AliasedReturnsRows.is_derived_froms( )) )||++J77rc ~|j}t|dd|i|||jur|jyy)Nrr)r$rrrj)rrrexisting_elementrKs rrz"AliasedReturnsRows._copy_internalssC << 2e2r2 4<< /  ) ) + 0rc|gSrrrs rr3z AliasedReturnsRows._from_objects v r)rrrrrrrr\)rrrrrrrrrrrrrr)rrrr_is_from_container_supports_derived_columnsrrTr dp_anon_namerrrr'rrcrXrrLr6rr9rr,rr3rrs@rr#r#sI %  %667 "//03/  #        ?C"5 ?  3     ""# ""/#/8 +1 ,' ,8; ,  ,rr#c>eZdZUded<ej ddZy)FromClauseAliasrr$cp|j}t|trd|jjS|S)NzAnonymous alias of )rrrEr$rLrs rrLzFromClauseAlias.descriptions3yy d, -()A)A(BC C rNr)rrrrrXrrLrrrrDrDs  ""#rrDcJeZdZUdZdZdZded<e d d dZy) raRepresents 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 Database). 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. .. seealso:: :meth:`_expression.FromClause.alias` rTrr$Ncptjtj|dj ||S)NT) allow_selectru)rrrr!r)rrrr<s r_factoryzAlias._factory"s2  *4 %T% % &rr)rrrrr<rrr) rrrrrrrrrIrrrrr sY"NM # &&& &  &&rrcDeZdZUdZdZdZdZdZdZde jfde jfde jfde jfd e jfgZd ed <d d dd  dfdZej$ddZ d ddZdddZ d ddZxZS)TableValuedAliasaAn alias against a "table valued" SQL function. This construct provides for a SQL function that returns columns to be used in the FROM clause of a SELECT statement. The object is generated using the :meth:`_functions.FunctionElement.table_valued` method, e.g.: .. sourcecode:: pycon+sql >>> from sqlalchemy import select, func >>> fn = func.json_array_elements_text('["one", "two", "three"]').table_valued( ... "value" ... ) >>> print(select(fn.c.value)) {printsql}SELECT anon_1.value FROM json_array_elements_text(:json_array_elements_text_1) AS anon_1 .. versionadded:: 1.4.0b2 .. seealso:: :ref:`tutorial_functions_table_valued` - in the :ref:`unified_tutorial` table_valued_aliasTFr$r_tableval_type_render_derived_render_derived_w_typesrSrNrtable_value_typejoins_implicitlyctt|||||_|tj|_y||_yrw)rr'rRrrrM)rrrrQrRrKs rr'zTableValuedAlias._initWsE  jt , 0 '    " rc.t||jS)aReturn a column expression representing this :class:`_sql.TableValuedAlias`. This accessor is used to implement the :meth:`_functions.FunctionElement.column_valued` method. See that method for further details. E.g.: .. sourcecode:: pycon+sql >>> print(select(func.some_func().table_valued("value").column)) {printsql}SELECT anon_1 FROM some_func() AS anon_1 .. seealso:: :meth:`_functions.FunctionElement.column_valued` )rOrMrs rrzTableValuedAlias.columnhs,!t':':;;rctj|||j|j}|jrd|_|j |_|S)zReturn a new alias of this :class:`_sql.TableValuedAlias`. This creates a distinct FROM object that will be distinguished from the original one when used in a SQL statement. rPT)rKrrMrRrNrO)rrr<tvas rrzTableValuedAlias.aliassW!1 ; ; !00!22 !<!    "&C *.*F*FC ' rc8|j|}d|_|S)zReturn a new :class:`_sql.TableValuedAlias` with the lateral flag set, so that it renders as LATERAL. .. seealso:: :func:`_expression.lateral` rT)rr)rrrVs rrzTableValuedAlias.laterals jjdj# rctj|j||j|j}d|_||_|S)aApply "render derived" to this :class:`_sql.TableValuedAlias`. This has the effect of the individual column names listed out after the alias name in the "AS" sequence, e.g.: .. sourcecode:: pycon+sql >>> print( ... select( ... func.unnest(array(["one", "two", "three"])) ... .table_valued("x", with_ordinality="o") ... .render_derived() ... ) ... ) {printsql}SELECT anon_1.x, anon_1.o FROM unnest(ARRAY[%(param_1)s, %(param_2)s, %(param_3)s]) WITH ORDINALITY AS anon_1(x, o) The ``with_types`` keyword will render column types inline within the alias expression (this syntax currently applies to the PostgreSQL database): .. sourcecode:: pycon+sql >>> print( ... select( ... func.json_to_recordset('[{"a":1,"b":"foo"},{"a":"2","c":"bar"}]') ... .table_valued(column("a", Integer), column("b", String)) ... .render_derived(with_types=True) ... ) ... ) {printsql}SELECT anon_1.a, anon_1.b FROM json_to_recordset(:json_to_recordset_1) AS anon_1(a INTEGER, b VARCHAR) :param name: optional string name that will be applied to the alias generated. If left as None, a unique anonymizing name will be used. :param with_types: if True, the derived columns will include the datatype specification with each column. This is a special syntax currently known to be required by PostgreSQL for some SQL functions. rPT)rKrr$rMrRrNrO)rr with_types new_aliass rrender_derivedzTableValuedAlias.render_derivedsOn'7&A&A LL!00!22 'B' %) !,6 )r) rrrrrQzOptional[TableValueType]rRrrrrr)rrr<rrrKrr)rrrYrrrK)rrrrrrArNrOrRrTrrBdp_typerrrr'rBmemoized_attributerrrr[rrs@rrKrK.s-2*N $O# %667 "//0 ,445 -889 "$5$@$@A 3/#59!&     3      "##<$<08=!04 . # ???  ?rrKc<eZdZdZdZdZdZe d ddZy)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. .. seealso:: :ref:`tutorial_lateral_correlation` - overview of usage. rTNcntjtj|dj |S)NT)explicit_subqueryr)rrrr!rrrrs rrIzLateral._factorys0   * 't'  rr)rz&Union[SelectBase, _FromClauseArgument]rrrr) rrrrrrrrrIrrrrrsK NKM#:  rrceZdZUdZdZej dejfdejfgzZde d<e d ddZ e jd ddd  dfd Zdd ZxZS)r@aIRepresent 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. .. seealso:: :func:`_expression.tablesample` rAr>r?rSrNcntjtj|j |||S)Nrr?)rrrr!rA)rrr>rr?s rrIzTableSample._factorys7 4 4jAMM 4dN  rzsqlalchemy.sql.functionsrdc|Jtjj}t||js|j j |}||_||_t|)||yrw) rXr sql_functionsrr}funcsystemr>r?rr')rrrr>r? functionsrKs rr'zTableSample._init+sb###NN00 (I$6$67 ~~,,X6H'/    jt ,rc|jSr)r>rs r _get_methodzTableSample._get_method=s }}rr) rr_r>rrrr?rrr@) rrrrr>rr?rrr)rz Function[Any])rrrrrr#rrTrrrrIrXrr'rkrrs@rr@r@s #N .. *;; < &77 8  / #;?  '  .    9      T34 #;? -- - . - 9 - -5-"rr@ceZdZUdZdZej dejfdejfdejfdejfgze jze jzZded<d ed <e d dd Zd d d d d d d d dfdZ ddZdddZddZ ddZddZxZS)CTEaURepresent a Common Table Expression. The :class:`_expression.CTE` object is obtained using the :meth:`_sql.SelectBase.cte` method from any SELECT statement. A less often available syntax also allows use of the :meth:`_sql.HasCTE.cte` method present on :term:`DML` constructs such as :class:`_sql.Insert`, :class:`_sql.Update` and :class:`_sql.Delete`. See the :meth:`_sql.HasCTE.cte` method for usage details on CTEs. .. seealso:: :ref:`tutorial_subqueries_ctes` - in the 2.0 tutorial :meth:`_sql.HasCTE.cte` - examples of calling styles cte _cte_alias _restates recursivenestingrSrHasCTEr$NFcltjtj|j ||S)zReturn a new :class:`_expression.CTE`, or Common Table Expression instance. Please see :meth:`_expression.HasCTE.cte` for detail on CTE usage. )rrq)rrr HasCTERolern)rrrrqs rrIz CTE._factoryks5 0 0*=AAB  r)rrqrrrorprr c||_||_||_||_|r||_|r||_t |||yrw)rqrrrorprr rr') rrrrqrrrorprr rKs rr'z CTE._init|sE# $" &DN &DN  jt ,rc|j |jj||||y|jj||||yr1)rorr$rrs rrczCTE._populate_column_collectionsW ?? & OO ? ?') @  LL < <') = rc tj|j||j|j||j |j S)a2Return 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:`tutorial_using_aliases` :func:`_expression.alias` )rrqrrrorr )rmrr$rqrrrr r;s rrz CTE.aliassC~~ LLnnLLnnnn  rc  t|jsJd|jdtj|jj||j |j |j||j|jS)aReturn a new :class:`_expression.CTE` with a SQL ``UNION`` of the original CTE against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. .. seealso:: :meth:`_sql.HasCTE.cte` - examples of calling styles CTE element fz does not support union()rrqrrrprr ) r&r$rmrr rrqrrrr rFs rr z CTE.unions# LL  C 4<<.(A B C ~~ DLL   &nnLLnnnn  rc  t|jsJd|jdtj|jj||j |j |j||j|jS)aReturn a new :class:`_expression.CTE` with a SQL ``UNION ALL`` of the original CTE against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. .. seealso:: :meth:`_sql.HasCTE.cte` - examples of calling styles rzz does not support union_all()r{) r&r$rmr union_allrrqrrrr rFs rr}z CTE.union_alls$# LL  G 4<<.(E F G ~~ "DLL " "E *nnLLnnnn  rc6|j |jS|S)z A recursive CTE is updated to attach the recursive part. Updated CTEs should still refer to the original CTE. This function returns this reference identifier. )rprs r_get_reference_ctezCTE._get_reference_ctes "&!;t~~EErr)rrsrrrqrrrm)rrrrrqrrrrro Optional[CTE]rprrOptional[Tuple[()]]r rrrr)rrr<rrrm)rGz(_SelectStatementForCompoundArgument[Any]rrm)rrm)rrrrrr#rrTrrrrr r rrrIr'rcrr r}rrrs@rrmrmAs$N .. ,== > +<< = +66 7 )44 5     6 6 7  6 6 7/ O#        (#$(#')-)--- -  -  -"-!-'-'- -.?3   * 0 : >  @FrrmceZdZUded<y)_CTEOptsrrrNrrrrrrrrr s MrrcHeZdZUded< ded< ded< ded< ded<y ) _ColumnsPlusNamesrrequired_label_name proxy_keyfallback_label_name%Union[ColumnElement[Any], TextClause]rrrepeatedNrrrrrr s@&&  '& 21Nrrc6eZdZUdZeZded< d ddZy) SelectsRowszvSub-base of ReturnsRows for elements that deliver rows directly, namely SELECT and INSERT/UPDATE/DELETE..RETURNINGr _label_styleNc | |j}tj|j}i}g}|j}|jt u}|jt u}d} |D]} d} | jsdx} x} }n|r2tr t| sJdx} } | jxs | j}ntr t| sJ|r| jx} x} }n| jx} }d} | t| j}|`| j|v} | || j<dx} } | r0|r| j| }| dz } n*| j| }| dz } n| j}n|x} x} }| tr t| sJ| |vrt!|| t!| k7r}|r| j"x} }n| jx} }|rV| |vrRt!|| t!| k(sJ|r| j| x} }| dz } n| j| x} }| dz } d} nC| || <n=|r;|r| j| x} }| dz } n| j| x} }| dz } d} n| || <|t%| || || | |S)aGenerate column names as rendered in a SELECT statement by the compiler, as well as tokens used to populate the .c. collection on a :class:`.FromClause`. This is distinct from the _column_naming_convention generator that's intended for population of the Select.selected_columns collection, different rules. the collection returned here calls upon the _column_naming_convention as well. NrFT)r SelectState_column_naming_conventionrrrr_render_label_in_columns_clauserr%_non_anon_label_anon_name_label _tq_label_expression_label_dedupe_anon_tq_label_idx_dedupe_anon_label_idxr_anon_tq_labelr)ranon_for_dupe_keycolskey_naming_conventionnamesresult result_appendtable_qualifiedlabel_style_none dedupe_hashrXreffective_namerr expr_labels r_generate_columns_plus_namesz(SelectsRows._generate_columns_plus_names1 sT <--D + E E   ! *, ++/MM,,0@@ } AH44!47J" ,Q///7;;!4&'&7&7&M1;M;M# ,Q///" $'$.+<=;L;LLN%8*.'!)"#!4!4J!)#$#5#5#>45a001?CC)<# /$%$?$? $L!4!,q 0 676N6N$/7" 3!,q 0 232D2D/''+'n/) ,Q///!U*E.12d1g=+ ! 0 0/2E !" 2 2/2E-1D1M $(.A(B#CtAw#NN#N /$%$?$? $L!" 36I!,q 0 %&$<$<[$I!" 36I!,q 0 '+H9:E"56*+ ! ; ;K H/2E(1,K!" 8 8 E/2E(1,K#',-E.) !')!,'  k} ~ rr)rrrzOptional[_SelectIterable]rzList[_ColumnsPlusNames])rrrrrrrrrrrrr+ s?C&6L"5 +/ff(f ! frrceZdZUdZdej fdej fgZded<dZ ded<dZ ded<d Z d ed < e d d dd Z d ddZy)rsz3Mixin that declares a class to include CTE support._independent_ctes_independent_ctes_optsrS_has_ctes_traverse_internalsrzTuple[CTE, ...]zTuple[_CTEOpts, ...]Frname_cte_columns nest_herect|}|D]R}tjtj|}|xj |fz c_|xj |fz c_T|S)aAdd one or more :class:`_sql.CTE` constructs to this statement. This method will associate the given :class:`_sql.CTE` constructs with the parent statement such that they will each be unconditionally rendered in the WITH clause of the final statement, even if not referenced elsewhere within the statement or any sub-selects. The optional :paramref:`.HasCTE.add_cte.nest_here` parameter when set to True will have the effect that each given :class:`_sql.CTE` will render in a WITH clause rendered directly along with this statement, rather than being moved to the top of the ultimate rendered statement, even if this statement is rendered as a subquery within a larger statement. This method has two general uses. One is to embed CTE statements that serve some purpose without being referenced explicitly, such as the use case of embedding a DML statement such as an INSERT or UPDATE as a CTE inline with a primary statement that may draw from its results indirectly. The other is to provide control over the exact placement of a particular series of CTE constructs that should remain rendered directly in terms of a particular statement that may be nested in a larger statement. E.g.:: from sqlalchemy import table, column, select t = table("t", column("c1"), column("c2")) ins = t.insert().values({"c1": "x", "c2": "y"}).cte() stmt = select(t).add_cte(ins) Would render: .. sourcecode:: sql WITH anon_1 AS ( INSERT INTO t (c1, c2) VALUES (:param_1, :param_2) ) SELECT t.c1, t.c2 FROM t Above, the "anon_1" CTE is not referenced in the SELECT statement, however still accomplishes the task of running an INSERT statement. Similarly in a DML-related context, using the PostgreSQL :class:`_postgresql.Insert` construct to generate an "upsert":: from sqlalchemy import table, column from sqlalchemy.dialects.postgresql import insert t = table("t", column("c1"), column("c2")) delete_statement_cte = t.delete().where(t.c.c1 < 1).cte("deletions") insert_stmt = insert(t).values({"c1": 1, "c2": 2}) update_statement = insert_stmt.on_conflict_do_update( index_elements=[t.c.c1], set_={ "c1": insert_stmt.excluded.c1, "c2": insert_stmt.excluded.c2, }, ).add_cte(delete_statement_cte) print(update_statement) The above statement renders as: .. sourcecode:: sql WITH deletions AS ( DELETE FROM t WHERE t.c1 < %(c1_1)s ) INSERT INTO t (c1, c2) VALUES (%(c1)s, %(c2)s) ON CONFLICT (c1) DO UPDATE SET c1 = excluded.c1, c2 = excluded.c2 .. versionadded:: 1.4.21 :param \*ctes: zero or more :class:`.CTE` constructs. .. versionchanged:: 2.0 Multiple CTE instances are accepted :param nest_here: if True, the given CTE or CTEs will be rendered as though they specified the :paramref:`.HasCTE.cte.nesting` flag to ``True`` when they were added to this :class:`.HasCTE`. Assuming the given CTEs are not referenced in an outer-enclosing statement as well, the CTEs given should render at the level of this statement when this flag is given. .. versionadded:: 2.0 .. seealso:: :paramref:`.HasCTE.cte.nesting` )rrrr IsCTERolerr)rrctesoptrns radd_ctezHasCTE.add_cte saJy! 2C""5??C8C  " "sf , "  ' 'C6 1 ' 2 rNc4tj||||S)a&Return 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. 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. :param nesting: if ``True``, will render the CTE locally to the statement in which it is referenced. For more complex scenarios, the :meth:`.HasCTE.add_cte` method using the :paramref:`.HasCTE.add_cte.nest_here` parameter may also be used to more carefully control the exact placement of a particular CTE. .. versionadded:: 1.4.24 .. seealso:: :meth:`.HasCTE.add_cte` The following examples include two from PostgreSQL's documentation at https://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) Example 4, Nesting CTE (SQLAlchemy 1.4.24 and above):: value_a = select(literal("root").label("n")).cte("value_a") # A nested CTE with the same name as the root one value_a_nested = select(literal("nesting").label("n")).cte( "value_a", nesting=True ) # Nesting CTEs takes ascendency locally # over the CTEs at a higher level value_b = select(value_a_nested.c.n).cte("value_b") value_ab = select(value_a.c.n.label("a"), value_b.c.n.label("b")) The above query will render the second CTE nested inside the first, shown with inline parameters below as: .. sourcecode:: sql WITH value_a AS (SELECT 'root' AS n), value_b AS (WITH value_a AS (SELECT 'nesting' AS n) SELECT value_a.n AS n FROM value_a) SELECT value_a.n AS a, value_b.n AS b FROM value_a, value_b The same CTE can be set up using the :meth:`.HasCTE.add_cte` method as follows (SQLAlchemy 2.0 and above):: value_a = select(literal("root").label("n")).cte("value_a") # A nested CTE with the same name as the root one value_a_nested = select(literal("nesting").label("n")).cte("value_a") # Nesting CTEs takes ascendency locally # over the CTEs at a higher level value_b = ( select(value_a_nested.c.n) .add_cte(value_a_nested, nest_here=True) .cte("value_b") ) value_ab = select(value_a.c.n.label("a"), value_b.c.n.label("b")) Example 5, Non-Linear CTE (SQLAlchemy 1.4.28 and above):: edge = Table( "edge", metadata, Column("id", Integer, primary_key=True), Column("left", Integer), Column("right", Integer), ) root_node = select(literal(1).label("node")).cte("nodes", recursive=True) left_edge = select(edge.c.left).join( root_node, edge.c.right == root_node.c.node ) right_edge = select(edge.c.right).join( root_node, edge.c.left == root_node.c.node ) subgraph_cte = root_node.union(left_edge, right_edge) subgraph = select(subgraph_cte) The above query will render 2 UNIONs inside the recursive CTE: .. sourcecode:: sql WITH RECURSIVE nodes(node) AS ( SELECT 1 AS node UNION SELECT edge."left" AS "left" FROM edge JOIN nodes ON edge."right" = nodes.node UNION SELECT edge."right" AS "right" FROM edge JOIN nodes ON edge."left" = nodes.node ) SELECT nodes.node FROM nodes .. seealso:: :meth:`_orm.Query.cte` - ORM version of :meth:`_expression.HasCTE.cte`. )rrqrr)rmr)rrrqrrs rrnz HasCTE.cteY s$P ~~ ty'  rrrmrrrr\r)rrrqrrrrrrm)rrrrrTdp_clauseelement_list dp_plain_objrrrrrr4rrnrrrrsrs s= /EEF !#4#A#AB< "8 *,+3505"d"49iiZ# j j j  j j rrsc|eZdZUdZdZdZdZded<e d d dZ e jdd d d Z y)SubqueryaRepresent a subquery of a SELECT. A :class:`.Subquery` is created by invoking the :meth:`_expression.SelectBase.subquery` method, or for convenience the :meth:`_expression.SelectBase.alias` method, on any :class:`_expression.SelectBase` subclass which includes :class:`_expression.Select`, :class:`_expression.CompoundSelect`, and :class:`_expression.TextualSelect`. As rendered in a FROM clause, it represents the body of the SELECT statement inside of parenthesis, followed by the usual "AS " that defines all "alias" objects. The :class:`.Subquery` object is very similar to the :class:`_expression.Alias` object and can be used in an equivalent way. The difference between :class:`_expression.Alias` and :class:`.Subquery` is that :class:`_expression.Alias` always contains a :class:`_expression.FromClause` object whereas :class:`.Subquery` always contains a :class:`_expression.SelectBase` object. .. versionadded:: 1.4 The :class:`.Subquery` class was added which now serves the purpose of providing an aliased version of a SELECT statement. subqueryT SelectBaser$Ncjtjtj|j |S)z#Return a :class:`.Subquery` object.r)rrrSelectStatementRolerras rrIzSubquery._factory s.   % %z ((  rraxThe :meth:`.Subquery.as_scalar` method, which was previously ``Alias.as_scalar()`` prior to version 1.4, is deprecated and will be removed in a future release; Please use the :meth:`_expression.Select.scalar_subquery` method of the :func:`_expression.select` construct before constructing a subquery object, or with the ORM use the :meth:`_query.Query.scalar_subquery` method.c\|jjtjSr)r$rrscalar_subqueryrs r as_scalarzSubquery.as_scalar s#||++,<=MMOOrr)rrrrrrrScalarSelect[Any]) rrrrr _is_subqueryrrrrIrXrrrrrrr st8 NLM ;?#+8 T__  ? P PrrcZeZdZUdZdej fgZded<ded<ddZe j ddZ e jddZ e dd Ze dd Zdd Z d dd ZddZe jddZe jddZddZddZer d d!dZy y )"rz%Represent a grouping of a FROM clauser$rSrrcVtjtj||_yr)rrrr!r$rr$s rrzFromGrouping.__init__ s ''(<(DLL>>DDEErc.|jjSr)r$r(rs rr(zFromGrouping._hide_froms rrc.|jjSrr$r3rs rr3zFromGrouping._from_objects ||)))rcd|jiSNr$r8rs r __getstate__zFromGrouping.__getstate__ s4<<((rc|d|_yrr8rstates r __setstate__zFromGrouping.__setstate__ sY' rcyrrrzs rr|zFromGrouping.self_group r)r$rrrrrr)rrr<rrr)rrrrr}r)rDict[str, FromClause])rrrrrr{rrr\)rrrrrTrrrrrXrrrXrrrrrrxr(r3rrrr|rrrrr s+/ %6673/G ""$ ?$#$  ""$#$(())88=K!K04K K F ""(#( ""*#*)(59 1   rrc,eZdZdZdZer d ddZyy)rzLrepresent a grouping of a named FROM clause .. versionadded:: 2.0 TNcyrrrzs rr|zNamedFromGrouping.self_group rrrr)rrrrrrr|rrrrr s0 M59 1   rrceZdZUdZdZdej fdejfdejfgZde d<dZ d e d <d Z e jdd Zdfd Zer(e j" ddZe j"ddZddZddZe jddZddZe j0dddZe j0dd dZe j0dd!dZe j"d"dZxZS)# TableClausea.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. rrrr+rSrTrfullnameFcy)z4No PK or default support so no autoincrement column.Nrrs r_autoincrement_columnz!TableClause._autoincrement_columnD srct|||_t|_t |_t|_|D]}|j||jdd}|||_ |j!|jd|j|_ n|j|_ |r!tjdt|zy)Nr+.zUnsupported argument(s): %s)rrrr=r*r;rrbr append_columnrhr+rrW ArgumentErrorr)rrrrrXr+rKs rrzTableClause.__init__I s  .0 $;E "A   q ! "$'   DK ;; "'+{{DII>DM IIDM ##$ADH$LM M rcyrrrs rrzTableClause.columns^ s @Crcyrrrs rrXz TableClause.cc sILrcj|j|jdz|jzS|jS)Nr)r+rrs r__str__zTableClause.__str__f s. ;; ";;$tyy0 099 rcyrrrs rrz#TableClause._refresh_for_new_columnl s rc|jSrrrs rrLzTableClause.descriptiono s yyrc|j}|*||ur&tjd|jd|d|jj |||_y)Nzcolumn object 'z' already assigned to table '')rrWrrir*add)rrXexistings rrzTableClause.append_columns sT77  HD$8##55($  !rzsqlalchemy.sql.dmlcTtjjj|S)zGenerate an :class:`_sql.Insert` construct against this :class:`_expression.TableClause`. E.g.:: table.insert().values(name="foo") See :func:`_expression.insert` for argument and usage information. )rXrsql_dmlInsertrs rinsertzTableClause.insert~ s~~%%,,T22rcTtjjj|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. )rXrrrwrs rrzTableClause.update s$~~%%,,   rcTtjjj|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. )rXrrrvrs rdeletezTableClause.delete s~~%%,,T22rc|gSrrrs rr3zTableClause._from_objects r?r)rzOptional[ColumnClause[Any]])rrrColumnClause[Any]rr)rz0ReadOnlyColumnCollection[str, ColumnClause[Any]]rr)rXrrr)rzutil.preloaded.sql_dml.Insert)rrw)rrvr)rrrrrrT)dp_fromclause_canonical_column_collection dp_stringrr _is_tabler6rXrrrrrrrXrrrLrrrrrr3rrs@rrr sp<N   G G  ",,- $../ 3/IM= N& & & C = C ' C  & &L 'L    T-. 3/ 3T-.  /  T-. 3/ 3 ""#rr ForUpdateArgc eZdZUdejfdej fdej fdej fdej fgZded<ded<d ed<d ed<d ed<e dd Z dd Z dd Z dd Z dddddd ddZ y)rofnowaitread skip_locked key_sharerSrz!Optional[Sequence[ClauseElement]]rcvt|tr|S|dvry|dur tStditd|S)NrTDict[str, Any]r)rrr)rwith_for_updates r_from_argumentzForUpdateArg._from_argument sE o| 4" "  -  $> !J$'7"IJ Jrc.t|txr|j|jk(xri|j|jk(xrN|j|jk(xr3|j |j k(xr|j |j uSr)rrrrrrrrFs r__eq__zForUpdateArg.__eq__ s ul + $  + $ dii' $!!T%5%55 $4>>1  $ DGG#  rc&|j| Sr)r rFs r__ne__zForUpdateArg.__ne__ s;;u%%%rct|Sr)rrs r__hash__zForUpdateArg.__hash__ s $xrFNrrrrrc||_||_||_||_|Kt j |Dcgc]&}t jtj|(c}|_ yd|_ ycc}w)zZRepresents arguments specified to :meth:`_expression.Select.for_update`. N) rrrrrXto_listrrrColumnsClauseRoler)rrrrrrelems rrzForUpdateArg.__init__ sl  &" >!LL,  !8!8$?DG DG s+A2)rForUpdateParameterrOptional[ForUpdateArg])rGrrr)rint) rrrrrOptional[_ForUpdateOfArgument]rrrr)rrrrTrrrrrr r r rrrrrrr s  667 $//0 "--. )445 '223 3/ *) L J K0 K  K K & -1!  +   rceZdZUdZdZdZded<ded<dejfdejfd ejfd ejfge jzZd ed <d Zddd dfdZeddZej(ddZedddZedd dZed!dZd"dZ d#dZej(d$dZxZS)%ValueszRepresent a ``VALUES`` construct that can be used as a FROM element in a statement. The :class:`_expression.Values` object is created from the :func:`_expression.values` function. .. versionadded:: 1.4 rr%Tuple[Sequence[Tuple[Any, ...]], ...]_datar_unnamed _column_argsr literal_bindsrSrTNF)rrct|||_|,d|_t j t |d|_nd|_||_||_|j |_ y)NTr+F) rrrrrEr.rrrr)rrrrrKs rrzValues.__init__ sa # < DM(774&IDI!DMDI*%)]]!2rcT|jDcgc]}|jc}Scc}wrrtyperrTs r _column_typeszValues._column_types$ $($5$56S666%c|jSr)rrs rrzValues._all_selected_columns( s   rcx| tjt|d}n|}||_d|_d|_|S)aYReturn a new :class:`_expression.Values` construct that is a copy of this one with the given name. This method is a VALUES-specific specialization of the :meth:`_expression.FromClause.alias` method. .. seealso:: :ref:`tutorial_using_aliases` :func:`_expression.alias` r+TF)rEr.rrrr)rrr< non_none_names rrz Values.alias, s?$ <,;;BtHfMM M! !%  rcR| |j}n|}d|_||_d|_|S)zReturn a new :class:`_expression.Values` with the lateral flag set, so that it renders as LATERAL. .. seealso:: :func:`_expression.lateral` TF)rrr)rrr*s rrzValues.lateralH s2 < IIM M!   rc2|xj|fz c_|S)ajReturn a new :class:`_expression.Values` construct, adding the given data to the data list. E.g.:: my_values = my_values.data([(1, "value 1"), (2, "value2")]) :param values: a sequence (i.e. list) of tuples that map to the column expressions given in the :class:`_expression.Values` constructor. )r)rrs rdataz Values.data_ s vi  rcXt|j|j|jS)zReturns a scalar ``VALUES`` construct that can be used as a COLUMN element in a statement. .. versionadded:: 2.0.0b4 ) ScalarValuesrrrrs r scalar_valueszValues.scalar_valuesq s#D--tzz4;M;MNNrc|jD]\}|j&|j|ur|j|||\}}n|j|j |||_^yr1)rrrRrr)rrrrrXrs rrcz"Values._populate_column_collectionz sl "" Aww"qwwd':}}k %1%%' KKNAG rc|gSrrrs rr3zValues._from_objects r?r)rrrrrrrzList[TypeEngine[Any]]rr)rrr<rrr\r)rrrr\)rzSequence[Tuple[Any, ...]]rr\rr/rr)rrrrrrrrTrdp_dml_multi_valuesrrrsrrrrrr%rXrrr4rrr-r0rcr3rrs@rrr saN35E 05N *@@A #778 ",,- +667 3 ++ 3,/, ## 3#33 3$77 ""!#!6,"O?3   & ""#rrceZdZUdZdZdej fdejfdejfgZ de d< d fd Z e dd Z dd Zer d dd Zdd ZxZSxZS)r/a{Represent a scalar ``VALUES`` construct that can be used as a COLUMN element in a statement. The :class:`_expression.ScalarValues` object is created from the :meth:`_expression.Values.scalar_values` method. It's also automatically generated when a :class:`_expression.Values` is used in an ``IN`` or ``NOT IN`` condition. .. versionadded:: 2.0.0b4 r0rrrrSrcLt|||_||_||_yr)rrrrr)rrr-rrKs rrzScalarValues.__init__ s' # *rcT|jDcgc]}|jc}Scc}wrr"r$s rr%zScalarValues._column_types r&r'c|Srrrs r__clause_element__zScalarValues.__clause_element__  rcyrrrzs rr|zScalarValues.self_group rrcyrrrs r_ungroupzScalarValues._ungroup rsr)rzSequence[ColumnClause[Any]]r-rrrr3r4rr)rr)rrrrrrTrr5rrrrrr%r:rr|r>rrs@rr/r/ s %N *@@A #778 +6673/ +, +4 + +7759 1    6 rr/ceZdZUdZdZdZeZded<ddZ e j d dZ dd d!d Z e jd"d Ze d#d Zee j"d d d$dZe d$dZd%dZd&dZe j"d dd'dZej0d(dZd)dZe j"d dd*dZd+dZd*dZd,dZd-d.dZd-d/dZ d0dZ! d1 d2dZ"y)3rzBase class for SELECT statements. This includes :class:`_expression.Select`, :class:`_expression.CompoundSelect` and :class:`_expression.TextualSelect`. Trrc$|jyr)rrs rrz"SelectBase._refresh_for_new_column s   "rct)a$A :class:`_expression.ColumnCollection` representing the columns that this SELECT statement or similar construct returns in its result set. This collection differs from the :attr:`_expression.FromClause.columns` collection of a :class:`_expression.FromClause` in that the columns within this collection cannot be directly nested inside another SELECT statement; a subquery must be applied first which provides for the necessary parenthesization required by SQL. .. note:: The :attr:`_sql.SelectBase.selected_columns` collection does not include expressions established in the columns clause using the :func:`_sql.text` construct; these are silently omitted from the collection. To use plain textual column expressions inside of a :class:`_sql.Select` construct, use the :func:`_sql.literal_column` construct. .. seealso:: :attr:`_sql.Select.selected_columns` .. versionadded:: 1.4 rrs rselected_columnszSelectBase.selected_columns s <"##rNproxy_compound_columnsctrrrrrrrrDs rrz.SelectBase._generate_fromclause_column_proxies s "##rct)a A sequence of expressions that correspond to what is rendered in the columns clause, including :class:`_sql.TextClause` constructs. .. versionadded:: 1.4.12 .. seealso:: :attr:`_sql.SelectBase.exported_columns` rrs rrz SelectBase._all_selected_columns s "##rc6|jjS)afA :class:`_expression.ColumnCollection` that represents the "exported" columns of this :class:`_expression.Selectable`, not including :class:`_sql.TextClause` constructs. The "exported" columns for a :class:`_expression.SelectBase` object are synonymous with the :attr:`_expression.SelectBase.selected_columns` collection. .. versionadded:: 1.4 .. seealso:: :attr:`_expression.Select.exported_columns` :attr:`_expression.Selectable.exported_columns` :attr:`_expression.FromClause.exported_columns` )rBr_rs rrzSelectBase.exported_columnss2$$0022rraThe :attr:`_expression.SelectBase.c` and :attr:`_expression.SelectBase.columns` attributes are deprecated and will be removed in a future release; these attributes implicitly create a subquery that should be explicit. Please call :meth:`_expression.SelectBase.subquery` first in order to create a subquery, which then contains this attribute. To access the columns that this SELECT object SELECTs from, use the :attr:`_expression.SelectBase.selected_columns` attribute.c.|jjSr)_implicit_subqueryrrs rrXz SelectBase.c4s&&...rc|jSrrZrs rrzSelectBase.columnsEs vv rct)zX Retrieve the current label style. Implemented by subclasses. rrs rget_label_stylezSelectBase.get_label_styleKrrct)zeReturn a new selectable with the specified label style. Implemented by subclasses. rrstyles rrzSelectBase.set_label_styleTrra The :meth:`_expression.SelectBase.select` method is deprecated and will be removed in a future release; this method implicitly creates a subquery that should be explicit. Please call :meth:`_expression.SelectBase.subquery` first in order to create a subquery, which then can be selected.c:|jj|i|Sr)rJr/rs rr/zSelectBase.select]s".t&&--s9b99rc"|jSrrrs rrJzSelectBase._implicit_subqueryis}}rctrrrs r _scalar_typezSelectBase._scalar_typemrrzThe :meth:`_expression.SelectBase.as_scalar` method is deprecated and will be removed in a future release. Please refer to :meth:`_expression.SelectBase.scalar_subquery`.c"|jSr)rrs rrzSelectBase.as_scalarps##%%rct|S)aaReturn an :class:`_sql.Exists` representation of this selectable, which can be used as a column expression. The returned object is an instance of :class:`_sql.Exists`. .. seealso:: :func:`_sql.exists` :ref:`tutorial_exists` - in the :term:`2.0 style` tutorial. .. versionadded:: 1.4 )Existsrs rexistszSelectBase.existszsd|rcf|jtur|jt}t|S)aXReturn a 'scalar' representation of this selectable, which can be used as a column expression. The returned object is an instance of :class:`_sql.ScalarSelect`. Typically, a select statement which has only one column in its columns clause is eligible to be used as a scalar expression. The scalar subquery can then be used in the WHERE clause or columns clause of an enclosing SELECT. Note that the scalar subquery differentiates from the FROM-level subquery that can be produced using the :meth:`_expression.SelectBase.subquery` method. .. versionchanged: 1.4 - the ``.as_scalar()`` method was renamed to :meth:`_expression.SelectBase.scalar_subquery`. .. seealso:: :ref:`tutorial_scalar_subquery` - in the 2.0 tutorial )rrr ScalarSelectrs rrzSelectBase.scalar_subquerys/0   $4 4''(89DD!!rc@|jj|S)zReturn a 'scalar' representation of this selectable, embedded as a subquery with a label. .. seealso:: :meth:`_expression.SelectBase.scalar_subquery`. )rlabelrs rr]zSelectBase.labels##%++D11rc.tj||S)r)rrIrs rrzSelectBase.lateralsd++rcLtj|j|S)aReturn a subquery of this :class:`_expression.SelectBase`. A subquery is from a SQL perspective a parenthesized, named construct that can be placed in the FROM clause of another SELECT statement. Given a SELECT statement such as:: stmt = select(table.c.id, table.c.name) The above statement might look like: .. sourcecode:: sql SELECT table.id, table.name FROM table The subquery form by itself renders the same way, however when embedded into the FROM clause of another SELECT statement, it becomes a named sub-element:: subq = stmt.subquery() new_stmt = select(subq) The above renders as: .. sourcecode:: sql SELECT anon_1.id, anon_1.name FROM (SELECT table.id, table.name FROM table) AS anon_1 Historically, :meth:`_expression.SelectBase.subquery` is equivalent to calling the :meth:`_expression.FromClause.alias` method on a FROM object; however, as a :class:`_expression.SelectBase` object is not directly FROM object, the :meth:`_expression.SelectBase.subquery` method provides clearer semantics. .. versionadded:: 1.4 r)rr_ensure_disambiguated_namesrs rrzSelectBase.subquerys+X""  , , .T#  rct)ztEnsure that the names generated by this selectbase will be disambiguated in some way, if possible. rrs rr`z&SelectBase._ensure_disambiguated_namess "##rc&|j|S)a.Return a named subquery against this :class:`_expression.SelectBase`. For a :class:`_expression.SelectBase` (as opposed to a :class:`_expression.FromClause`), this returns a :class:`.Subquery` object which behaves mostly the same as the :class:`_expression.Alias` object that is used with a :class:`_expression.FromClause`. .. versionchanged:: 1.4 The :meth:`_expression.SelectBase.alias` method is now a synonym for the :meth:`_expression.SelectBase.subquery` method. rrSr;s rrzSelectBase.aliass"}}$}''rrrz)ColumnCollection[str, ColumnElement[Any]] rrrrrr;rrrD0Optional[Iterable[Sequence[ColumnElement[Any]]]]rrr)rz1ReadOnlyColumnCollection[str, ColumnElement[Any]]rrrrPrrr\)r rrrrr)rrrzTypeEngine[Any]r)rrX)rrrz Label[Any]rr)rrrrrr\r)rrr<rrr)#rrrrr is_selectrrrrrXrrBrrrrrrXrrMrr/rBr]rJrUrrYrr]rrr`rrrrrr sOI%5L"5# ""$ 2$#$P  $ $@ $ $ 3 $!  $  $ "" $# $3 :334T__   / / ? $$T__  2::##$$T__  :&&"": 2 ,. `$8=(!(04( (rr_SB)boundcZeZdZUdZdZdej fgejzZ de d<dZ de d<ddZ dd Z dd Z dd Zedd ZdddZerddZd d ddZej.d dZej.d!dZej.d"dZddd#dZy )$SelectStatementGroupingzRepresent a grouping of a :class:`_expression.SelectBase`. This differs from :class:`.Subquery` in that we are still an "inner" SELECT statement, this is strictly for grouping inside of compound selects. select_statement_groupingr$rSrTrkcrtttjtj ||_yr)rrkrrrrr$rs rrz SelectStatementGrouping.__init__!s& !!%";";WE  rcl|jj}||jur t|S|Sr)r$r`rn)r new_elements rr`z3SelectStatementGrouping._ensure_disambiguated_names&s0ll>>@ dll **;7 7Krc6|jjSr)r$rMrs rrMz'SelectStatementGrouping.get_label_style-s||++--rcJt|jj|Sr)rnr$r)r label_styles rrz'SelectStatementGrouping.set_label_style0s#' LL ( ( 5  rc|jSrr8rs rselect_statementz(SelectStatementGrouping.select_statement7s ||rNc|Srrrzs rr|z"SelectStatementGrouping.self_group;r;rcyrrrs rr>z SelectStatementGrouping._ungroup@rsrrCcD|jj|||||y)NrDrrr2rFs rrz;SelectStatementGrouping._generate_fromclause_column_proxiesGs* 88  #9#% 9 rc.|jjSr)r$rrs rrz-SelectStatementGrouping._all_selected_columnsZs||111rc.|jjS)a:A :class:`_expression.ColumnCollection` representing the columns that the embedded SELECT statement returns in its result set, not including :class:`_sql.TextClause` constructs. .. versionadded:: 1.4 .. seealso:: :attr:`_sql.Select.selected_columns` )r$rBrs rrBz(SelectStatementGrouping.selected_columns^s||,,,rc.|jjSrrrs rr3z%SelectStatementGrouping._from_objectsnrrFrctrr)rrrs rrzSelectStatementGrouping.add_cters!!r)r$rkrr)rSelectStatementGrouping[_SB]rf)rurrr)rrkrrrdrrcrr)rrrrrrTrr+%_clone_annotations_traverse_internalsrr_is_select_containerrr`rMrrrwr|rr>rrXrrrBr3rrrrrnrns,1N %6673 FF3G/G  L . + % &   @   3  !    & ""2#2 "" -# - ""*#*5:"rrnceZdZUdZdZded<dZded<dZded<dZded <dZ ded <dZ d ed <dZ d ed<e fd&dZ edddddd d'dZd(dZd)dZed*dZed*dZ d+ d,dZe d-dZe d.dZ d/dZed0dZd1dZed0dZed2dZed3dZe d4 d5d Zed6d!Zeej@d" d7d#Z!ee"jFf d8d$Z$ee"jFf d8d%Z%y)9GenerativeSelecta&Base class for SELECT statements where additional elements can be added. This serves as the base for :class:`_expression.Select` and :class:`_expression.CompoundSelect` where elements such as ORDER BY, GROUP BY can be added and column rendering can be controlled. Compare to :class:`_expression.TextualSelect`, 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. rTuple[ColumnElement[Any], ...]_order_by_clauses_group_by_clausesNOptional[ColumnElement[Any]] _limit_clause_offset_clause _fetch_clausezOptional[Dict[str, bool]]_fetch_clause_optionsr_for_update_argc||_yrr)rrs rrzGenerativeSelect.__init__s (rFrc0t||||||_|S)a~Specify 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 Database, the above would render a statement like: .. sourcecode:: sql SELECT table.a, table.b FROM table FOR UPDATE NOWAIT on other backends, the ``nowait`` option is ignored and instead would produce: .. sourcecode:: sql 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 Database 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, for some backends may also be a table expression) which will render into a ``FOR UPDATE OF`` clause; supported by PostgreSQL, Oracle Database, some MySQL versions and possibly others. May render as a table or as a column depending on backend. :param skip_locked: boolean, will render ``FOR UPDATE SKIP LOCKED`` on Oracle Database and PostgreSQL dialects or ``FOR SHARE SKIP LOCKED`` if ``read=True`` is also specified. :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. r)rr)rrrrrrs rrz GenerativeSelect.with_for_updates(v ,#   rc|jS)zS Retrieve the current label style. .. versionadded:: 1.4 rrs rrMz GenerativeSelect.get_label_styles   rcP|j|ur|j}||_|S)a{Return a new selectable with the specified label style. There are three "label styles" available, :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`, :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL`, and :attr:`_sql.SelectLabelStyle.LABEL_STYLE_NONE`. The default style is :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`. In modern SQLAlchemy, there is not generally a need to change the labeling style, as per-expression labels are more effectively used by making use of the :meth:`_sql.ColumnElement.label` method. In past versions, :data:`_sql.LABEL_STYLE_TABLENAME_PLUS_COL` was used to disambiguate same-named columns from different tables, aliases, or subqueries; the newer :data:`_sql.LABEL_STYLE_DISAMBIGUATE_ONLY` now applies labels only to names that conflict with an existing name so that the impact of this labeling is minimal. The rationale for disambiguation is mostly so that all column expressions are available from a given :attr:`_sql.FromClause.c` collection when a subquery is created. .. versionadded:: 1.4 - the :meth:`_sql.GenerativeSelect.set_label_style` method replaces the previous combination of ``.apply_labels()``, ``.with_labels()`` and ``use_labels=True`` methods and/or parameters. .. seealso:: :data:`_sql.LABEL_STYLE_DISAMBIGUATE_ONLY` :data:`_sql.LABEL_STYLE_TABLENAME_PLUS_COL` :data:`_sql.LABEL_STYLE_NONE` :data:`_sql.LABEL_STYLE_DEFAULT` )r _generaterOs rrz GenerativeSelect.set_label_styles,L   E )>>#D %D  rc^tjtj|jS)z9ClauseList access to group_by_clauses for legacy dialects)rI_construct_rawrcomma_oprrs r_group_by_clausez!GenerativeSelect._group_by_clause (((    6 6  rc^tjtj|jS)z9ClauseList access to order_by_clauses for legacy dialects)rIrrrrrs r_order_by_clausez!GenerativeSelect._order_by_clauserrcPtjtj|||S)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. )rtype_)rrrLimitOffsetRole)rr$rrs r_offset_or_limit_clausez(GenerativeSelect._offset_or_limit_clauses&  ! !7U  rcyrrrclauseattrnames r_offset_or_limit_clause_asintz.GenerativeSelect._offset_or_limit_clause_asint(srcyrrrs rrz.GenerativeSelect._offset_or_limit_clause_asint-src|y |j}tj|S#t$r}t j d|z|d}~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 %s)rrXasintAttributeErrorrW CompileError)rrrvalueerrs rrz.GenerativeSelect._offset_or_limit_clause_asint2sd > %..E::e$ $  ""')12  s & A AA c:|j|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. limit)rrrs r_limitzGenerativeSelect._limitHs11$2D2DgNNrc"t|tS)zkTrue if the clause is a simple integer, False if it is not present or is a SQL expression. )rr)rrs r_simple_int_clausez#GenerativeSelect._simple_int_clauseRs&"344rc:|j|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. offset)rrrs r_offsetzGenerativeSelect._offsetXs"11     rc^|jduxs|jduxs|jduSr)rrrrs r_has_row_limiting_clausez)GenerativeSelect._has_row_limiting_clauseds=   d * .""$. .!!- rcNdx|_|_|j||_|S)aReturn 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. .. note:: The :meth:`_sql.GenerativeSelect.limit` method will replace any clause applied with :meth:`_sql.GenerativeSelect.fetch`. :param limit: an integer LIMIT parameter, or a SQL expression that provides an integer result. Pass ``None`` to reset it. .. seealso:: :meth:`_sql.GenerativeSelect.fetch` :meth:`_sql.GenerativeSelect.offset` N)rrrr)rrs rrzGenerativeSelect.limitls,4;?>T7!99%@ rc |j|d|_|dx|_|_|S|j ||_||d|_|S)a6Return a new selectable with the given FETCH FIRST criterion applied. This is a numeric value which usually renders as ``FETCH {FIRST | NEXT} [ count ] {ROW | ROWS} {ONLY | WITH TIES}`` expression in the resulting select. This functionality is is currently implemented for Oracle Database, PostgreSQL, MSSQL. Use :meth:`_sql.GenerativeSelect.offset` to specify the offset. .. note:: The :meth:`_sql.GenerativeSelect.fetch` method will replace any clause applied with :meth:`_sql.GenerativeSelect.limit`. .. versionadded:: 1.4 :param count: an integer COUNT parameter, or a SQL expression that provides an integer result. When ``percent=True`` this will represent the percentage of rows to return, not the absolute value. Pass ``None`` to reset it. :param with_ties: When ``True``, the WITH TIES option is used to return any additional rows that tie for the last place in the result set according to the ``ORDER BY`` clause. The ``ORDER BY`` may be mandatory in this case. Defaults to ``False`` :param percent: When ``True``, ``count`` represents the percentage of the total number of selected rows to return. Defaults to ``False`` :param \**dialect_kw: Additional dialect-specific keyword arguments may be accepted by dialects. .. versionadded:: 2.0.41 .. seealso:: :meth:`_sql.GenerativeSelect.limit` :meth:`_sql.GenerativeSelect.offset` N) with_tiespercent)_validate_dialect_kwargsrrrr)rcountrr dialect_kws rfetchzGenerativeSelect.fetchscd %%j1! =>B BD !; "&!=!=e!DD &"*D & rc2|j||_|S)a2Return 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. :param offset: an integer OFFSET parameter, or a SQL expression that provides an integer result. Pass ``None`` to reset it. .. seealso:: :meth:`_sql.GenerativeSelect.limit` :meth:`_sql.GenerativeSelect.fetch` )rr)rrs rrzGenerativeSelect.offsets,#::6B rrctjj}dx|_|_|j |j |j||\|_|_|S)aApply LIMIT / OFFSET to this statement based on a slice. The start and stop indices behave like the argument to Python's built-in :func:`range` function. This method provides an alternative to using ``LIMIT``/``OFFSET`` to get a slice of the query. For example, :: stmt = select(User).order_by(User.id).slice(1, 3) renders as .. sourcecode:: sql SELECT users.id AS users_id, users.name AS users_name FROM users ORDER BY users.id LIMIT ? OFFSET ? (2, 1) .. note:: The :meth:`_sql.GenerativeSelect.slice` method will replace any clause applied with :meth:`_sql.GenerativeSelect.fetch`. .. versionadded:: 1.4 Added the :meth:`_sql.GenerativeSelect.slice` method generalized from the ORM. .. seealso:: :meth:`_sql.GenerativeSelect.limit` :meth:`_sql.GenerativeSelect.offset` :meth:`_sql.GenerativeSelect.fetch` N)rXrrrr _make_slicerr)rstartstoprs rslicezGenerativeSelect.slices[Z>>**:>>T72:2F2F    3 3UD3 /D/ rc|s | d_S|tjur+xjtfd|f|zDz c_S)a Return a new selectable with the given list of ORDER BY criteria applied. e.g.:: stmt = select(table).order_by(table.c.id, table.c.name) Calling this method multiple times is equivalent to calling it once with all the clauses concatenated. All existing ORDER BY criteria may be cancelled by passing ``None`` by itself. New ORDER BY criteria may then be added by invoking :meth:`_orm.Query.order_by` again, e.g.:: # will erase all ORDER BY and ORDER BY new_col alone stmt = stmt.order_by(None).order_by(new_col) :param \*clauses: a series of :class:`_expression.ColumnElement` constructs which will be used to generate an ORDER BY clause. Alternatively, an individual entry may also be the string name of a label located elsewhere in the columns clause of the statement which will be matched and rendered in a backend-specific way based on context; see :ref:`tutorial_order_by_label` for background on string label matching in ORDER BY and GROUP BY expressions. .. seealso:: :ref:`tutorial_order_by` - in the :ref:`unified_tutorial` :ref:`tutorial_order_by_label` - in the :ref:`unified_tutorial` rc3jK|]*}tjtj|,ywr)N)rrr OrderByRolerSrrs rrUz,GenerativeSelect.order_by..A8,  %%vT,03)rr7NO_ARGrr_GenerativeSelect__firstclausess` rorder_byzGenerativeSelect.order_bys_R7?%'D " FMM )  " "e, 'j72 ,'  "  rc|s | d_S|tjur+xjtfd|f|zDz c_S)aReturn a new selectable with the given list of GROUP BY criterion applied. All existing GROUP BY settings can be suppressed by passing ``None``. 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. Alternatively, an individual entry may also be the string name of a label located elsewhere in the columns clause of the statement which will be matched and rendered in a backend-specific way based on context; see :ref:`tutorial_order_by_label` for background on string label matching in ORDER BY and GROUP BY expressions. .. seealso:: :ref:`tutorial_group_by_w_aggregates` - in the :ref:`unified_tutorial` :ref:`tutorial_order_by_label` - in the :ref:`unified_tutorial` rc3jK|]*}tjtj|,ywr)rrr GroupByRolers rrUz,GenerativeSelect.group_by..prr)rr7rrrs` rgroup_byzGenerativeSelect.group_byIs_H7?%'D " FMM )  " "e, 'j72 ,'  "  r)rr) rrrrrrrrrrrr\rfrg)rrIr)r$rarrrz"Optional[_TypeEngineArgument[int]]rr)rrrrrr)rzOptional[_OffsetLimitParam]rrrr)rrrrrzUnion[NoReturn, Optional[int]]r)rrHrrr)rrarr\)FF) rrarrrrrrrr\)rrarr\)rrrrrr\)rzMUnion[Literal[None, _NoArg.NO_ARG], _ColumnExpressionOrStrLabelArgument[Any]]rz(_ColumnExpressionOrStrLabelArgument[Any]rr\)&rrrrrrrrrrrrrrr4rrMrrrrrrrrrrrrrrrXrrr7rrrrrrrrws 9;5:8:5:26M/637N0726M/67;4;.2O+28K)-1!AA A + A  AA AAF!)V    #48  !  2    (47 1=@ %2%>A% '%,OO5       :  ;;; ;  ;  ;;z0T./000  000d MM 1 1 ; 1 11f MM , , ; , ,,rrdefaultcompound_selectc6eZdZej ddZy)CompoundSelectStatec|jj}d|_|jDcic]}|j|}}|||fScc}wr) statementrrrXri)rhacky_subqueryrXds r_label_resolve_dictz'CompoundSelectState._label_resolve_dict{sO002+0(-// 0!QUUAX 0 0!Qw 1sA NrzbTuple[Dict[str, ColumnElement[Any]], Dict[str, ColumnElement[Any]], Dict[str, ColumnElement[Any]]])rrrrXmemoized_propertyrrrrrrys$     rrc$eZdZdZdZdZdZdZdZy)_CompoundSelectKeywordUNIONz UNION ALLEXCEPTz EXCEPT ALL INTERSECTz INTERSECT ALLN) rrrr UNION_ALLr EXCEPT_ALLr INTERSECT_ALLrrrrrs EI FJI#Mrrc eZdZUdZdZdej fdejfdejfdejfdejfdej fd ej fd ejfd ejfg e jze jzejzej"zZd ed <ded<dZdZ d#dZe d$dZe d$dZe d$dZe d$dZe d$dZe d$dZd%dZ d& d'dZd(dZ d)dZ!d*dZ"dd d+dZ#d,fd Z$e%jLd-d!Z'e%jL d.d"Z(xZ)S)/CompoundSelectaXForms 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` rselectsrrrrrrrkeywordrSrzList[SelectBase]TFc||_|Dcgc]8}tjtj||j |:c}|_tj|ycc}w)Nr)r) rrrrCompoundElementRoler|rrr)rrrss rrzCompoundSelect.__init__sg       ))1D jj& '   !!$' s=A'c6ttjg|Sr)rrrrrs r _create_unionzCompoundSelect._create_unions4::EWEErc6ttjg|Sr)rrrrs r_create_union_allz CompoundSelect._create_union_all4>>IIIrc6ttjg|Sr)rrrrs r_create_exceptzCompoundSelect._create_excepts4;;FgFFrc6ttjg|Sr)rrrrs r_create_except_allz!CompoundSelect._create_except_alls4??J'JJrc6ttjg|Sr)rrrrs r_create_intersectz CompoundSelect._create_intersectrrc6ttjg|Sr)rrrrs r_create_intersect_allz$CompoundSelect._create_intersect_alls4BBMWMMrc<|jdjSNr)rrUrs rrUzCompoundSelect._scalar_types||A++--rNct|Sr)rnrzs rr|zCompoundSelect.self_groups't,,rcL|jD]}|j|syyNTF)rr)rrrs rrzCompoundSelect.is_derived_froms+ A  , rc|j|urF|j}|jdj|}|g|jddz|_|SNrr)rrrr)rrPselect_0s rrzCompoundSelect.set_label_stylesR   E )>>#D||A66u=H$: QR(88DL rc|jdj}||jdur(|j}|g|jddz|_|Sr)rr`r)r new_selects rr`z*CompoundSelect._ensure_disambiguated_names sR\\!_@@B T\\!_ ,>>#D&<$,,qr*::DL rrCc |jd}|jtur|j|j}t t |jDcgc]\}}d|dzi|fc}}D  cgc]9\} }|j D cgc]} t| r| j|  c} ;c} }} } |j||| ||ycc}}wcc} wcc} }} w)Nrweightrr{) rrrrzip enumeraterr% _annotater) rrrrrrDristmtddrXextra_col_iterators rrz2CompoundSelect._generate_fromclause_column_proxiess <<?   $7 7//0A0ABH!$-T\\#:!4A&-!   B"77(+KKO   & 44  #5#% 5 !  sC 5C #C.C C cht|||jD]}|j|yr)rrr)rrr/rKs rrz&CompoundSelect._refresh_for_new_columnGs1 '/ll 3F  * *6 2 3rc4|jdjSr)rrrs rrz$CompoundSelect._all_selected_columnsLs||A444rc4|jdjS)a\A :class:`_expression.ColumnCollection` representing the columns that this SELECT statement or similar construct returns in its result set, not including :class:`_sql.TextClause` constructs. For a :class:`_expression.CompoundSelect`, the :attr:`_expression.CompoundSelect.selected_columns` attribute returns the selected columns of the first SELECT statement contained within the series of statements within the set operation. .. seealso:: :attr:`_sql.Select.selected_columns` .. versionadded:: 1.4 r)rrBrs rrBzCompoundSelect.selected_columnsPs,||A///r)rrr(_SelectStatementForCompoundArgument[_TP])rrrCompoundSelect[_TP]rhr)r{rrrMrrgrirdrrrc)*rrrrrrTrr dp_plain_dictrr+rrsrr>"_dialect_kwargs_traverse_internalsr?_executable_traverse_internalsrrr@_auto_correlaterrrrrrrrrUr|rrr`rrrXrrrBrrs@rrrs('N)?? @ /@@ A 0AA B /@@ A $&7&E&E F "3"I"I J "3"I"I J  1 B B C )33 4  # H H I  - - .  : : ;  3 3 4/$O (' (; (F?F FF J?J JJ G?G GG K?K KK J?J JJ N?N NN .15--- -  " 3 3 @3  3 3 3 ! 3  3 j3  ""5#5 ""0 20#0rrr/ceZdZUdZerded<n GddeZer e ddZ ddZ eddZ e ddZ e dd Z e dd Ze dd Zdd Ze d ddZ d d dZ d!dZe d"dZed#dZ d$dZej0d d%dZej0d d&dZy )'r) from_clausesfromscolumns_plus_namesrr9default_select_compile_optionsceZdZgZy)*SelectState.default_select_compile_optionsN)rrr_cache_key_traversalrrrrr{s#% rcyrrrrs rget_plugin_classzSelectState.get_plugin_class!$rc ^||_|j|_|jD](}|j |j|j *|jr&|j |j|j |j ||_|jd|_ yr;) r _from_objr_memoized_select_entities _setup_joins _raw_columns _get_fromsrrr)rrcompilerrmemoized_entitiess rrzSelectState.__init__s #%//!*!D!D     !..0A0N0N    ! !   i44i6L6L M__Y/ "+"H"H"Nrctd)NzLThe default SELECT construct without plugins does not implement this method.r)rs r_plugin_not_implementedz#SelectState._plugin_not_implementeds! %  rc ~|jdDcgc]\}}}}}||j|dc}}}Scc}}}w)NF)rr#expr)rr#)rrrrr$s rget_column_descriptionsz#SelectState.get_column_descriptionssO66u=   '4GQ      s8c$|jyr)r,)rrfrom_statements rr1zSelectState.from_statements ##%rc|jtjjd|jDS)Nc34K|]}|jywrr2)rSr$s rrUz7SelectState.get_columns_clause_froms..s**1%%*s)_normalize_fromsrr from_iterabler'r s rget_columns_clause_fromsz$SelectState.get_columns_clause_fromss<## OO ) )*5>5K5K*   rcv|tu|tutt d dfd }|S)Ncjt|rytr t|sJs|j}|d}|Sr |jn |j}|-d}|vr|j |zSj ||S|vr r|jzS|jzSj ||S)N _no_label) r)rr% _proxy_keyr _anon_labelr_anon_tq_key_label_anon_key_label)rXcol_namerrrpars rgoz1SelectState._column_naming_convention..gosa (+++||<&D &51??1<rrr)rrrUrb)rrur@rrr?rs @@@@rrz%SelectState._column_naming_conventions[&)GG$44  '+! 4! #! ! ! F rc ix|_}|jtj|jtjj |j Dcgc]}|jc}tjj |jDcgc]}|jc}||Scc}wcc}w)N)check_statementambiguous_table_name_map) _ambiguous_table_name_mapr4rrrr5r'r3_where_criteria)rrrCr$s rr(zSelectState._get_fromssDFF&)A$$ OO!!--(1'='=# -- --(1'@'@# -- &%=#%   s B;CNc (t}g}|D]x}t|r#|j|urtjd|j |j rM|j||j|j z|r{ttjj|Dcgc]}t|jc}}|r|Dcgc] }||vs| }}jfd|D|Scc}wcc}w)a0given an iterable of things to select FROM, reduce them to what would actually render in the FROM clause of a SELECT. This does the job of checking for JOINs, tables, etc. that are in fact overlapping due to cloning, adaption, present in overlapping joins, etc. z-select() construct refers to itself as a FROMc3K|]y}|jD]h}t|r[|jrO|jvrA|jt j t |j|jfj{ywr)r3r(r+rrEr.r)rSitemfrrCs rrUz/SelectState._normalize_froms..0s{ 0"00 0| '??(77 M277 0 0sA?B)rbr'r$rWInvalidRequestErrorrErCrrrrr5r1r() riterable_of_fromsrBrCseenrrHrtoremoves ` rr4zSelectState._normalize_fromss !$"$% .D4 T\\_%D--C$$T%5%56 T" D,,- . --??'3(// 0!& 0  /C @s/D  D&Dc x|j}|jjrC|jj}|r+|Dcgc] }|tt||xsd|vr|"}}|jj?|Dcgc]4}|t t||xsd|jjvr|6}}|jj rZ|rXt|dkDrJ|Dcgc]}|t||vr|}}t|s"tjd|jz|Scc}wcc}wcc}w)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. rrzSelect statement '%r' returned no FROM clauses due to auto-correlation; specify correlate() to control correlation manually.) rr _correlater._correlate_exceptr-rrrWrJ)rexplicit_correlate_fromsimplicit_correlate_fromsr to_correlaters r_get_display_fromszSelectState._get_display_froms@sl  >> $ $>>44L# /,!#;#Ar%    >> + + 7 )(7=2NN44  E  NN * *(E Q+E3KLMEu:-- #'.. 1 _  "s%D-9D2%D7c|jjDcic])}|jr|jxs |j|+}}t |j Dcic]}|jr |j|}}|j}|jD]\}}|j|||||fScc}wcc}wr) rr_allow_label_resolverrir8rcopyitems setdefault)rrX with_cols only_froms only_colsrirs r"_memoized_attr__label_resolve_dictz.SelectState._memoized_attr__label_resolve_dicts^^994 %% KK 155! #4 4 'tzz25 %% EE1H5 5 4=>>3C $**, -JC  e , -*i//4 5 s .C Cc@|jr|jddSy)Nr)r&)rr s rdetermine_last_joined_entityz(SelectState.determine_last_joined_entitys&   $$R(+ +rcRt|jDcgc]}|c}Scc}wr)r8r')rrrXs rall_selected_columnsz SelectState.all_selected_columnss!,Y-C-CDEaEEEs $c |D]\}}}}tr|t|tsJ|d}|d}||j||||\}} n|j |} tr&t|t sJ|t|tsJ| I|j | } |j d| t| ||||fz|j | dzdz|_|J|j t|||||fz|_y)Nr5r6rr)rrrK"_join_determine_implicit_left_side_join_place_explicit_left_siderrr2) rargs raw_columnsr3r4rflagsr5r6replace_from_obj_index left_clauses rr&zSelectState._setup_joinss^ -14  (E8T5'%h >>>I&G=D|;;uh* ,0+N+N,'!%444'%h >>>%1#//0FG %%&='=>'!$$+!%  ''(>(B(DE F!'''$($5$5uhdK9%!e4 rrc tjj}d}|j}|r,|j |||}t |dk(r|d}||}ni} |j } tjtjj|D cgc]} | jc} tjj| jD cgc]} | jc} D]} d| | < t| j} |j | ||}t |dk(r| |d}t |dkDrtjd|stjd|d||fScc} wcc} w)zWhen join conditions don't express the left side explicitly, determine if an existing FROM or entity in this query can serve as the left hand side. NrrraCan't determine which FROM clause to join from, there are multiple FROMS which can join to this entity. Please use the .select_from() method to establish an explicit left side, as well as providing an explicit ON clause if not present already to help resolve the ambiguity.zDon't know how to join to z. Please use the .select_from() method to establish an explicit left side, as well as providing an explicit ON clause if not present already to help resolve the ambiguity.)rXrrrfind_left_clause_to_join_fromrrrrr5r3rErkeysrWrJ)rrgrr3r4rririndexes potentialrr$ from_clause all_clausess rrdz.SelectState._join_determine_implicit_left_sides>>**04(( !)!G!GeX"G7|q )0&#$:;II(--:EFwW**F--(1'@'@# --  , *, +& ,y~~/0K<<UHG7|q "71:. w>**DNNAACD !)!M!M!!4"GG w> 2'+}}':':'<=tq!ad= **>4@>s A<c|js |jrit}|j|_|j|_|j|_|xj|fz c_g|_dx|_|_yyr')r&rrr'r%)r select_stmtrs r_generate_for_statementz/_MemoizedSelectEntities._generate_for_statementsv  # #{'@'@*,D + 8 8D  + 8 8D !,!:!:D   1 1dW < 1')K $CE EK ${'@(ArN)rrrr\)rrrr)rrrrrrTrdp_setup_join_tupledp_executable_optionsrrrX EMPTY_DICT _annotationsr,rrrrrrrms(0N *@@A *>>? +AAB3/ *)--00//??L F FrrcX eZdZUdZdZdZded<dZded<ded <d Zd ed <dZ d ed<dZ ded<dZ ded<dZ d ed<dZ d ed<dZded<dZdZej$Zded<d ej*fdej,fdej*fdej.fdej.fdej.fdej.fdej0fdej.fdej.fdej2fdej2fdej2fdej4fd ej2fd ej6fdej.fd!ej8fgej<zej@ze!jDze#jHze%jLze'jPze)jTzZ+d"ed#<e+dejXfgzZ-d$ed%<d&ed'<e.djd(Z/ dkd)Z0dld*Z1dmd+Z2 dnd,Z3e4r'e5 dod-Z6e5 dpd.Z6e5dqd/Z6dqd0Z6drd1Z7e8dsd2Z9 dtd3Z:e; dud d d4 dvd5Z< dud d6 dwd7Z=e; dud d d4 dxd8Z> dud d6 dyd9Z?dzd:Z@e8eAjd;d<dzd=ZCe8d{d>ZDe8d|d?ZEd}d@ZFeGf d~fdA ZHdfdB ZIe; ddCZJ ddDZKeAjdEdFddGZLeAjdHdddIZNe5dJdK ddLZOe5dJdK ddMZOe5dJdK ddNZOe5dJdK ddOZOe5dJdK ddPZOe5dJdK ddQZOe5dJdK ddRZOe5dJdK ddSZOe5d dK ddTZOe;d dK ddUZOe8ddVZPePZQe;ddWZRe;ddXZSe;ddYZTe;ddZZUe; dd[ZVe; dd\ZWeX dd]ZYeXd|d^ZZdd_Z[dd` ddaZ\ddbZ] du ddcZ^ dddZ_ ddeZ` ddfZa ddgZb ddhZc ddiZdxZeS)r.aRepresents a ``SELECT`` statement. The :class:`_sql.Select` object is normally constructed using the :func:`_sql.select` function. See that function for details. .. seealso:: :func:`_sql.select` :ref:`tutorial_selecting_data` - in the 2.0 tutorial r/rrzr&zTuple[TODO_Any, ...]r%r{r'Fr _distinctr _distinct_onrrONz Optional[Tuple[FromClause, ...]]rPrE_having_criteriar$Tr9_compile_optionsrrrrrrrrrSrrtrru_compile_state_factoryc ntjt}|jj||S)zCreate a :class:`.Select` using raw ``__new__`` with no coercions. Used internally to build up :class:`.Select` constructs with pre-established state. )r.r&r]r)rrr s r_create_raw_selectzSelect._create_raw_selects)~~f% R  rc|Dcgc](}tjtj||*c}|_t j |ycc}w)zConstruct a new :class:`_expression.Select`. The public constructor for :class:`_expression.Select` is the :func:`_sql.select` function. r)N)rrrrr'rr)rentitiesrents rrzSelect.__init__sN     ''D   !!$'  s-Ac|jstS|jd}t|j}|djSr)r'rRrrnr#)rrrs rrUzSelect._scalar_types>  O  #D))*Aw||rc |j|S)z3A synonym for the :meth:`_sql.Select.where` method.where)rcriterias rfilterz Select.filterstzz8$$rc|jr+tj|j}||}||S|jr|jdS|j dSr)r&rr!r`r$r')rmeth_last_joined_entitys r_filter_by_zerozSelect._filter_by_zero"sh   //** #'t* ".** >>>>!$ $  ##rcyrrrs rrzSelect.scalar_subquery6r"rcyrrrs rrzSelect.scalar_subquery;s),rcyrrrs rrzSelect.scalar_subquery@s8;rcyrrrs rrzSelect.scalar_subqueryCrsrc |j}|jDcgc]\}}t|||k(}}}|j|Scc}}w)zWapply the given filtering criterion as a WHERE clause to this select. )rrXr/r)rkwargs from_entityrirrs r filter_byzSelect.filter_byEs_ **, %lln U "+s 3u <  t{{G$$  sAcPtj|j}||S)a5Return a :term:`plugin-enabled` 'column descriptions' structure referring to the columns which are SELECTed by this statement. This attribute is generally useful when using the ORM, as an extended structure which includes information about mapped entities is returned. The section :ref:`queryguide_inspection` contains more background. For a Core-only statement, the structure returned by this accessor is derived from the same objects that are returned by the :attr:`.Select.selected_columns` accessor, formatted as a list of dictionaries which contain the keys ``name``, ``type`` and ``expr``, which indicate the column expressions to be selected:: >>> stmt = select(user_table) >>> stmt.column_descriptions [ { 'name': 'id', 'type': Integer(), 'expr': Column('id', Integer(), ...)}, { 'name': 'name', 'type': String(length=30), 'expr': Column('name', String(length=30), ...)} ] .. versionchanged:: 1.4.33 The :attr:`.Select.column_descriptions` attribute returns a structure for a Core-only set of entities, not just ORM-only entities. .. seealso:: :attr:`.UpdateBase.entity_description` - entity information for an :func:`.insert`, :func:`.update`, or :func:`.delete` :ref:`queryguide_inspection` - ORM background )rr!r/rrs rcolumn_descriptionszSelect.column_descriptionsRs%R++D1IIDzrcRtj|j}|||S)aApply the columns which this :class:`.Select` would select onto another statement. This operation is :term:`plugin-specific` and will raise a not supported exception if this :class:`_sql.Select` does not select from plugin-enabled entities. The statement is typically either a :func:`_expression.text` or :func:`_expression.select` construct, and should return the set of columns appropriate to the entities represented by this :class:`.Select`. .. seealso:: :ref:`orm_queryguide_selecting_text` - usage examples in the ORM Querying Guide )rr!r1)rrrs rr1zSelect.from_statement~s',++D1@@D)$$rrctjtj||}|%tjtj|}nd}|xj ||d||dffz c_|S)a Create a SQL JOIN against this :class:`_expression.Select` object's criterion and apply generatively, returning the newly resulting :class:`_expression.Select`. E.g.:: stmt = select(user_table).join( address_table, user_table.c.id == address_table.c.user_id ) The above statement generates SQL similar to: .. sourcecode:: sql SELECT user.id, user.name FROM user JOIN address ON user.id = address.user_id .. versionchanged:: 1.4 :meth:`_expression.Select.join` now creates a :class:`_sql.Join` object between a :class:`_sql.FromClause` source that is within the FROM clause of the existing SELECT, and a given target :class:`_sql.FromClause`, and then adds this :class:`_sql.Join` to the FROM clause of the newly generated SELECT statement. This is completely reworked from the behavior in 1.3, which would instead create a subquery of the entire :class:`_expression.Select` and then join that subquery to the target. This is a **backwards incompatible change** as the previous behavior was mostly useless, producing an unnamed subquery rejected by most databases in any case. The new behavior is modeled after that of the very successful :meth:`_orm.Query.join` method in the ORM, in order to support the functionality of :class:`_orm.Query` being available by using a :class:`_sql.Select` object with an :class:`_orm.Session`. See the notes for this change at :ref:`change_select_join`. :param target: target table to join towards :param onclause: ON clause of the join. If omitted, an ON clause is generated automatically based on the :class:`_schema.ForeignKey` linkages between the two tables, if one can be unambiguously determined, otherwise an error is raised. :param isouter: if True, generate LEFT OUTER join. Same as :meth:`_expression.Select.outerjoin`. :param full: if True, generate FULL OUTER join. .. seealso:: :ref:`tutorial_select_join` - in the :doc:`/tutorial/index` :ref:`orm_queryguide_joins` - in the :ref:`queryguide_toplevel` :meth:`_expression.Select.join_from` :meth:`_expression.Select.outerjoin` r)Nr)rrrJoinTargetRolerr&)rtargetr4r5r6 join_targetonclause_elements rr7z Select.joins|P &&  &   (//0B0BHM #   #T2     r)r6c.|j|||d|S)aCreate a SQL LEFT OUTER JOIN against this :class:`_expression.Select` object's criterion and apply generatively, returning the newly resulting :class:`_expression.Select`. Usage is the same as that of :meth:`_selectable.Select.join_from`. Tr4r5r6) join_from)rfrom_rr4r6s routerjoin_fromzSelect.outerjoin_froms%~~ 6Hd  rc*tjtj||}tjtj||}|%tjtj |}nd}|xj |||||dffz c_|S)aCreate a SQL JOIN against this :class:`_expression.Select` object's criterion and apply generatively, returning the newly resulting :class:`_expression.Select`. E.g.:: stmt = select(user_table, address_table).join_from( user_table, address_table, user_table.c.id == address_table.c.user_id ) The above statement generates SQL similar to: .. sourcecode:: sql SELECT user.id, user.name, address.id, address.email, address.user_id FROM user JOIN address ON user.id = address.user_id .. versionadded:: 1.4 :param from\_: the left side of the join, will be rendered in the FROM clause and is roughly equivalent to using the :meth:`.Select.select_from` method. :param target: target table to join towards :param onclause: ON clause of the join. :param isouter: if True, generate LEFT OUTER join. Same as :meth:`_expression.Select.outerjoin`. :param full: if True, generate FULL OUTER join. .. seealso:: :ref:`tutorial_select_join` - in the :doc:`/tutorial/index` :ref:`orm_queryguide_joins` - in the :ref:`queryguide_toplevel` :meth:`_expression.Select.join` r)Nr)rrrr!rrr&)rrrr4r5r6rrs rrzSelect.join_fromsr   %t  &&  &   (//0B0BHM #   #T2     rc,|j||d|S)aCreate a left outer join. Parameters are the same as that of :meth:`_expression.Select.join`. .. versionchanged:: 1.4 :meth:`_expression.Select.outerjoin` now creates a :class:`_sql.Join` object between a :class:`_sql.FromClause` source that is within the FROM clause of the existing SELECT, and a given target :class:`_sql.FromClause`, and then adds this :class:`_sql.Join` to the FROM clause of the newly generated SELECT statement. This is completely reworked from the behavior in 1.3, which would instead create a subquery of the entire :class:`_expression.Select` and then join that subquery to the target. This is a **backwards incompatible change** as the previous behavior was mostly useless, producing an unnamed subquery rejected by most databases in any case. The new behavior is modeled after that of the very successful :meth:`_orm.Query.join` method in the ORM, in order to support the functionality of :class:`_orm.Query` being available by using a :class:`_sql.Select` object with an :class:`_orm.Session`. See the notes for this change at :ref:`change_select_join`. .. seealso:: :ref:`tutorial_select_join` - in the :doc:`/tutorial/index` :ref:`orm_queryguide_joins` - in the :ref:`queryguide_toplevel` :meth:`_expression.Select.join` Tr)r7)rrr4r6s rr9zSelect.outerjoinRsRyy(DtyLLrcb|j}|j||jS)aGCompute the final displayed list of :class:`_expression.FromClause` elements. This method will run through the full computation required to determine what FROM elements will be displayed in the resulting SELECT statement, including shadowing individual tables with JOIN objects, as well as full computation for ORM use cases including eager loading clauses. For ORM use, this accessor returns the **post compilation** list of FROM objects; this collection will include elements such as eagerly loaded tables and joins. The objects will **not** be ORM enabled and not work as a replacement for the :meth:`_sql.Select.select_froms` collection; additionally, the method is not well performing for an ORM enabled statement as it will incur the full ORM construction process. To retrieve the FROM list that's implied by the "columns" collection passed to the :class:`_sql.Select` originally, use the :attr:`_sql.Select.columns_clause_froms` accessor. To select from an alternative set of columns while maintaining the FROM list, use the :meth:`_sql.Select.with_only_columns` method and pass the :paramref:`_sql.Select.with_only_columns.maintain_column_froms` parameter. .. versionadded:: 1.4.23 - the :meth:`_sql.Select.get_final_froms` method replaces the previous :attr:`_sql.Select.froms` accessor, which is deprecated. .. seealso:: :attr:`_sql.Select.columns_clause_froms` )_default_compilerrrT)rr)s rget_final_fromszSelect.get_final_froms}s/J))+**4:MMOOrz1.4.23zqThe :attr:`_expression.Select.froms` attribute is moved to the :meth:`_expression.Select.get_final_froms` method.c"|jS)zYReturn the displayed list of :class:`_expression.FromClause` elements. )rrs rrz Select.fromss##%%rcJtj|j|S)aReturn the set of :class:`_expression.FromClause` objects implied by the columns clause of this SELECT statement. .. versionadded:: 1.4.23 .. seealso:: :attr:`_sql.Select.froms` - "final" FROM list taking the full statement into account :meth:`_sql.Select.with_only_columns` - makes use of this collection to set up a new FROM list )rr!r6rs rcolumns_clause_fromszSelect.columns_clause_fromss%"++D1JJ   rc,t|jS)a0An iterator of all :class:`_expression.ColumnElement` expressions which would be rendered into the columns clause of the resulting SELECT statement. This method is legacy as of 1.4 and is superseded by the :attr:`_expression.Select.exported_columns` collection. )iterrrs r inner_columnszSelect.inner_columnssD..//rcv|||jvry|jD]}|j|syyr)rCrsr)rrrs rrzSelect.is_derived_fromsF  !dj.D.D&D,,. A  , rc  ttjt|jt|j t|j Dcgc]}|d c}}|Dcic] }|||fi|c} |jDcgc] }||fi| }} jDchc]}t|ts|c}j|j|}t|t|z|_ d fd }||d<t |8d|dd||jycc}wcc}wcc}wcc}w)Nrct|tr.|jvr |jj|}|Syrrrs rrz'Select._copy_internals..replacerrr)r$)r omit_attrsrr)rbrrr3r'rEr&r$rrr2 differencerrrr) rrrrrrexisting_from_obj add_fromsrrrKs @rrzSelect._copy_internalssL OOt001t334D4E4EFDQFG  1>>1Qa2&> 6:^^DU1^^DD!((* B1jD.AQ B Z & Z) *  01E)4DD @  /  9 MeM"M   "S G?E Bs D9(D> E.EEc jtjt| dddi||j S)Nr)r$rOrPr)rrr get_childrenrs)rrrKs rrzSelect.get_childrens? G  K    ' ' )   rc |j|j|Dcgc](}tjtj ||*c}z|_|Scc}w)aReturn a new :func:`_expression.select` construct with the given entities appended to its columns clause. E.g.:: my_select = my_select.add_columns(table.c.new_column) The original expressions in the columns clause remain in place. To replace the original expressions with new ones, see the method :meth:`_expression.Select.with_only_columns`. :param \*entities: column, table, or other entity expressions to be added to the columns clause .. seealso:: :meth:`_expression.Select.with_only_columns` - replaces existing expressions rather than appending. :ref:`orm_queryguide_select_multiple_entities` - ORM-centric example r))rr'rrrr)rrrs r add_columnszSelect.add_columns"sa6   " --# 1    ''t 1    1 s-Actj|Dcgc](}tjtj ||*c}|_ycc}w)Nr))rXrrrrrr')rrrs r _set_entitieszSelect._set_entitiesGsG||H-     ''D   s-ArzThe :meth:`_expression.Select.column` method is deprecated and will be removed in a future release. Please use :meth:`_expression.Select.add_columns`c$|j|S)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. )rrs rrz Select.columnQs(''rrc|jtjjj|j g|j |jzd|i}|S)a"Return 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.set_label_style` 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_columnsrXrrrrrEr$)rrwocs rrzSelect.reduce_columnsgs_2%d$$ ^^ $ $ 3 3**&&7+  r.)maintain_column_fromscyrr)r _Select__ent0rs rrzSelect.with_only_columnss!rcyrr)rr _Select__ent1rs rrzSelect.with_only_columnss#&rcyrr)rrr _Select__ent2rs rrzSelect.with_only_columnss(+rcyrr)rrrr _Select__ent3rs rrzSelect.with_only_columnss-0rcyrr)rrrrr _Select__ent4rs rrzSelect.with_only_columnss25rcyrr)rrrrrr _Select__ent5rs rrzSelect.with_only_columnss7:rcyrr) rrrrrrr _Select__ent6rs rrzSelect.with_only_columnss}tjt j ||}|xj|fz c_@|S)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. r))rrErrrrWhereHavingRole)rr criterionwhere_criterias rrz Select.whereTsc$..666$ 6I1:1A1A%%y2N  ^$5 5  6  rc|D]>}tjtj||}|xj|fz c_@|S)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. r))rrrrr)rhavingrhaving_criterias rrz Select.havingesM  8I'..%%yO  ! !o%7 7 !  8  rcx|r/d_jtfd|Dz_Sd_S)a.Return a new :func:`_expression.select` construct which will apply DISTINCT to the SELECT statement overall. E.g.:: from sqlalchemy import select stmt = select(users_table.c.id, users_table.c.name).distinct() The above would produce an statement resembling: .. sourcecode:: sql SELECT DISTINCT user.id, user.name FROM user The method also accepts an ``*expr`` parameter which produces the PostgreSQL dialect-specific ``DISTINCT ON`` expression. Using this parameter on other backends which don't support this syntax will raise an error. :param \*expr: optional column expressions. When present, the PostgreSQL dialect will render a ``DISTINCT ON ()`` construct. A deprecation warning and/or :class:`_exc.CompileError` will be raised on other backends. .. deprecated:: 1.4 Using \*expr in other dialects is deprecated and will raise :class:`_exc.CompileError` in a future version. Tc3jK|]*}tjtj|,ywr)rrrByOfRole)rSers rrUz"Select.distinct..s/:  $OO:r)rrr)rr.s` rdistinctzSelect.distincttsK> !DN $ 1 1E::5!D   "DN rcVxjtfd|Dz c_S)aReturn 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) c3jK|]*}tjtj|,ywrrrrr!)rSrrs rrUz%Select.select_from..s8    $$j   r)r$r)rrs` rrzSelect.select_froms1F % $      rcd|_|r|ddvr,t|dkDrtjdd|_|S|jt d|Dz|_|S)aReturn 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: one or more :class:`.FromClause` or other FROM-compatible construct such as an ORM mapped entity to become part of the correlate collection; alternatively pass a single value ``None`` to remove all existing correlations. .. seealso:: :meth:`_expression.Select.correlate_except` :ref:`tutorial_scalar_subquery` FrFNrzKadditional FROM objects not accepted when passing None/False to correlate()rc3dK|](}tjtj|*ywrrrSrs rrUz#Select.correlate.. s(6>?   !5!5q96.0)rrrWrrOrr fromclausess rr zSelect.correlates}v %k!n =;!#''8!DO  #oo6CN61DO rcd|_|r|ddvr,t|dkDrtjdd|_|S|jxsdt d|Dz|_|S)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, or no arguments are 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:`tutorial_scalar_subquery` FrrrzRadditional FROM objects not accepted when passing None/False to correlate_except()rc3dK|](}tjtj|*ywrrrs rrUz*Select.correlate_except..;s*L>?   !5!5q9Lr)rrrWrrPrrs rcorrelate_exceptzSelect.correlate_exceptsB %k!n =;!#''?&(D "  '+&<&<&BeLCNLG&D " rctdtj|j}t |j Dcgc]}t |r |||fc}}|jScc}w)aA :class:`_expression.ColumnCollection` representing the columns that this SELECT statement or similar construct returns in its result set, not including :class:`_sql.TextClause` constructs. This collection differs from the :attr:`_expression.FromClause.columns` collection of a :class:`_expression.FromClause` in that the columns within this collection cannot be directly nested inside another SELECT statement; a subquery must be applied first which provides for the necessary parenthesization required by SQL. For a :func:`_expression.select` construct, the collection here is exactly what would be rendered inside the "SELECT" statement, and the :class:`_expression.ColumnElement` objects are directly present as they were given, e.g.:: col1 = column("q", Integer) col2 = column("p", Integer) stmt = select(col1, col2) Above, ``stmt.selected_columns`` would be a collection that contains the ``col1`` and ``col2`` objects directly. For a statement that is against a :class:`_schema.Table` or other :class:`_expression.FromClause`, the collection will use the :class:`_expression.ColumnElement` objects that are in the :attr:`_expression.FromClause.c` collection of the from element. A use case for the :attr:`_sql.Select.selected_columns` collection is to allow the existing columns to be referenced when adding additional criteria, e.g.:: def filter_on_id(my_select, id): return my_select.where(my_select.selected_columns["id"] == id) stmt = select(MyModel) # adds "WHERE id=:param" to the statement stmt = filter_on_id(stmt, 42) .. note:: The :attr:`_sql.Select.selected_columns` collection does not include expressions established in the columns clause using the :func:`_sql.text` construct; these are silently omitted from the collection. To use plain textual column expressions inside of a :class:`_sql.Select` construct, use the :func:`_sql.literal_column` construct. .. versionadded:: 1.4 zCallable[[Any], str])rrrrr:rr%r_)rconvrXccs rrBzSelect.selected_columnsAsu| "  1 1$2C2C D  9I33 $Q'a!  9 ~~  sA0cbtj|j}t||Sr)rr!rbrrs rrzSelect._all_selected_columnss'++D1FFDJrcT|jtur|jt}|Sr)rrrrrs rr`z"Select._ensure_disambiguated_namess'    0 0''(EFD rrCc|r_|}t|jd|D cgc].\\}}} } } } t| r| j|||d| ||0} } } } }}} nL|jdD cgc]*\}}} } } t| r| j|||d||,} } } }}} |j | ycc} } } } }}wcc} } } }}w)zYGenerate column proxies to place in the exported ``.c`` collection of a subquery.FT)rirname_is_truncatablecompound_select_colsrr)rirrrrN)rrr%rRrW)rrrrrrDr rrrrXr extra_colsproxs rrz*Select._generate_fromclause_column_proxiess "!7 *99%@*) +!+ %Q'1 !,(,)3 +!-DV77>''$Q' !,(, +!- D& ''-_8s 3C9/C c\|jxst|jjSr)rrrrrs r_needs_parens_for_groupingz!Select._needs_parens_for_groupings+,,   ! ! ) )1  rc\t|tr|js|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. )rrrrnrzs rr|zSelect.self_groups* w /335K*40 0rc.tj|g|S)aReturn a SQL ``UNION`` of this select() construct against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. :param \**kwargs: keyword arguments are forwarded to the constructor for the newly created :class:`_sql.CompoundSelect` object. )rrrFs rr z Select.unions"++D9599rc.tj|g|S)aReturn a SQL ``UNION ALL`` of this select() construct against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. :param \**kwargs: keyword arguments are forwarded to the constructor for the newly created :class:`_sql.CompoundSelect` object. )rrrFs rr}zSelect.union_all"//=u==rc.tj|g|S)a.Return a SQL ``EXCEPT`` of this select() construct against the given selectable provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. )rrrFs rexcept_zSelect.except_s,,T:E::rc.tj|g|S)a3Return a SQL ``EXCEPT ALL`` of this select() construct against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. )rrrFs r except_allzSelect.except_all&s00>>>rc.tj|g|S)aReturn a SQL ``INTERSECT`` of this select() construct against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. :param \**kwargs: keyword arguments are forwarded to the constructor for the newly created :class:`_sql.CompoundSelect` object. )rrrFs r intersectzSelect.intersect6rrc.tj|g|S)aReturn a SQL ``INTERSECT ALL`` of this select() construct against the given selectables provided as positional arguments. :param \*other: one or more elements with which to create a UNION. .. versionchanged:: 1.4.28 multiple elements are now accepted. :param \**kwargs: keyword arguments are forwarded to the constructor for the newly created :class:`_sql.CompoundSelect` object. )rrrFs r intersect_allzSelect.intersect_allIs"33DA5AAr)rrrr)r_ColumnsClauseArgument[Any]rrrh)r_ColumnExpressionArgument[bool]rr\)rzFUnion[FromClause, _JoinTargetProtocol, ColumnElement[Any], TextClause])rzSelect[Tuple[_MAYBE_ENTITY]]rr)rzSelect[Tuple[_NOT_ENTITY]]rzScalarSelect[_NOT_ENTITY]r)rrrr\)rr)rrwrrr) rr`r4rr5rr6rrr\) rr_rr`r4rr6rrr\) rr_rr`r4rr5rr6rrr\)rr`r4rr6rrr\)rzSequence[FromClause]rrrr)rrrzIterable[ClauseElement])rr$rr)rz%Iterable[_ColumnsClauseArgument[Any]]rr)rr$rr)T)rrrr)r _TCCA[_T0]rrrzSelect[Tuple[_T0]])rr&r _TCCA[_T1]rrrzSelect[Tuple[_T0, _T1]]) rr&rr'r _TCCA[_T2]rrrzSelect[Tuple[_T0, _T1, _T2]]) rr&rr'rr(r _TCCA[_T3]rrrz!Select[Tuple[_T0, _T1, _T2, _T3]])rr&rr'rr(rr)r _TCCA[_T4]rrrz&Select[Tuple[_T0, _T1, _T2, _T3, _T4]])rr&rr'rr(rr)rr*r _TCCA[_T5]rrrz+Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])rr&rr'rr(rr)rr*rr+r _TCCA[_T6]rrrz0Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])rr&rr'rr(rr)rr*rr+rr,rz _TCCA[_T7]rrrz5Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])rr$rrrrrr)rr)rr%rr\)rr%rr\)r.rrr\rr_rr\rz0Union[Literal[None, False], _FromClauseArgument]rr\rcrrdr)r{rrz*Union[SelectStatementGrouping[Self], Self])rGrrr)frrrrrr&rr%rrrOrPrErr$rrrrrrTrdp_memoized_select_entitiesdp_clauseelement_tuplerrrrrrsrrrr r rrr+rr?rr>rrdp_has_cache_keyrrrrrUrrrrrrrrr1r4r7rrr9rrXrrrrrr,rrrrrrrrr _whereclauserrrrr r rYrBrr`rrr|r r}rrr!r#rrs@rr.r.s  N35L056838--It35L05)+J&+:>7>68O387949(*I%*O22& .DD E+!== +AA B  1 H H I !2!I!I J "3"J"J K "3"J"J K .BB C ,CC D "3"J"J K /@@ A 0AA B /@@ A $&7&E&E F  1 B B C +66 7 .EE F .;; <+ .  - -/ .0  6 61 72  6 63 74  0 05 16 # H H7 I8  3 39 4:  : :; ;/B4G .??@J40.-  (4(DG("% $ $$  $. $  $  $  ,, , & ,  , ; ;; %))V%.% %215W  W#W.W  W  W WWz15    " $ .      & 15 K K"K$K. K  KK KK`15)M  )M#)M.)M  )M  )MV'PRT__ A &  &  ( 0 0+18#'8#8;8# 8#t "4" ""H =  T__  1 (  ( T./0LCF! !<@! !! '* &&& $ & ! &&'* +++ + $ + &++'*000 0  0 $0 +00'* 5 5 5 5  5  5 $ 5 0 5 5'* : : : :  :  : : $ : 5 : :'* ? ? ? ?  ?  ? ? ? $ ? : ? ?'* D D D D  D  D D D D $ D ? D D ',. $   ',M.M $M M  MM^  L   &&P((TFFF FFP-F- --^'I 2I 'I V' '  ?.?.@?. ?. 3 ?.! ?. ?.B 151-1 31&:>: :&>>> >&;>; ; ?>? ? >>> >&B>B Brr.c eZdZUdZdej fdej fgZded<gZ ded<dZ e sd Z dZ d ed<dd Zdd Zdd ZddZeddZeZeddZdddZddZe ddZe ddZy) r[aRepresent a scalar subquery. A :class:`_sql.ScalarSelect` is created by invoking the :meth:`_sql.SelectBase.scalar_subquery` method. The object then participates in other SQL expressions as a SQL column expression within the :class:`_sql.ColumnElement` hierarchy. .. seealso:: :meth:`_sql.SelectBase.scalar_subquery` :ref:`tutorial_scalar_subquery` - in the 2.0 tutorial r$r#rSrrr3TFrc^||_|j|_|j|_yr)r$rUr#_propagate_attrsrs rrzScalarSelect.__init__}s' ((* ' 8 8rc.t|j|Sr)rJr$)rattrs r __getattr__zScalarSelect.__getattr__st||T**rc4|j|jdS)Nr$r#r:rs rrzScalarSelect.__getstate__s<<;;rc,|d|_|d|_y)Nr$r#r:rs rrzScalarSelect.__setstate__sY' &M rc,tjd)NzcScalar Select expression has no columns; use this object directly within a column-level expression.)rWrJrs rrzScalarSelect.columnss%% 0  rcZtd|jj||_|S)zuApply a WHERE clause to the SELECT statement referred to by this :class:`_expression.ScalarSelect`. r)rr$r)rrs rrzScalarSelect.wheres& M4<<8>>tD  rNc|Srrrzs rr|zScalarSelect.self_groupr;rc|Srrrs rr>zScalarSelect._ungroupr;rcVtd|jj||_|S)aReturn a new :class:`_expression.ScalarSelect` which will correlate the given FROM clauses to that of an enclosing :class:`_expression.Select`. This method is mirrored from the :meth:`_sql.Select.correlate` method of the underlying :class:`_sql.Select`. The method applies the :meth:_sql.Select.correlate` method, then returns a new :class:`_sql.ScalarSelect` against that statement. .. versionadded:: 1.4 Previously, the :meth:`_sql.ScalarSelect.correlate` method was only available from :class:`_sql.Select`. :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.ScalarSelect.correlate_except` :ref:`tutorial_scalar_subquery` - in the 2.0 tutorial r)rr$r rs rr zScalarSelect.correlates.>CtM4<<8BB    rcVtd|jj||_|S)aReturn a new :class:`_expression.ScalarSelect` which will omit the given FROM clauses from the auto-correlation process. This method is mirrored from the :meth:`_sql.Select.correlate_except` method of the underlying :class:`_sql.Select`. The method applies the :meth:_sql.Select.correlate_except` method, then returns a new :class:`_sql.ScalarSelect` against that statement. .. versionadded:: 1.4 Previously, the :meth:`_sql.ScalarSelect.correlate_except` method was only available from :class:`_sql.Select`. :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.ScalarSelect.correlate` :ref:`tutorial_scalar_subquery` - in the 2.0 tutorial r)rr$r rs rr zScalarSelect.correlate_excepts/BJtM4<<8II    r)r$rrr)r7rrr)rr)rrrrrv)rr%rr\rrrir.)rrrrrTrr\rrr3r@r_is_implicitly_booleanrrr8rrrrrXr4rr|r>r r rrrr[r[]s" %667 "**+3/ ')M#( !&M 9 +<"   A!F! !!F#F# ##rr[ceZdZdZdZ d d dZejddZ ddZ ddZ ddZ dd Z dd Z dd Zy)rXzRepresent an ``EXISTS`` clause. See :func:`_sql.exists` for a description of usage. An ``EXISTS`` clause can also be constructed from a :func:`_sql.select` instance by calling :meth:`_sql.SelectBase.exists`. TNct|#ttdj}n^t|tr"|j}|j |_n,t|t r|}nt|j}tj||tjtjy)Nr)operatorr) r.rNrrrr5r[rPrrrYr BOOLEANTYPE)r_Exists__argumentrs rrzExists.__init__s  ~c*+;;=A  J /**,A!+!.Ns-G--{;rr,rLr$rrrs ` rr zExists.correlate@s* KKMMM ;  rcZ|j}|jfd|_|S)zApply correlation to the subquery noted by this :class:`_sql.Exists`. .. seealso:: :meth:`_sql.ScalarSelect.correlate_except` c"|jSr)r rPs rrz)Exists.correlate_except..`s4G44kBrrQrRs ` rr zExists.correlate_exceptRs* KKMMM B  rcZ|j}|jfd|_|S)aReturn a new :class:`_expression.Exists` construct, applying the given expression to the :meth:`_expression.Select.select_from` method of the select statement contained. .. note:: it is typically preferable to build a :class:`_sql.Select` statement first, including the desired WHERE clause, then use the :meth:`_sql.SelectBase.exists` method to produce an :class:`_sql.Exists` object at once. c"|jSr)r)r$rs rrz$Exists.select_from..rs2E'2E2Eu2MrrQ)rrrs ` rrzExists.select_fromds& KKMMM"MN rcZ|j}|jfd|_|S)aReturn a new :func:`_expression.exists` construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any. .. note:: it is typically preferable to build a :class:`_sql.Select` statement first, including the desired WHERE clause, then use the :meth:`_sql.SelectBase.exists` method to produce an :class:`_sql.Exists` object at once. c"|jSrr)r$rs rrzExists.where..s-'--2HrrQ)rrrs ` rrz Exists.whereus& KKMMM"HI rr)rGzKOptional[Union[_ColumnsClauseArgument[Any], SelectBase, ScalarSelect[Any]]]r)rJz$Callable[[Select[Any]], Select[Any]]rr)rzSelect[Tuple[bool]]r.r-)rr%rr\)rrrrrrrXrr3rLr/r r rrrrrrXrXsM     4 ""# 0  ,F $F $"rrXceZdZUdZdZeZdejfdejfge jze jzejzZded<dZdZdZ d ddZ d dd Ze dd Zej4dd Zdd Zdd Ze ddZdd ddZ ddZ!y) TextualSelectaFWrap 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:`_expression.TextualSelect` construct is produced via the :meth:`_expression.TextClause.columns` method - see that method for details. .. versionchanged:: 1.4 the :class:`_expression.TextualSelect` class was renamed from ``TextAsFrom``, to more correctly suit its role as a SELECT-oriented object and not a FROM clause. .. seealso:: :func:`_expression.text` :meth:`_expression.TextClause.columns` - primary creation interface. textual_selectr$ column_argsrSrTc |j||Dcgc]&}tjtj|(c}|ycc}wr)r'rrrLabeledColumnExprRole)rrr positionalrXs rrzTextualSelect.__init__sH !   !.s QUUAJ r)r:r\r_rs rrBzTextualSelect.selected_columnss+0  $ 0 0  +- rc|jSr)r\rs rrz#TextualSelect._all_selected_columnssrc|SrrrOs rrzTextualSelect.set_label_styler;rc|Srrrs rr`z)TextualSelect._ensure_disambiguated_namesr;rcH|jj|i||_|Sr)r$ bindparams)rbindsbind_as_valuess rrgzTextualSelect.bindparamss& /t||..HH  rNrCctrttsJ|r1|jfdt |j |Dy|jfd|j Dy)Nc3NK|]\}}|j|yw))rrrNrQ)rSrXrrrrs rrUzDTextualSelect._generate_fromclause_column_proxies.. s9 ,"Az  )3 +!-  ,s"%c3FK|]}|jywrOrQ)rSrXrrrs rrUzDTextualSelect._generate_fromclause_column_proxies..s2,    +!-,rV)rrrrWrr\)rrrrrrDs ` `` rrz1TextualSelect._generate_fromclause_column_proxiessn j(3 33 !  + + ,&)$$&<& ,   + +, )) , rc4|jdjSr)r\r#rs rrUzTextualSelect._scalar_type"s"'''rr)rr|rz$List[_ColumnExpressionArgument[Any]]r_rrr)rr|rzList[NamedColumn[Any]]r_rrr)rrr)rPrrrZ)rrZ)rhzBindParameter[Any]rirrr\) rrrrrr;rrrDrerr)rzUnion[TypeEngine[Any], Any])"rrrrrrrrTrrr+rrsrr?rrr _is_textualis_textrjrr'rYrBrXrrrr`r4rgrrUrrrrZrZs6&N#L):: ; -CC D  # H H  I  - -  .  3 3  4/KGI !   6     (! %%(% %  %' 7'6 "" # "  " ""@" " 3 "! " "H(rrZcFeZdZdfd Zej ddZxZS)AnnotatedFromClausec t|di||jddr7|j}|jj j ||_yy)Nind_cols_on_fromclauseFr)rrr_Annotated__elementrKrXfget)rreerKs rrz#AnnotatedFromClause._copy_internals+sL %"% 66*E 2))B\\^^((.DF 3rc2|j}|jS)aoproxy the .c collection of the underlying FromClause. Originally implemented in 2008 as a simple load of the .c collection when the annotated construct was created (see d3621ae961a), in modern SQLAlchemy versions this can be expensive for statements constructed with ORM aliases. So for #8796 SQLAlchemy 2.0 we instead proxy it, which works just as well. Two different use cases seem to require the collection either copied from the underlying one, or unique to this AnnotatedFromClause. See test_selectable->test_annotated_corresponding_column )rtrX)rrvs rrXzAnnotatedFromClause.c2s  % %tt r)rrrrr)rrrrrXrrXrrs@rrqrq*s"/ rrq)r __future__rrenumrrtypingrrrrrr r r r r rrrrrrrrrrrrrrrrrrr _typingr!r"r#r$r%r&r'r(r) annotationr*r+baser,r-r.r/r0r1r3r4r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrrErFrGrHrIrJrKrLrMrNrOrPrQsqltypesrRrSrTrUrWrXrY util.typingrZr[r\rr]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnro_TCCArprqrrrsrtr)rudmlrvrwrxryrzr{r|rir}r+r~rrrr_ColumnsClauseElementrrxrr|_OnClauseElement_ForUpdateOfArgument_SetupJoinsElementrrrr,rrrrrr rAnonymizedFromClauseRolerrrrrrrrr DMLTableRoler2rrr#rDrrKrr@rrmrrrrursrrrrrrr InElementRolerr/r DMLSelectRolerrrkrnr plugin_forrrrrsetattrr MemoizedSlotsrr HasCacheKeyHasCopyInternals Traversiblerr.r[rXrZ TextAsFromrqrrrrs #" +&( #!0$&'" &#""(!.&#'# "#)$$'%#,'%4!"2<,,)&$*<7<,,&.1%*,%$#",($,lM#,> LM# -./#> 8(8<)<<=.0CCD    -. 0  \cN5!CDE$ c*$U$%'')<U$p;J ;C,gclCK K \00f11h{{|D,//D,N):;|  o  \%$$i\~>4tCH~EFC=CLVU &*6GVr-65&& c8J-6`G(     G(T e:&e"nj'#,e"P}j*D$56 , 7  $T$S0_&68H8MS0n #-D NDIIt,-H-\&$$$l\&.\&~>7F :668L8L7FtsB SsBl-P ^]25FPfS_T "Sl](J 5z](@ 4)r