
    -h[                         S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SrSrSr\R*                  " S5      r\R*                  " S5      r " S S\5      r " S S\5      rS rS rS rS rS rS r S r!S r" " S S \RF                  RH                  5      r% " S! S"\RF                  RH                  5      r&\RN                  " S#5      S$ 5       r( " S% S&\5      r) " S' S(\5      r* " S) S*\5      r+ " S+ S,\5      r, " S- S.\+5      r- " S/ S0\.5      r/ " S1 S2\R`                  " \/5      5      r1 " S3 S4\1\5      r2 " S5 S6\	5      r3 " S7 S8\Rh                  \+5      r5 " S9 S:\65      r7 " S; S<\5      r8 " S= S>\5      r9 " S? S@\5      r: " SA SB\:5      r; " SC SD\Rx                  \:5      r= " SE SF\R|                  5      r?SJSG jr@SH rA\4SI jrBg)Kz4Foundational utilities common to many sql modules.

    N   )roles)visitors)HasCacheKey)HasCopyInternals)MemoizedHasCacheKey)ClauseVisitor)ExtendedInternalTraversal)InternalTraversal   )exc)util)HasMemoized)hybridmethodPARSE_AUTOCOMMITNO_ARGc                   4    \ rS rSrSrSrS rS rS rS r	Sr
g	)
	Immutable'   z@mark a ClauseElement as 'immutable' when expressions are cloned.Tc                     [        S5      eNz(Immutable objects do not support copyingNotImplementedErrorselfoptionaldictkwargss      hC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/sql/base.pyunique_paramsImmutable.unique_params,       !"LMM    c                     [        S5      er   r   r   s      r   paramsImmutable.params/   r!   r"   c                     U $ N r   kws     r   _cloneImmutable._clone2   s    r"   c                     g r'   r(   r)   s     r   _copy_internalsImmutable._copy_internals5   s    r"   r(   N)__name__
__module____qualname____firstlineno____doc___is_immutabler   r$   r+   r.   __static_attributes__r(   r"   r   r   r   '   s     JMNNr"   r   c                   2    \ rS rSrSrSrS r\S 5       rSr	g)SingletonConstant9   z.Represent SQL constants like NULL, TRUE, FALSETc                     U R                   $ r'   )
_singleton)clsargr*   s      r   __new__SingletonConstant.__new__>   s    ~~r"   c                 |    [         R                  U 5      nUR                  5         [        U/5      Ul        Xl        g r'   )objectr>   __init__	frozenset	proxy_setr;   )r<   objs     r   _create_singleton#SingletonConstant._create_singletonA   s.    nnS! "3%(r"   r(   N)
r0   r1   r2   r3   r4   _is_singleton_constantr>   classmethodrF   r6   r(   r"   r   r8   r8   9   s$    8!  r"   r8   c                  ~    [         R                  R                  U  Vs/ s H  oR                  PM     sn5      $ s  snf r'   )	itertoolschainfrom_iterable_from_objects)elementselements     r   rN   rN   Q   s2    ??((.67h7		h7 7   :c                 ~    [         R                  R                  U  Vs/ s H  oR                  PM     sn5      $ s  snf )zPexpand tables into individual columns in the
given list of column expressions.

)rK   rL   rM   _select_iterable)rO   cs     r   _select_iterablesrU   W   s4    
 ??((%-.X		X. .rQ   c                 N    [         R                  S 5       nU" U 5      nXl        U$ )znon-caching _generative() decorator.

This is basically the legacy decorator that copies the object and
runs a method on the new copy.

c                 R    UR                  5       nU " U/UQ70 UD6nUb   S5       eU$ )zMark a method as generative.z,generative methods must have no return value)	_generate)fnr   argsr*   xs        r   _generative _generative.<locals>._generativei   s9     ~~t!d!b!yHHHyr"   )r   	decoratornon_generative)rY   r\   	decorateds      r   r\   r\   a   s1     
^^  BI!r"   c            	        ^^ UR                  S0 5      mUR                  S0 5      nU  Vs/ s H,  nU[        R                  " U5      UR                  US 5      4PM.     snm[        R
                  UU4S j5       nU$ s  snf )Nmsgsdefaultsc           	         > US   nUSS  nT HV  u  pEnU" U5      ULd  M  T	R                  USU R                  < SUR                  < S35      n[        R                  " U5      e   U " U/UQ70 UD6$ )Nr   r   zMethod z$() has already been invoked on this z
 construct)getr0   	__class__r   InvalidRequestError)
rY   rZ   r*   r   namegetterdefault_msggettersrb   s
           r   check!_exclusive_against.<locals>.check   s     AwABx&-"D(d|8+hh{{DNN4
 --c22 '. $$$$$r"   )popoperator
attrgetterre   r   r^   )namesr*   rc   rh   rm   rl   rb   s        @@r   _exclusive_againstrs   w   s    66&"Dvvj"%H D 
x""4((,,tT*BCG
 
^^% % L+s   3A=c                 &    U R                   " S0 UD6$ Nr(   )r+   )rP   r*   s     r   r+   r+      s    >>Br"   c                 f    [         R                  " U  Vs/ s H  oR                  PM     sn6 $ s  snf )zTexpand the given set of ClauseElements to be the set of all 'cloned'
predecessors.

)rK   rL   _cloned_set)rO   r[   s     r   _expand_clonedrx      s'    
 ??H=Hq]]H=>>=s   .c                    ^ [        [        U 5      5      R                  [        U5      5      m[        U4S jU  5       5      $ )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'.

c              3   l   >#    U  H)  nTR                  UR                  5      (       d  M%  Uv   M+     g 7fr'   intersectionrw   .0elemall_overlaps     r   	<genexpr>'_cloned_intersection.<locals>.<genexpr>   s)      k66t7G7GH   $4	4setrx   r|   abr   s     @r   _cloned_intersectionr      s>     nQ'(55nQ6GHK   r"   c                    ^ [        [        U 5      5      R                  [        U5      5      m[        U4S jU  5       5      $ )Nc              3   l   >#    U  H)  nTR                  UR                  5      (       a  M%  Uv   M+     g 7fr'   r{   r}   s     r   r   %_cloned_difference.<locals>.<genexpr>   s)      +":":4;K;K"Lr   r   r   s     @r   _cloned_differencer      s<    nQ'(55nQ6GHK   r"   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)_DialectArgView   zYA dictionary view of dialect-level arguments in the form
<dialectname>_<argument_name>.

c                     Xl         g r'   rE   )r   rE   s     r   rB   _DialectArgView.__init__   s    r"   c                      UR                  SS5      u  p#X#4$ ! [         a(  n[        R                  " [	        U5      US9   S nAg S nAff = f)N_r   replace_context)split
ValueErrorr   raise_KeyError)r   keydialect	value_keyerrs        r   _key_DialectArgView._key   sI    	&!$3!2G %%  	<KKs;	<s    
AAAc                     U R                  U5      u  p# U R                  R                  U   nXC   $ ! [        R                   a(  n[
        R                  " [        U5      US9   S nAg S nAff = fNr   )r   rE   dialect_optionsr   NoSuchModuleErrorr   r   r   )r   r   r   r   optr   s         r   __getitem___DialectArgView.__getitem__   s_    !YYs^	"((**73C >! $$ 	<KKs;	<s   2 A.A))A.c                      U R                  U5      u  p4X R                  R                  U   U'   g ! [         a3  n[        R
                  " [        R                  " S5      US9   S nAg S nAff = f)Nz0Keys must be of the form <dialectname>_<argname>r   )r   rE   r   r   r   r   r   ArgumentError)r   r   valuer   r   r   s         r   __setitem___DialectArgView.__setitem__   sf    
	A!%3G <AHH$$W-i8  	KK!!F !$		s   1 
A.)A))A.c                 ^    U R                  U5      u  p#U R                  R                  U   U	 g r'   )r   rE   r   )r   r   r   r   s       r   __delitem___DialectArgView.__delitem__   s)    !YYs^HH$$W-i8r"   c                 j    [        S U R                  R                  R                  5        5       5      $ )Nc              3   L   #    U  H  n[        UR                  5      v   M     g 7fr'   )len_non_defaults)r~   rZ   s     r   r   *_DialectArgView.__len__.<locals>.<genexpr>   s%      
9 ""##9s   "$)sumrE   r   valuesr   s    r   __len___DialectArgView.__len__   s/     
00779
 
 	
r"   c                 D   ^  U 4S jT R                   R                   5       $ )Nc              3      >#    U  H9  nTR                   R                  U   R                    H  nU< S U< 3v   M     M;     g7f)r   N)rE   r   r   )r~   dialect_name
value_namer   s      r   r   +_DialectArgView.__iter__.<locals>.<genexpr>   sH      
 8"hh66m
 $Z0 1 8s   AA)rE   r   r   s   `r   __iter___DialectArgView.__iter__   s    
 $ 8 8
 	
r"   r   N)r0   r1   r2   r3   r4   rB   r   r   r   r   r   r   r6   r(   r"   r   r   r      s+    
&"A9

r"   r   c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)_DialectArgDict   zA dictionary view of dialect-level arguments for a specific
dialect.

Maintains a separate collection of user-specified arguments
and dialect-specified default arguments.

c                      0 U l         0 U l        g r'   r   	_defaultsr   s    r   rB   _DialectArgDict.__init__   s    r"   c                 p    [        [        U R                  5      R                  U R                  5      5      $ r'   )r   r   r   unionr   r   s    r   r   _DialectArgDict.__len__   s'    3t))*00@AAr"   c                 p    [        [        U R                  5      R                  U R                  5      5      $ r'   )iterr   r   r   r   r   s    r   r   _DialectArgDict.__iter__   s'    C**+11$..ABBr"   c                 \    XR                   ;   a  U R                   U   $ U R                  U   $ r'   r   r   r   s     r   r   _DialectArgDict.__getitem__  s.    $$$%%c**>>#&&r"   c                      X R                   U'   g r'   r   r   r   r   s      r   r   _DialectArgDict.__setitem__	  s    "'3r"   c                     U R                   U	 g r'   r   r   s     r   r   _DialectArgDict.__delitem__  s    s#r"   )r   r   N)r0   r1   r2   r3   r4   rB   r   r   r   r   r   r6   r(   r"   r   r   r      s'    BC'($r"   r   zsqlalchemy.dialectsc                     [         R                  R                  R                  R	                  U 5      nUR
                  c  g [        UR
                  5      $ r'   )r   	preloadeddialectsregistryloadconstruct_argumentsdict)r   dialect_clss     r   _kw_reg_for_dialectr     sB    ..))2277EK&&.//00r"   c                       \ rS rSrSrS\R                  4/r\S 5       r	\
R                  S 5       r\S 5       r\
R                  " \5      rS r\
R                  S 5       rS	 rS
rg)DialectKWArgsi  a!  Establish 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   c                     [         R                  U   nUc  [        R                  " SU-  5      eX;  a  0 X@'   X4U    U'   g)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.

.. versionadded:: 0.9.4

NzRDialect '%s' does have keyword-argument validation and defaults enabled configured)r   _kw_registryr   r   )r<   r   argument_namedefaultconstruct_arg_dictionarys        r   argument_forDialectKWArgs.argument_for)  s[    P $1#=#=l#K #+##=?KL  .,.$)7>%m4r"   c                     [        U 5      $ )a  A collection of keyword arguments specified as dialect-specific
options to this construct.

The arguments are present here in their original ``<dialect>_<kwarg>``
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 ``<dialect>_<kwarg>`` where the value will be assembled
into the list of options.

.. versionadded:: 0.9.2

.. versionchanged:: 0.9.4 The :attr:`.DialectKWArgs.dialect_kwargs`
   collection is now writable.

.. seealso::

    :attr:`.DialectKWArgs.dialect_options` - nested dictionary form

)r   r   s    r   dialect_kwargsDialectKWArgs.dialect_kwargs[  s    0 t$$r"   c                     U R                   $ )z4A synonym for :attr:`.DialectKWArgs.dialect_kwargs`.)r   r   s    r   r   DialectKWArgs.kwargsu  s     """r"   c                    [         R                  U   n[        5       nUc  UR                  R	                  SS 05        U$ [        U R                  R                  5       H'  nXB;   d  M
  UR                  R	                  X$   5        M)     U$ )N*)r   r   r   r   updatereversedrf   __mro__)r   r   r   dr<   s        r   _kw_reg_for_dialect_cls%DialectKWArgs._kw_reg_for_dialect_cls|  s|    #0#=#=l#K #+KKT{+
    6 672KK&&'?'DE 8 r"   c                 j    [         R                  " [         R                  " U R                  5      5      $ )a  A collection of keyword arguments specified as dialect-specific
options to this construct.

This is a two-level nested registry, keyed to ``<dialect_name>``
and ``<argument_name>``.  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   PopulateDictportable_instancemethodr   r   s    r   r   DialectKWArgs.dialect_options  s+    &   (()E)EF
 	
r"   c           	      B   U(       d  g U H  n[         R                  " SU5      nU(       d  [        SU-  5      eUR                  SS5      u  pE U R                  U   nSU;  a1  XV;  a,  [
        R                  " SU< SU< SU R                  < 35      eX   Xe'   M     g ! [
        R                   aj    [        R                  " S	U< S
U< 35        [        5       =U R                  U'   nUR                  R                  SS 05        X   UR                  U'    GM  f = f)Nz^(.+?)_(.+)$zGAdditional arguments should be named <dialectname>_<argument>, got '%s'r   r   r   z	Argument z is not accepted by dialect z on behalf of zCan't validate argument z,; can't locate any SQLAlchemy dialect named )rematch	TypeErrorgroupr   r   r   rf   r   r   warnr   r   r   r   )r   r   kmr   arg_namer   r   s           r   _validate_dialect_kwargs&DialectKWArgs._validate_dialect_kwargs  s!    A+A?ABC  &'WWQ]"LC+/+?+?+M( 77 @++ lDNN<  :@,6?  (( 6		 ,(
 :I9JJ$$\2Q""C;/,2I)6s   B  A9DDr(   N)r0   r1   r2   r3   r4   r   dp_dialect_options"_dialect_kwargs_traverse_internalsrI   r   r   memoized_propertyr   propertyr   r   r   r   r   r   r  r6   r(   r"   r   r   r     s    
 
-@@A*& /? /?b 
% %2 # # $$%89L
 

 
,%Cr"   r   c                   f    \ rS rSrSrSr0 r\S 5       rS r	\S 5       r
\S 5       r\S 5       rSrg	)
CompileStatei  a  Produces 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

	statementc                 ^   UR                   (       ab  UR                   R                  SS5      nU R                  R                  XAR                  4S 5      nUc  U R                  SUR                  4   nOU R                  SUR                  4   nXPL a	  U " X40 UD6$ UR                  " X40 UD6$ Ncompile_state_pluginr   )_propagate_attrsre   plugins_effective_plugin_targetcreate_for_statement)r<   r  compilerr*   plugin_nameklasss         r   r  !CompileState.create_for_statement  s     %%#4488&	K KKOO@@A4E }	 B BC
 KKI>>?E <y1b11--iHRHHr"   c                     Xl         g r'   r  )r   r  r  r*   s       r   rB   CompileState.__init__   s    "r"   c                     UR                   R                  SS 5      nU(       a+  X!R                  4nX0R                  ;   a  U R                  U   $  U R                  SUR                  4   $ ! [         a     g f = fr  )r  re   r  r  r   )r<   r  r  r   s       r   get_plugin_classCompileState.get_plugin_class  sz    0044"D
  B BCCkk!{{3''	;;	9+M+MNOO 		s   A+ +
A87A8c                 X     U R                   X!R                  4   $ ! [         a     g f = fr'   )r  r  r   )r<   r  r  s      r   _get_plugin_class_for_plugin)CompileState._get_plugin_class_for_plugin  s8    	;;@@A   		s    
))c                    ^ ^^ U UU4S jnU$ )Nc                 *   > U TR                   TT4'   U $ r'   )r  )cls_to_decorater<   r  
visit_names    r   decorate)CompileState.plugin_for.<locals>.decorate"  s    5DCKKj12""r"   r(   )r<   r  r$  r%  s   ``` r   
plugin_forCompileState.plugin_for   s    	# r"   N)r0   r1   r2   r3   r4   	__slots__r  rI   r  rB   r  r  r'  r6   r(   r"   r   r  r    sh    4 IGI I2#  &    r"   r  c                       \ rS rSrSrS rSrg)
Generativei)  zQProvide a method-chaining pattern in conjunction with the
@_generative decorator.c                 F   U R                   nU R                  nUR                  U5      nU(       aK  U R                  R	                  5       R                  5        VVs0 s H  u  pEXA;  d  M  XE_M     snnUl        U$ U R                  R	                  5       Ul        U$ s  snnf r'   )_memoized_keysrf   r>   __dict__copyitems)r   skipr<   sr  vs         r   rX   Generative._generate-  s    ""nnKK "&!3!3!5!;!;!=!=!=AJ
  ++-AJs   B+Br(   Nr0   r1   r2   r3   r4   rX   r6   r(   r"   r   r+  r+  )  s    r"   r+  c                       \ rS rSrSrS rSrg)InPlaceGenerativei;  zgProvide a method-chaining pattern in conjunction with the
@_generative decorator that mutates in place.c                 h    U R                   nU H  nU R                  R                  US 5        M!     U $ r'   )r-  r.  ro   )r   r1  r  s      r   rX   InPlaceGenerative._generate?  s0    ""AMMa& r"   r(   Nr5  r(   r"   r   r7  r7  ;  s    5r"   r7  c                   V    \ rS rSrSrSr\R                  " 5       r\	R                  rSrg)HasCompileStateiF  z=A class that has a :class:`.CompileState` associated with it.Nr(   )r0   r1   r2   r3   r4   _compile_state_pluginr   immutabledict_attributesr  r  _compile_state_factoryr6   r(   r"   r   r;  r;  F  s%    G $$&K)>>r"   r;  c                   $    \ rS rSrSrS rS rSrg)_MetaOptionsiP  z metaclass for the Options class.c                 p    [        [        S U 5       5      5      U l        [        R	                  XX#5        g )Nc              3   f   #    U  H'  nUR                  S 5      (       a  M  US;  d  M#  Uv   M)     g7f)__)_cache_key_traversalN)
startswith)r~   r   s     r   r   (_MetaOptions.__init__.<locals>.<genexpr>U  s5      A||D)  66 s   11	1)tuplesorted_cache_attrstyperB   )r<   	classnamebasesdict_s       r   rB   _MetaOptions.__init__S  s4       
 	ce3r"   c                    U " 5       n[        U5      R                  U R                  5      (       a5  [        SU < S[        U5      R                  U R                  5      < 35      eUR                  R                  U5        U$ Nz<dictionary contains attributes not covered by Options class z: )r   
differencerJ  r   r.  r   r   othero1s      r   __add___MetaOptions.__add__^  sl    Vu:  !2!233 U..t/@/@AC  	5!	r"   r(   N)r0   r1   r2   r3   r4   rB   rV  r6   r(   r"   r   rA  rA  P  s    *	4r"   rA  c                       \ rS rSrSrS rS rS rS r\	S 5       r
\S 5       r\S	 5       r\R                  " 5       r\R"                  S
 5       r\	S 5       r\	S 5       rSrg)Optionsil  z,A cacheable option dictionary with defaults.c                 :    U R                   R                  U5        g r'   )r.  r   r)   s     r   rB   Options.__init__o  s    R r"   c                    U R                   R                  U R                   5      nUR                  R                  U R                  5        [	        U5      R                  U R                  5      (       a5  [        SU < S[	        U5      R                  U R                  5      < 35      eUR                  R                  U5        U$ rQ  )rf   r>   r.  r   r   rR  rJ  r   rS  s      r   rV  Options.__add__r  s    ^^##DNN3
4==)u:  !2!233 U..t/@/@AC  	5!	r"   c                     [         R                  " U R                  UR                  5       H  u  p#[        X5      [        X5      :w  d  M    g   gNFT)r   zip_longestrJ  getattr)r   rT  r   r   s       r   __eq__Options.__eq__  sD     $$T%6%68J8JKDAt75#44 L r"   c                    ^  T R                   R                  < SSR                  U 4S jT R                   5       5      < S3$ )N(, c              3   t   >#    U  H-  nUTR                   ;   d  M  U< S TR                   U   < 3v   M/     g7f)=Nr.  )r~   r  r   s     r   r   #Options.__repr__.<locals>.<genexpr>  s4      *A% 01dmmA./*s   88))rf   r0   joinrJ  r   s   `r   __repr__Options.__repr__  s;     NN##II ** 
 	
r"   c                     [        X5      $ r'   )
issubclass)r<   r  s     r   
isinstanceOptions.isinstance  s    #%%r"   c                 &    X[        X5      U-   0-   $ r'   )ra  )r   rh   r   s      r   add_to_elementOptions.add_to_element  s    WT058999r"   c                     U R                   $ r'   ri  r   s    r   _state_dictOptions._state_dict  s    }}r"   c                     U R                   $ r'   )_state_dict_const)r<   s    r   rw  rx    s    $$$r"   c           
      T   UR                  5       nXR                  La  UR                  (       av  [        UR                  5      R	                  U R                  5      (       aC  [        SU< SU < S[        UR                  5      R	                  U R                  5      < 35      eX-   $ )Nzother element z is not empty, is not of type z+, and contains attributes not covered here )rw  rf   rJ  r   rR  r   )r<   rT  r   s      r   
safe_mergeOptions.safe_merge  s     &""E&&'2233C3CDD **+66s7G7GH  wr"   c                 8   UR                  [        U5      R                  U5      5      nUR                  X5      nU(       aW  0 nU H"  nSU-   n	X;   a  X8   Xy'   M  X;   d  M  XH   Xy'   M$     Xg-   n
[        R
                  " 5       R                  X1U
05      nX4$ Xc4$ )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   )r|   r   r   re   r   r=  
merge_with)r<   r   attrsexec_optionsstatement_exec_optionscheck_argnamesexisting_optionsresultargnamelocalnew_optionss              r   from_execution_optionsOptions.from_execution_options  s    < ++##$:;
 (++C5F)g*$0$9FM6$:$CFM * +3K--/::K0L ,, $11r"   r(   N)r0   r1   r2   r3   r4   rB   rV  rb  rm  rI   rq  r   rt  rw  r   r=  rz  
classlevelr|  r  r6   r(   r"   r   rY  rY  l  s    6!

 & & : :   **,% %  0 32 32r"   rY  c                   X    \ rS rSr\S 5       r\R                  S 5       r\S 5       rSrg)CacheableOptionsi  c                 0    [         R                  " XU5      $ r'   )r   _gen_cache_key)r   anon_map
bindparamss      r   r  CacheableOptions._gen_cache_key  s    ))$*EEr"   c                 
    U S4$ ru   r(   )r<   r  r  s      r   r  r    s    Ryr"   c                 .    [         R                  " U 5      $ r'   )r   _generate_cache_key_for_objectr   s    r   _generate_cache_key$CacheableOptions._generate_cache_key  s    99$??r"   r(   N)	r0   r1   r2   r3   r   r  r  r  r6   r(   r"   r   r  r    sF    F F   @ @r"   r  c                   :    \ rS rSr\R
                  rSrSrS r	Sr
g)ExecutableOptioni  executable_optionFc                     U R                   R                  U R                   5      n[        U R                  5      Ul        U$ )z/Create a shallow copy of this ExecutableOption.)rf   r>   r   r.  )r   r*   rT   s      r   r+   ExecutableOption._clone  s/    NN""4>>2$--(
r"   r(   N)r0   r1   r2   r3   r   
EMPTY_DICT_annotations__visit_name___is_has_cache_keyr+   r6   r(   r"   r   r  r    s    ??L(Nr"   r  c                      \ rS rSrSrSr\R                  " 5       rSr	Sr
SrS\R                  4S\R                  4S\R                   4/rS	rS	rS	rS	rS	rS	r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rS r \RB                  " SSS9S 5       r"\RB                  " SSS9S 5       r#\\RB                  " SSS	S9S 5       5       r$Sr%g)
Executablei  zMark 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`.

TNr(   _with_options_with_context_optionsr  Fc                     U R                   $ r'   )r  r   s    r   r  #Executable._effective_plugin_target1  s    """r"   c                 N    U =R                   [        S U 5       5      -  sl         g)a  Apply 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:`.Generative.options` to
   Core statement objects towards the goal of allowing unified
   Core / ORM querying capabilities.

.. seealso::

    :ref:`deferred_options` - refers to options specific to the usage
    of ORM queries

    :ref:`relationship_loader_options` - refers to options specific
    to the usage of ORM queries

c              3   j   #    U  H)  n[         R                  [        R                  U5      v   M+     g 7fr'   )	coercionsexpectr   ExecutableOptionRole)r~   r   s     r   r   %Executable.options.<locals>.<genexpr>S  s-      $
 U77==s   13N)r  rH  r   optionss     r   r  Executable.options5  s)    < 	e $
$
 
 	
r"   c                     Xl         g)zlAssign the compile options to a new value.

:param compile_options: appropriate CacheableOptions structure

N_compile_options)r   compile_optionss     r   _set_compile_optionsExecutable._set_compile_optionsX  s
     !0r"   c                 .    U =R                   U-  sl         g)z*update the _compile_options with new keys.Nr  r  s     r   _update_compile_options"Executable._update_compile_optionsb  s     	(r"   c                 2    U =R                   X44-  sl         g)a  Add 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.

N)r  )r   	callable_
cache_argss      r   _add_context_optionExecutable._add_context_optionh  s     	""	'>&@@"r"   c                     SU;   a  [         R                  " S5      eSU;   a  [         R                  " S5      eU R                  R                  U5      U l        g)a  Set non-SQL options for the statement which take effect during
execution.

Execution options can be set on a per-statement or
per :class:`_engine.Connection` basis.   Additionally, the
:class:`_engine.Engine` and ORM :class:`~.orm.query.Query`
objects provide
access to execution options which they in turn configure upon
connections.

The :meth:`execution_options` method is generative.  A new
instance of this statement is returned that contains the options::

    statement = select(table.c.x, table.c.y)
    statement = statement.execution_options(autocommit=True)

Note that only a subset of possible execution options can be applied
to a statement - these include "autocommit" and "stream_results",
but not "isolation_level" or "compiled_cache".
See :meth:`_engine.Connection.execution_options` for a full list of
possible options.

.. seealso::

    :meth:`_engine.Connection.execution_options`

    :meth:`_query.Query.execution_options`

    :meth:`.Executable.get_execution_options`

isolation_levelz'isolation_level' execution option may only be specified on Connection.execution_options(), or per-engine using the isolation_level argument to create_engine().compiled_cachezm'compiled_cache' execution option may only be specified on Connection.execution_options(), not per statement.N)r   r   _execution_optionsr   r)   s     r   execution_optionsExecutable.execution_optionsv  sc    B "##/  r!##H  #'"9"9"?"?"Cr"   c                     U R                   $ )zGet the non-SQL options which will take effect during execution.

.. versionadded:: 1.3

.. seealso::

    :meth:`.Executable.execution_options`
)r  r   s    r   get_execution_options Executable.get_execution_options  s     &&&r"   z:meth:`.Executable.execute`zAll statement execution in SQLAlchemy 2.0 is performed by the :meth:`_engine.Connection.execute` method of :class:`_engine.Connection`, or in the ORM by the :meth:`.Session.execute` method of :class:`.Session`.)alternativec                     U R                   nUcE  [        U SS5      =(       d    U R                  R                  nSU-  n[        R
                  " U5      eUR                  XU[        R                  " 5       5      $ )z.Compile and execute this :class:`.Executable`.NdescriptionzThis %s is not directly bound to a Connection or Engine. Use the .execute() method of a Connection or Engine to execute this construct.)	bindra  rf   r0   r   UnboundExecutionError_execute_clauseelementr   r=  )r   multiparamsr$   elabelrk   s         r   executeExecutable.execute  sz     II9mT2Mdnn6M6M -/45 
 ++C00''vt'9'9';
 	
r"   z:meth:`.Executable.scalar`zScalar execution in SQLAlchemy 2.0 is performed by the :meth:`_engine.Connection.scalar` method of :class:`_engine.Connection`, or in the ORM by the :meth:`.Session.scalar` method of :class:`.Session`.c                 B    U R                   " U0 UD6R                  5       $ )z^Compile and execute this :class:`.Executable`, returning the
result's scalar representation.

)r  scalar)r   r  r$   s      r   r  Executable.scalar  s!     ||[3F3::<<r"   z:attr:`.Executable.bind`z5Bound metadata is being removed as of SQLAlchemy 2.0.)r  enable_warningsc                     U R                   b  U R                   $ [        U 5       H  nXL a  M	  UR                  nUc  M  Us  $    g)a  Returns the :class:`_engine.Engine` or :class:`_engine.Connection`
to
which this :class:`.Executable` is bound, or None if none found.

This is a traversal which checks locally, then
checks among the "from" clauses of associated objects
until a bound engine or connection is found.

N)_bindrN   r  )r   fengines      r   r  Executable.bind  sH      ::!::t$AyVVF! % r"   )r  r  )&r0   r1   r2   r3   r4   supports_executionr   r=  r  r  r  r  r   dp_executable_optionsr
   dp_with_context_optionsdp_propagate_attrs_executable_traverse_internals	is_select	is_update	is_insertis_text	is_deleteis_dmlr	  r  r\   r  r  r  r  r  r  deprecated_20r  r  r  r6   r(   r"   r   r  r    s    ++-EM 
+AAB#%==	
 
6IIJ&" IIIGIF# #  
  
D 0 0 ) )
 A A ,D ,D\	' 
%

" 
$== 	"K
 r"   r  c                       \ rS rSrSrS rSrg)prefix_anon_mapi  aN  A map that creates new keys for missing key access.

Considers keys of the form "<ident> <name>" to produce
new symbols "<name>_<index>", where "index" is an incrementing integer
corresponding to <name>.

Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
is otherwise usually used for this type of operation.

c                     UR                  SS5      u  p#U R                  US5      nUS-   X'   US-   [        U5      -   nXPU'   U$ )N r   r   )r   re   str)r   r   identderivedanonymous_counterr   s         r   __missing__prefix_anon_map.__missing__  sR    99S!, HHWa0)A-#$5 66S	r"   r(   N)r0   r1   r2   r3   r4   r  r6   r(   r"   r   r  r    s    	r"   r  c                   $    \ rS rSrSrS rS rSrg)SchemaEventTargeti
  zBase class for elements that are the targets of :class:`.DDLEvents`
events.

This includes :class:`.SchemaItem` as well as :class:`.SchemaType`.

c                     g)z0Associate with this SchemaEvent's parent object.Nr(   r   parentr*   s      r   _set_parentSchemaEventTarget._set_parent  s    r"   c                     U R                   R                  X5        U R                  " U40 UD6  U R                   R                  X5        g r'   )dispatchbefore_parent_attachr  after_parent_attachr  s      r   _set_parent_with_dispatch+SchemaEventTarget._set_parent_with_dispatch  s9    **48&2&))$7r"   r(   N)r0   r1   r2   r3   r4   r  r  r6   r(   r"   r   r  r  
  s    ?8r"   r  c                        \ rS rSrSrSS0rSrg)SchemaVisitori  z/Define the visiting for ``SchemaItem`` objects.schema_visitorTr(   N)r0   r1   r2   r3   r4   __traverse_options__r6   r(   r"   r   r  r    s    9,d3r"   r  c                       \ rS rSrSrSrS#S jrS r\S 5       r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS#S jrS rS rS rS rS rS rS rSrS rS#S jrS r S r!S r"S  r#S$S! jr$S"r%g)%ColumnCollectioni!  ao  Collection 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
    <sqlalchemy.sql.elements.ColumnClause at 0x7f59dcf04fa0; 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_colsetNc                     [         R                  U S[        5       5        [         R                  U S0 5        [         R                  U S/ 5        U(       a  U R                  U5        g g )Nr  r  r  )rA   __setattr__r   _initial_populate)r   columnss     r   rB   ColumnCollection.__init__  sP    4CE242.43""7+ r"   c                 &    U R                  U5        g r'   _populate_separate_keysr   iter_s     r   r	  "ColumnCollection._initial_populate  s    $$U+r"   c                 P    U R                    VVs/ s H  u  pUPM	     snn$ s  snnf r'   r  r   r  cols      r   _all_columnsColumnCollection._all_columns  s$    $($4$45$4$4555   "c                 P    U R                    VVs/ s H  u  pUPM	     snn$ s  snnf )zIReturn a sequence of string key names for all columns in this
collection.r  r  s      r   keysColumnCollection.keys  s&     #'"2"23"2hq"2333r  c                 P    U R                    VVs/ s H  u  pUPM	     snn$ s  snnf )zvReturn a sequence of :class:`_sql.ColumnClause` or
:class:`_schema.Column` objects for all columns in this
collection.r  r  s      r   r   ColumnCollection.values  s&     %)$4$45$4$4555r  c                 ,    [        U R                  5      $ )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.
)listr  r   s    r   r0  ColumnCollection.items  s     D$$%%r"   c                 ,    [        U R                  5      $ r'   )boolr  r   s    r   __bool__ColumnCollection.__bool__  s    D$$%%r"   c                 ,    [        U R                  5      $ r'   )r   r  r   s    r   r   ColumnCollection.__len__  s    4##$$r"   c                 b    [        U R                   VVs/ s H  u  pUPM	     snn5      $ s  snnf r'   )r   r  r  s      r   r   ColumnCollection.__iter__  s)    t'7'78'7VQS'78998s   +
c                      U R                   U   $ ! [         aH  n[        U[        R                  5      (       a#  [        R
                  " [        U5      US9   S nAg e S nAff = fr   )r  r   rq  r   	int_typesr   
IndexErrorr   r   r   s      r   r   ColumnCollection.__getitem__  sL    	;;s## 	#t~~..JsOSA		s    
A#=AAA#c                      U R                   U   $ ! [         a(  n[        R                  " [	        U5      US9   S nAg S nAff = fr   )r  r   r   r   AttributeErrorr,  s      r   __getattr__ColumnCollection.__getattr__  s<    	B;;s## 	BKKs+SA	Bs    
A>Ac                     XR                   ;  a6  [        U[        R                  5      (       d  [        R
                  " S5      egg)Nz'__contains__ requires a string argumentFT)r  rq  r   string_typesr   r   r   s     r   __contains__ColumnCollection.__contains__  s=    kk!c4#4#455''=  r"   c                 N    [         R                  " X5       H  u  p#X#Ld  M    g   g)z\Compare this :class:`_expression.ColumnCollection` to another
based on the names of the keysFT)r   r`  )r   rT  lrs       r   compareColumnCollection.compare  s(     $$T1DAz 2 r"   c                 $    U R                  U5      $ r'   )r9  r   rT  s     r   rb  ColumnCollection.__eq__  s    ||E""r"   c                 B    XR                   ;   a  U R                   U   $ U$ )zGet a :class:`_sql.ColumnClause` or :class:`_schema.Column` object
based on a string key name from this
:class:`_expression.ColumnCollection`.)r  )r   r   r   s      r   re   ColumnCollection.get  s"    
 ++;;s##Nr"   c                 j    U R                   R                  < SSR                  S U  5       5      < S3$ )Nre  rf  c              3   8   #    U  H  n[        U5      v   M     g 7fr'   )r  )r~   rT   s     r   r   +ColumnCollection.__str__.<locals>.<genexpr>  s     +dc!ffds   rk  )rf   r0   rl  r   s    r   __str__ColumnCollection.__str__  s+    NN##II+d++
 	
r"   c                     [        5       er'   r   r   s      r   r   ColumnCollection.__setitem__      !##r"   c                     [        5       er'   r   r   s     r   r   ColumnCollection.__delitem__  rG  r"   c                     [        5       er'   r   )r   r   rE   s      r   r  ColumnCollection.__setattr__  rG  r"   c                     [        5       e)zIDictionary clear() is not implemented for
:class:`_sql.ColumnCollection`.r   r   s    r   clearColumnCollection.clear       "##r"   c                     [        5       e)zJDictionary remove() is not implemented for
:class:`_sql.ColumnCollection`.r   )r   columns     r   removeColumnCollection.remove   rO  r"   c                     [        5       e)zJDictionary update() is not implemented for
:class:`_sql.ColumnCollection`.r   r  s     r   r   ColumnCollection.update  rO  r"   c                    [        U5      nX R                  SS& U R                  R                  S U R                   5       5        U R                  R                  S [        U R                  5       5       5        U R                  R                  [        U R                  5       VVs0 s H  u  p4X4_M	     snn5        gs  snnf )*populate from an iterator of (key, column)Nc              3   *   #    U  H	  u  pUv   M     g 7fr'   r(   r~   r  rT   s      r   r   ;ColumnCollection._populate_separate_keys.<locals>.<genexpr>  s     ;*:$!A*:   c              3   2   #    U  H  u  nu  p#X4v   M     g 7fr'   r(   r~   idxr  rT   s       r   r   rZ          
(CfqSH(C   )r  r  r  r   r  	enumerater   )r   r  colsr  r  s        r   r  (ColumnCollection._populate_separate_keys  s    E{";$*:*:;; 
(1$2B2B(C
 	
 	$:J:J1KL1KvqAF1KLMLs   (B?
c                    Uc  UR                   n[        U R                  5      nU R                  R                  X!45        U R                  R                  U5        XR                  U'   X R                  ;  a  XR                  U'   gg)a  Add 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)r   r   r  appendr  addr  )r   rQ  r   r7  s       r   rf  ColumnCollection.add  sp     ;**C  !. Akk!%KK "r"   c                 4    U R                   U R                  S.$ )Nr  r  ri  r   s    r   __getstate__ColumnCollection.__getstate__,  s    #//4;;GGr"   c           
          [         R                  U SUS   5        [         R                  U SUS   5        [         R                  U SU R                   VVs1 s H  u  p#UiM	     snn5        g s  snnf )Nr  r  r  )rA   r  r  )r   stater  r  s       r   __setstate__ColumnCollection.__setstate__/  s`    45?;4m0DE)0@0@A0@fac0@A	
As   A,c                     XR                   ;  a6  [        U[        R                  5      (       a  [        R
                  " S5      egg)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  rq  r   r3  r   r   r   r  s     r   contains_column ColumnCollection.contains_column6  s?    ll"#t0011'';  r"   c                     [        U 5      $ )zBReturn an "immutable" form of this
:class:`_sql.ColumnCollection`.)ImmutableColumnCollectionr   s    r   as_immutableColumnCollection.as_immutableB  s     )..r"   c                    S nXR                   ;   a  U$ Su  pEUR                  nU R                   VVs/ s H  u  pxUPM	     n	nnU	 GHr  n[        [	        UR                  5      5      n
UR                  U
5      nU(       d  M<  U(       a  U" X5      (       d  MR  Uc  XpTMY  [        U5      [        U5      :  a  XpTMu  X:X  d  M|  [        R                  " [        R                  UR                  5        Vs/ s H7  nUR                  U5      (       d  M  UR                  R                  SS5      PM9     sn5      n[        R                  " [        R                  UR                  5        Vs/ s H7  nUR                  U5      (       d  M  UR                  R                  SS5      PM9     sn5      nX:  d  GMp  XpTGMu     U$ s  snnf s  snf s  snf )a*  Given 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.

c                     UR                  U 5       H.  n[        [        U/5      5      R                  U 5      (       a  M.    g   gr_  )rR  r   rx   r|   )expanded_proxy_set
target_setts      r   embedded7ColumnCollection.corresponding_column.<locals>.embeddedh  sD    **+=>>1#./<<&  !	 ?
 r"   )NNweightr   )r  rD   r  r   rx   r|   r   r   reducerp   rf  _uncached_proxy_listshares_lineager  re   )r   rQ  require_embeddedr}  r  	intersectr{  r  rT   rb  rz  isccol_distance
c_distances                  r   corresponding_column%ColumnCollection.corresponding_columnH  s   @	 \\!M#%%
 $ 0 01 0fq 01A!$^AKK%@!A''(:;Aq$.;;; &'Vc)n, &'^ $(;;  '*&>&>&@&@!008 =BOO//!<&@$L "&  '(&<&<&>&>!008 =BOO//!<&>"J "0)*Ya b 
e 2Ds   G 4G G*G Gr(   r'   )F)&r0   r1   r2   r3   r4   r)  rB   r	  r	  r  r  r   r0  r#  r   r   r   r0  r4  r9  rb  re   rC  r   r   r  rM  rR  r   __hash__r  rf  rj  rn  rr  rv  r  r6   r(   r"   r   r  r  !  s    jX 3I,, 6 64
6&&%:B#
$$$$
$
$
 HN&,H

/_r"   r  c                   :    \ rS rSrSrS
S jrS rS rS rS r	S	r
g)DedupeColumnCollectioni  aY  A :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

Nc                    Ub&  UR                   U:w  a  [        R                  " S5      eUR                   nUc  [        R                  " S5      eX R                  ;   aF  U R                  U   nX1L a  g U R	                  U5        [
        R                  R                  US5        g [        U R                  5      nU R                  R                  X!45        U R                  R                  U5        XR                  U'   XR                  U'   g )NKDedupeColumnCollection requires columns be under the same key as their .keyz-Can't add unnamed column to column collectionrD   )r   r   r   r  replacer   r  resetr   r  re  r  rf  )r   rQ  r   existingr7  s        r   rf  DedupeColumnCollection.add  s    ?vzzS0##-  jj;##?  ++{{3'H!LL 
 ""((=D$$%A##SM2LLV$#KKN%KKr"   c                    [        U5      n/ nU H  u  pEUR                  U:w  a  [        R                  " S5      eUR                  U R
                  ;   a-  UR                  UR                  :w  a  UR                  U5        Mr  UR                  U R
                  ;   a  UR                  U5        M  XPR
                  U'   U R                  R                  XE45        M     U R                  R                  S U R                   5       5        U R
                  R                  S [        U R                  5       5       5        U H  nU R                  U5        M     g)rW  r  c              3   *   #    U  H	  u  pUv   M     g 7fr'   r(   rY  s      r   r   ADedupeColumnCollection._populate_separate_keys.<locals>.<genexpr>  s     =,<&1A,<r[  c              3   2   #    U  H  u  nu  p#X4v   M     g 7fr'   r(   r]  s       r   r   r    r_  r`  N)r  r   r   r   rh   r  re  r  r  r   ra  r  )r   r  rb  replace_colr  r  s         r   r  .DedupeColumnCollection._populate_separate_keys  s   E{FAww!|''1  xx4;;&377chh+>""3'DKK'""3'!$A  ''1  	=D,<,<== 
(1$2B2B(C
 	
 CLL r"   c                 4    U R                  S U 5       5        g )Nc              3   <   #    U  H  oR                   U4v   M     g 7fr'   )r   )r~   r  s     r   r   0DedupeColumnCollection.extend.<locals>.<genexpr>  s     $Euggs^us   r  r  s     r   extendDedupeColumnCollection.extend  s    $$$Eu$EEr"   c           	         XR                   ;  a  [        SU-  5      eU R                  UR                  	 U R                   R	                  U5        U R
                   VVs/ s H  u  p#X1Ld  M  X#4PM     snnU R
                  S S & U R                  R                  [        U R
                  5       VVVs0 s H
  u  nu  p%XE_M     snnn5        U R                  [        U R
                  5      	 g s  snnf s  snnnf )Nz8Can't remove column %r; column is not in this collection)	r  r   r  r   rR  r  r   ra  r   )r   rQ  r  rT   r^  r  s         r   rR  DedupeColumnCollection.remove  s    %J  KK

#F#!%!1!1
!1vQ_FQF!1
 	+4T5E5E+FG+F-#xSX+FG	
 KKD,,-.
 Hs   
C.-C.3C4c           	      :   [        5       nUR                  U R                  ;   a^  UR                  UR                  :w  aD  U R                  UR                     nUR                  UR                  :X  a  UR	                  U5        UR                  U R                  ;   a(  UR	                  U R                  UR                     5        / nSnU R
                   HF  u  pgXr;   a*  U(       d!  SnUR                  UR                  U45        M2  M4  UR                  Xg45        MH     U(       a  U R                  R                  U5        U(       d  UR                  UR                  U45        U R                  R	                  U5        X@R
                  SS& U R                  R                  5         U R                  R                  [        U R
                  5       VVVs0 s H
  u  nu  pgX_M     snnn5        U R                  R                  U R
                  5        gs  snnnf )a  add the given column to this collection, removing unaliased
versions of this column  as well as existing columns with the
same key.

e.g.::

    t = Table('sometable', metadata, Column('col1', Integer))
    t.columns.replace(Column('col1', Integer, key='columnone'))

will remove the original 'col1' from the collection, and add
the new column under the name 'columnname'.

Used by schema.Column to override columns during table reflection.

FTN)r   rh   r  r   rf  r  re  r  difference_updaterM  r   ra  )	r   rQ  
remove_colrT  new_colsreplacedr  r  r^  s	            r   r  DedupeColumnCollection.replace  s   " U
;;$++%&***CKK,EzzUYY&u%::$NN4;;vzz23&&FA #HOOVZZ$89   ) ' LL**:6OOVZZ01 &+4T5E5E+FG+F-#xSX+FG	
 	4++, Hs   Hr(   r'   )r0   r1   r2   r3   r4   rf  r  r  rR  r  r6   r(   r"   r   r  r    s"    
 &D2F/"2-r"   r  c                   ^    \ rS rSrSrS rS rS r\R                  R                  =r=rrSrg)ru  i;  _parentc                     [         R                  U SU5        [         R                  U SUR                  5        [         R                  U SUR                  5        [         R                  U SUR                  5        g )Nr  r  r  r  )rA   r  r  r  r  )r   
collections     r   rB   "ImmutableColumnCollection.__init__>  s\    4J74J,>,>?4:+<+<=4
0F0FGr"   c                     SU R                   0$ Nr  r  r   s    r   rj  &ImmutableColumnCollection.__getstate__D  s    4<<((r"   c                 0    US   nU R                  U5        g r  )rB   )r   rm  r  s      r   rn  &ImmutableColumnCollection.__setstate__G  s    y!fr"   r(   N)r0   r1   r2   r3   r)  rB   rj  rn  r   ImmutableContainer
_immutablerf  r  rR  r6   r(   r"   r   ru  ru  ;  s4    IH) !33>>>C>&6r"   ru  c                   2    \ rS rSrS rS rS rS rS rSr	g)		ColumnSetiN  c                 
    X;   $ r'   r(   rq  s     r   rr  ColumnSet.contains_columnO  s
    {r"   c                 8    U H  nU R                  U5        M     g r'   )rf  )r   rb  r  s      r   r  ColumnSet.extendR  s    CHHSM r"   c                 0    [        U 5      [        U5      -   $ r'   )r  r<  s     r   rV  ColumnSet.__add__V  s    DzDK''r"   c                     / nU H7  nU  H.  nUR                  U5      (       d  M  UR                  X4:H  5        M0     M9     [        R                  " U6 $ r'   )r  re  rO   and_)r   rT  r7  rT   r  s        r   rb  ColumnSet.__eq__Y  sK    A##E**HHQZ(   }}a  r"   c                 8    [        [        S U  5       5      5      $ )Nc              3   $   #    U  H  ov   M     g 7fr'   r(   )r~   r[   s     r   r   %ColumnSet.__hash__.<locals>.<genexpr>b  s     *T!Ts   )hashrH  r   s    r   r  ColumnSet.__hash__a  s    E*T**++r"   r(   N)
r0   r1   r2   r3   rr  r  rV  rb  r  r6   r(   r"   r   r  r  N  s    (!,r"   r  c           	         [         R                  " S5        U R                  nU(       db  U R                  R                  n[        U S[        U SS 5      5      nU(       a
  U< SU< 3nOSU-  nUc  SU-  n[        R                  " U5      eU$ )Nz|The ``bind`` argument for schema methods that invoke SQL against an engine or connection will be required in SQLAlchemy 2.0.fullnamerh   z object z	%s objectzm%s is not bound to an Engine or Connection.  Execution can not proceed without a database to execute against.)r   warn_deprecated_20r  rf   r0   ra  r   r  )
schemaitemrk   r  rh   r  items         r   _bind_or_errorr  e  s    	N ??D##,,
GJ$E
 %)51D%D;!" 
 '',,Kr"   c                      U R                   $ ! [         a@    [        R                  " U 5       H$  n[	        US5      (       d  M  UR                   s  s $    e f = f)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.

entity_namespace)r  r/  r   iteratehasattr)entityr   s     r   _entity_namespacer    sV    &&& $$V,Dt/00,,, - s    2AAAc           
           [        U 5      nU[        La  [        X1U5      $ [        X15      $ ! [         a<  n[        R
                  " [        R                  " SU < SU< S35      US9   SnAgSnAff = f)zReturn an entry from an entity_namespace.


Raises :class:`_exc.InvalidRequestError` rather than attribute error
on not found.

zEntity namespace for "z" has no property ""r   N)r  r   ra  r/  r   r   r   rg   )r  r   r   nsr   s        r   _entity_namespace_keyr    sj    
v&& 2G,,2## 
##3   	

s   - 
- 
A32A..A3r'   )Cr4   rK   rp   r    r   r   
traversalsr   r   r   r	   r
   r   r   r   r   r   r  rO   type_apisymbolr   r   rA   r   r8   rN   rU   r\   rs   r+   rx   r   r   collections_abcMutableMappingr   r   preload_moduler   r   r  r+  r7  r;  rK  rA  with_metaclassrY  r  r  StatementRoler  r   r  r  r  r  r  r  ru  ordered_column_setr  r  r  r  r(   r"   r   <module>r     s  
   	   # ( + # / '     	;;12 	X	 $	 0,: ?
9
d**99 9
x$d**99 $@ *+1 ,1lCF lC^_6 _D $ ?j ?4 8G2d!!,/ G2T@w @' `$$j `Fd *8 8"4M 4Fv FRN-- N-b? 7 79I ?&,'' ,.4" 06 
r"   