g dZddlmZddlZddlmZddlZddlmZddlZddl Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd l mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl m Z ddl!m"Z"ddl!m#Z#ddl$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,d&d'l!m-Z-d&d(l!m.Z.d&d)l!m/Z/d&d*l/m0Z0d&d+l/m1Z1d&d,l/m Z2d&d-l3m4Z4d&d.l3m5Z5d&d/l3m6Z6erdd0l!m7Z7dd1l!m8Z8dd2l!m9Z9dd3l:m;Z;dd4l:mZ>dd6l?m@Z@dd7l8mAZAdd8l8mBZBdd9l8mCZCdd:l8mDZDdd;l8mEZEddlHmIZIdd?lHmJZJdd@lKmLZLddAlKmMZMddBlKmNZNd&dClOmPZPd&dDlOmQZQd&dElRmSZSd&dFlRmTZTd&dGlRmUZUd&dHlRmVZVd&dIlRmWZWd&dJlRmXZXd&dKlRmYZYd&dLlRmZZZd&dMlRm[Z[d&dNlRm\Z\d&dOl-m]Z]esdZ7dZ8dZ9GdPdQeZ^e^jZ_GdRdSeZ`e`jZbedTe UZcedVe dWe fUZdeeeeefZfGdXdYeZgejdZZiGd[d\e4ZjGd]d^e4Zkdd_Zled`e UZmGdadbZnGdcddenZo ddeZp ddfZqedgdhUZrGdidhe2jhZsddjZtddkZudlZv ddmZw ddnZxddoZyddpZzGdqdreeee fZ{Gdsdteeee fZ|e/jdudvZ~GdwdxZGdydzZGd{d|e0ZGd}d~e0ZGddeZGddeZGddeZGddee%ZGdde(ZGdde"jZGdde-jZGdde)ZGddeZGddeZede deefeeZedddZeddUZGddeeZGddeeefZeddUZGddeeeefZGdde/j.eeefZGdde/j2dZ ddZe_f ddZy)z4Foundational utilities common to many sql modules. ) annotationsN)Enum zip_longest)Any)Callable)cast)Dict) FrozenSet)Generic)Iterable)Iterator)List)Mapping)MutableMapping) NamedTuple)NoReturn)Optional)overload)Sequence)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union)roles)visitors) HasCacheKey)MemoizedHasCacheKey)HasCopyInternals) ClauseVisitor)ExtendedInternalTraversal)ExternallyTraversible)InternalTraversal)event)exc)util) HasMemoized) hybridmethod)typing)Protocol)Self) TypeGuard) coercions)elements)type_api)DMLStrategyArgument)SynchronizeSessionArgument)_CLE) SQLCompiler) BindParameter) ClauseList) ColumnClause) ColumnElement) NamedColumn)SQLCoreOperations) TextClause)Column)DefaultGenerator)_JoinTargetElement)_SelectIterable) FromClause) Connection) CursorResult)_CoreMultiExecuteParams)_ExecuteOptions)_ImmutableExecuteOptions) CacheStats)Compiled)CompiledCacheType)CoreExecuteOptionsParameter)Dialect)IsolationLevel)SchemaTranslateMapType) dispatcherceZdZdZdZy)_NoArgrc d|jS)Nz_NoArg.)nameselfs D/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/base.py__repr__z_NoArg.__repr__ks $$N)__name__ __module__ __qualname__NO_ARGrXrYrWrRrRhs F%rYrRceZdZdZy) _NoneNamerN)rZr[r\ NONE_NAMEr^rYrWr`r`rs IHrYr`_T)bound_Fn.cPeZdZUded<ded<ded<ded<e d dZy) _DefaultDescriptionTuplerargzOptional[bool] is_scalar is_callable is_sentinelc|rZ|js|jsB|jr6t|j|j |j |jStddddSN)has_arg for_updaterjrfrgrhri)clsdefaults rW_from_column_defaultz-_DefaultDescriptionTuple._from_column_defaultse**w/B/B % !!####   *$dDA rYN)rpzOptional[DefaultGenerator]returnrf)rZr[r\__annotations__ classmethodrqr^rYrWrfrfs; H 0 !  rYrf_omit_from_statementsceZdZddZy)_EntityNamespacecyrlr^rVkeys rW __getattr__z_EntityNamespace.__getattr__ssrYN)rzstrrrSQLCoreOperations[Any])rZr[r\r{r^rYrWrwrwsBrYrwc2eZdZejddZy)_HasEntityNamespacecyrlr^rUs rWentity_namespacez$_HasEntityNamespace.entity_namespaces47rYN)rrrw)rZr[r\r*ro_non_memoized_propertyrr^rYrWrrs ""7#7rYrct|dS)Nr)hasattr)elements rW_is_has_entity_namespacers 7. //rY_SelfcDeZdZdZdZdZdZdZd dZdd d dZ y ) Immutablea%mark a ClauseElement as 'immutable' when expressions are cloned. "immutable" objects refers to the "mutability" of an object in the context of SQL DQL and DML generation. Such as, in DQL, one can compose a SELECT or subquery of varied forms, but one cannot modify the structure of a specific table or column within DQL. :class:`.Immutable` is mostly intended to follow this concept, and as such the primary "immutable" objects are :class:`.ColumnClause`, :class:`.Column`, :class:`.TableClause`, :class:`.Table`. r^TctdNz(Immutable objects do not support copyingNotImplementedErrorrV optionaldictkwargss rW unique_paramszImmutable.unique_params!"LMMrYctdrrrs rWparamszImmutable.paramsrrYc |Srlr^rVkws rW_clonezImmutable._clones rY) omit_attrsc yrlr^)rVrrs rW_copy_internalszImmutable._copy_internalss rYN)rVrrrrrr)rz Iterable[str]rrrrNone) rZr[r\__doc__ __slots__ _is_immutablerrrrr^rYrWrrsF IMNN.0 * 7:  rYrc^eZdZUdZdZded<ddZejd dZ e dZ y) SingletonConstantz.Represent SQL constants like NULL, TRUE, FALSET _singletonc6tt|jSrl)r rbr)rorgrs rW__new__zSingletonConstant.__new__sB''rYctrlrrUs rW proxy_setzSingletonConstant.proxy_set !##rYc~tj|}|jt|g|_||_yrl)objectr__init__ frozensetrr)roobjs rW_create_singletonz#SingletonConstant._create_singletons0nnS! "3%( rYN)rorbrgrrrrrrb)rrzFrozenSet[ColumnElement[Any]]) rZr[r\r_is_singleton_constantrsrr*non_memoized_propertyrrtrr^rYrWrrsD8!!!( $ $  rYrcztjj|Dcgc]}|jc}Scc}wrl) itertoolschain from_iterable _from_objects)r2rs rWrrs6 ?? ( (.67h7  h7 78cztjj|Dcgc]}|jc}Scc}w)zXexpand tables into individual columns in the given list of column expressions. )rrr_select_iterable)r2cs rW_select_iterablesrs6 ?? ( (%-.X  X. .r_SelfGenerativeType_GenerativeTypeceZdZddZy)rcyrlr^rUs rW _generatez_GenerativeType._generatesrYNrrr/)rZr[r\rr^rYrWrrs$rYcftj dd}||}||_|S)znon-caching _generative() decorator. This is basically the legacy decorator that copies the object and runs a method on the new copy. cT|j}||g|i|}||usJd|S)zMark a method as generative.z#generative methods must return self)r)fnrVargsrxs rW _generativez _generative.._generatives; ~~ t !d !b !Dy???y rY) rrdrVrrrrrrrr)r* decoratornon_generative)rr decorateds rWrr s[ ^^ *36>A BI!I rYc |jdi|jdi}|Dcgc]*}|tj||j|df,c}tj fd}|Scc}w)Nmsgsdefaultsc |d}|dd}D]R\}}}|||us j|d|jd|jd}tj|||g|i|S)NrrzMethod z$() has already been invoked on this z construct)getrZ __class__r)InvalidRequestError) rrrrVrTgetterdefault_msggettersrs rWcheckz!_exclusive_against..check+sAwABx&- "D&(d|8+hh{{DNN4 --c22'.$$$$$rY)popoperator attrgetterrr*r)namesrrrTrrrs @@rW_exclusive_againstr!s 66&" Dvvj"%HD x""4((,,tT*BCG  ^^ % % L+s/A8c &|jdi|SNr^)r)rrs rWrr>s 7>> B rYc`tj|Dcgc]}|jc}Scc}w)z\expand the given set of ClauseElements to be the set of all 'cloned' predecessors. )rr _cloned_setr2rs rW_expand_clonedrBs) ??H=HqQ]]H= >>=s+c#lK|D]+}|j|j}|j|-ywrl) _is_clone_ofrs rW _de_clonerMs6nn(Ann(s*44ctt|jt|}|Dchc] }|j|js|"c}Scc}w)zreturn the intersection of sets a and b, counting any overlap between 'cloned' predecessors. The returned set is in terms of the entities present within 'a'. setr intersectionrab all_overlapelems rW_cloned_intersectionrVsNnQ'(55nQ6GHK MQT+":":4;K;K"LDQ MM M AActt|jt|}|Dchc] }|j|jr|"c}Scc}wrlrrs rW_cloned_differencerasUnQ'(55nQ6GHK +":":4;K;K"L  rc:eZdZdZdZdZdZdZdZdZ dZ y ) _DialectArgViewzaA dictionary view of dialect-level arguments in the form _. c||_yrl)r)rVrs rWrz_DialectArgView.__init__ns rYcp |jdd\}}||fS#t$r}t||d}~wwxYw)N_r)split ValueErrorKeyError)rVrzdialect value_keyerrs rW_keyz_DialectArgView._keyqsG &!$3!2 GYI% % )3-S ( )s 5 05c|j|\}} |jj|}||S#tj$r}t ||d}~wwxYwrl)rrdialect_optionsr)NoSuchModuleErrorr)rVrzrroptrs rW __getitem__z_DialectArgView.__getitem__ys]!YYs^ "((**73Cy> !$$ )3-S ( )s4A AAc |j|\}}||jj||<y#t$r}t j d|d}~wwxYw)Nz0Keys must be of the form _)rrrrr) ArgumentError)rVrzvaluerrrs rW __setitem__z_DialectArgView.__setitem__sa A!%3 GY z*_DialectArgView.__len__..s# 9 "" #9s!)sumrrvaluesrUs rW__len__z_DialectArgView.__len__s/ 00779   rYcBfdjjDS)Nc3|K|]3}jj|jD] }|d| 5yw)rN)rrr )r  dialect_name value_namerVs rWr z+_DialectArgView.__iter__..sI 8 "hh66m $Z 0 1 8s9<)rrrUs`rW__iter__z_DialectArgView.__iter__s $ 8 8  rYN) rZr[r\rrrrrrrrr^rYrWrrhs+ &"A9  rYrc4eZdZdZdZdZdZdZdZdZ y) _DialectArgDictzA dictionary view of dialect-level arguments for a specific dialect. Maintains a separate collection of user-specified arguments and dialect-specified default arguments. c i|_i|_yrlr  _defaultsrUs rWrz_DialectArgDict.__init__srYcptt|jj|jSrl)r rr unionrrUs rWrz_DialectArgDict.__len__s'3t))*00@AArYcptt|jj|jSrl)iterrr rrrUs rWrz_DialectArgDict.__iter__s'C**+11$..ABBrYcZ||jvr|j|S|j|Srlrrys rWrz_DialectArgDict.__getitem__s0 $$$ $%%c* *>>#& &rYc"||j|<yrlr rVrzrs rWrz_DialectArgDict.__setitem__s"'3rYc|j|=yrlr rys rWrz_DialectArgDict.__delitem__s   s #rYN) rZr[r\rrrrrrrr^rYrWrrs'BC' ($rYrzsqlalchemy.dialectsctjjjj |}|j yt |j Srl)r* preloadeddialectsregistryloadconstruct_argumentsdict)r dialect_clss rW_kw_reg_for_dialectr+sB..))2277 EK&&.  // 00rYceZdZdZdZdej fgZedZ e jdZ e dZe jeZdZe jdZd d Zy ) DialectKWArgsa9Establish the ability for a class to have dialect-specific arguments with defaults and constructor validation. The :class:`.DialectKWArgs` interacts with the :attr:`.DefaultDialect.construct_arguments` present on a dialect. .. seealso:: :attr:`.DefaultDialect.construct_arguments` r^rctj|}|tjd|z||vri||<||||<y)a_Add a new kind of dialect-specific keyword argument for this class. E.g.:: Index.argument_for("mydialect", "length", None) some_index = Index("a", "b", mydialect_length=5) The :meth:`.DialectKWArgs.argument_for` method is a per-argument way adding extra arguments to the :attr:`.DefaultDialect.construct_arguments` dictionary. This dictionary provides a list of argument names accepted by various schema-level constructs on behalf of a dialect. New dialects should typically specify this dictionary all at once as a data member of the dialect class. The use case for ad-hoc addition of argument names is typically for end-user code that is also using a custom compilation scheme which consumes the additional arguments. :param dialect_name: name of a dialect. The dialect must be locatable, else a :class:`.NoSuchModuleError` is raised. The dialect must also include an existing :attr:`.DefaultDialect.construct_arguments` collection, indicating that it participates in the keyword-argument validation and default system, else :class:`.ArgumentError` is raised. If the dialect does not include this collection, then any keyword argument can be specified on behalf of this dialect already. All dialects packaged within SQLAlchemy include this collection, however for third party dialects, support may vary. :param argument_name: name of the parameter. :param default: default value of the parameter. NzRDialect '%s' does have keyword-argument validation and defaults enabled configured)r- _kw_registryr)r)ror argument_namerpconstruct_arg_dictionarys rW argument_forzDialectKWArgs.argument_forscL$1#=#=l#K # +##=?KL  . .,. $S )7> %m4rYct|S)aA collection of keyword arguments specified as dialect-specific options to this construct. The arguments are present here in their original ``_`` format. Only arguments that were actually passed are included; unlike the :attr:`.DialectKWArgs.dialect_options` collection, which contains all options known by this dialect including defaults. The collection is also writable; keys are accepted of the form ``_`` where the value will be assembled into the list of options. .. seealso:: :attr:`.DialectKWArgs.dialect_options` - nested dictionary form )rrUs rWdialect_kwargszDialectKWArgs.dialect_kwargs s&t$$rYc|jS)z4A synonym for :attr:`.DialectKWArgs.dialect_kwargs`.)r4rUs rWrzDialectKWArgs.kwargs!s"""rYctj|}t}||jj ddi|St |j jD]%}||vs|jj ||'|S)N*)r-r/rrupdatereversedr__mro__)rVrr1dros rW_kw_reg_for_dialect_clsz%DialectKWArgs._kw_reg_for_dialect_cls(s#0#=#=l#K   # + KK  T{ +   6 6722KK&&'?'DE8rYcftjtj|jS)aA collection of keyword arguments specified as dialect-specific options to this construct. This is a two-level nested registry, keyed to ```` and ````. For example, the ``postgresql_where`` argument would be locatable as:: arg = my_object.dialect_options["postgresql"]["where"] .. versionadded:: 0.9.2 .. seealso:: :attr:`.DialectKWArgs.dialect_kwargs` - flat dictionary form )r* PopulateDictportable_instancemethodr<rUs rWrzDialectKWArgs.dialect_options4s+&   ( ()E)E F  rYc |sy|D]}tjd|}|std|z|jdd\}} |j|}d|vr,||vr(t j d|d|d|j||||<y#t j$rgtjd |d |tx|j|<}|jjddi|||j|<YwxYw) Nz ^(.+?)_(.+)$zGAdditional arguments should be named _, got '%s'rr'r7z Argument z is not accepted by dialect z on behalf of zCan't validate argument z,; can't locate any SQLAlchemy dialect named )rematch TypeErrorgrouprr)rrrr*warnrrr8r )rVrkmrarg_namer1r;s rW_validate_dialect_kwargsz&DialectKWArgs._validate_dialect_kwargsKs, A+A?ABC&'WWQ] "L( C+/+?+? +M(77 (@@++lDNN< :@,X6?(( 6 ,( :I9JJ$$\2Q ""C;/,21I) 6sBA6D D N)rDict[str, Any]rrr)rZr[r\rrr&dp_dialect_options"_dialect_kwargs_traverse_internalsrtr2r*memoized_propertyr4propertyrr>r+r/r<rrIr^rYrWr-r-s I -@@A*&-?-?^ %%(##%4$$%89L    ,%CrYr-ceZdZUdZdZiZded<ded<e d dZdZ e dd Z e dd Z e dd Z y ) CompileStateaProduces additional object state necessary for a statement to be compiled. the :class:`.CompileState` class is at the base of classes that assemble state for a particular statement object that is then used by the compiler. This process is essentially an extension of the process that the SQLCompiler.visit_XYZ() method takes, however there is an emphasis on converting raw user intent into more organized structures rather than producing string output. The top-level :class:`.CompileState` for the statement being executed is also accessible when the execution context works with invoking the statement and collecting results. The production of :class:`.CompileState` is specific to the compiler, such as within the :meth:`.SQLCompiler.visit_insert`, :meth:`.SQLCompiler.visit_select` etc. methods. These methods are also responsible for associating the :class:`.CompileState` with the :class:`.SQLCompiler` itself, if the statement is the "toplevel" statement, i.e. the outermost SQL statement that's actually being executed. There can be other :class:`.CompileState` objects that are not the toplevel, such as when a SELECT subquery or CTE-nested INSERT/UPDATE/DELETE is generated. .. versionadded:: 1.4 ) statement_ambiguous_table_name_mapz)Dict[Tuple[str, str], Type[CompileState]]pluginsz Optional[_AmbiguousTableNameMap]rRc X|jrb|jjdd}|jj||jfd}|7|jd|jf}n|jd|jf}||ur |||fi|S|j||fi|SNcompile_state_pluginrp)_propagate_attrsrrS_effective_plugin_targetcreate_for_statement)rorQcompilerr plugin_nameklasss rWrYz!CompileState.create_for_statements  % %#4488& KKKOOi@@A4E}  B BC KKI>>?E C<y(1b1 1-5--iHRH HrYc ||_yrl)rQ)rVrQrZrs rWrzCompileState.__init__s "rYc|jjdd}|r+||jf}||jvr|j|S |jd|jfS#t$rYywxYwrU)rWrrXrSr)rorQr[rzs rWget_plugin_classzCompileState.get_plugin_classs 0044 "D   B BCCckk!{{3''  ;; 9+M+MNO O  s A&& A21A2cX |j||jfS#t$rYywxYwrl)rSrXr)rorQr[s rW_get_plugin_class_for_pluginz)CompileState._get_plugin_class_for_plugins: ;;i@@A   s  ))cfd}|S)Nc*|jf<|Srl)rS)cls_to_decorateror[ visit_names rWdecoratez)CompileState.plugin_for..decorates5DCKKj1 2" "rYr^)ror[rerfs``` rW plugin_forzCompileState.plugin_fors #rYN)rQ ExecutablerZr7rrrrrP)rQrhrrOptional[Type[CompileState]])rQrhr[r|rrri)r[r|rer|rrCallable[[_Fn], _Fn]) rZr[r\rrrSrsrtrYrr_rargr^rYrWrPrPss4;I9;G 6;??I"I.9IADI II6#" %*"14 %+. rYrPceZdZdZddZy) GenerativezUProvide a method-chaining pattern in conjunction with the @_generative decorator.c6|j}|j}|j|}|rH|jj j Dcic] \}}||vs ||c}}|_|S|jj |_|Scc}}wrl)_memoized_keysrr__dict__copyitems)rVskiprosrFvs rWrzGenerative._generates""nn KK  "&!3!3!5!;!;!=!=A$1!=AJ ++-AJ s  B$BNr)rZr[r\rrr^rYrWrlrls  rYrlceZdZdZdZdZy)InPlaceGenerativezkProvide a method-chaining pattern in conjunction with the @_generative decorator that mutates in place.r^cd|j}|D]}|jj|d |Srl)rnror)rVrrrFs rWrzInPlaceGenerative._generates0""A MM  a & rYN)rZr[r\rrrr^rYrWrvrvs5IrYrvcZeZdZUdZdZded<ejZded<e jZ y)HasCompileStatez=A class that has a :class:`.CompileState` associated with it.Nri_compile_state_pluginutil.immutabledict[str, Any] _attributes) rZr[r\rrzrsr* EMPTY_DICTr|rPrY_compile_state_factoryr^rYrWryrys,G:>7>04K-?)>>rYryc@eZdZUdZded<dZer d dZd dZd dZ yy) _MetaOptionszmetaclass for the Options class. This metaclass is actually necessary despite the availability of the ``__init_subclass__()`` hook as this type also provides custom class-level behavior for the ``__add__()`` method. Tuple[str, ...] _cache_attrsc|}t|j|jr3td|dt|j|j|jj ||SNz.4s-A||D)66s!#)rotuplesortedrsuper__init_subclass__)rodict_rs rWrzOptions.__init_subclass__1s;     !#rYc :|jj|yrl)ror8rs rWrzOptions.__init__=s R rYc~|jj|j}|jj|jt |j |j r3td|dt |j |j |jj||Sr)rrror8rrrrCrs rWrzOptions.__add__@s ^^ # #DNN 3 4==) u: !2!2 3U..t/@/@AC  5! rYct|j|jD] \}}t||t||k7s yyNFT)rrgetattr)rVrrrs rW__eq__zOptions.__eq__NsD  1 153E3EFDAqtQ75!#44GrYcjjddjfdjDdS)N(, c3bK|]&}|jvr|dj|(yw)=Nro)r rFrVs rWr z#Options.__repr__..[s3*A %dmmA./*s,/))rrZjoinrrUs`rWrXzOptions.__repr__Vs; NN # # II**   rYct||Srl) issubclass)ror\s rW isinstancezOptions.isinstancebs#u%%rYc*||t|||zizSrl)r)rVrTrs rWadd_to_elementzOptions.add_to_elementfstWT4058999rYc|jSrlrrUs rW_state_dict_instzOptions._state_dict_instjs }}rYr{_state_dict_constc|jSrl)r)ros rW _state_dictzOptions._state_dictps$$$rYc <|j}||jurz|jrnt|jj |jr@t d|d|dt|jj |j||zS)Nzother element z is not empty, is not of type z+, and contains attributes not covered here )rrrrrrC)rorr;s rW safe_mergezOptions.safe_mergets     u &""E&&'2233C3CD**+66s7G7GH  QwrYc2|jt|j|}|j||}|rWi}|D]!}d|z} ||vr |||| <||vs|||| <#||z} t j j ||| i}| |fS||fS)a-process Options argument in terms of execution options. e.g.:: ( load_options, execution_options, ) = QueryContext.default_load_options.from_execution_options( "_sa_orm_load_options", {"populate_existing", "autoflush", "yield_per"}, execution_options, statement._execution_options, ) get back the Options and refresh "_sa_orm_load_options" in the exec options dict w/ the Options as well r)rrrrr* immutabledict merge_with) rorzattrs exec_optionsstatement_exec_optionscheck_argnamesexisting_optionsresultargnamelocal new_optionss rWfrom_execution_optionszOptions.from_execution_optionss4++   # #$: ; (++C5 F)g l*$0$9F5M 66$:7$CF5M *+V3K--/::sK0L , ,$\1 1rYcyrlr^rys rWr{zOptions.__getattr__rrYcyrlr^r!s rWrzOptions.__setattr__rrYcyrlr^rys rWrzOptions.__delattr__rrY)rrr)r\z Type[Any]rrbool)rrzMapping[str, Any]rrr)rZr[r\rrrsrrrrrXrtrr,rrr*r}r classlevelrrrrr{rr __classcell__)rs@rWrr*s6I!! $!   &&::7;oo3E  %!%0/2/2b3@4 rYr) metaclasscTeZdZdZedZej dZedZy)CacheableOptionsr^c0tj|||Srl)r _gen_cache_key)rVanon_map bindparamss rW_gen_cache_key_instz$CacheableOptions._gen_cache_key_insts))$*EErYc |dfSrr^)rorrs rWrzCacheableOptions._gen_cache_keys RyrYc,tj|Srl)r _generate_cache_key_for_objectrUs rW_generate_cache_keyz$CacheableOptions._generate_cache_keys99$??rYN) rZr[r\rr,rrrrr^rYrWrrsKIFF##$@@rYrc:eZdZdZej ZdZdZdZ dZ y)ExecutableOptionr^executable_optionFTc |jj|j}t|j|_|S)z/Create a shallow copy of this ExecutableOption.)rrr)ro)rVrrs rWrzExecutableOption._clones/ NN " "4>> 2$--( rYN) rZr[r\rr*r} _annotations__visit_name___is_has_cache_key_is_corerr^rYrWrrs%I??L(NHrYrczeZdZUdZdZded<ejZded<dZ dZ d ed <dZ d ed <d ed<d e jfd ejfdej fgZdZdZdZdZdZdZdZer2ded<ddd d#dZ d$dZ d%dZej:dZed&dZ e!d'dZ"e!d(dZ#e!d)dZ$e! d*dZ%e&dddddddddddddddddd d+dZ'e&d,d Z'e!d-d!Z'd.d"Z(y)/rhzMark a :class:`_expression.ClauseElement` as supporting execution. :class:`.Executable` is a superclass for all "statement" types of objects, including :func:`select`, :func:`delete`, :func:`update`, :func:`insert`, :func:`text`. Trsupports_executionrH_execution_optionsFr^zTuple[ExecutableOption, ...] _with_optionsz6Tuple[Tuple[Callable[[CompileState], None], Any], ...]_with_context_optionsz9Optional[Union[Type[CacheableOptions], CacheableOptions]]_compile_optionsrWr|rN)for_executemanyschema_translate_mapc yrlr^)rVrcompiled_cache column_keysrrrs rW_compile_w_cachezExecutable._compile_w_caches rYcyrlr^rV connectiondistilled_paramsexecution_optionss rW_execute_on_connectionz!Executable._execute_on_connections !$rYcyrlr^rs rW_execute_on_scalarzExecutable._execute_on_scalar$s rYctrlrrUs rW_all_selected_columnsz Executable._all_selected_columns+rrYc|jSrl)rrUs rWrXz#Executable._effective_plugin_target/s"""rYcP|xjtd|Dz c_|S)aJApply options to this statement. In the general sense, options are any kind of Python object that can be interpreted by the SQL compiler for the statement. These options can be consumed by specific dialects or specific kinds of compilers. The most commonly known kind of option are the ORM level options that apply "eager load" and other loading behaviors to an ORM query. However, options can theoretically be used for many other purposes. For background on specific kinds of options for specific kinds of statements, refer to the documentation for those option objects. .. versionchanged:: 1.4 - added :meth:`.Executable.options` to Core statement objects towards the goal of allowing unified Core / ORM querying capabilities. .. seealso:: :ref:`loading_columns` - refers to options specific to the usage of ORM queries :ref:`relationship_loader_options` - refers to options specific to the usage of ORM queries c3dK|](}tjtj|*ywrl)r1expectrExecutableOptionRole)r rs rWr z%Executable.options..Qs+$    U77 =s.0)rrrVoptionss rWrzExecutable.options3s0< e$ $    rYc||_|S)z|Assign the compile options to a new value. :param compile_options: appropriate CacheableOptions structure r)rVcompile_optionss rW_set_compile_optionszExecutable._set_compile_optionsWs!0 rYcL|jJ|xj|z c_|S)z*update the _compile_options with new keys.rrs rW_update_compile_optionsz"Executable._update_compile_optionsbs,$$000 ( rYc6|xj||ffz c_|S)aMAdd a context option to this statement. These are callable functions that will be given the CompileState object upon compilation. A second argument cache_args is required, which will be combined with the ``__code__`` identity of the function itself in order to produce a cache key. )r)rV callable_ cache_argss rW_add_context_optionzExecutable._add_context_optionjs" "" :'>&@@" rY.)r logging_tokenisolation_level no_parametersstream_resultsmax_row_buffer yield_perinsertmanyvalues_page_sizerpopulate_existing autoflushsynchronize_session dml_strategy render_nullsis_delete_usingis_update_frompreserve_rowcountc yrlr^)rVrr r r r r rrrrrrrrrrrrs rWrzExecutable.execution_options}s,rYc yrlr^)rVrs rWrzExecutable.execution_optionss58rYc d|vrtjdd|vrtjd|jj||_|S)aSet non-SQL options for the statement which take effect during execution. Execution options can be set at many scopes, including per-statement, per-connection, or per execution, using methods such as :meth:`_engine.Connection.execution_options` and parameters which accept a dictionary of options such as :paramref:`_engine.Connection.execute.execution_options` and :paramref:`_orm.Session.execute.execution_options`. The primary characteristic of an execution option, as opposed to other kinds of options such as ORM loader options, is that **execution options never affect the compiled SQL of a query, only things that affect how the SQL statement itself is invoked or how results are fetched**. That is, execution options are not part of what's accommodated by SQL compilation nor are they considered part of the cached state of a statement. The :meth:`_sql.Executable.execution_options` method is :term:`generative`, as is the case for the method as applied to the :class:`_engine.Engine` and :class:`_orm.Query` objects, which means when the method is called, a copy of the object is returned, which applies the given parameters to that new copy, but leaves the original unchanged:: statement = select(table.c.x, table.c.y) new_statement = statement.execution_options(my_option=True) An exception to this behavior is the :class:`_engine.Connection` object, where the :meth:`_engine.Connection.execution_options` method is explicitly **not** generative. The kinds of options that may be passed to :meth:`_sql.Executable.execution_options` and other related methods and parameter dictionaries include parameters that are explicitly consumed by SQLAlchemy Core or ORM, as well as arbitrary keyword arguments not defined by SQLAlchemy, which means the methods and/or parameter dictionaries may be used for user-defined parameters that interact with custom code, which may access the parameters using methods such as :meth:`_sql.Executable.get_execution_options` and :meth:`_engine.Connection.get_execution_options`, or within selected event hooks using a dedicated ``execution_options`` event parameter such as :paramref:`_events.ConnectionEvents.before_execute.execution_options` or :attr:`_orm.ORMExecuteState.execution_options`, e.g.:: from sqlalchemy import event @event.listens_for(some_engine, "before_execute") def _process_opt(conn, statement, multiparams, params, execution_options): "run a SQL function before invoking a statement" if execution_options.get("do_special_thing", False): conn.exec_driver_sql("run_special_function()") Within the scope of options that are explicitly recognized by SQLAlchemy, most apply to specific classes of objects and not others. The most common execution options include: * :paramref:`_engine.Connection.execution_options.isolation_level` - sets the isolation level for a connection or a class of connections via an :class:`_engine.Engine`. This option is accepted only by :class:`_engine.Connection` or :class:`_engine.Engine`. * :paramref:`_engine.Connection.execution_options.stream_results` - indicates results should be fetched using a server side cursor; this option is accepted by :class:`_engine.Connection`, by the :paramref:`_engine.Connection.execute.execution_options` parameter on :meth:`_engine.Connection.execute`, and additionally by :meth:`_sql.Executable.execution_options` on a SQL statement object, as well as by ORM constructs like :meth:`_orm.Session.execute`. * :paramref:`_engine.Connection.execution_options.compiled_cache` - indicates a dictionary that will serve as the :ref:`SQL compilation cache ` for a :class:`_engine.Connection` or :class:`_engine.Engine`, as well as for ORM methods like :meth:`_orm.Session.execute`. Can be passed as ``None`` to disable caching for statements. This option is not accepted by :meth:`_sql.Executable.execution_options` as it is inadvisable to carry along a compilation cache within a statement object. * :paramref:`_engine.Connection.execution_options.schema_translate_map` - a mapping of schema names used by the :ref:`Schema Translate Map ` feature, accepted by :class:`_engine.Connection`, :class:`_engine.Engine`, :class:`_sql.Executable`, as well as by ORM constructs like :meth:`_orm.Session.execute`. .. seealso:: :meth:`_engine.Connection.execution_options` :paramref:`_engine.Connection.execute.execution_options` :paramref:`_orm.Session.execute.execution_options` :ref:`orm_queryguide_execution_options` - documentation on all ORM-specific execution options r z'isolation_level' execution option may only be specified on Connection.execution_options(), or per-engine using the isolation_level argument to create_engine().rzm'compiled_cache' execution option may only be specified on Connection.execution_options(), not per statement.)r)rrrrs rWrzExecutable.execution_optionsshP  "##/  r !##H #'"9"9"?"?"C rYc|jS)zGet the non-SQL options which will take effect during execution. .. versionadded:: 1.3 .. seealso:: :meth:`.Executable.execution_options` )rrUs rWget_execution_optionsz Executable.get_execution_optionss&&&rY)rrMrOptional[CompiledCacheType]rz List[str]rrr Optional[SchemaTranslateMapType]rrrrzCTuple[Compiled, Optional[Sequence[BindParameter[Any]]], CacheStats])rrDrrFrrLrrzCursorResult[Any])rrDrrFrrLrrrrrr|)rrrrr/)rrrrr/)rrrrr/)rzCallable[[CompileState], None]rrrrr/)&rrr r|r rNr rr rr intrr rr rrrrrrrr5rr4rrrrrrrrrrrrr/)rrrrr/)rrrrr/)rrrG))rZr[r\rrrsr*r}r_is_default_generatorrrr&dp_executable_optionsr$dp_with_context_optionsdp_propagate_attrs_executable_traverse_internals is_selectis_from_statement is_update is_insertis_text is_deleteis_dmlrrrrrrrNrXrrrrrrrrr^rYrWrhrhs0 $#37??0B!24M/4  PO +AAB # % = =  6IIJ &"IIIGI F%*EI  8  #  " #C     $" $6 $ ;  $   $ " 6  ;      ""$#$##!!F1  $7: *-#$!*-AD"':=,/ #""''4  (   %(? 8* !"#$%& '()* +.88ttl 'rYrhc8eZdZUdZded<ddZ ddZy)SchemaEventTargetzBase class for elements that are the targets of :class:`.DDLEvents` events. This includes :class:`.SchemaItem` as well as :class:`.SchemaType`. zdispatcher[SchemaEventTarget]dispatchc y)z0Associate with this SchemaEvent's parent object.Nr^rVparentrs rW _set_parentzSchemaEventTarget._set_parent%srYc |jj|||j|fi||jj||yrl)r/before_parent_attachr3after_parent_attachr1s rW_set_parent_with_dispatchz+SchemaEventTarget._set_parent_with_dispatch(sA **48&2& ))$7rYN)r2r.rrrrr)rZr[r\rrsr3r7r^rYrWr.r.s1,+?8'8/28 8rYr.ceZdZdZddiZy) SchemaVisitorz/Define the visiting for ``SchemaItem`` objects.schema_visitorTN)rZr[r\r__traverse_options__r^rYrWr9r90s9,d3rYr9c(eZdZdZdZdZdZdZdZdZ y) _SentinelDefaultCharacterizationnoneunknown clientsidesentinel_default serversideidentitysequenceN) rZr[r\NONEUNKNOWN CLIENTSIDESENTINEL_DEFAULT SERVERSIDEIDENTITYSEQUENCEr^rYrWr=r=6s& DGJ)JHHrYr=cZeZdZUdZded<dZded<dZded<ejZ ded <y) _SentinelColumnCharacterizationNzOptional[Sequence[Column[Any]]]columnsFr is_explicit is_autoincr=default_characterization) rZr[r\rNrsrOrPr=rErQr^rYrWrMrM@s7/3G ,3KJ(-->rYrM_COLKEY_COL_coColumnElement[Any]T)rc covariant_COLcHeZdZUdZded< d dZdZdZ d dZy) _ColumnMetrics)columnrSrYcz||_|j}|r&|jD]}||j|yyrl)rY _proxy_index_expanded_proxy_setadd)rV collectioncolpieps_cols rWrz_ColumnMetrics.__init__Ts@  $ $ 227 %3 rYc.|jjSrl)rYr\rUs rWget_expanded_proxy_setz%_ColumnMetrics.get_expanded_proxy_set`s{{...rYc|j}|sy|jjD]0}|j|d}|r|j ||+|r.||=2yrl)r[rYr\rdiscard)rVr^r`r_colsets rWdisposez_ColumnMetrics.disposecsU  $ $ ;;22CVVC&Ft$!&sG 3rYc|jj}|j|D]}|jt |gryyr)rYr\rrr)rV target_setexpanded_proxy_setts rWembeddedz_ColumnMetrics.embeddednsG "[[<<&&'9:A%22>1#3FG;rYN)r^zColumnCollection[Any, _COL_co]r_rS)riz=Union[Set[ColumnElement[Any]], FrozenSet[ColumnElement[Any]]]rrr) rZr[r\rrsrrcrgrlr^rYrWrXrXOsDI O &8 &?F &/      rYrXc eZdZUdZdZded<ded<ded<d ed < d1 d2d Zejd d3dZ d4dZ e d5dZ d6dZ d5dZd7dZd8dZd9dZd:dZed;dZe ddZd?dZd@dZdAdZdBdZed1dCdZedDd Z d1 dEd!ZdFd"ZdGd#ZdHd$ZdId%ZdJd&ZdKd'ZdLd(Z d Z! d4d)Z" d1 dMd*Z#dNd+Z$dOd,Z%dPd-Z&dQd.Z'd/Z( dR dSd0Z)y )TColumnCollectionaCollection of :class:`_expression.ColumnElement` instances, typically for :class:`_sql.FromClause` objects. The :class:`_sql.ColumnCollection` object is most commonly available as the :attr:`_schema.Table.c` or :attr:`_schema.Table.columns` collection on the :class:`_schema.Table` object, introduced at :ref:`metadata_tables_and_columns`. The :class:`_expression.ColumnCollection` has both mapping- and sequence- like behaviors. A :class:`_expression.ColumnCollection` usually stores :class:`_schema.Column` objects, which are then accessible both via mapping style access as well as attribute access style. To access :class:`_schema.Column` objects using ordinary attribute-style access, specify the name like any other object attribute, such as below a column named ``employee_name`` is accessed:: >>> employee_table.c.employee_name To access columns that have names with special characters or spaces, index-style access is used, such as below which illustrates a column named ``employee ' payment`` is accessed:: >>> employee_table.c["employee ' payment"] As the :class:`_sql.ColumnCollection` object provides a Python dictionary interface, common dictionary method names like :meth:`_sql.ColumnCollection.keys`, :meth:`_sql.ColumnCollection.values`, and :meth:`_sql.ColumnCollection.items` are available, which means that database columns that are keyed under these names also need to use indexed access:: >>> employee_table.c["values"] The name for which a :class:`_schema.Column` would be present is normally that of the :paramref:`_schema.Column.key` parameter. In some contexts, such as a :class:`_sql.Select` object that uses a label style set using the :meth:`_sql.Select.set_label_style` method, a column of a certain key may instead be represented under a particular label name such as ``tablename_columnname``:: >>> from sqlalchemy import select, column, table >>> from sqlalchemy import LABEL_STYLE_TABLENAME_PLUS_COL >>> t = table("t", column("c")) >>> stmt = select(t).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) >>> subq = stmt.subquery() >>> subq.c.t_c :class:`.ColumnCollection` also indexes the columns in order and allows them to be accessible by their integer position:: >>> cc[0] Column('x', Integer(), table=None) >>> cc[1] Column('y', Integer(), table=None) .. versionadded:: 1.4 :class:`_expression.ColumnCollection` allows integer-based index access to the collection. Iterating the collection yields the column expressions in order:: >>> list(cc) [Column('x', Integer(), table=None), Column('y', Integer(), table=None)] The base :class:`_expression.ColumnCollection` object can store duplicates, which can mean either two columns with the same key, in which case the column returned by key access is **arbitrary**:: >>> x1, x2 = Column("x", Integer), Column("x", Integer) >>> cc = ColumnCollection(columns=[(x1.name, x1), (x2.name, x2)]) >>> list(cc) [Column('x', Integer(), table=None), Column('x', Integer(), table=None)] >>> cc["x"] is x1 False >>> cc["x"] is x2 True Or it can also mean the same column multiple times. These cases are supported as :class:`_expression.ColumnCollection` is used to represent the columns in a SELECT statement which may include duplicates. A special subclass :class:`.DedupeColumnCollection` exists which instead maintains SQLAlchemy's older behavior of not allowing duplicates; this collection is used for schema level objects like :class:`_schema.Table` and :class:`.PrimaryKeyConstraint` where this deduping is helpful. The :class:`.DedupeColumnCollection` class also has additional mutation methods as the schema constructs have more use cases that require removal and replacement of columns. .. versionchanged:: 1.4 :class:`_expression.ColumnCollection` now stores duplicate column keys as well as the same column in multiple positions. The :class:`.DedupeColumnCollection` class is added to maintain the former behavior in those cases where deduplication as well as additional replace/remove operations are needed. ) _collection_index_colsetr[z6List[Tuple[_COLKEY, _COL_co, _ColumnMetrics[_COL_co]]]roz4Dict[Union[None, str, int], Tuple[_COLKEY, _COL_co]]rpz6Dict[ColumnElement[Any], Set[_ColumnMetrics[_COL_co]]]r[z Set[_COL_co]rqNc6tj|dttj|ditj|dtjt j tj|dg|r|j|yy)Nrqrpr[ro)rrr collections defaultdictr* OrderedSet_initial_populate)rVrNs rWrzColumnCollection.__init__sx 4CE242. .+"9"9$//"J  43   " "7 + rYzsqlalchemy.sql.elementsctjj}|j|jt j ddS)NF)_literal_as_text_rolerD)r*r$ sql_elementsr9 _all_columnsrColumnsClauseRolerVr2s rW__clause_element__z#ColumnCollection.__clause_element__s?>>.."x""  #("9"9  rYc&|j|yrl_populate_separate_keysrViter_s rWrvz"ColumnCollection._initial_populates $$U+rYcN|jDcgc]\}}}| c}}Scc}}wrlrorVrr_s rWrzzColumnCollection._all_columns s('+'7'78'7 C'7888 !cN|jDcgc]\}}}| c}}Scc}}w)zQReturn a sequence of string key names for all columns in this collection.r)rVrFrs rWkeyszColumnCollection.keyss*$(#3#34#3iq!Q#3444rcN|jDcgc]\}}}| c}}Scc}}w)zReturn a sequence of :class:`_sql.ColumnClause` or :class:`_schema.Column` objects for all columns in this collection.rrs rWrzColumnCollection.valuess*(,'7'78'7 C'7888rcX|jDcgc] \}}}||f c}}}Scc}}}w)zReturn a sequence of (key, column) tuples for all columns in this collection each consisting of a string key name and a :class:`_sql.ColumnClause` or :class:`_schema.Column` object. r)rVrFr_rs rWrqzColumnCollection.itemss.-1,<,<=,<[aaC,<===s%c,t|jSrl)rrorUs rW__bool__zColumnCollection.__bool__"sD$$%%rYc,t|jSrl)r rorUs rWrzColumnCollection.__len__%s4##$$rYc `t|jDcgc]\}}}| c}}Scc}}wrl)rrors rWrzColumnCollection.__iter__(s-$*:*:;*:YQQS*:;<<;s * cyrlr^rys rWrzColumnCollection.__getitem__,s.?s#1F-Wc1!#1Fsc3<K|]}j|ywrlrp)r rrVs rWr z/ColumnCollection.__getitem__..DsDWDKK0srr) rrslicerorn as_readonlyrprrr  IndexError)rVrzcolsrs` rWrzColumnCollection.__getitem__9s #u~.c5)151A1A#1FD EDD'-99;;{{3'** #((1+s+ !-36  sA A6$A66 B;?7B66B;cb |j|dS#t$r}t||d}~wwxYw)Nr)rprAttributeError)rVrzrs rWr{zColumnCollection.__getattr__Os8 /;;s#A& & / %3 . /s . ).cl||jvr&t|tstjdyy)Nz'__contains__ requires a string argumentFT)rprr|r)rrys rW __contains__zColumnCollection.__contains__Us6 dkk !c3'''=rYc8t||D] \}}||us yy)zdCompare this :class:`_expression.ColumnCollection` to another based on the names of the keysFTr)rVrlrs rWcomparezColumnCollection.compare_s( e,DAqz-rYc$|j|Srl)r)rVrs rWrzColumnCollection.__eq__is||E""rYcyrlr^rVrzrps rWrzColumnCollection.getlsHKrYcyrlr^rs rWrzColumnCollection.getosDGrYcF||jvr|j|dS|S)zGet a :class:`_sql.ColumnClause` or :class:`_schema.Column` object based on a string key name from this :class:`_expression.ColumnCollection`.rrrs rWrzColumnCollection.getrs) $++ ;;s#A& &NrYcf|jjddjd|DdS)Nrrc32K|]}t|ywrl)r|)r rs rWr z+ColumnCollection.__str__..s+dc!fdsr)rrZrrUs rW__str__zColumnCollection.__str__~s+ NN # # II+d+ +  rYctrlrr!s rWrzColumnCollection.__setitem__ !##rYctrlrrys rWrzColumnCollection.__delitem__rrYctrlr)rVrzrs rWrzColumnCollection.__setattr__rrYct)zQDictionary clear() is not implemented for :class:`_sql.ColumnCollection`.rrUs rWclearzColumnCollection.clear "##rYctrlr)rVrYs rWremovezColumnCollection.removerrYct)zRDictionary update() is not implemented for :class:`_sql.ColumnCollection`.rrs rWr8zColumnCollection.updaterrYc |Dcgc]\}}||t||fc}}x|jdd}|jjd|D|jjt |Dcic]\}\}}}|||fc}}}}|jjt |Dcic] \}}}|||f c}}}ycc}}wcc}}}}wcc}}}w)*populate from an iterator of (key, column)Nc3DK|]\}}}|jywrl _deannotate)r rrs rWr z;ColumnCollection._populate_separate_keys..sF:1aAMMO: )rXrorqr8rp enumerater9)rVrrFrr^idxrr_s rWrz(ColumnCollection._populate_separate_keyss 9>, 8=1Q>$* +,  j F:FF /8/D E/D^S)1aS1a&[/D E  *9MN9MIAsAA3xK9MNO, FNsC9C:C" ct| |j}n|}t|j}tt|}|jj ||t ||f|jj|j||f|j|<||jvr||f|j|<yy)aAdd a column to this :class:`_sql.ColumnCollection`. .. note:: This method is **not normally used by user-facing code**, as the :class:`_sql.ColumnCollection` is usually part of an existing object such as a :class:`_schema.Table`. To add a :class:`_schema.Column` to an existing :class:`_schema.Table` object, use the :meth:`_schema.Table.append_column` method. N) rzr ror rSappendrXrqr]rrp)rVrYrzcolkeyr_columns rWr]zColumnCollection.adds ;ZZFF   ! w'  WnT7; <  ,,./ '* A  $#)7"3DKK  %rYcr|jDcgc] \}}}||f c}}}|jdScc}}}w)Nrorpr)rVrFrrs rW __getstate__zColumnCollection.__getstate__s:262B2BC2Bwq!QQF2BCkk  Cs2ctj|d|dtj|dtjtj tj|d|dDcgc]\}}||t ||fc}}tj|d|jDchc]\}}}| c}}}ycc}}wcc}}}w)Nrpr[rorq)rrrsrtr*rurXro)rVstaterFrr_rs rW __setstate__zColumnCollection.__setstate__s45?; .+"9"9$//"J    $M2 2FQA~dA./2    )43C3CD3Ciaac3CD   Es ,C. C cl||jvr&t|trtjdyy)z3Checks if a column object exists in this collectionzZcontains_column cannot be used with string arguments. Use ``col_name in table.c`` instead.FT)rqrr|r)rrVr_s rWcontains_columnz ColumnCollection.contains_columns8 dll "#s#'';rYct|S)zIReturn a "read only" form of this :class:`_sql.ColumnCollection`.)ReadOnlyColumnCollectionrUs rWrzColumnCollection.as_readonlys(--rYc|j}|ry|jD]7\}}}|jj}|D]}||j |9y)apopulate the "proxy index", if empty. proxy index is added in 2.0 to provide more efficient operation for the corresponding_column() method. For reasons of both time to construct new .c collections as well as memory conservation for large numbers of large .c collections, the proxy_index is only filled if corresponding_column() is called. once filled it stays that way, and new _ColumnMetrics objects created after that point will populate it with new data. Note this case would be unusual, if not nonexistent, as it means a .c collection is being mutated after corresponding_column() were used, however it is tested in test/base/test_utils.py. N)r[rorYr\r])rVr`rmetricsepsras rW_init_proxy_indexz"ColumnCollection._init_proxy_indexsT    !--MAq'..44C7 (.rYc n ||jvr|Sd\}}|j}|j s|j fd|DD]M}|r|j |s||}|j |j j}|%|j |j j}t|t|kDr|}|}||k(st|j jDcgc]/}|j|r|jjdd1c}} t|j jDcgc]/}|j|r|jjdd1c}} | | ksJ|}|}P|r |j SdScc}wcc}w)aGiven a :class:`_expression.ColumnElement`, return the exported :class:`_expression.ColumnElement` object from this :class:`_expression.ColumnCollection` 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:: :meth:`_expression.Selectable.corresponding_column` - invokes this method against the collection returned by :attr:`_expression.Selectable.exported_columns`. .. versionchanged:: 1.4 the implementation for ``corresponding_column`` was moved onto the :class:`_expression.ColumnCollection` itself. )NNc3@K|]}|vs|D]}|ywrlr^)r tsmmr`s rWr z8ColumnCollection.corresponding_column..@s' #2rRx"R&BB&Bs Nweightr)rqrr[rrlrrYr\r r _uncached_proxy_listshares_lineagerr) rVrYrequire_embeddedselected_intersectionselected_metricsricurrent_metricscurrent_intersectionscselected_col_distancecurrent_col_distancer`s @rWcorresponding_columnz%ColumnCollection.corresponding_columnsH T\\ !M2<//%%     " " $ # O$'?'? 'K#+'6$'1'>'>#**>>($)0,6,C,C(//CC-)+,s3H/II (7$,@))-BB-0!1 7 7 L L N!O!# "008 OO//!< N-),/!0 6 6 K K M!N!# "008 OO//!< M,(,.CC+:(0D-q t+;&&DD+s 84F- 4F2 rl)rNz+Optional[Iterable[Tuple[_COLKEY, _COL_co]]])rrr9)rz!Iterable[Tuple[_COLKEY, _COL_co]]rrr)rrz List[_COL_co])rrz List[_COLKEY])rrzList[Tuple[_COLKEY, _COL_co]])rrr)rrr )rrzIterator[_COL_co])rzzUnion[str, int]rrrS)rzzTuple[Union[str, int], ...]rr*ReadOnlyColumnCollection[_COLKEY, _COL_co])rzrrrr)rzz3Union[str, int, slice, Tuple[Union[str, int], ...]]rrz:Union[ReadOnlyColumnCollection[_COLKEY, _COL_co], _COL_co])rzr|rrrS)rzr|rrr)rzColumnCollection[Any, Any]rrr)rrrrr)rzr|rprrrzOptional[_COL_co])rzr|rprVrrzUnion[_COL_co, _COL])rzr|rpzOptional[_COL]rrzOptional[Union[_COL_co, _COL]]r)rzr|rrrrr)rzr|rrr)rzr|rrrrr)rrr)rYrrrr)rrrrr)rYrTrzzOptional[_COLKEY]rrr)rrrJ)rrJrrr)r_rTrrr)rrr)F)rYrVrrrrzOptional[Union[_COL, _COL_co]])*rZr[r\rrrsrr*preload_moduler}rvrNrzrrrqrrrrrr{rrrrrrrrrrr8__hash__rr]rrrrrrr^rYrWrnrn{sjXCIGG @@HH FJ ,B ,T23 4 ,6, , 995 9 >&%=?? 9.9 39999 399F C,/ #KK GG37  !/  '  $$$$ $$ H P6 P  PDH"4("4/@"4 "4H  " . )66;hEhE.2hE 'hErYrn _NAMEDCOLzNamedColumn[Any]cdeZdZdZ d d dZd dZ d dZd dZddZ d ddZ y)DedupeColumnCollectionauA :class:`_expression.ColumnCollection` that maintains deduplicating behavior. This is useful by schema level objects such as :class:`_schema.Table` and :class:`.PrimaryKeyConstraint`. The collection includes more sophisticated mutator methods as well to suit schema objects which require mutable column collections. .. versionadded:: 1.4 Nch|$|j|k7rtjd|j}|tjd||jvrI|j|d}||ury|j |t j j|dy|j||y)NKDedupeColumnCollection requires columns be under the same key as their .keyz-Can't add unnamed column to column collectionrr) rzr)rrpreplacer*rMreset_append_new_column)rVrYrzexistings rWr]zDedupeColumnCollection.adds ?vzzS0##- jj ;##?  $++ {{3'*H6! LL  " " ( ( =  # #C 0rYct|j}|jj||t||f|jj |j ||f|j|<||f|j|<yrl)r rorrXrqr]rrp)rVrz named_columnrs rWrz)DedupeColumnCollection._append_new_columnsy   !  ,t\ B C  1134|, A. CrYc t|}g}|D]\}}|j|k7rtjd|j|j vr+|j|jk7r|j |m|j|j vr|j |||f|j |<|jj ||t||f|jjd|jD|j jdt|jD|D]}|j|y)rrc3DK|]\}}}|jywrlr)r rFrrs rWr zADedupeColumnCollection._populate_separate_keys..sN=M AqAMMO=Mrc36K|]\}\}}}|||ffywrlr^)r rrFrrs rWr zADedupeColumnCollection._populate_separate_keys..s' 0Knc9Aq!S1a&M0KsN) listrzr)rrTrprrorXrqr8rr)rVrr replace_colrFr_s rWrz.DedupeColumnCollection._populate_separate_keyss%E{ FAsww!|''1xx4;;&377chh+>""3'DKK'""3'"#S A  ''Cc1J(KL NT=M=MNN  09$:J:J0K  C LL rYc4|jd|Dy)Nc38K|]}|j|fywrl)rz)r r_s rWr z0DedupeColumnCollection.extend..s$Eucggs^usrrs rWextendzDedupeColumnCollection.extends $$$Eu$EErYc f||jvrtd|z|j|j=|jj ||j Dcgc]\}}}||ur|||fc}}}|j dd|j j|dD]}|j||jjt|j Dcic]\}\}}}|||fc}}}}|jt|j =ycc}}}wcc}}}}w)Nz8Can't remove column %r; column is not in this collectionr^) rqrrprzrror[rrgr8rr )rVrYrFrrrr_rs rWrzDedupeColumnCollection.removes"  %J  KK # F#$(#3#3 #3Aw7O#3  ((,,VR8G OOD !9 3,>?4:+<+<=4 0F0FG41H1HIrYcd|jiSNrrrUs rWrz%ReadOnlyColumnCollection.__getstate__;s4<<((rYc0|d}|j|yr)r)rVrr2s rWrz%ReadOnlyColumnCollection.__setstate__>sy! frYc$|jyrl _readonly)rVrYrzs rWr]zReadOnlyColumnCollection.addB  rYc$|jyrlrr|s rWrzReadOnlyColumnCollection.extendEr rYc$|jyrlr)rVitems rWrzReadOnlyColumnCollection.removeHr rYN).)rYrrzrrrr)r2rrrr)r rrrr) rZr[r\rrrrr]rrr^rYrWrr/s(IJ)rYrc$eZdZdZdZdZdZy) ColumnSetc ||vSrlr^rs rWrzColumnSet.contains_columnMs d{rYc4|D]}|j|yrl)r])rVrr_s rWrzColumnSet.extendPsC HHSMrYcg}|D]/}|D](}|j|s|j||k(*1tj|Srl)rrr2and_)rVrrrrs rWrzColumnSet.__eq__TsJ A##E*HHQ%Z(}}a  rYc8ttd|DS)Nc3 K|]}|ywrlr^)r rs rWr z%ColumnSet.__hash__..]s*T!Ts )hashrrUs rWrzColumnSet.__hash__\sE*T**++rYN)rZr[r\rrrrr^rYrWrrLs!,rYrzColumnClause[Any]c tt|jS#t$rEt j tt |D]}t|s|jccYSwxYw)zReturn the nearest .entity_namespace for the given entity. If not immediately available, does an iterate to find a sub-element that has one, if any. )r rrrriterater%r)entityrs rW_entity_namespacer`sa'0AAA $$T*?%HID'-,,,J  s:A*A*'A*c t|}|tur t|||St||S#t$r"}t j d|d|d|d}~wwxYw)zReturn an entry from an entity_namespace. Raises :class:`_exc.InvalidRequestError` rather than attribute error on not found. zEntity namespace for "z" has no property ""N)rr]rrr)r)rrzrpnsrs rW_entity_namespace_keyrssc  v & & 2sG, ,2s# # %%@F L  s. . AAA)rrrrzTypeGuard[_HasEntityNamespace])r2zEUnion[ColumnElement[Any], FromClause, TextClause, _JoinTargetElement]rrzIterator[FromClause])r2z!Iterable[roles.ColumnsClauseRole]rrrB)rrdrrrd)rr|rrrrrj)r2Iterable[_CLE]rrr)rrrrrrz Set[_CLE])r1Union[_HasEntityNamespace, ExternallyTraversible]rrrw)rrrzr|rpz%Union[SQLCoreOperations[Any], _NoArg]rrr})r __future__rrsenumrrrrrAr-rrr r r r r rrrrrrrrrrrrrrrrr cache_keyr r! traversalsr"r#r$r%r&r(r)r*r+r, compat_typing util.typingr.r/r0r1r2r3 _orm_typesr4r5_typingr6rZr7r8r9r:r;r<r=r>schemar?r@ selectablerArBrCenginerDrEengine.interfacesrFrGrHrIrJrKrLrMrNrOrPrRr]r`ra _NONE_NAMErbrdr|_AmbiguousTableNameMaprfr_never_select_columnrwrrrrrrrrrrrrrrrrrrrr+r-rPrlrvrytyperrrr StatementRolerh EventTargetr.r9r=rMrRrSrVrXrnrrReadOnlyContainerrrurrrr^rYrWr4s #! ! "*(#/+'-*"#/6%'$&'%+$(.+&#%;3<.,5?+2:"IHH%T% II   T e8CH-.'S1 z 4+x**+BCCxC8(8 0 s#  @ <  /  3;LM%m,,%0: ???N6 nS#X.6 r$nS#X.$@*+1,1gCgCTiiX$  ?j?545B[5 [5| @w @ '$n'$$n'b 8))8*4M4 tj )U49-s 3 )#74 Hv12)WW%)XEww/0ED K'9 : lN-c9n=lN^,Wg-=>:, 34,( =,6< = 3 rY