+
    }¯³j5A  ã                  ó®  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RIH
t
 ^ R	IHt ^ R
IHt ^ RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIH t  ^RI!H"t" ^RI!H#t# ]'       da   ^RI$H%t% ^RI$H&t& ^RI$H't' ^RI(H)t) ^RI(H*t* ^RIH+t+ ^R IH,t, ^R!I-H.t. ^R"I/H0t0 ^R#IH1t1 ^R$IH2t2 ^R%IH3t3 ^R&I4H5t5 ^R'I6H7t7 ^R(I8H9t9 ^R)I:H;t; R*R+.t<]! R,]R-7      t=]>t? ! R. R/]"4      t@ ! R0 R1]"4      tA ! R2 R+]]=,          4      tB ! R3 R*] 4      tC ! R4 R5]4      tDR6 R7 ltER8# )9aÌ  Horizontal sharding support.

Defines a rudimental 'horizontal sharding' system which allows a Session to
distribute queries and persistence operations across multiple databases.

For a usage example, see the :ref:`examples_sharding` example included in
the source distribution.

.. deepalchemy:: The horizontal sharding extension is an advanced feature,
   involving a complex statement -> database interaction as well as
   use of semi-public APIs for non-trivial cases.   Simpler approaches to
   referring to multiple database "shards", most commonly using a distinct
   :class:`_orm.Session` per "shard", should always be considered first
   before using this more complex and less-production-tested system.



)Úannotations)ÚAny)ÚCallable)ÚDict)ÚIterable)ÚOptional)ÚTuple)ÚType)ÚTYPE_CHECKING)ÚTypeVar)ÚUnion)Úevent)Úexc)Úinspect)Úutil)ÚPassiveFlag)ÚOrmExecuteOptionsParameter)Ú	ORMOption)ÚMapper)ÚQuery)Ú_BindArguments)Ú_PKIdentityArgument)ÚSession)ÚProtocol)ÚSelf)Ú
Connection)ÚEngine)ÚOptionEngine)ÚIteratorResult)ÚResult)ÚLoaderCallableStatus)Ú_O)ÚBulkUDCompileState)ÚQueryContext)Ú_EntityBindKey)Ú_SessionBind)ÚORMExecuteState)ÚInstanceState)Ú
Executable)Ú_TP)ÚClauseElementÚShardedSessionÚShardedQueryÚ_T)Úboundc                  ó"   € ] tR t^QtR R ltRtR# )ÚShardChooserc               ó(   € V ^8„  d   QhRRRRRRRR/# )é   ÚmapperúOptional[Mapper[_T]]Úinstancer   ÚclauseúOptional[ClauseElement]Úreturn© )Úformats   "Ú`/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sqlalchemy/ext/horizontal_shard.pyÚ__annotate__ÚShardChooser.__annotate__R   s2   € ÷ ñ à$ðð ðð (ð	ð
 
ñó    c                	ó   € R # ©Nr9   )Úselfr3   r5   r6   s   &&&&r;   Ú__call__ÚShardChooser.__call__R   s   € ñ
 r>   r9   N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rB   Ú__static_attributes__r9   r>   r;   r0   r0   Q   s   † ÷ñ r>   r0   c                  ó"   € ] tR t^ZtR R ltRtR# )ÚIdentityChooserc               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# ©r2   r3   z
Mapper[_T]Úprimary_keyr   Úlazy_loaded_fromúOptional[InstanceState[Any]]Úexecution_optionsr   Úbind_argumentsr   Úkwr   r8   r9   )r:   s   "r;   r<   ÚIdentityChooser.__annotate__[   sP   € ÷ 	ñ 	àð	ð )ð	ð
 7ð	ð 6ð	ð 'ð	ð ð	ð 
ñ	r>   c               	ó   € R # r@   r9   )rA   r3   rN   rO   rQ   rR   rS   s   &&&$$$,r;   rB   ÚIdentityChooser.__call__[   s   € ñ r>   r9   NrD   r9   r>   r;   rK   rK   Z   s   † ÷	ñ 	r>   rK   c                  ó>   a € ] tR t^gtRtR V 3R lltR R ltRtV ;t# )r,   a  Query class used with :class:`.ShardedSession`.

.. legacy:: The :class:`.ShardedQuery` is a subclass of the legacy
   :class:`.Query` class.   The :class:`.ShardedSession` now supports
   2.0 style execution via the :meth:`.ShardedSession.execute` method.

c               ó$   € V ^8„  d   QhRRRRRR/# )r2   Úargsr   Úkwargsr8   ÚNoner9   )r:   s   "r;   r<   ÚShardedQuery.__annotate__p   s!   € ÷ ñ ˜cð ¨Sð °Tñ r>   c                	óæ   <€ \         SV `  ! V/ VB  \        V P                  \        4      '       g   Q hV P                  P
                  V n        V P                  P                  V n        R V n        R # r@   )ÚsuperÚ__init__Ú
isinstanceÚsessionr+   Úidentity_chooserÚexecute_chooserÚ	_shard_id)rA   rY   rZ   Ú	__class__s   &*,€r;   r_   ÚShardedQuery.__init__p   sW   ø€ Ü‰Ò˜$Ð) &Ò)Ü˜$Ÿ,™,¬×7Ò7Ð7Ð7à $§¡× =Ñ =ˆÔØ#Ÿ|™|×;Ñ;ˆÔØˆŽr>   c               ó    € V ^8„  d   QhRRRR/# )r2   Úshard_idÚShardIdentifierr8   r   r9   )r:   s   "r;   r<   r\   x   s   € ÷ =ñ = /ð =°dñ =r>   c                ó&   € V P                  VR7      # )ae  Return a new query, limited to a single shard ID.

All subsequent operations with the returned query will
be against the single shard regardless of other state.

The shard_id can be passed for a 2.0 style execution to the
bind_arguments dictionary of :meth:`.Session.execute`::

    results = session.execute(stmt, bind_arguments={"shard_id": "my_shard"})

)Ú_sa_shard_id)rQ   )rA   rh   s   &&r;   Ú	set_shardÚShardedQuery.set_shardx   s   € ð ×%Ñ%°8Ð%Ó<Ð<r>   )rd   rc   rb   )	rE   rF   rG   rH   Ú__doc__r_   rl   rI   Ú__classcell__©re   s   @r;   r,   r,   g   s   ø† ñ÷ð ÷=ó =r>   c                  óö   a € ] tR t^‡t$ R]R&   R]R&   R]R&   RRR]3RRR	R/R
 V 3R lllltR]P                  R]	P                  R3R V 3R llltR R ltRR R lltRRRRRRR/R R llltR R ltRtV ;t# )r+   r0   Úshard_chooserrK   rb   z*Callable[[ORMExecuteState], Iterable[Any]]rc   NÚ
id_chooserÚquery_chooserc               ó<   € V ^8„  d   QhRRRRRRRRR	R
RRRRRRRR/	# )r2   rr   r0   rb   zOptional[IdentityChooser]rc   z4Optional[Callable[[ORMExecuteState], Iterable[Any]]]ÚshardszOptional[Dict[str, Any]]Ú	query_clszType[Query[_T]]rs   z<Optional[Callable[[Query[_T], Iterable[_T]], Iterable[Any]]]rt   z/Optional[Callable[[Executable], Iterable[Any]]]rZ   r   r8   r[   r9   )r:   s   "r;   r<   ÚShardedSession.__annotate__Œ   sp   € ÷ n.ñ n.à#ðn.ð 4ðn.ð
ð	n.ð )ðn.ð #ðn.ð
ðn.ð Gðn.ð ðn.ð 
ñn.r>   c               óh  <a aa€ \         SS `  ! RRV/VB  \        P                  ! S R\        RR7       VS n        V'       d,   Vo\        P                  ! RR4       R VV 3R llp	V	S n        M&V'       d	   VS n        M\        P                  ! R	4      hV'       dG   Vo\        P                  ! R
R4       V'       d   \        P                  ! R4      hR V3R llp
Vf   T
pVf   \        P                  ! R4      hVS n        / S n        Ve$   V F  pS P                  W´V,          4       K  	  R# R# )aN  Construct a ShardedSession.

:param shard_chooser: A callable which, passed a Mapper, a mapped
  instance, and possibly a SQL clause, returns a shard ID.  This id
  may be based off of the attributes present within the object, or on
  some round-robin scheme. If the scheme is based on a selection, it
  should set whatever state on the instance to mark it in the future as
  participating in that shard.

:param identity_chooser: A callable, passed a Mapper and primary key
 argument, which should return a list of shard ids where this
 primary key might reside.

  .. versionchanged:: 2.0  The ``identity_chooser`` parameter
     supersedes the ``id_chooser`` parameter.

:param execute_chooser: For a given :class:`.ORMExecuteState`,
  returns the list of shard_ids
  where the query should be issued.  Results from all shards returned
  will be combined together into a single listing.

  .. versionchanged:: 1.4  The ``execute_chooser`` parameter
     supersedes the ``query_chooser`` parameter.

:param shards: A dictionary of string shard names
  to :class:`~sqlalchemy.engine.Engine` objects.

rw   Údo_orm_executeT)ÚretvalzLThe ``id_chooser`` parameter is deprecated; please use ``identity_chooser``.z2.0c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# rM   r9   )r:   s   "r;   r<   Ú-ShardedSession.__init__.<locals>.__annotate__Ç   sN   € ÷ 3ñ 3Ø"ð3à0ð3ð #?ð	3ð
 $>ð3ð !/ð3ð ð3ð ñ3r>   c               óh   <€ SP                  V 4      pV'       d   VP                  V4      pS! Wa4      # r@   )ÚqueryÚ_set_lazyload_from)	r3   rN   rO   rQ   rR   rS   ÚqÚ_id_chooserrA   s	   &&$$$, €€r;   Ú_legacy_identity_chooserÚ9ShardedSession.__init__.<locals>._legacy_identity_chooserÇ   s2   ø€ ð —J‘J˜vÓ&�ß#Ø×,Ñ,Ð-=Ó>�AÙ" 1Ó2Ð2r>   z*identity_chooser or id_chooser is requiredzNThe ``query_chooser`` parameter is deprecated; please use ``execute_chooser``.z1.4z>Can't pass query_chooser and execute_chooser at the same time.c               ó    € V ^8„  d   QhRRRR/# )r2   Úorm_contextr&   r8   zIterable[Any]r9   )r:   s   "r;   r<   r}   ê   s   € ÷ =ñ =Ø,ð=àñ=r>   c                ó(   <€ S! V P                   4      # r@   )Ú	statement)r†   Ú_query_choosers   &€r;   Ú_default_execute_chooserÚ9ShardedSession.__init__.<locals>._default_execute_chooserê   s   ø€ ñ & k×&;Ñ&;Ó<Ð<r>   Nz,execute_chooser or query_chooser is requiredr9   )r^   r_   r   ÚlistenÚexecute_and_instancesrr   r   Úwarn_deprecatedrb   r   ÚArgumentErrorrc   Ú_ShardedSession__shardsÚ
bind_shard)rA   rr   rb   rc   rv   rw   rs   rt   rZ   rƒ   rŠ   Úkr‚   r‰   re   s   f&&&&&$$,   @@€r;   r_   ÚShardedSession.__init__Œ   s5  û€ ôX 	‰ÒÑ7 9Ð7°Ò7ä�ŠØÐ"Ô$9À$õ	
ð +ˆÔçØ$ˆKÜ× Ò ð3àô÷3ñ 3ð %=ˆDÕ!ßØ$4ˆDÕ!ä×#Ò#Ø<óð ÷ Ø*ˆNÜ× Ò ð2àô÷
 Ü×'Ò'ð(óð ÷
=ð =ð
 Ò&Ø":�àÒ"Ü×#Ò#Ø>óð ð  /ˆÔØ=?ˆŒØÒÛ�Ø—‘ ¨!¥9Ö-ó ñ r>   c               ó<   € V ^8„  d   QhRRRRRRRRR	R
RRRRRRRR/	# )r2   r3   z
Mapper[_O]Úprimary_key_identityzUnion[Any, Tuple[Any, ...]]Úidentity_tokenúOptional[Any]Úpassiver   rO   rP   rQ   r   rR   zOptional[_BindArguments]rS   r   r8   z)Union[Optional[_O], LoaderCallableStatus]r9   )r:   s   "r;   r<   rx   ü   sd   € ÷ /ñ /àð/ð :ð/ð &ð	/ð
 ð/ð 7ð/ð 6ð/ð 1ð/ð ð/ð 
3ñ/r>   c           	     óØ   <€ Ve   \         SV `  ! VV3RV/VB p	V	# T P                  TTTTV'       d   \        V4      M/ R7       F!  p
\         SV `  ! VV3RV
RV/VB pVf   K  Vu # 	  R# )a7  override the default :meth:`.Session._identity_lookup` method so
that we search for a given non-token primary key identity across all
possible identity tokens (e.g. shard ids).

.. versionchanged:: 1.4  Moved :meth:`.Session._identity_lookup` from
   the :class:`_query.Query` object to the :class:`.Session`.

Nr–   )rO   rQ   rR   rO   )r^   Ú_identity_lookuprb   Údict)rA   r3   r•   r–   r˜   rO   rQ   rR   rS   Úobjrh   Úobj2re   s   &&&&&&&&,   €r;   rš   ÚShardedSession._identity_lookupü   s´   ø€ ð( Ò%Ü‘'Ò*ØØ$ñð  .ðð ñ	ˆCð ˆJà ×1Ñ1ØØ$Ø!1Ø"3ß7Eœt NÔ3È2ð 2ö �ô ‘wÒ/ØØ(ñð $,ðð &6ð	ð
 ñ�ð Ô#Ø’Kññ" r>   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r2   r3   úOptional[_EntityBindKey[_O]]r5   r   rS   r8   r9   )r:   s   "r;   r<   rx   -  s2   € ÷ ñ à,ðð ðð ð	ð
 
ñr>   c                	ó&  € VeW   \        V4      pVP                  '       d   VP                  ^,          pVf   Q hV# VP                  '       d   VP                  # \        V\        4      '       g   Q hV P
                  ! W3/ VB pVe   VXn        V# r@   )r   Úkeyr–   r`   r   rr   )rA   r3   r5   rS   ÚstateÚtokenrh   s   &&&,   r;   Ú_choose_shard_and_assignÚ'ShardedSession._choose_shard_and_assign-  sŽ   € ð ÒÜ˜HÓ%ˆEØ�y�yˆyØŸ	™	 !��ØÒ(Ð(Ð(Ø�Ø×%×%Ð%Ø×+Ñ+Ð+ä˜&¤&×)Ò)Ð)Ð)Ø×%Ò% fÑ=¸"Ñ=ˆØÒØ#+ˆEÔ Øˆr>   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r2   r3   r4   r5   r—   rh   úOptional[ShardIdentifier]rS   r   r8   r   r9   )r:   s   "r;   r<   rx   B  s<   € ÷ ñ à$ðð  ðð ,ð	ð
 ðð 
ñr>   c                óR  € Vf   V P                  W4      pV P                  4       '       d)   V P                  4       pVf   Q hVP                  WR7      # V P	                  WVR7      p\        V\        4      '       d   VP                  ! R/ VB # \        V\        4      '       g   Q hV# )zQProvide a :class:`_engine.Connection` to use in the unit of work
flush process.

)rh   )r3   rh   r5   r9   )	r¥   Úin_transactionÚget_transactionÚ
connectionÚget_bindr`   r   Úconnectr   )rA   r3   r5   rh   rS   ÚtransÚbinds   &&&&,  r;   Úconnection_callableÚ"ShardedSession.connection_callableB  s¨   € ð ÒØ×4Ñ4°VÓFˆHà×Ñ× Ò Ø×(Ñ(Ó*ˆEØÒ$Ð$Ð$Ø×#Ñ# FÐ#Ó>Ð>à—=‘=Ø¸8ð !ó ˆDô ˜$¤×'Ò'Ø—|’|Ñ) bÑ)Ð)ä! $¬
×3Ò3Ð3Ð3Ø�r>   rh   r5   r6   c               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# )r2   r3   r    rh   r¨   r5   r—   r6   r7   rS   r   r8   r%   r9   )r:   s   "r;   r<   rx   `  sF   € ÷ 'ñ 'à,ð'ð ,ð	'ð
  ð'ð (ð'ð ð'ð 
ñ'r>   c               	ób   € Vf   V P                  WVR7      pVf   Q hV P                  V,          # )N)r5   r6   )r¥   r�   )rA   r3   rh   r5   r6   rS   s   &&$$$,r;   r­   ÚShardedSession.get_bind`  sA   € ð ÒØ×4Ñ4Ø°&ð 5ó ˆHð Ò'Ð'Ð'Ø�}‰}˜XÕ&Ð&r>   c               ó$   € V ^8„  d   QhRRRRRR/# )r2   rh   ri   r°   zUnion[Engine, OptionEngine]r8   r[   r9   )r:   s   "r;   r<   rx   p  s$   € ÷ 'ñ 'Ø'ð'Ø/Jð'à	ñ'r>   c                	ó"   € W P                   V&   R # r@   )r�   )rA   rh   r°   s   &&&r;   r‘   ÚShardedSession.bind_shardp  s   € ð #'�‰�hÓr>   )Ú__shardsrc   rb   rr   )NNNr@   )rE   rF   rG   rH   Ú__annotations__r,   r_   r   ÚPASSIVE_OFFr   Ú
EMPTY_DICTrš   r¥   r±   r­   r‘   rI   ro   rp   s   @r;   r+   r+   ‡   s¬   ø‡ ØÓØ%Ó%Ø?Ó?ð
 7;ð Ø+/Ø%1ñn.ð ðn.ð JN÷n.ó n.ðh )-Ø*×6Ñ6Ø9=Ø8<¿¹Ø37÷/ò /õb÷*ñ<'ð /3ð	'ð
 #'ð'ð +/÷'ð '÷ 'ó 'r>   c                  ó.   € ] tR tRtRtRtRR R lltRtR# )	Úset_shard_idiv  a¸  a loader option for statements to apply a specific shard id to the
primary query as well as for additional relationship and column
loaders.

The :class:`_horizontal.set_shard_id` option may be applied using
the :meth:`_sql.Executable.options` method of any executable statement::

    stmt = (
        select(MyObject)
        .where(MyObject.name == "some name")
        .options(set_shard_id("shard1"))
    )

Above, the statement when invoked will limit to the "shard1" shard
identifier for the primary query as well as for all relationship and
column loading strategies, including eager loaders such as
:func:`_orm.selectinload`, deferred column loaders like :func:`_orm.defer`,
and the lazy relationship loader :func:`_orm.lazyload`.

In this way, the :class:`_horizontal.set_shard_id` option has much wider
scope than using the "shard_id" argument within the
:paramref:`_orm.Session.execute.bind_arguments` dictionary.


.. versionadded:: 2.0.0

c               ó    € V ^8„  d   QhRRRR/# )r2   rh   ri   Úpropagate_to_loadersÚboolr9   )r:   s   "r;   r<   Úset_shard_id.__annotate__•  s   € ÷ 9ñ 9Ø'ð9Ø?Cñ9r>   c                ó   € Wn         W n        R# )a   Construct a :class:`_horizontal.set_shard_id` option.

:param shard_id: shard identifier
:param propagate_to_loaders: if left at its default of ``True``, the
 shard option will take place for lazy loaders such as
 :func:`_orm.lazyload` and :func:`_orm.defer`; if False, the option
 will not be propagated to loaded objects. Note that :func:`_orm.defer`
 always limits to the shard_id of the parent row in any case, so the
 parameter only has a net effect on the behavior of the
 :func:`_orm.lazyload` strategy.

N©rh   rÀ   )rA   rh   rÀ   s   &&&r;   r_   Úset_shard_id.__init__•  s   € ð !ŒØ$8Ö!r>   )rÀ   rh   NrÄ   )T)rE   rF   rG   rH   rn   Ú	__slots__r_   rI   r9   r>   r;   r¾   r¾   v  s   † ñð8 5€I÷9ó 9r>   r¾   c               ó    € V ^8„  d   QhRRRR/# )r2   r†   r&   r8   ú&Union[Result[_T], IteratorResult[_TP]]r9   )r:   s   "r;   r<   r<   ¨  s   € ÷ 7.ñ 7.Ø ð7.à+ñ7.r>   c                ó  a € S P                   '       d   S P                  pM3S P                  '       g   S P                  '       d   S P                  pMR pS P
                  p\        V\        4      '       g   Q hR V 3R llpS P                   F'  p\        V\        4      '       g   K  VP                  p Mq	  V'       d   VP                  e   VP                  pMLRS P                  9   d   S P                  R,          pM'RS P                  9   d   S P                  R,          pMR pVe	   V! V4      # . pVP                  S 4       F  pV! V4      pVP                  V4       K  	  V^ ,          P                   ! VR,          !  # )Nc               ó    € V ^8„  d   QhRRRR/# )r2   rh   ri   r8   rÈ   r9   )r:   s   "r;   r<   Ú+execute_and_instances.<locals>.__annotate__¾  s    € ÷ Kñ KØ!ðKà	/ñKr>   c                ó~   <€ \        SP                  4      pWR &   SP                  V R7       SP                  VR7      # )rh   )r–   )rR   )r›   rR   Úupdate_execution_optionsÚinvoke_statement)rh   rR   r†   s   & €r;   Úiter_for_shardÚ-execute_and_instances.<locals>.iter_for_shard¾  sB   ø€ ô ˜k×8Ñ8Ó9ˆØ%-�zÑ"à×,Ñ,¸HÐ,ÔEØ×+Ñ+¸>Ð+ÓJÐJr>   rk   rh   :é   NN)Ú	is_selectÚload_optionsÚ	is_updateÚ	is_deleteÚupdate_delete_optionsra   r`   r+   Ú_non_compile_orm_optionsr¾   rh   Ú_identity_tokenrQ   rR   rc   ÚappendÚmerge)r†   Úactive_optionsra   rÏ   Úorm_optrh   ÚpartialÚresult_s   f       r;   r�   r�   ¨  sT  ø€ ð ××ÐØ$×1Ñ1‰à	×	×	Ð	 +×"7×"7Ð"7Ø$×:Ñ:‰àˆà×!Ñ!€GÜ�gœ~×.Ò.Ð.Ð.÷Kð Kð ×7Ô7ˆô �gœ|×,Ô,Ø×'Ñ'ˆHÙñ 8÷ ˜n×<Ñ<ÒHØ%×5Ñ5‰HØ˜{×<Ñ<Ô<Ø"×4Ñ4°^ÕD‰HØ˜;×5Ñ5Ô5Ø"×1Ñ1°*Õ=‰HàˆHàÒÙ˜hÓ'Ð'àˆØ×/Ñ/°Ö<ˆHÙ$ XÓ.ˆGØ�N‰N˜7Ö#ñ =ð �q�z×Ò ¨¥Ñ-Ð-r>   N)Frn   Ú
__future__r   Útypingr   r   r   r   r   r   r	   r
   r   r   Ú r   r   r   r   Úormr   Úorm._typingr   Úorm.interfacesr   Ú
orm.mapperr   Ú	orm.queryr   Úorm.sessionr   r   r   Úutil.typingr   r   Úengine.baser   r   r   Úengine.resultr   r   r    r!   Úorm.bulk_persistencer"   Úorm.contextr#   r$   r%   r&   Ú	orm.stater'   Úsqlr(   Úsql._typingr)   Úsql.elementsr*   Ú__all__r-   Ústrri   r0   rK   r,   r+   r¾   r�   r9   r>   r;   Ú<module>ró      sñ   ðñõ& #å Ý Ý Ý Ý Ý Ý Ý  Ý Ý å Ý Ý Ý Ý Ý 4Ý &Ý Ý Ý (Ý -Ý !Ý "Ý çÝ(Ý$Ý*Ý.Ý&Ý*Ý Ý9Ý*Ý,Ý*Ý-Ý)Ý Ý!Ý,à˜^Ð
,€áˆT˜Ô€ð €ô�8ô ô
�hô 
ô=�5˜•9ô =ô@l'�Wô l'ô^/9�9ô /9÷d7.r>   