L iS(J UdZddlmZddlZddlmZddlZddlmZddlZddl 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,dd&l$m-Z-d'd(l"m.Z.d'd)l"m/Z/d'd*l"m0Z0d'd+l0m1Z1d'd,l0m2Z2d'd-l0m Z3d'd.l4m5Z5d'd/l4m6Z6d'd0l4m7Z7d'd1l4m8Z8erdd2l"m9Z9dd3l"m:Z:dd4l"m;Z;dd5lZ>dd7l?m@Z@dd8l%mAZAdd9lBmCZCdd:l:mDZDdd;l:mEZEddl:mHZHdd?l:mIZIdd@l:mJZJddAlKmLZLddBlKmMZMddClNmOZOddDlNmPZPddElNmQZQddFl$mRZRd'dGlSmTZTd'dHlSmUZUd'dIlVmWZWd'dJlVmXZXd'dKlVmYZYd'dLlVmZZZd'dMlVm[Z[d'dNlVm\Z\d'dOlVm]Z]d'dPlVm^Z^d'dQlVm_Z_d'dRlVm`Z`d'dSl.maZaesdZ9dZ:dZ;GdTdUeZbebjZcdVeddW<GdXdYeZeeejZgdVeddZ<e d[e \Zhe d]e d^e f\ZieejejfZkGd_d`eZlejdaZndbeddc<Gdddee6ZoGdfdge6ZpddhZqe die \ZrGdjdkZsGdldmesZt ddnZu ddoZve dpdq\ZwGdrdqe3jlZxddsZyddtZzduZ{ ddvZ| ddwZ}ddxZ~ddyZGdzd{eeje fZGd|d}eeje fZe0jd~ddZGddZGddZGdde1ZGdde1ZGddeZGddeZGddeZGddee&ZGdde)ZGdde#jZGdde.j ZGddee$j$ZGdde*ZGddeZGddeZe de!dejfejZe dddZe dd\ZGddeeZGddeeefZe dd\ZGddeejefZGdde0j<eeefZGdde0j@dZ ddZecf ddZy)z2Foundational utilities common to many sql modules.) annotationsN)Enum zip_longest)Any)Callable)cast)Dict) FrozenSet) Generator)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)Final)Protocol)Self) TypeGuard) coercions)elements)type_api)DMLStrategyArgument)SynchronizeSessionArgument)_CLE)CacheKey) SQLCompiler) BindParameter) ClauseList) ColumnClause) ColumnElement) NamedColumn)SQLCoreOperations) TextClause)Column)DefaultGenerator)_JoinTargetElement)_SelectIterable) FromClause)anon_map) Connection) CursorResult)_CoreMultiExecuteParams)_ExecuteOptions)_ImmutableExecuteOptions) CacheStats)Compiled)CompiledCacheType)CoreExecuteOptionsParameter)Dialect)IsolationLevel)SchemaTranslateMapType) dispatcherceZdZdZdZy)_NoArgrc d|jS)Nz_NoArg.)nameselfs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/sql/base.py__repr__z_NoArg.__repr__ms $$N)__name__ __module__ __qualname__NO_ARGr\r]r[rVrVjs F%r]rVr/raceZdZdZy) _NoneNamerN)r^r_r` NONE_NAMErbr]r[rdrdts IHr]rd _NONE_NAME_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_updaterorkrlrmrn)clsdefaults r[_from_column_defaultz-_DefaultDescriptionTuple._from_column_defaultse**w/B/B % !!####   *$dDA r]N)ruzOptional[DefaultGenerator]returnrk)r^r_r`__annotations__ classmethodrvrbr]r[rkrks; H 0 !  r]rk_omit_from_statementszoperator.attrgetter[Any]_never_select_columnceZdZddZy)_EntityNamespacecyrqrbrZkeys r[ __getattr__z_EntityNamespace.__getattr__r]N)rstrrwSQLCoreOperations[Any])r^r_r`rrbr]r[r}r}sBr]r}c2eZdZejddZy)_HasEntityNamespacecyrqrbrYs r[entity_namespacez$_HasEntityNamespace.entity_namespaces47r]N)rwr})r^r_r`r+ro_non_memoized_propertyrrbr]r[rrs ""7#7r]rct|dS)Nr)hasattr)elements r[_is_has_entity_namespacers 7. //r]_SelfcTeZdZUdZdZdZded<d dZd dZd dZ dd  dd Z 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`. rbTbool _is_immutablectdNz(Immutable objects do not support copyingNotImplementedErrorrZ optionaldictkwargss r[ unique_paramszImmutable.unique_params!"LMMr]ctdrrrs r[paramszImmutable.paramsrr]c |SrqrbrZkws r[_clonezImmutable._clones r]) omit_attrsc yrqrb)rZrrs r[_copy_internalszImmutable._copy_internalss r]N)rrrrrwr)rZrrrrwr)rz Iterable[str]rrrwNone) r^r_r`__doc__ __slots__rrxrrrrrbr]r[rrsK IM4NN.0 * 7:  r]rcjeZdZUdZdZded<ded<d dZejd dZ e d dZ y ) SingletonConstantz.Represent SQL constants like NULL, TRUE, FALSETr_is_singleton_constant _singletonc6tt|jSrq)r rgr)rtrlrs r[__new__zSingletonConstant.__new__sB''r]ctrqrrYs r[ proxy_setzSingletonConstant.proxy_set !##r]c~tj|}|jt|g|_||_yrq)objectr__init__ frozensetrr)rtobjs r[_create_singletonz#SingletonConstant._create_singletons0nnS! "3%( r]N)rtrgrlrrrrwrgrwzFrozenSet[ColumnElement[Any]]rwr) r^r_r`rrrxrr+non_memoized_propertyrryrrbr]r[rrsI8#'D'!!( $ $  r]rcztjj|Dcgc]}|jc}Scc}wrq) itertoolschain from_iterable _from_objects)r4rs r[rrs2 ?? ( (.677  7 78cztjj|Dcgc]}|jc}Scc}w)zXexpand tables into individual columns in the given list of column expressions. )rrr_select_iterable)r4cs r[_select_iterablesrs2 ?? ( (%-.  . .r_SelfGenerativeType_GenerativeTypeceZdZddZy)rcyrqrbrYs r[ _generatez_GenerativeType._generate rr]Nrwr1)r^r_r`rrbr]r[rr s$r]cftj 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)fnrZargsrxs r[ _generativez _generative.._generatives; ~~ t !d !b !Dy???y r]) rrirZrrrrrrwr)r+ decoratornon_generative)rr decorateds r[rr s[ ^^ *36>A BI!I r]c |jdi|jdi}|Dcgc]*}|tj||j|df,c}tj dfd }|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)getr^ __class__r*InvalidRequestError) rrrrZrXgetterdefault_msggettersrs r[checkz!_exclusive_against..check/sAwABx&- 3 "D&(d|8+hh{{DNN4 --c22 3$$$$$r])rrirrrrrwr)popoperator attrgetterrr+r)namesrrrXrrrs @@r[_exclusive_againstr%s66&"-D!vvj"5HJ  x""4((,,tT*BCJG  ^^ % % L+Js/A9c &|jdi|SNrb)r)rrs r[rrBs 7>> B r]c`tj|Dcgc]}|jc}Scc}w)z\expand the given set of ClauseElements to be the set of all 'cloned' predecessors. )rr _cloned_setr4rs r[_expand_clonedrFs% ??H=qQ]]= >>=s+c#lK|D]+}|j|j}|j|-ywrq) _is_clone_ofrs r[ _de_clonerQs;nn(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 r[_cloned_intersectionrZsO!!23@@qK MT+":":4;K;K"LD MM M AActt|jt|}|Dchc] }|j|jr|"c}Scc}wrqrrs r[_cloned_differencergsV !23@@qK +":":4;K;K"L  rcLeZdZdZdZd dZd dZd dZddZddZ ddZ dd Z y )_DialectArgViewzaA dictionary view of dialect-level arguments in the form _. rc||_yrqr)rZrs r[rz_DialectArgView.__init__xs r]cp |jdd\}}||fS#t$r}t||d}~wwxYw)N_r)split ValueErrorKeyError)rZrdialect value_keyerrs r[_keyz_DialectArgView._key{sG &!$3!2 GYI% % )3-S ( )s 5 05c|j|\}} |jj|}||S#tj$r}t ||d}~wwxYwrq)rrdialect_optionsr*NoSuchModuleErrorr)rZrrroptrs r[ __getitem__z_DialectArgView.__getitem__s]!YYs^ "((**73Cy> !$$ )3-S ( )s4A AAc |j|\}}||jj||<y#t$r}t j d|d}~wwxYw)Nz0Keys must be of the form _)rrrrr* ArgumentError)rZrvaluerrrs r[ __setitem__z_DialectArgView.__setitem__sa A!%3 GY z*_DialectArgView.__len__..s#  "" # s!)sumrrvaluesrYs r[__len__z_DialectArgView.__len__s/ 00779   r]cBfdjjDS)Nc3|K|]3}jj|jD] }|d| 5yw)rN)rrr)r dialect_name value_namerZs r[rz+_DialectArgView.__iter__..sJ "hh66m  $Z 0 0 s9<)rrrYs`r[__iter__z_DialectArgView.__iter__s $ 8 8  r]N)r DialectKWArgsrwr)rrrwzTuple[str, str]rrrwrrrrrrwrrrrwrrwint)rwzGenerator[str, None, None]) r^r_r`rrrrr rrrrrbr]r[rrps2 I&"A9  r]rc@eZdZdZd dZd dZd dZd dZd dZddZ 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|_yrqr _defaultsrYs r[rz_DialectArgDict.__init__s-/)+r]cptt|jj|jSrq)rrrunionr*rYs r[rz_DialectArgDict.__len__s'3t))*00@AAr]cptt|jj|jSrq)iterrrr,r*rYs r[rz_DialectArgDict.__iter__s'C**+11$..ABBr]cZ||jvr|j|S|j|Srqr)rs r[r z_DialectArgDict.__getitem__s0 $$$ $%%c* *>>#& &r]c"||j|<yrqrrZrrs r[rz_DialectArgDict.__setitem__s"'3r]c|j|=yrqr1rs r[rz_DialectArgDict.__delitem__s   s #r]Nrr$)rwz Iterator[str]r!r"r#) r^r_r`rrrrr rrrbr]r[r'r's',BC' ($r]r'zsqlalchemy.dialectsctjjjj |}|j yt |j Srq)r+ preloadeddialectsregistryloadconstruct_argumentsdict)r dialect_clss r[_kw_reg_for_dialectr<sB..))2277 EK&&.  // 00r]ceZdZUdZdZdej fgZded<e ddZ e ddZ e ddZ ejeZd ed <e dd Zej&dd Zdd Zy)r a9Establish 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` rbrzList[Tuple[str, Any]]"_dialect_kwargs_traverse_internalsctj|}|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 )rtr argument_nameruconstruct_arg_dictionarys r[ argument_forzDialectKWArgs.argument_forsgR  & &| 4 ! $ +##=?KL  . .,. $S )7> %m4r]ct|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 )rrYs r[dialect_kwargszDialectKWArgs.dialect_kwargss&t$$r]c|jS)z4A synonym for :attr:`.DialectKWArgs.dialect_kwargs`.)rErYs r[rzDialectKWArgs.kwargs/s"""r]z0util.PopulateDict[str, Optional[Dict[Any, Any]]]r@ctj|}t}||jj ddi|St |j D]%}||vs|jj ||'|S)N*)r r@r'r*updatereversed__mro__)rtrrBds r[_kw_reg_for_dialect_clsz%DialectKWArgs._kw_reg_for_dialect_cls8s#0#=#=l#K   # + KK  T{ +   , F22KK&&'?'DE Fr]c@tj|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+ PopulateDictrMrYs r[rzDialectKWArgs.dialect_optionsEs&  !=!=>>r]c |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(rHz 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*r rr r+warnr'r*rIr)rZrkmrarg_namerBrLs r[_validate_dialect_kwargsz&DialectKWArgs._validate_dialect_kwargsZs3  CA+A?ABC&'WWQ] "L( C+/+?+? +M(77 (@@++lDNN< :@,X6? C(( 6 ,( :I9JJ$$\2Q ""C;/,21I) 6sBA6D D N)rrrArrurrwr)rwr)rrrwr')rwz'util.PopulateDict[str, _DialectArgDict])rDict[str, Any]rwr)r^r_r`rrr'dp_dialect_optionsr>rxryrCpropertyrErr+rOr<r@rMmemoized_propertyrrYrbr]r[r r s I -@@AA&(=1?1?/21?=@1? 1?1?f%%(## -.B   ??(%Cr]r 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]rac X|jrb|jjdd}|jj||jfd}|7|jd|jf}n|jd|jf}||ur |||fi|S|j||fi|SNcompile_state_pluginru)_propagate_attrsrrb_effective_plugin_targetcreate_for_statement)rtr`compilerr plugin_nameklasss r[rhz!CompileState.create_for_statements  % %#4488& KKKOOi@@A4E}  B BC KKI>>?E C<y(1b1 1-5--iHRH Hr]c ||_yrq)r`)rZr`rirs r[rzCompileState.__init__s "r]c|jjdd}|r+||jf}||jvr|j|S |jd|jfS#t$rYywxYwrd)rfrrgrbr)rtr`rjrs r[get_plugin_classzCompileState.get_plugin_classs 0044 "D   B BCCckk!{{3''  ;; 9+M+MNO O  s A&& A21A2cX |j||jfS#t$rYywxYwrq)rbrgr)rtr`rjs r[_get_plugin_class_for_pluginz)CompileState._get_plugin_class_for_plugins: ;;i@@A   s  ))cfd}|S)Nc*|jf<|Srq)rb)cls_to_decoratertrj visit_names r[decoratez)CompileState.plugin_for..decorates5DCKKj1 2" "r]rb)rtrjrtrus``` r[ plugin_forzCompileState.plugin_fors #r]N)r` Executablerir:rrrwr_)r`rwrwOptional[Type[CompileState]])r`rwrjrrwrx)rjrrtrrwCallable[[_Fn], _Fn]) r^r_r`rrrbrxryrhrrnrprvrbr]r[r_r_s4;I9;G 6;??I"I.9IADI II6#" %*"14 %+. r]r_ceZdZdZddZy) GenerativezUProvide a method-chaining pattern in conjunction with the @_generative decorator.c6|j}|j}|j|}|rH|jj j Dcic] \}}||vs ||c}}|_|S|jj |_|Scc}}wrq)_memoized_keysrr__dict__copyitems)rZskiprtsrVvs r[rzGenerative._generates""nn KK  "&!3!3!5!;!;!=A$1AJ ++-AJ s  B$BNr)r^r_r`rrrbr]r[r{r{s  r]r{ceZdZdZdZdZy)InPlaceGenerativezkProvide a method-chaining pattern in conjunction with the @_generative decorator that mutates in place.rbcd|j}|D]}|jj|d |Srq)r}r~r)rZrrVs r[rzInPlaceGenerative._generates5"" 'A MM  a & ' r]N)r^r_r`rrrrbr]r[rrs5Ir]rcZeZdZUdZdZded<ejZded<e jZ y)HasCompileStatez=A class that has a :class:`.CompileState` associated with it.Nrx_compile_state_pluginutil.immutabledict[str, Any] _attributes) r^r_r`rrrxr+ EMPTY_DICTrr_rh_compile_state_factoryrbr]r[rrs,G:>7>04K-?)>>r]rc@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.Cs-||D)66s!#)r~tuplesortedrsuper__init_subclass__)rtdict_rs r[rzOptions.__init_subclass__@s;     !#r]c :|jj|yrq)r~rIrs r[rzOptions.__init__Ls R r]c~|jj|j}|jj|jt |j |j r3td|dt |j |j |jj||Sr)rrr~rIrrrrSrs r[rzOptions.__add__Os ^^ # #DNN 3 4==) u: !2!2 3U..t/@/@AC  5! r]ct|j|jD] \}}t||t||k7s yyNFT)rrgetattr)rZrrrs r[__eq__zOptions.__eq__]sH  1 153E3EF DAqtQ75!#44 r]cjjddjfdjDdS)N(, c3bK|]&}|jvr|dj|(yw)=Nr~)rrVrZs r[rz#Options.__repr__..js3 %dmmA./s,/))rr^joinrrYs`r[r\zOptions.__repr__es; NN # # II**   r]ct||Srq) issubclass)rtrks r[ isinstancezOptions.isinstanceqs#u%%r]c*||t|||zizSrq)r)rZrXrs r[add_to_elementzOptions.add_to_elementustWT4058999r]c|jSrqrrYs r[_state_dict_instzOptions._state_dict_instys }}r]r_state_dict_constc|jSrq)r)rts r[ _state_dictzOptions._state_dicts$$$r]c <|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 )rrrrrrS)rtrrLs r[ safe_mergezOptions.safe_merges     u &""E&&'2233C3CD**+66s7G7GH  Qwr]c2|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)rrr,rr+ immutabledict merge_with) rtrattrs exec_optionsstatement_exec_optionscheck_argnamesexisting_optionsresultargnamelocal new_optionss r[from_execution_optionszOptions.from_execution_optionss<++   # #$: ; (++C5 F) Dg l*$0$9F5M 66$:7$CF5M  D+V3K--l;FFk"L , ,$\1 1r]cyrqrbrs r[rzOptions.__getattr__rr]cyrqrbr2s r[rzOptions.__setattr__rr]cyrqrbrs r[rzOptions.__delattr__rr]r)rrrwrrwr)rkz Type[Any]rwr)rXrrrrwr)rwMapping[str, Any])rz 'Options'rwr) rrrzset[str]rrrrrwz#Tuple['Options', Mapping[str, Any]]r!r"r#)r^r_r`rrrxrrrrr\ryrr-rrr+rr classlevelrrrrrrr __classcell__)rs@r[rr9s6I!! $!   &&::7;oo3E  %!%032 3232( 32 !2 32 - 3232j3@4 r]r) metaclasscreZdZdZe ddZej ddZeddZy) CacheableOptionsrbc0tj|||Srq)r!_gen_cache_key)rZrG bindparamss r[_gen_cache_key_instz$CacheableOptions._gen_cache_key_insts))$*EEr]c |dfSrrb)rtrGrs r[rzCacheableOptions._gen_cache_keysRyr]c,tj|Srq)r!_generate_cache_key_for_objectrYs r[_generate_cache_keyz$CacheableOptions._generate_cache_keys99$??r]N)rGrrList[BindParameter[Any]]rwzOptional[Tuple[Any]])rGz 'anon_map'rrrwzTuple[CacheableOptions, Any])rwzOptional[CacheKey]) r^r_r`rr-rrrrrbr]r[rrs~IFF)AF FF ##!/G %$ @@r]rcdeZdZUdZej Zded<dZded<dZ ded <d Z ded <d Z y )ExecutableOptionrbrL _annotationsexecutable_optionr__visit_name__Fr_is_has_cache_keyT_is_corec |jj|j}t|j|_|S)z/Create a shallow copy of this ExecutableOption.)rrr:r~)rZrrs r[rzExecutableOption._clones/ NN " "4>> 2$--( r]N) r^r_r`rr+rrrxrrrrrbr]r[rrs:I-1__L*<-NC-#t#Hdr]rceZdZUdZdZded<ejZded<dZ ded<d Z d ed <d Z d ed <ded<d e jfd ejfdej fgZdZded<dZded<dZded<dZded<dZded<dZded<dZded<er2ded<ddd d+dZ d,dZ d-dZej:d.dZed/d Z e!d0d!Z"e!d1d"Z#e!d2d#Z$e! d3d$Z%e&d%d%d%ddd%d%d%d%ddd%d%d%d%d%dd& d4d'Z'e&d5d(Z'e!d6d)Z'd7d*Z(y)8rwzMark 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_executionrL_execution_optionsF_is_default_generatorrbzTuple[ExecutableOption, ...] _with_optionsz6Tuple[Tuple[Callable[[CompileState], None], Any], ...]_with_context_optionsz9Optional[Union[Type[CacheableOptions], CacheableOptions]]_compile_optionsrf is_selectis_from_statement is_update is_insertis_text is_deleteis_dmlrrN)for_executemanyschema_translate_mapc yrqrb)rZrcompiled_cache column_keysrrrs r[_compile_w_cachezExecutable._compile_w_cache's r]cyrqrbrZ connectiondistilled_paramsexecution_optionss r[_execute_on_connectionz!Executable._execute_on_connection4s !$r]cyrqrbrs r[_execute_on_scalarzExecutable._execute_on_scalar;s r]ctrqrrYs r[_all_selected_columnsz Executable._all_selected_columnsBrr]c|jSrq)rrYs r[rgz#Executable._effective_plugin_targetFs"""r]cP|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|*ywrq)r3expectrExecutableOptionRole)rr s r[rz%Executable.options..hs+$    U77 =$ s.0)rrrZoptionss r[rzExecutable.optionsJs0< e$ $    r]c||_|S)z|Assign the compile options to a new value. :param compile_options: appropriate CacheableOptions structure r)rZcompile_optionss r[_set_compile_optionszExecutable._set_compile_optionsns!0 r]cL|jJ|xj|z c_|S)z*update the _compile_options with new keys.rrs r[_update_compile_optionsz"Executable._update_compile_optionsys,$$000 ( r]c6|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)rZ callable_ cache_argss r[_add_context_optionzExecutable._add_context_options" "" :'>&@@" r].)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 yrqrb)rZrrrrrrr r!rr"r#r$r%r&r'r(r)r s r[rzExecutable.execution_optionss,r]c yrqrb)rZr s r[rzExecutable.execution_optionss58r]c 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 rz'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*r rr,rs r[rzExecutable.execution_optionsshP  "##/  r !##H #'"9"9"?"?"C r]c|jS)zGet the non-SQL options which will take effect during execution. .. versionadded:: 1.3 .. seealso:: :meth:`.Executable.execution_options` )rrYs r[get_execution_optionsz Executable.get_execution_options&s&&&r])rrQrOptional[CompiledCacheType]rz List[str]rrr Optional[SchemaTranslateMapType]rrrwzCTuple[Compiled, Optional[Sequence[BindParameter[Any]]], CacheStats])rrHrrJrrPrwzCursorResult[Any])rrHrrJrrPrwr)rwrEr)rrrwr1)rrrwr1)rrrwr1)rzCallable[[CompileState], None]rrrwr1)&rr/rrrrRrrrrrr%r r%r!r%rr0r"rr#rr$r7r%r6r&rr'rr(rr)rr rrwr1)r rrwr1)rrrwr1)rwrK))r^r_r`rrrxr+rrrrrr'dp_executable_optionsr%dp_with_context_optionsdp_propagate_attrs_executable_traverse_internalsrrrrrrrrrrrrr r\rgrrrrrrrr.rbr]r[rwrwsX $#37??0B"'4'24M/4  PO +AAB # % = =  6IIJ &"It#t#ItItGTItFD%*EI  8  #  " #C     $" $6 $ ;  $   $ " 6  ;      ""$#$##!!F1  $7: *-#$!*-AD"':=,/ #""''4  (   %(? 8* !"#$%& '()* +.88ttl 'r]rwc8eZdZUdZded<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.NrbrZparentrs r[ _set_parentzSchemaEventTarget._set_parent<rr]c |jj|||j|fi||jj||yrq)r7before_parent_attachr;after_parent_attachr9s r[_set_parent_with_dispatchz+SchemaEventTarget._set_parent_with_dispatch?sA **48&2& ))$7r]N)r:r6rrrwr)r^r_r`rrxr;r?rbr]r[r6r62s1,+?8'8/28 8r]r6ceZdZdZy)SchemaVisitablezjBase class for elements that are targets of a :class:`.SchemaVisitor`. .. versionadded:: 2.0.41 N)r^r_r`rrbr]r[rArAGsr]rAc$eZdZUdZddiZded<y) SchemaVisitorz`Define the visiting for ``SchemaItem`` and more generally ``SchemaVisitable`` objects. schema_visitorTrZ__traverse_options__N)r^r_r`rrErxrbr]r[rCrCOs -=d+C.Cr]rCc(eZdZdZdZdZdZdZdZdZ y) _SentinelDefaultCharacterizationnoneunknown clientsidesentinel_default serversideidentitysequenceN) r^r_r`NONEUNKNOWN CLIENTSIDESENTINEL_DEFAULT SERVERSIDEIDENTITYSEQUENCErbr]r[rGrGXs& DGJ)JHHr]rGcZeZdZUdZded<dZded<dZded<ejZ ded <y) _SentinelColumnCharacterizationNzOptional[Sequence[Column[Any]]]columnsFr is_explicit is_autoincrGdefault_characterization) r^r_r`rXrxrYrZrGrOr[rbr]r[rWrWbs7/3G ,3KJ(-->r]rW_COLKEY_COL_coColumnElement[Any]T)rh covariant_COLcPeZdZUdZded< d dZd dZd dZ d dZy) _ColumnMetrics)columnr]rccz||_|j}|r&|jD]}||j|yyrq)rc _proxy_index_expanded_proxy_setadd)rZ collectioncolpieps_cols r[rz_ColumnMetrics.__init__vsE  $ $ 22 &7 % & r]c.|jjSrq)rcrfrYs r[get_expanded_proxy_setz%_ColumnMetrics.get_expanded_proxy_sets{{...r]c|j}|sy|jjD]0}|j|d}|r|j ||+|r.||=2yrq)rercrfrdiscard)rZrhrjricolsets r[disposez_ColumnMetrics.disposesZ  $ $ ;;22 CVVC&Ft$!&sG  r]c|jj}|j|D]}|jt |gryyr)rcrfrrr)rZ target_setexpanded_proxy_setts r[embeddedz_ColumnMetrics.embeddedsL "[[<<&&'9: A%22>1#3FG r]N)rhzColumnCollection[Any, _COL_co]rir]rwrr)rh"ColumnCollection[_COLKEY, _COL_co]rwr)rsz=Union[Set[ColumnElement[Any]], FrozenSet[ColumnElement[Any]]]rwr) r^r_r`rrxrrmrqrvrbr]r[rbrbqsLI O &8 &?F &  &/      r]rbc,eZdZUdZdZded<ded<ded<d ed < d3 d4d Zejd d5dZ d6dZ e d7dZ d8dZ d7dZd9dZd:dZd;dZddZe d?dZ d@dZdAdZdBdZdCdZdDdZed3dEdZedFd Z d3 dGd!ZdHd"ZdId#ZdJd$ZdKd%ZdLd&ZdMd'ZdNd(Z d Z!d)ed*< d6d+Z" d3 dOd,Z#dPd-Z$dQd.Z%dRd/Z&dSd0Z'dTd1Z( dU dVd2Z)y )WColumnCollectionaCollection 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_colsetrez6List[Tuple[_COLKEY, _COL_co, _ColumnMetrics[_COL_co]]]rzz4Dict[Union[None, str, int], Tuple[_COLKEY, _COL_co]]r{z6Dict[ColumnElement[Any], Set[_ColumnMetrics[_COL_co]]]rez Set[_COL_co]r|Nc6tj|dttj|ditj|dtjt j tj|dg|r|j|yy)Nr|r{rerz)rrr collections defaultdictr+ OrderedSet_initial_populate)rZrXs r[rzColumnCollection.__init__sx 4CE242. .+"9"9$//"J  43   " "7 + r]zsqlalchemy.sql.elementsctjj}|j|jt j ddS)NF)_literal_as_text_rolerT)r+r5 sql_elementsr< _all_columnsrColumnsClauseRolerZr4s r[__clause_element__z#ColumnCollection.__clause_element__s?>>.."x""  #("9"9  r]c&|j|yrq_populate_separate_keysrZiter_s r[rz"ColumnCollection._initial_populate's $$U+r]cN|jDcgc]\}}}| c}}Scc}}wrqrzrZrris r[rzColumnCollection._all_columns,s"'+'7'78 C888 !cN|jDcgc]\}}}| c}}Scc}}w)zQReturn a sequence of string key names for all columns in this collection.r)rZrVrs r[keyszColumnCollection.keys0s$$(#3#34iq!Q444rcN|jDcgc]\}}}| c}}Scc}}w)zReturn a sequence of :class:`_sql.ColumnClause` or :class:`_schema.Column` objects for all columns in this collection.rrs r[rzColumnCollection.values5s$(,'7'78 C888rcX|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)rZrVrirs r[rzColumnCollection.items;s+-1,<,<==[aaC===s%c,t|jSrq)rrzrYs r[__bool__zColumnCollection.__bool__DsD$$%%r]c,t|jSrq)rrzrYs r[rzColumnCollection.__len__Gs4##$$r]c `t|jDcgc]\}}}| c}}Scc}}wrq)r.rzrs r[rzColumnCollection.__iter__Js'$*:*:;YQQS;<<;s * cyrqrbrs r[r zColumnCollection.__getitem__Ns.as"-Wc1!#sc3<K|]}j|ywrqr{)rrrZs r[rz/ColumnCollection.__getitem__..fsDWDKK0Dsrr) rrslicerzry as_readonlyr{rrr% IndexError)rZrcolsrs` r[r zColumnCollection.__getitem__[s #u~.c5)151A1A#1FD EDD'-99;;{{3'** #((1+s+ !-36  sA A6$A66 B;?7B66B;cb |j|dS#t$r}t||d}~wwxYw)Nr)r{rAttributeError)rZrrs r[rzColumnCollection.__getattr__qs8 /;;s#A& & / %3 . /s . ).cl||jvr&t|tstjdyy)Nz'__contains__ requires a string argumentFT)r{rrr*r rs r[ __contains__zColumnCollection.__contains__ws6 dkk !c3'''=r]c8t||D] \}}||us yy)zdCompare this :class:`_expression.ColumnCollection` to another based on the names of the keysFTr)rZrlrs r[comparezColumnCollection.compares- e, DAqz r]c$|j|Srq)r)rZrs r[rzColumnCollection.__eq__s||E""r]cyrqrbrZrrus r[rzColumnCollection.getsHKr]cyrqrbrs r[rzColumnCollection.getsDGr]cF||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 r[rzColumnCollection.gets) $++ ;;s#A& &Nr]cf|jjddjd|DdS)Nrrc32K|]}t|ywrq)r)rrs r[rz+ColumnCollection.__str__..s+c!f+sr)rr^rrYs r[__str__zColumnCollection.__str__s+ NN # # II+d+ +  r]ctrqrr2s r[rzColumnCollection.__setitem__ !##r]ctrqrrs r[rzColumnCollection.__delitem__rr]ctrqr)rZrrs r[rzColumnCollection.__setattr__rr]ct)zQDictionary clear() is not implemented for :class:`_sql.ColumnCollection`.rrYs r[clearzColumnCollection.clear "##r]ctrqr)rZrcs r[removezColumnCollection.removerr]ct)zRDictionary update() is not implemented for :class:`_sql.ColumnCollection`.rrs r[rIzColumnCollection.updaterr]z Optional[int]__hash__c |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|]\}}}|jywrq _deannotate)rrrs r[rz;ColumnCollection._populate_separate_keys..sF1aAMMOF )rbrzr|rIr{ enumeraterJ)rZrrVrrhidxrris r[rz(ColumnCollection._populate_separate_keyss 9>, 041Q>$* +,  j F:FF /8/D E E^S)1aS1a&[ E  *9MNNIAsAA3xKNO, 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) rrrzr r]appendrbr|rgrr{)rZrcrcolkeyr_columns r[rgzColumnCollection.adds ;ZZFF   ! w'  WnT7; <  ,,./ '* A  $#)7"3DKK  %r]cr|jDcgc] \}}}||f c}}}|jdScc}}}w)Nrzr{r)rZrVrrs r[ __getstate__zColumnCollection.__getstate__s7262B2BCCwq!QQFCkk  Cs2ctj|d|dtj|dtjtj tj|d|dDcgc]\}}||t ||fc}}tj|d|jDchc]\}}}| c}}}ycc}}wcc}}}w)Nr{rerzr|)rrr~rr+rrbrz)rZstaterVrrirs r[ __setstate__zColumnCollection.__setstate__s45?; .+"9"9$//"J    $M2 QA~dA./    )43C3CDDiaacD   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)r|rrr*r rZris r[contains_columnz ColumnCollection.contains_columns8 dll "#s#'';r]ct|S)zIReturn a "read only" form of this :class:`_sql.ColumnCollection`.)ReadOnlyColumnCollectionrYs r[rzColumnCollection.as_readonlys(--r]c|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)rerzrcrfrg)rZrjrmetricsepsrks r[_init_proxy_indexz"ColumnCollection._init_proxy_indexs^    !-- )MAq'..44C )7 ( ) )r]c 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]}|ywrqrb)rtsmmrjs r[rz8ColumnCollection.corresponding_column..bs2 rRx"R& 46B  s Nweightr)r|rrerrvrrcrfrr_uncached_proxy_listshares_lineagerr) rZrcrequire_embeddedselected_intersectionselected_metricsrscurrent_metricscurrent_intersectionscselected_col_distancecurrent_col_distancerjs @r[corresponding_columnz%ColumnCollection.corresponding_column4sH T\\ !M2<//%%     " " $ # 8 EO$'?'? 'K#+'6$'1'>'>#**>>($)0,6,C,C(//CC-)+,s3H/II (7$,@))-BB-0!1 7 7 L L N " "008 OO//!<-),/!0 6 6 K K M " "008 OO//!<,(,.CC+:(0D-q8 Et+;&&DD+s 84F- 4F2 rq)rXz+Optional[Iterable[Tuple[_COLKEY, _COL_co]]])rwr<)rz!Iterable[Tuple[_COLKEY, _COL_co]]rwr)rwz List[_COL_co])rwz List[_COLKEY])rwzList[Tuple[_COLKEY, _COL_co]])rwrr$)rwzIterator[_COL_co])rzUnion[str, int]rwr])rzTuple[Union[str, int], ...]rw*ReadOnlyColumnCollection[_COLKEY, _COL_co])rrrwr)rz3Union[str, int, slice, Tuple[Union[str, int], ...]]rwz:Union[ReadOnlyColumnCollection[_COLKEY, _COL_co], _COL_co])rrrwr])rrrwr)rrwrwr)rrrwr)rrrurrwzOptional[_COL_co])rrrur`rwzUnion[_COL_co, _COL])rrruzOptional[_COL]rwzOptional[Union[_COL_co, _COL]]r)rrrrrwr)rrrwr)rrrrrwr)rwr)rcrrwr)rrrwr)rcr^rzOptional[_COLKEY]rwr)rwrZrrZrwr)rir^rwr)rwrr)F)rcr`rrrwzOptional[Union[_COL, _COL_co]])*r^r_r`rrrxrr+preload_modulerrr\rrrrrrrrr rrrrrrrrrrrrIrrrgrrrrrrrbr]r[ryrysjXEIGG @@HH FJ ,B ,T23 4 ,6, , 995 9 >&%=?? 9.9 39999 399F C,/ #KK GG37  !/  '  $$$$ $$ #Hm" P6 P  PDH"4("4/@"4 "4H  " . )66;hEhE.2hE 'hEr]ry _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) rr*r r{replacer+r]reset_append_new_column)rZrcrexistings r[rgzDedupeColumnCollection.adds ?vzzS0##- jj ;##?  $++ {{3'*H6! LL  " " ( ( =  # #C 0r]ct|j}|jj||t||f|jj |j ||f|j|<||f|j|<yrq)rrzrrbr|rgrr{)rZr named_columnrs r[rz)DedupeColumnCollection._append_new_columnsy   !  ,t\ B C  1134|, A. Cr]c 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|]\}}}|jywrqr)rrVrrs r[rzADedupeColumnCollection._populate_separate_keys..sN AqAMMONrc36K|]\}\}}}|||ffywrqrb)rrrVrrs r[rzADedupeColumnCollection._populate_separate_keys..s' ,c9Aq!S1a&M sN) listrr*r rXr{rrzrbr|rIrr)rZrr replace_colrVris r[rz.DedupeColumnCollection._populate_separate_keyss1E{  MFAsww!|''1xx4;;&377chh+>""3'DKK'""3'"#S A  ''Cc1J(KL M NT=M=MNN  09$:J:J0K   C LL  r]c4|jd|Dy)Nc38K|]}|j|fywrq)r)rris r[rz0DedupeColumnCollection.extend..s$Ecggs^$Esrrs r[extendzDedupeColumnCollection.extends $$$Eu$EEr]c 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 collectionrb) r|rr{rrrzrerrqrIrr)rZrcrVrrrrirs r[rzDedupeColumnCollection.removes$  %J  KK # F#$(#3#3  Aw7O  ((,,VR8 "G OOD ! " 3,>?4:+<+<=4 0F0FG41H1HIr]cd|jiSNr r rYs r[rz%ReadOnlyColumnCollection.__getstate__]s4<<((r]c0|d}|j|yr)r)rZrr:s r[rz%ReadOnlyColumnCollection.__setstate__`sy! fr]c$|jyrq _readonly)rZrcrs r[rgzReadOnlyColumnCollection.addd  r]c$|jyrqrrs r[rzReadOnlyColumnCollection.extendgrr]c$|jyrqr)rZitems r[rzReadOnlyColumnCollection.removejrr]N)rhrw)rwzDict[str, _COL_co]r).)rcrrrrwr)r4rrwr)rrrwr) r^r_r`rrrrrgrrrbr]r[rrQs(IJ)r]rc*eZdZddZddZdZddZy) ColumnSetc ||vSrqrbrs r[rzColumnSet.contains_columnos d{r]c4|D]}|j|yrq)rg)rZrris r[rzColumnSet.extendrs C HHSM r]cg}|D]/}|D](}|j|s|j||k(*1tj|Srq)rrr4and_)rZrrrrs r[rzColumnSet.__eq__vsT  )A )##E*HHQ%Z( ) )}}a  r]c8ttd|DS)Nc3 K|]}|ywrqrb)rrs r[rz%ColumnSet.__hash__..s*!*s )hashrrYs r[rzColumnSet.__hash__~sE*T**++r]N)riColumnClause[Any]rwr)rz Iterable[Any]rwrr$)r^r_r`rrrrrbr]r[rrns!,r]rr"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 rrrr iterater&r)entityrs r[_entity_namespacer&se'0AAA $$T*?%HI D'-,,,   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)r&rarrr*r)r%rrunsrs r[_entity_namespace_keyr*sc  v & & 2sG, ,2s# # %%@F L  s. . AAA)rrrwzTypeGuard[_HasEntityNamespace])r4zEUnion[ColumnElement[Any], FromClause, TextClause, _JoinTargetElement]rwzIterator[FromClause])r4z!Iterable[roles.ColumnsClauseRole]rwrE)rrirwri)rrrrrwry)r4Iterable[_CLE]rwr+)rr+rr+rwz Set[_CLE])rrrwzOptional[Dict[Any, Any]])r%1Union[_HasEntityNamespace, ExternallyTraversible]rwr})r%r,rrruz%Union[SQLCoreOperations[Any], _NoArg]rwr)r __future__rr~enumrrrrrQr.rrr r r r r rrrrrrrrrrrrrrrrrr cache_keyr!r" traversalsr#r$r%r&r'r)r*r+r,r- compat_typing util.typingr/r0r1r2r3r4r5 _orm_typesr6r7_typingr8r9rir:r;r<r=r>r?r@rAschemarBrC selectablerDrErFrGenginerHrIengine.interfacesrJrKrLrMrNrOrPrQrRrSrTrVrarxrdrerfrgrir_AmbiguousTableNameMaprkrr{r}rrrrrrrrrrrrrrrrrr'rr<r r_r{rrtyperrrr StatementRolerw EventTargetr6 VisitablerArCrGrWr\r]r`rbryrrReadOnlyContainerrrrr&r*rbr]r[r@s9#! ! "*(#/+'-*"#/6#%'$&'%+$(.+&"#%;3<.,5?+2:"IHH%T% II '' E' T e8CH-.'S1 z 42E1D1D2. CxC8(8 0 s#  @ <  /  3;LM%m,,%0: ??? N8 nS#X.8 v$nS#X.$@*+1,1lClC^iiX$  ?j?545B_5 _5D@w @('$n'$$n'b 8))8*'););DMDtj )U49-s 3 )#74 Hv12)WW%)XEww/0ED K'9 : lN-c9n=lN^,Wg-=>:, 34,( =,6< = 3 r]