Ë
    V.j„'  ã                  ón  — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! er0ddlm"Z" ddl#m$Z$ ddlm%Z% ddlm&Z& ddl'm(Z( dd lm)Z) dd!l*m+Z+ dd"l,m-Z-  ed#e¬$«      Z. G d%„ d&ee.   «      Z/ G d'„ d(e«      Z0ejb                  je                  d)¬*«       G d+„ d,e«      «       Z3 G d-„ d.ee.   «      Z4 G d/„ d0e4e.   ee.   «      Z5d3d1„Z6y2)4zâDynamic collection API.

Dynamic collections act like Query() objects for read operations and support
basic add/delete mutation.

.. legacy:: the "dynamic" loader is a legacy feature, superseded by the
 "write_only" loader.


é    )Úannotations)ÚAny)ÚIterable)ÚIterator)ÚList)ÚOptional)ÚTuple)ÚType)ÚTYPE_CHECKING)ÚTypeVar)ÚUnioné   )Ú
attributes)Úexc)Úrelationships)Úutil)ÚPassiveFlag)ÚQuery)Úobject_session)ÚAbstractCollectionWriter)ÚWriteOnlyAttributeImpl)ÚWriteOnlyHistory)ÚWriteOnlyLoaderé   )Úresult)ÚQueryableAttribute)ÚMapper)Ú_RelationshipOrderByArg)ÚSession)ÚInstanceState)ÚAliasedClass)Ú	_Dispatch)ÚColumnElementÚ_T)Úboundc                  ó*   — e Zd Z	 d	 	 	 	 	 	 	 	 	 dd„Zy)ÚDynamicCollectionHistoryNc                ój  — |r_t        ||«      j                  d«      }t        j                  |«      | _        |j
                  | _        |j                  | _        d| _        y t        j                  «       | _        t        j                  «       | _        t        j                  «       | _        d| _        y )NFT)ÚAppenderQueryÚ	autoflushr   ÚOrderedIdentitySetÚunchanged_itemsÚadded_itemsÚdeleted_itemsÚ_reconcile_collection)ÚselfÚattrÚstateÚpassiveÚapply_toÚcolls         úXC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\sqlalchemy/orm/dynamic.pyÚ__init__z!DynamicCollectionHistory.__init__>   s�   € ñ Ü   uÓ-×7Ñ7¸Ó>ˆDÜ#'×#:Ñ#:¸4Ó#@ˆDÔ Ø'×3Ñ3ˆDÔØ!)×!7Ñ!7ˆDÔØ)-ˆDÕ&ä!%×!8Ñ!8Ó!:ˆDÔÜ#×6Ñ6Ó8ˆDÔÜ#'×#:Ñ#:Ó#<ˆDÔ Ø).ˆDÕ&ó    ©N)
r1   ÚDynamicAttributeImplr2   úInstanceState[_T]r3   r   r4   z&Optional[DynamicCollectionHistory[_T]]ÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__r7   © r8   r6   r'   r'   =   s=   „ ð <@ð/à"ð/ð !ð/ð ð	/ð
 9ð/ð 
ô/r8   r'   c                  óP   — e Zd ZU dZee   Zded<   	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zy)r:   TzType[AppenderMixin[Any]]Úquery_classNc                óö   — t        j                  j                  | ||d |fi |¤Ž || _        |rt	        |«      | _        |st        | _        y t        |j                  «       v r|| _        y t        |«      | _        y r9   )r   ÚAttributeImplr7   Útarget_mapperÚtupleÚorder_byr)   rC   ÚAppenderMixinÚmroÚmixin_user_query)r0   Úclass_ÚkeyÚdispatchrF   rH   rC   Úkws           r6   r7   zDynamicAttributeImpl.__init__W   sr   € ô 	× Ñ ×)Ñ)Ø�&˜#˜t Xñ	
Ø13ò	
ð +ˆÔÙÜ! (›OˆDŒMÙÜ,ˆDÕÜ˜kŸo™oÓ/Ñ/Ø*ˆDÕä/°Ó<ˆDÕr8   r9   )rL   z#Union[Type[Any], AliasedClass[Any]]rM   ÚstrrN   z"_Dispatch[QueryableAttribute[Any]]rF   z
Mapper[_T]rH   r   rC   z!Optional[Type[AppenderMixin[_T]]]rO   r   r<   r=   )	r>   r?   r@   Ú_supports_dynamic_iterationr'   r   Úcollection_history_clsÚ__annotations__r7   rA   r8   r6   r:   r:   R   sq   … Ø"&ÐØ5°cÑ:ÐØ)Ó)ð :>ð=à3ð=ð ð=ð 5ð	=ð
 "ð=ð *ð=ð 7ð=ð ð=ð 
ô=r8   r:   Údynamic)Úlazyc                  ó   — e Zd ZeZy)Ú
DynaLoaderN)r>   r?   r@   r:   Ú
impl_classrA   r8   r6   rW   rW   o   s   „ à%�Jr8   rW   c                  óà   ‡ — e Zd ZU dZdZded<   ded<   	 	 	 	 	 	 dˆ fd„Zedd„«       Zej                  dd	„«       Zdd
„Z
erdd„Zdd„Zdd„Z	 d	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zˆ xZS )rI   zTA mixin that expects to be mixing in a Query class with
    AbstractAppender.


    NzOptional[Type[Query[_T]]]rC   zTuple[ColumnElement[Any], ...]Ú_order_by_clausesc                óh   •— t        j                  | |j                  d «       t        ‰| �  ||«       y r9   )r   r7   rF   Úsuper)r0   r1   r2   Ú	__class__s      €r6   r7   zAppenderMixin.__init__~   s1   ø€ ô 	�‰ØØ×ÑØô	
ô
 	‰Ñ˜˜uÕ%r8   c                óÈ   — t        | j                  «      }|�*|j                  r| j                  |v r|j                  «        t	        j
                  | j                  «      sy |S r9   )r   Úinstancer*   ÚflushÚorm_utilÚhas_identity©r0   Úsesss     r6   ÚsessionzAppenderMixin.sessionˆ   sJ   € ä˜dŸm™mÓ,ˆØÐ §¢°4·=±=ÀDÑ3HØ�J‰JŒLÜ×$Ñ$ T§]¡]Ô3ØàˆKr8   c                ó   — || _         y r9   )rd   )r0   re   s     r6   re   zAppenderMixin.session’   s	   € àˆ�	r8   c           
     ój  — | j                   }|�€t        j                  | j                  «      }|j                  r+t        j                  dt        j                  |«      z  «       t        j                  t        j                  | j                  j                  j                  g«      t        | j                  j!                  t        j                  | j                  «      t"        j$                  «      j&                  «      d¬«      j)                  «       S | j+                  |«      j-                  «       S )Nz•Instance %s is detached, dynamic relationship cannot return a correct result.   This warning will become a DetachedInstanceError in a future release.T)Ú_source_supports_scalars)re   r   Úinstance_stater_   Údetachedr   Úwarnra   Ú	state_strr   ÚIteratorResultÚSimpleResultMetaDatar1   rL   r>   ÚiterÚ_get_collection_historyr   ÚPASSIVE_NO_INITIALIZEr-   ÚscalarsÚ	_generateÚ_iter)r0   rd   r2   s      r6   rt   zAppenderMixin._iter–   sì   € Ø�|‰|ˆØ‰<Ü×-Ñ-¨d¯m©mÓ<ˆEØ�~Š~Ü—	‘	ðCô  ×)Ñ)¨%Ó0ñ2ôô ×(Ñ(Ü×+Ñ+¨T¯Y©Y×-=Ñ-=×-FÑ-FÐ,GÓHÜØ—I‘I×5Ñ5Ü"×1Ñ1°$·-±-Ó@Ü#×9Ñ9ó÷ "‘kó	ð *.ô	÷ ‰g‹ið	ð —>‘> $Ó'×-Ñ-Ó/Ð/r8   c                 ó   — y r9   rA   )r0   s    r6   Ú__iter__zAppenderMixin.__iter__±   s   € ¨Cr8   c                ó
  — | j                   }|€V| j                  j                  t        j                  | j
                  «      t        j                  «      j                  |«      S | j                  |«      j                  |«      S r9   )re   r1   rp   r   ri   r_   r   rq   Úindexedrs   Ú__getitem__)r0   Úindexrd   s      r6   ry   zAppenderMixin.__getitem__³   si   € Ø�|‰|ˆØˆ<Ø—9‘9×4Ñ4Ü×)Ñ)¨$¯-©-Ó8Ü×1Ñ1ó÷ ‰g�e‹nðð
 —>‘> $Ó'×3Ñ3°EÓ:Ð:r8   c                ó  — | j                   }|€Zt        | j                  j                  t	        j
                  | j                  «      t        j                  «      j                  «      S | j                  |«      j                  «       S r9   )re   Úlenr1   rp   r   ri   r_   r   rq   r-   rs   Úcountrc   s     r6   r}   zAppenderMixin.count½   sk   € Ø�|‰|ˆØˆ<ÜØ—	‘	×1Ñ1Ü×-Ñ-¨d¯m©mÓ<Ü×5Ñ5ó÷ ‘+ó	ð ð —>‘> $Ó'×-Ñ-Ó/Ð/r8   c                óÚ  — | j                   }|€Pt        |«      }|€Ct        j                  dt	        j
                  |«      ›d| j                  j                  ›d�«      ‚| j                  r(| j                  | j                  j                  |¬«      }n%|j                  | j                  j                  «      }| j                  |_        | j                  |_        | j                  |_        |S )NzParent instance zh is not bound to a Session, and no contextual session is established; lazy load operation of attribute 'z' cannot proceed)re   )r_   r   Úorm_excÚDetachedInstanceErrorra   Úinstance_strr1   rM   rC   rF   ÚqueryÚ_where_criteriaÚ	_from_objrZ   )r0   rd   r_   r‚   s       r6   rs   zAppenderMixin._generateÉ   sÂ   € ð —=‘=ˆØˆ<Ü! (Ó+ˆDØˆ|Ü×3Ò3ô  ×,Ñ,¨XÕ6¸¿	¹	¿»ðGóð ð ×ÒØ×$Ñ$ T§Y¡Y×%<Ñ%<ÀdÐ$ÓK‰Eà—J‘J˜tŸy™y×6Ñ6Ó7ˆEà $× 4Ñ 4ˆÔØŸ.™.ˆŒØ"&×"8Ñ"8ˆÔàˆr8   c                ó&   — | j                  |«       y)a~  Add an iterable of items to this :class:`_orm.AppenderQuery`.

        The given items will be persisted to the database in terms of
        the parent instance's collection on the next flush.

        This method is provided to assist in delivering forwards-compatibility
        with the :class:`_orm.WriteOnlyCollection` collection class.

        .. versionadded:: 2.0

        N©Ú_add_all_impl©r0   Úiterators     r6   Úadd_allzAppenderMixin.add_allæ   s   € ð 	×Ñ˜8Õ$r8   c                ó(   — | j                  |g«       y)ap  Add an item to this :class:`_orm.AppenderQuery`.

        The given item will be persisted to the database in terms of
        the parent instance's collection on the next flush.

        This method is provided to assist in delivering forwards-compatibility
        with the :class:`_orm.WriteOnlyCollection` collection class.

        .. versionadded:: 2.0

        Nr†   ©r0   Úitems     r6   ÚaddzAppenderMixin.addô   s   € ð 	×Ñ˜D˜6Õ"r8   c                ó&   — | j                  |«       y)zÊAdd an iterable of items to this :class:`_orm.AppenderQuery`.

        The given items will be persisted to the database in terms of
        the parent instance's collection on the next flush.

        Nr†   rˆ   s     r6   ÚextendzAppenderMixin.extend  s   € ð 	×Ñ˜8Õ$r8   c                ó(   — | j                  |g«       y)z¿Append an item to this :class:`_orm.AppenderQuery`.

        The given item will be persisted to the database in terms of
        the parent instance's collection on the next flush.

        Nr†   rŒ   s     r6   ÚappendzAppenderMixin.append  s   € ð 	×Ñ˜D˜6Õ"r8   c                ó&   — | j                  |«       y)z¨Remove an item from this :class:`_orm.AppenderQuery`.

        The given item will be removed from the parent instance's collection on
        the next flush.

        N)Ú_remove_implrŒ   s     r6   ÚremovezAppenderMixin.remove  s   € ð 	×Ñ˜$Õr8   )r1   r:   r2   r;   r<   r=   )r<   úOptional[Session])re   r   r<   r=   )r<   z1Union[result.ScalarResult[_T], result.Result[_T]])r<   zIterator[_T])rz   r   r<   zUnion[_T, List[_T]])r<   Úintr9   )rd   r–   r<   z	Query[_T])r‰   zIterable[_T]r<   r=   )r�   r$   r<   r=   )r>   r?   r@   Ú__doc__rC   rS   r7   Úpropertyre   Úsetterrt   r   rv   ry   r}   rs   rŠ   rŽ   r�   r’   r•   Ú__classcell__)r]   s   @r6   rI   rI   t   s°   ø… ñð .2€KÐ*Ó1Ø5Ó5ð&Ø(ð&Ø1Bð&à	õ&ð òó ðð ‡^�^òó ðó0ñ2 ã/ó;ó
0ð #'ðàðð 
óó:%ó#ó%ó#÷ r8   rI   c                  ó   — e Zd ZdZy)r)   zÞA dynamic query that supports basic collection storage operations.

    Methods on :class:`.AppenderQuery` include all methods of
    :class:`_orm.Query`, plus additional methods used for collection
    persistence.


    N)r>   r?   r@   r˜   rA   r8   r6   r)   r)     s   „ òr8   r)   c                óJ   — d| j                   z   }t        |t        | fd| i«      S )zAReturn a new class with AppenderQuery functionality layered over.ÚAppenderrC   )r>   ÚtyperI   )ÚclsÚnames     r6   rK   rK   )  s)   € à˜Ÿ™Ñ$€DÜ�”} cÐ*¨]¸CÐ,@ÓAÐAr8   N)r    r   r<   ztype[AppenderMixin[Any]])7r˜   Ú
__future__r   Útypingr   r   r   r   r   r	   r
   r   r   r   Ú r   r   r   r   r   ra   Úbaser   r‚   r   re   r   Ú	writeonlyr   r   r   r   Úenginer   r   Úmapperr   r   r   r2   r    r!   Úeventr"   Úsql.elementsr#   r$   r'   r:   ÚRelationshipPropertyÚstrategy_forrW   rI   r)   rK   rA   r8   r6   Ú<module>r­      sþ   ðñ	õ #å Ý Ý Ý Ý Ý Ý Ý  Ý Ý å Ý Ý Ý Ý Ý Ý #Ý /Ý -Ý 'Ý &Ý Ý ñ Ý$ÝÝ6Ý Ý$Ý"Ý!Ý,áˆT˜Ô€ô/Ð/°Ñ3ô /ô*=Ð1ô =ð: ×#Ñ#×0Ñ0°iÐ0Ó@ô&�ó &ó Að&ôg Ð,¨RÑ0ô g ôT�M "Ñ% u¨R¡yô ôBr8   