
    ,hߍ                    t   S r SSKJr  SSKJr  SSKJ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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#  \(       a  SSK$J%r%  SS K&J'r'  \	R.                  (       d  \(       d  SS!K(J)r)  SS"K(J*r+  OSS!K,J)r)  SS"K,J*r+  / S#Qr- " S$ S%\"5      r. " S& S'5      r/ " S( S)\5      r0\\\1\04      r2  " S* S+5      r3 " S, S-\"5      r4 " S. S/5      r5\0r6SPS0 jr7\5Rp                  r8\7" 5          " S1 S2\3\/5      r9\" S3\9S49r:\" S5S6S49r;\\:/S4   r< " S7 S8\"5      r= " S9 S:\"\:   5      r>\" S;S<S49r? " S= S<\R                  5      rA " S> S?\A5      rB " S@ SA\B5      rC\/rD\ArE\BrF\CrG\R                  4     SQSB jjrI\        SRSC j5       rJ\        SSSD j5       rJ        STSE jrJ\        SUSF j5       rK\        SVSG j5       rK        SWSH jrK\        SUSI j5       rL\        SXSJ j5       rL        SWSK jrL\        SYSL j5       rM\        SZSM j5       rM\        S[SN j5       rM        S\SO jrMg)]z5Visitor/traversal interface and library functions.


    )annotations)deque)EnumN)Any)Callable)cast)ClassVar)Dict)Iterable)Iterator)List)Mapping)Optional)overload)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )exc)util)langhelpers)HAS_CYEXTENSION)Literal)Protocol)Self   )_AnnotationDict)ColumnElement)prefix_anon_map)cache_anon_map)	iteratetraverse_usingtraversecloned_traversereplacement_traverse	VisitableExternalTraversalInternalTraversalanon_mapc                      \ rS rSrSS jrSrg)_CompilerDispatchTypeJ   c                    g N )_selfselfvisitorkws       O/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/sql/visitors.py__call___CompilerDispatchType.__call__K   s    #    r1   N)r3   r(   r4   r   r5   r   returnr   __name__
__module____qualname____firstlineno__r7   __static_attributes__r1   r9   r6   r-   r-   J   s    Mr9   r-   c                     ^  \ rS rSr% SrSrS\S'   S\S'   \R                  (       a  SS jr	SU 4S	 jjr
\SS
 j5       rSS jrSrU =r$ )r(   N   a  Base class for visitable objects.

:class:`.Visitable` is used to implement the SQL compiler dispatch
functions.    Other forms of traversal such as for cache key generation
are implemented separately using the :class:`.HasTraverseInternals`
interface.

.. versionchanged:: 2.0  The :class:`.Visitable` class was named
   :class:`.Traversible` in the 1.4 series; the name is changed back
   to :class:`.Visitable` in 2.0 which is what it was prior to 1.4.

   Both names remain importable in both 1.4 and 2.0 versions.

r1   str__visit_name__r-   _original_compiler_dispatchc                    g r0   r1   )r3   r4   r5   s      r6   _compiler_dispatchVisitable._compiler_dispatchf   s    cr9   c                b   > SU R                   ;   a  U R                  5         [        TU ]  5         g )NrD   )__dict___generate_compiler_dispatchsuper__init_subclass__)cls	__class__s    r6   rM   Visitable.__init_subclass__h   s&    s||+++-!#r9   c                F  ^ U R                   nSU R                  ;   a  U R                  U l        g [	        U[
        5      (       d$  [        R                  " SU R                   S35      eSU-  n[        R                  " U5      m        SU4S jjnU=U l        U l        g )NrG   z__visit_name__ on class z$ must be a string at the class levelvisit_%sc                |   >  T" U5      nU" U 40 UD6$ ! [          a  nUR                  " X40 UD6s SnA$ SnAff = f)zgLook for an attribute named "visit_<visit_name>" on the
visitor, and call it with the same kw params.

N)AttributeErrorvisit_unsupported_compilation)r3   r4   r5   metherrgetters        r6   rG   AVisitable._generate_compiler_dispatch.<locals>._compiler_dispatch   sM    (g D'B'' " N<<TM"MMNs    
;6;;)r3   r(   r4   r   r5   r   r:   rC   )rD   rJ   rG   rE   
isinstancerC   r   InvalidRequestErrorr<   operator
attrgetter)rN   
visit_namenamerG   rX   s       @r6   rK   %Visitable._generate_compiler_dispatchm   s    ''
3<</ /2.D.DC+*c**))*3<<. 9% % 
 J&$$T*	(	(&)	(14	(	(  	+r9   c                    U $ r0   r1   )rN   keys     r6   __class_getitem__Visitable.__class_getitem__   s    
r9   )r4   r   r5   r   r:   rC   r:   None)rb   r   r:   r   )r<   r=   r>   r?   __doc__	__slots____annotations__typingr   rG   rM   classmethodrK   rc   r@   __classcell__)rO   s   @r6   r(   r(   N   sK     I!66I$
 # #J r9   r(   c                      \ rS rSrSrSr Sr Sr Sr Sr	 Sr
 S	r S
rSrSr Sr Sr Sr Sr Sr Sr Sr Sr Sr Sr Sr Sr Sr Sr Sr SrSrSr  Sr! S r" S!r# S"r$ S#r%  S$r& S%r' S&r( S'r) S(r* S)r+S*r,g+),r*      a  Defines visitor symbols used for internal traversal.

The :class:`.InternalTraversal` class is used in two ways.  One is that
it can serve as the superclass for an object that implements the
various visit methods of the class.   The other is that the symbols
themselves of :class:`.InternalTraversal` are used within
the ``_traverse_internals`` collection.   Such as, the :class:`.Case`
object defines ``_traverse_internals`` as ::

    class Case(ColumnElement[_T]):
        _traverse_internals = [
            ("value", InternalTraversal.dp_clauseelement),
            ("whens", InternalTraversal.dp_clauseelement_tuples),
            ("else_", InternalTraversal.dp_clauseelement),
        ]

Above, the :class:`.Case` class indicates its internal state as the
attributes named ``value``, ``whens``, and ``else_``.    They each
link to an :class:`.InternalTraversal` method which indicates the type
of datastructure to which each attribute refers.

Using the ``_traverse_internals`` structure, objects of type
:class:`.InternalTraversible` will have the following methods automatically
implemented:

* :meth:`.HasTraverseInternals.get_children`

* :meth:`.HasTraverseInternals._copy_internals`

* :meth:`.HasCacheKey._gen_cache_key`

Subclasses can also implement these methods directly, particularly for the
:meth:`.HasTraverseInternals._copy_internals` method, when special steps
are needed.

.. versionadded:: 1.4

HCHLCEFCCTSCLCTEOWCCOSSLANBOTPDDOCDMDAKPODDPSTHSJMESHUKDML_OVDML_VDML_MVPAIGISMMTHTILr1   N)-r<   r=   r>   r?   rg   dp_has_cache_keydp_has_cache_key_listdp_clauseelement)dp_fromclause_canonical_column_collectiondp_clauseelement_tuplesdp_clauseelement_listdp_clauseelement_tupledp_executable_optionsdp_with_context_optionsdp_fromclause_ordered_set	dp_stringdp_string_listdp_anon_name
dp_booleandp_operatordp_typedp_plain_dictdp_dialect_optionsdp_string_clauseelement_dictdp_string_multi_dictdp_annotations_keydp_plain_objdp_named_ddl_elementdp_prefix_sequencedp_table_hint_listdp_setup_join_tupledp_memoized_select_entitiesdp_statement_hint_listdp_unknown_structuredp_dml_ordered_valuesdp_dml_valuesdp_dml_multi_valuesdp_propagate_attrs	dp_ignoredp_inspectabledp_multidp_multi_listdp_has_cache_key_tuplesdp_inspectable_listr@   r1   r9   r6   r*   r*      s   %N / 8<04-	 $
 ! " !" $KI N"L J K G M ,#' 
  
  L   
 
 "&!   %+ M
 #
 ) I N% H M' #
 r9   r*   c                  |    \ rS rSr% SrSrS\S'   SrS\S'   \R                  " S	5      SS
.     SS jj5       r
Srg)HasTraverseInternalsi  a  base for classes that have a "traverse internals" element,
which defines all kinds of ways of traversing the elements of an object.

Compared to :class:`.Visitable`, which relies upon an external visitor to
define how the object is travered (i.e. the :class:`.SQLCompiler`), the
:class:`.HasTraverseInternals` interface allows classes to define their own
traversal, that is, what attributes are accessed and in what order.

r1   _TraverseInternalsType_traverse_internalsFbool_is_immutablezsqlalchemy.sql.traversals
omit_attrsc                 ^^ [         R                  R                  n U R                  nUR
                  R                  n[        R                  R                  UU4S jU" XS5       5       5      $ ! [         a    / s $ f = f)a  Return immediate child :class:`.visitors.HasTraverseInternals`
elements of this :class:`.visitors.HasTraverseInternals`.

This is used for visit traversal.

\**kw may contain flags that change the collection that is
returned, for example to return a subset of items in order to
cut down on larger traversals, or to return child items from a
different context (such as schema-level collections instead of
clause-level).

c              3  V   >#    U  H  u  pnUT;  d  M  Uc  M  U" U40 TD6v   M      g 7fr0   r1   ).0attrnameobjrV   r5   r   s       r6   	<genexpr>4HasTraverseInternals.get_children.<locals>.<genexpr>  s?      -
(#t z)	  /2	 DOO(s   )))!_generated_get_children_traversal)
r   	preloadedsql_traversalsr   rT   _get_childrenrun_generated_dispatch	itertoolschainfrom_iterable)r3   r   r5   
traversalstraverse_internalsdispatchs    ``   r6   get_children!HasTraverseInternals.get_children  s}    " ^^22
	!%!9!9
 ++BB,, -
'/*M(-
 
 	
  	I	s   A1 1B ?B N)r   Tuple[str, ...]r5   r   r:   zIterable[HasTraverseInternals])r<   r=   r>   r?   rg   rh   ri   r   r   preload_moduler   r@   r1   r9   r6   r   r     sW     I//M4	45/1
,
9<
	'
 6
r9   r   c                      \ rS rSrSS jrSrg)_InternalTraversalDispatchTypei  c                    g r0   r1   )sr3   r4   s      r6   r7   '_InternalTraversalDispatchType.__call__  s    r9   r1   N)r3   objectr4   HasTraversalDispatchr:   r   r;   r1   r9   r6   r   r     s    Lr9   r   c                      \ rS rSr% SrSr0 rS\S'   SS jr        SS jr	        SS jr
      SS	 jrSrg
)r   i  z[Define infrastructure for classes that perform internal traversals

.. versionadded:: 2.0

r1   z2ClassVar[Dict[Union[InternalTraversal, str], str]]_dispatch_lookupc                ,    [         U   n[        XS5      $ )zdGiven a method from :class:`.HasTraversalDispatch`, return the
corresponding method on a subclass.

N)r   getattr)r3   visit_symbolr_   s      r6   r   HasTraversalDispatch.dispatch  s    
  -t4((r9   c                     UR                   R                  U   nU" X5      $ ! [         a    U R                  UR                   X#5      n N0f = fr0   )rO   rJ   KeyErrorgenerate_dispatch)r3   targetinternal_dispatchgenerate_dispatcher_name
dispatchers        r6   r   +HasTraversalDispatch.run_generated_dispatch  sZ    		))223KLJ &''  	
 //  "3J	s   # &AAc                @    U R                  X#5      n[        XU5        U$ r0   )_generate_dispatchersetattr)r3   
target_clsr   r   r   s        r6   r   &HasTraversalDispatch.generate_dispatch  s)     ..

 	
jAr9   c                   / nU H6  u  pEU R                  U5      nUc  M  [        U   nUR                  XG45        M8     SSR                  S U 5       5      -   S-   nSU-  U-   S-   n	[	        [
        [        R                  " U	0 U5      5      $ )Nz    return [
z, 
c              3  D   #    U  H  u  pS U< SU< SU< S3v   M     g7f)z	        (z, self.z
, visitor.)Nr1   )r   r   r^   s      r6   r   <HasTraversalDispatch._generate_dispatcher.<locals>.<genexpr>1  s'       16,*  :705s    z
    ]
zdef %s(self, visitor):

)r   r   appendjoinr   r   r   _exec_code_in_env)
r3   r   method_namenamesr   	visit_symrV   r^   code	meth_texts
             r6   r   )HasTraversalDispatch._generate_dispatcher$  s     #4H==+D-i8
h34	 $5   16   	 0+=EL	*)))RE
 	
r9   N)r   r*   r:   zCallable[..., Any])r   r   r   r   r   rC   r:   r   )r   zType[object]r   r   r   rC   r:   r   )r   r   r   rC   r:   r   )r<   r=   r>   r?   rg   rh   r   ri   r   r   r   r   r@   r1   r9   r6   r   r     s     IKMHM)(( 2( #&	(
 
(&  2 #&	
 
(
!7
FI
	'
r9   r   c                     [         n [         HY  nUR                  nUR                  S5      (       d  M'  UR	                  SS5      nUR
                  nX@;  d   U5       eU=X'   X'   M[     g )Ndp_visit_)r   r*   r_   
startswithreplacevalue)lookupsymrb   	visit_keysym_names        r6   _generate_traversal_dispatchr  C  sb    F hh>>%  E84IyyH)383)-66FK&* !r9   c                      \ rS rSr% Sr\R                  rS\S'   \	R                  (       a  SS jrSS.     SS jjrSS jrSS.     SS	 jjrSrg
)ExternallyTraversibleiS  r1   zMapping[Any, Any]_annotationsc                    g r0   r1   )r3   valuess     r6   	_annotateExternallyTraversible._annotateZ  s    cr9   r   c                   g r0   r1   r3   r   r5   s      r6   r   "ExternallyTraversible.get_children\  s    .1r9   c                    [        5       e)zclone this elementNotImplementedError)r3   r5   s     r6   _cloneExternallyTraversible._clone`  s    !##r9   c                   [        5       e)aD  Reassign internal elements to be clones of themselves.

Called during a copy-and-traverse operation on newly
shallow-copied elements to create a deep copy.

The given clone function should be used, which may be applying
additional transformations to the element (i.e. replacement
traversal, cloned traversal, annotations).

r  r  s      r6   _copy_internals%ExternallyTraversible._copy_internalsd  s     "##r9   N)r  r   r:   r   )r   r   r5   r   r:   Iterable[ExternallyTraversible])r5   r   r:   r   )r   r   r5   r   r:   rf   )r<   r=   r>   r?   rh   r   
EMPTY_DICTr  ri   rj   r   r  r   r  r  r@   r1   r9   r6   r  r  S  sp    I&*ooL#5A 46	2!0	2=@	2,	2$
 02$,$9<$	$ $r9   r  _ET)bound_CEzColumnElement[Any]c                      \ rS rSrSS jrSrg)_CloneCallableTypei{  c                    g r0   r1   r3   elementr5   s      r6   r7   _CloneCallableType.__call__|  s    r9   r1   N)r)  r"  r5   r   r:   r"  r;   r1   r9   r6   r&  r&  {  s    ;r9   r&  c                      \ rS rSrSS jrSrg)_TraverseTransformCallableTypei  c                    g r0   r1   r(  s      r6   r7   '_TraverseTransformCallableType.__call__  s    #r9   r1   N)r)  r"  r5   r   r:   zOptional[_ET]r;   r1   r9   r6   r,  r,    s    Er9   r,  _ExtTr)   c                      \ rS rSr% SrSr0 rS\S'   S\S'   SS jr    SS	 jr	\
SS
 j5       r\
    SS j5       r    SS jr  SS jr\SS j5       rSS jrSrg)r)   i  zBase class for visitor objects which can traverse externally using
the :func:`.visitors.traverse` function.

Direct usage of the :func:`.visitors.traverse` function is usually
preferred.

)_visitor_dict_nextzDict[str, Any]__traverse_options__zOptional[ExternalTraversal]r2  c                    U R                    H/  n[        USUR                  -  S 5      nU(       d  M&  U" U40 UD6s  $    g )NrR   )visitor_iteratorr   rD   )r3   r   r5   vrV   s        r6   traverse_single!ExternalTraversal.traverse_single  s>    &&A1j3+=+==tDDtC2& 'r9   c                ,    [        XR                  5      $ )zQTraverse the given expression structure, returning an iterator
of all elements.

)r#   r3  r3   r   s     r6   r#   ExternalTraversal.iterate  s     s5566r9   c                    g r0   r1   r:  s     r6   r%   ExternalTraversal.traverse      47r9   c                    g r0   r1   r:  s     r6   r%   r=         !$r9   c                B    [        XR                  U R                  5      $ 2Traverse and visit the given expression structure.)r%   r3  r1  r:  s     r6   r%   r=    s    
 668J8JKKr9   c                ~    0 n[        U 5       H+  nUR                  S5      (       d  M  [        X5      XSS  '   M-     U$ )Nr     )dirr  r   )r3   visitorsr_   s      r6   _memoized_attr__visitor_dict.ExternalTraversal._memoized_attr__visitor_dict  s@     IDx((%,T%8ab"  r9   c              #  T   #    U nU(       a  Uv   [        USS5      nU(       a  M  gg7f)z8Iterate through this visitor and each 'chained' visitor.r2  N)r   )r3   r6  s     r6   r5  "ExternalTraversal.visitor_iterator  s)      *.G7D)A as   "((c                B    [        U R                  5      S   nXl        U $ )z'Chain' an additional ExternalTraversal onto this ExternalTraversal

The chained visitor will receive all visit events after this one.

)listr5  r2  )r3   r4   tails      r6   r   ExternalTraversal.chain  s#     D))*2.
r9   r1   N)r   r(   r5   r   r:   r   )r   Optional[ExternallyTraversible]r:   Iterator[ExternallyTraversible]r   Literal[None]r:   rf   r   r  r:   r  r   rQ  r:   rQ  )r:   z%Dict[str, _TraverseCallableType[Any]])r:   zIterator[ExternalTraversal])r3   r/  r4   r)   r:   r/  )r<   r=   r>   r?   rg   rh   r3  ri   r7  r#   r   r%   rH  propertyr5  r   r@   r1   r9   r6   r)   r)     s     +I+-.-&&'727	(7 7 7$($	$ $L2L	(L	. * *r9   c                  p    \ rS rSrSrSr    S	S jr\S
S j5       r\    SS j5       r    SS jrSr	g)CloningExternalTraversali  zBase class for visitor objects which can traverse using
the :func:`.visitors.cloned_traverse` function.

Direct usage of the :func:`.visitors.cloned_traverse` function is usually
preferred.


r1   c                N    U Vs/ s H  o R                  U5      PM     sn$ s  snf )zPApply cloned traversal to the given list of elements, and return
the new list.

)r%   )r3   list_xs      r6   copy_and_process)CloningExternalTraversal.copy_and_process  s#     +00%Qa %000s   "c                    g r0   r1   r:  s     r6   r%   !CloningExternalTraversal.traverse  r>  r9   c                    g r0   r1   r:  s     r6   r%   r`    r@  r9   c                B    [        XR                  U R                  5      $ rB  )r&   r3  r1  r:  s     r6   r%   r`    s"    
 **D,>,>
 	
r9   N)r[  List[ExternallyTraversible]r:   rc  rS  rU  rV  )
r<   r=   r>   r?   rg   rh   r]  r   r%   r@   r1   r9   r6   rY  rY    sj     I101	$1 7 7$($	$ $
2
	(
r9   rY  c                  p    \ rS rSrSrSr    S	S jr\S
S j5       r\    SS j5       r    SS jrSr	g)ReplacingExternalTraversali  zBase class for visitor objects which can traverse using
the :func:`.visitors.replacement_traverse` function.

Direct usage of the :func:`.visitors.replacement_traverse` function is
usually preferred.

r1   c                    g)zReceive pre-copied elements during a cloning traversal.

If the method returns a new element, the element is used
instead of creating a simple copy of the element.  Traversal
will halt on the newly returned element if it is re-encountered.
Nr1   )r3   elems     r6   r  "ReplacingExternalTraversal.replace  s     r9   c                    g r0   r1   r:  s     r6   r%   #ReplacingExternalTraversal.traverse  r>  r9   c                    g r0   r1   r:  s     r6   r%   rj    r@  r9   c                N   ^        SU 4S jjn[        UT R                  U5      $ )rC  c                x   > TR                    H)  n[        [        U5      R                  U 5      nUc  M'  Us  $    g r0   )r5  r   re  r  )r)  r5   r6  er3   s       r6   r  4ReplacingExternalTraversal.traverse.<locals>.replace  s<     **3Q7??H=H +
 r9   )r)  r  r5   r   r:   rQ  )r'   r3  )r3   r   r  s   `  r6   r%   rj    s9    
		*				 -		 $C)B)BGLLr9   N)rg  r  r:   rQ  rS  rU  rV  )
r<   r=   r>   r?   rg   rh   r  r   r%   r@   r1   r9   r6   re  re    sm     I	)		(	 7 7$($	$ $M2M	(Mr9   re  c              #    #    U c  gU v   U R                   " S0 UD6nU(       d  g[        U/5      nU(       aH  UR                  5       nU H(  nUv   UR                  UR                   " S0 UD65        M*     U(       a  MG  gg7f)a  Traverse the given expression structure, returning an iterator.

Traversal is configured to be breadth-first.

The central API feature used by the :func:`.visitors.iterate`
function is the
:meth:`_expression.ClauseElement.get_children` method of
:class:`_expression.ClauseElement` objects.  This method should return all
the :class:`_expression.ClauseElement` objects which are associated with a
particular :class:`_expression.ClauseElement` object. For example, a
:class:`.Case` structure will refer to a series of
:class:`_expression.ColumnElement` objects within its "whens" and "else\_"
member variables.

:param obj: :class:`_expression.ClauseElement` structure to be traversed

:param opts: dictionary of iteration options.   This dictionary is usually
 empty in modern usage.

Nr1   )r   r   popleftr   )r   optschildrenstack
t_iteratorts         r6   r#   r#   0  su     0 {
I'$'H8*E
]]_
AGLL/$/0  %s   A;B?Bc                    g r0   r1   iteratorr   rG  s      r6   r$   r$   Y      
 r9   c                    g r0   r1   rx  s      r6   r$   r$   a      
  r9   c                r    U  H0  nUR                  UR                  S5      nU(       d  M(  U" U5        M2     U$ )a  Visit the given expression structure using the given iterator of
objects.

:func:`.visitors.traverse_using` is usually called internally as the result
of the :func:`.visitors.traverse` function.

:param iterator: an iterable or sequence which will yield
 :class:`_expression.ClauseElement`
 structures; the iterator is assumed to be the
 product of the :func:`.visitors.iterate` function.

:param obj: the :class:`_expression.ClauseElement`
 that was used as the target of the
 :func:`.iterate` function.

:param visitors: dictionary of visit functions.  See :func:`.traverse`
 for details on this dictionary.

.. seealso::

    :func:`.traverse`


N)getrD   )ry  r   rG  r   rV   s        r6   r$   r$   i  s7    : ||F11484L  Jr9   c                    g r0   r1   r   rr  rG  s      r6   r%   r%     rz  r9   c                    g r0   r1   r  s      r6   r%   r%     r|  r9   c                ,    [        [        X5      X5      $ )a  Traverse and visit the given expression structure using the default
iterator.

 e.g.::

    from sqlalchemy.sql import visitors

    stmt = select(some_table).where(some_table.c.foo == "bar")


    def visit_bindparam(bind_param):
        print("found bound value: %s" % bind_param.value)


    visitors.traverse(stmt, {}, {"bindparam": visit_bindparam})

The iteration of objects uses the :func:`.visitors.iterate` function,
which does a breadth-first traversal using a stack.

:param obj: :class:`_expression.ClauseElement` structure to be traversed

:param opts: dictionary of iteration options.   This dictionary is usually
 empty in modern usage.

:param visitors: dictionary of visit functions.   The dictionary should
 have strings as keys, each of which would correspond to the
 ``__visit_name__`` of a particular kind of SQL expression object, and
 callable functions  as values, each of which represents a visitor function
 for that kind of object.

)r$   r#   r  s      r6   r%   r%     s    H '#,c<<r9   c                    g r0   r1   r  s      r6   r&   r&     rz  r9   c                    g r0   r1   r  s      r6   r&   r&         
 r9   c                   ^^^^^ 0 m[        TR                  S/ 5      5      m    SUU4S jjnSUUUU4S jjmU b  T" U 4SU0TD6n SmU $ )a  Clone the given expression structure, allowing modifications by
visitors for mutable objects.

Traversal usage is the same as that of :func:`.visitors.traverse`.
The visitor functions present in the ``visitors`` dictionary may also
modify the internals of the given structure as the traversal proceeds.

The :func:`.cloned_traverse` function does **not** provide objects that are
part of the :class:`.Immutable` interface to the visit methods (this
primarily includes :class:`.ColumnClause`, :class:`.Column`,
:class:`.TableClause` and :class:`.Table` objects). As this traversal is
only intended to allow in-place mutation of objects, :class:`.Immutable`
objects are skipped. The :meth:`.Immutable._clone` method is still called
on each object to allow for objects to replace themselves with a different
object based on a clone of their sub-internals (e.g. a
:class:`.ColumnClause` that clones its subquery to return a new
:class:`.ColumnClause`).

.. versionchanged:: 2.0  The :func:`.cloned_traverse` function omits
   objects that are part of the :class:`.Immutable` interface.

The central API feature used by the :func:`.visitors.cloned_traverse`
and :func:`.visitors.replacement_traverse` functions, in addition to the
:meth:`_expression.ClauseElement.get_children`
function that is used to achieve
the iteration, is the :meth:`_expression.ClauseElement._copy_internals`
method.
For a :class:`_expression.ClauseElement`
structure to support cloning and replacement
traversals correctly, it needs to be able to pass a cloning function into
its internal members in order to make copies of them.

.. seealso::

    :func:`.visitors.traverse`

    :func:`.visitors.replacement_traverse`

stop_onc                   > [        U TT5      $ r0   )r&   r  s    r6   deferred_copy_internals0cloned_traverse.<locals>.deferred_copy_internals  s     sD(33r9   c                  > U T;   a  U $ [        U 5      T;  a  SU;   a3  [        [        [           US   " U 5      5      nUb  UT[        U 5      '   U$ U R                  " SST0UD6=T[        U 5      '   nUR
                  " SST0UD6  U R                  (       d+  TR                  UR                  S 5      nU(       a  U" U5        T[        U 5         $ )Nr  cloner1   )	idr   r   r  r  r  r   r~  rD   )rg  r5   newelemrV   r  clonedr  rG  s       r6   r  cloned_traverse.<locals>.clone  s    7?K$xv%?" !67It9LG *+2r$x(& .2[[-Ku-K-KKr$x 7'':e:r:
 ))#<<(>(>EDW"T(##r9   Nr  rU  rg  r  r5   r   r:   r  )setr~  )r   rr  rG  r  r  r  r  s    `` @@@r6   r&   r&     st    Z 02F$((9b)*G4"4	4 4
$ $< 
)@
DH
 EJr9   c                    g r0   r1   r   rr  r  s      r6   r'   r'   3  rz  r9   c                    g r0   r1   r  s      r6   r'   r'   ;  r  r9   c                    g r0   r1   r  s      r6   r'   r'   C  r|  r9   c                   ^^^^^ 0 mTR                  S/ 5       Vs1 s H  n[        U5      iM     snm    SUU4S jjnSUUUU4S jjmU b  T" U 4SU0TD6n SmU $ s  snf )a  Clone the given expression structure, allowing element
replacement by a given replacement function.

This function is very similar to the :func:`.visitors.cloned_traverse`
function, except instead of being passed a dictionary of visitors, all
elements are unconditionally passed into the given replace function.
The replace function then has the option to return an entirely new object
which will replace the one given.  If it returns ``None``, then the object
is kept in place.

The difference in usage between :func:`.visitors.cloned_traverse` and
:func:`.visitors.replacement_traverse` is that in the former case, an
already-cloned object is passed to the visitor function, and the visitor
function can then manipulate the internal state of the object.
In the case of the latter, the visitor function should only return an
entirely different object, or do nothing.

The use case for :func:`.visitors.replacement_traverse` is that of
replacing a FROM clause inside of a SQL structure with a different one,
as is a common use case within the ORM.

r  c                   > [        U TT5      $ r0   )r'   r  s    r6   r  5replacement_traverse.<locals>.deferred_copy_internalsj  s     $Cw77r9   c                L  > [        U 5      T;   d  SU R                  ;   a  U $ T" U 5      nUb  TR                  [        U5      5        U$ [        U 5      nUT;  aF  SU;   a  US   " U 5      nUb  UTU'   U$ U R                  " S0 UD6=TU'   nUR                  " SST0UD6  TU   $ )Nno_replacement_traverser  r  r1   )r  r  addr  r  )rg  r5   r  id_elemr  r  r  r  s       r6   r  #replacement_traverse.<locals>.cloneo  s    tH(D,=,==KdmG"BwK(
 T(&( B"$Y-"5"..5F7O#*N040Ab0AAF7Og++>%>2>g&r9   Nr  rU  r  )r~  r  )r   rr  r  r\  r  r  r  r  s    ``  @@@r6   r'   r'   K  s    8 F"hhy"565r!u56G8"8	8 8
' '6 
)@
DH
 EJO 7s   Are   )r   rQ  rr  Mapping[str, Any]r:   rR  )ry  r   r   rT  rG  (Mapping[str, _TraverseCallableType[Any]]r:   rf   )ry  r   r   r  rG  r  r:   r  )ry  r   r   rQ  rG  r  r:   rQ  )r   rT  rr  r  rG  r  r:   rf   )r   r  rr  r  rG  r  r:   r  )r   rQ  rr  r  rG  r  r:   rQ  )r   r"  rr  r  rG  r  r:   r"  )r   rT  rr  r  r  #_TraverseTransformCallableType[Any]r:   rf   )r   r$  rr  r  r  r  r:   r$  )r   r  rr  r  r  r  r:   r  )r   rQ  rr  r  r  r  r:   rQ  )Nrg   
__future__r   collectionsr   enumr   r   r\   rj   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r    r   r   r   util._has_cyr   util.typingr   r   r   
annotationr   elementsr    _py_utilr!   r"   r+   sqlalchemy.cyextension.util__all__r-   r(   r*   rC   r   r   r   r   ExtendedInternalTraversalr  r   r  r"  r$  _TraverseCallableTyper&  r,  r/  MemoizedSlotsr)   rY  re  TraversibleClauseVisitorCloningVisitorReplacingCloningVisitorr!  r#   r$   r%   r&   r'   r1   r9   r6   <module>r     s  
 #                          * ! " +'	<4

NH NG GTP Pf eC):$:;< 
1
 1
hMX ML
 L
^ . 	7 (88   $0) $B e01e/0 #- < <FXc] F 	23G** GT$
0 $
N.M!9 .Md !)4 
 #oo&1	(&1
&1 %&1R 
-	 7 
	 
 
 - 	  7  	  
 !-!	(! 7! %	!H 
	
 7 
	 
 
 	 
  7  	  
 $=	($=
$= 7$= %	$=N 
	
 7 
	 
 
	
 7 		 
X	(X
X 7X %	Xv 
	
 1 
	 
 
	
 1 		 
 
 	 
  1  	  
 D	(D
D 1D %	Dr9   