
    ,h                   b   S r SSKJr  SSKJ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!  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/J0r0  SS)K/J1r1  SS*K/J2r2  SS+K/J3r3  SS,K/J4r4  SS-K5J6r6  SS.K5J7r7  SS/K5J8r8  SS0K5J9r9  SS1K5J:r:  SS2K5J;r;  SS3K5J<r<  SS4K5J=r=  SS5K5J>r>  SS6K?J@r@  SS7KAJBrB  S8S9KJCrC  S8SKJr  S8S:KDJErE  S8S;KDJFrF  \(       a  SS<KJGrG  SS=KJHrH  SS>KJIrI  SS?KJJrJ  SS@KJKrK  SSAKJLrL  SSBKJMrM  SSCKJNrN  SSDKJOrO  SSEKJPrP  SSFKJQrQ  SSGKJRrR  SSHKJSrS  SSIKJTrU  SSJK"JVrV  SSKKWJXrX  SSLK/JYrY  SSMK5JZrZ  SSNK5J[r[  SSOK5J\r\  SSPK5J]r]  SwSR jr^SxSS jr_SyST jr`O6\R                  " SU5      r^\R                  " SV5      r_\R                  " SW5      r`\" SX\SY9rb\\c\2\   4   rd\\=\6\;4   re " SZ SQ\*5      rf\*R                  " S[S\5       " S] S^\f5      5       rh\*R                  " S[S_5       " S` Sa\f5      5       ri\*R                  " S[Sb5       " Sc Sd\f5      5       rj " Se Sf\R                  \9\.\+\:\-\7\15
      rl " Sg Sh\l5      rm " Si Sj\m5      rn " Sk Sl\n\>\   5      ro " Sm Sn5      rp " So Sp\p\m5      rq " Sq Sr\q\>\   5      rr " Ss St\p\l5      rs " Su Sv\q\>\   5      rtg)zzd
Provide :class:`_expression.Insert`, :class:`_expression.Update` and
:class:`_expression.Delete`.

    )annotationsN)Any)cast)Dict)Iterable)List)MutableMapping)NoReturn)Optional)overload)Sequence)Set)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )	coercions)roles)util)_TP)_unexpected_kw)is_column_element)is_named_from_clause)_entity_namespace_key)_exclusive_against)_from_objects)_generative)_select_iterables)ColumnCollection)	ColumnSet)CompileState)DialectKWArgs)
Executable)
Generative)HasCompileState)BooleanClauseList)ClauseElement)ColumnClause)ColumnElement)Null)Alias)ExecutableReturnsRows)
FromClause)HasCTE)HasPrefixes)Join)SelectLabelStyle)TableClause)TypedReturnsRows)NullType)InternalTraversal   )exc)Self)	TypeGuard)_ColumnExpressionArgument)_ColumnsClauseArgument)_DMLColumnArgument)_DMLColumnKeyMapping)_DMLTableArgument)_T0)_T1)_T2)_T3)_T4)_T5)_T6)_T7)_TypedColumnClauseArgument)ReadOnlyColumnCollection)SQLCompiler)KeyedColumnElement)_ColumnsClauseElement)_SelectIterable)Select)
SelectableDMLStatec                    g N dmls    J/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/sql/dml.pyisupdaterX   `       c    c                    g rS   rT   rU   s    rW   isdeleter\   b   rY   rZ   c                    g rS   rT   rU   s    rW   isinsertr^   d   rY   rZ   rX   r\   r^   _T)boundc                  p   \ rS rSr% SrSrS\S'   SrS\S'   SrS\S	'   Sr	S
\S'   S\S'   Sr
SrSrSrS\S'         SS jr\SS j5       r\    S S j5       r\S!S j5       r\(       a
  \S"S j5       r\      S#S j5       r\        S$S j5       r    S%S jrS&S jrS&S jrS'S jrS(S jrSrg))rQ   r   TNz0Optional[MutableMapping[_DMLColumnElement, Any]]_dict_parametersz6Optional[List[MutableMapping[_DMLColumnElement, Any]]]_multi_parameters-Optional[List[Tuple[_DMLColumnElement, Any]]]_ordered_valuesz!Optional[List[_DMLColumnElement]]_parameter_orderingr/   _primary_tableF
UpdateBase	statementc                    [        5       erS   NotImplementedError)selfrj   compilerkws       rW   __init__DMLState.__init__   s     "##rZ   c                    [        UR                  5      (       a  UR                  R                  OS UR                  S.$ )N)nametable)r   ru   rt   clsrj   s     rW   get_entity_descriptionDMLState.get_entity_description   s6    
 (	88 $$__
 	
rZ   c                v    UR                    Vs/ s H  nUR                  UR                  US.PM     sn$ s  snf )N)rt   typeexpr)_all_selected_columnskeyr{   )rw   rj   cs      rW   !get_returning_column_descriptions*DMLState.get_returning_column_descriptions   sF     44
 5	 
 5
 	
 
s   $6c                .    U R                   R                  $ rS   )rj   ru   rn   s    rW   	dml_tableDMLState.dml_table   s    ~~###rZ   c                    g rS   rT   rv   s     rW   get_plugin_classDMLState.get_plugin_class   s    LOrZ   c                    U VVVs/ s HL  nUR                  5        VVs0 s H+  u  pE[        R                  " [        R                  U5      U_M-     snnPMN     snnn$ s  snnf s  snnnf rS   )itemsr   expectr   DMLColumnRole)rw   rj   multi_kv_iteratormappingkvs         rW   _get_multi_crud_kv_pairs!DMLState._get_multi_crud_kv_pairs   sj     -

 - $MMO+DA   !4!4a8!;+ -
 	

s   A%2AA%A%c                    U VVs/ s H`  u  pE[         R                  " [        R                  U5      U(       d  UO,[         R                  " [        R                  U[        5       SS94PMb     snn$ s  snnf )NT)type_is_crud)r   r   r   r   ExpressionElementRoler6   )rw   rj   kv_iteratorneeds_to_be_cacheabler   r   s         rW   _get_crud_kv_pairsDMLState._get_crud_kv_pairs   ss    * $
 $   !4!4a8 1 "))33&j $	 $
 	
 
s   A'A1c                   / n[        [        R                  " UR                  5      5      nUS   nU1nUR                  nU R
                  (       a&  U[        U R
                  R                  5       5      -  nU Ha  n[        U5       HO  nUR                  UR                  5      (       d  UR                  U5        UR                  UR                  5        MQ     Mc     UR                  USS  5        XB4$ )Nr   r   )listsql_utiltables_from_leftmostru   _where_criteriarc   tuplevaluesr   intersection_cloned_setappendupdateextend)	rn   rj   froms
all_tablesprimary_tableseenconsidercrititems	            rW   _make_extra_fromsDMLState._make_extra_froms   s     #%(77	HI
"1,,  d33::<==HD%d+(()9)9::LL&D,,- ,  	Z^$##rZ   c                X    U R                   (       a  UR                  U l        SU l         g g NF)_no_parameters_valuesrc   rn   rj   s     rW   _process_valuesDMLState._process_values   s&    $-$5$5D!"'D rZ   c                    UR                   c   eUR                    Vs0 s H  o"[        5       _M     nnU R                  (       a  SU l        X0l        g  S5       es  snf )NFz%This statement already has parameters)_select_namesr,   r   rc   )rn   rj   rt   
parameterss       rW   _process_select_valuesDMLState._process_select_values   sg    &&222%.%<%<>
%<T$&L%< 	 >
 "'D$.! BAA5>
s   Ac                d    [         R                  " SUR                  R                  5       -  5      e)Nz6%s construct does not support multiple parameter sets.)r9   InvalidRequestError__visit_name__upperr   s     rW   _no_multi_values_supported#DMLState._no_multi_values_supported   s2    %%')2)A)A)G)G)IJ
 	
rZ   c                .    [         R                  " S5      e)NzCan't mix single and multiple VALUES formats in one INSERT statement; one style appends to a list while the other replaces values, so the intent is ambiguous.)r9   r   r   s    rW   _cant_mix_formats_error DMLState._cant_mix_formats_error   s    %%
 	
rZ   )rc   r   )rj   ri   ro   rK   rp   r   )rj   ri   returnDict[str, Any])rj   ri   r   List[Dict[str, Any]]r   _DMLTableElement)rj   r%   r   zType[DMLState])rj   ri   r   z'Iterable[Dict[_DMLColumnArgument, Any]]r   z"List[Dict[_DMLColumnElement, Any]])rj   ri   r   z(Iterable[Tuple[_DMLColumnArgument, Any]]r   boolr   z#List[Tuple[_DMLColumnElement, Any]])rj   DMLWhereBaser   z#Tuple[FromClause, List[FromClause]]rj   
ValuesBaser   None)rj   r   r   r
   )r   r
   )__name__
__module____qualname____firstlineno__r   rc   __annotations__rd   rf   rg   _supports_implicit_returningrX   r\   r^   rq   classmethodrx   r   propertyr   r   r   r   r   r   r   r   r   r   __static_attributes__rT   rZ   rW   rQ   rQ   r   sr   NIMFM 	    FJOBI=A:A#' HHH$#$/:$BE$
 
 
 

"

	

 

 $ $ 	O 
O

 C
 
,	
 
 

 >
  $	

 
-
 
.$%$	,$,(
B

rZ   defaultinsertc                  z    \ rS rSrSrSrSr S
       SS jjr\R                  SS j5       r
SS jrSS jrSrg	)InsertDMLStatei  TFc                "   Xl         UR                  U l        U(       a  SU l        SU l        UR
                  (       a  U R                  U5        UR                  b  U R                  U5        UR                  (       a  U R                  U5        g g )NFT)rj   ru   rh   r   r^   r   r   r   r   _multi_values_process_multi_values)rn   rj   ro   disable_implicit_returningrp   s        rW   rq   InsertDMLState.__init__  st     #'oo%05D-""''	2(  +""&&y1 #rZ   c           	         U R                   =(       d    S Vs/ s H'  n[        R                  " [        R                  USS9PM)     sn$ s  snf )NrT   Tas_key)rc   r   r   r   r   )rn   cols     rW   _insert_col_keysInsertDMLState._insert_col_keys$  sL    
 ,,22
2 U00#dC2
 	
 
s   .A	c                    U R                   (       a   SU l        UR                  U l        SU l         g U R                  (       a  U R	                  5         g g r   )r   _has_multi_parametersr   rc   r   r   s     rW   r   InsertDMLState._process_values,  sC    ).D&$-$5$5D!"'D''((* (rZ   c                J   UR                    GH  nU VVVs/ s Hd  n[        U[        R                  5      (       a@  [	        UR
                  R                  U5       VVs0 s H  u  pEUR                  U_M     snnOUPMf     nnnnU R                  (       a*  SU l        SU l	        X`l
        U R                  S   U l        M  U R                  (       d  U R                  5         M  U R                  (       d   eU R                  R                  U5        GM     g s  snnf s  snnnf )NFTr   )r   
isinstancecollections_abcr   zipru   r   r~   r   r   rd   rc   r   r   )rn   rj   r   parameter_setr   valuemulti_parameterss          rW   r   $InsertDMLState._process_multi_values4  s   #11J &0
N &0M "-1I1IJJ ),IOO,=,=}(M(MHA u(M
 '' &0  
N ""&+#-1*)9&(,(>(>q(A%//,,.----&&--.>?- 2
Ns   AD
D8
D
D
)rc   r   rd   r   rh   r   r^   rj   NF)rj   Insertro   rK   r   r   rp   r   )r   z	List[str]r   )r   r   r   r   r^   include_table_with_column_exprsr   rq   r   memoized_propertyr   r   r   r   rT   rZ   rW   r   r     sh    H&+#! ,1	22 2 %)	2
 2* 

 
+@rZ   r   r   c                  0    \ rS rSrSrSrSS jrS	S jrSrg)
UpdateDMLStateiN  TFc                t   Xl         SU l        UR                  b  U R                  U5        OAUR                  b  U R                  U5        O"UR                  (       a  U R                  U5        U R                  U5      u  pEX@l	        XPl
        U=U l        n[        U=(       a    UR                  5      U l        g NT)rj   rX   rf   _process_ordered_valuesr   r   r   r   r   rh   _extra_fromsis_multitabler   'render_table_with_column_in_update_fromr   )rn   rj   ro   rp   tefmts          rW   rq   UpdateDMLState.__init__T  s    "$$0((3*  +$$++I6&&y1"$$R/3C8CC0
,rZ   c                    UR                   nU R                  (       a?  SU l        Uc   e[        U5      U l        X l         U VVs/ s H  u  p4UPM	     snnU l        g [
        R                  " S5      es  snnf )NFzQCan only invoke ordered_values() once, and not mixed with any other values() call)rf   r   dictrc   rg   r9   r   )rn   rj   r   r~   r   s        rW   r   &UpdateDMLState._process_ordered_valuesg  st    ..
"'D)))$($4D!#- >H'Ij
j'ID$))/  (Js   A3)
rc   r   r   rf   rg   rh   r   r   rX   rj   N)rj   Updatero   rK   rp   r   r   )	r   r   r   r   rX   r   rq   r   r   rT   rZ   rW   r   r   N  s    H&+#
&rZ   r   deletec                  "    \ rS rSrSrSS jrSrg)DeleteDMLStateiw  Tc                h    Xl         SU l        U R                  U5      u  pEX@l        XPl        XPl        g r   )rj   r\   r   rh   r   r   )rn   rj   ro   rp   r   r   s         rW   rq   DeleteDMLState.__init__{  s2    "&&y1rZ   )r   rh   r   r\   rj   N)rj   Deletero   rK   rp   r   )r   r   r   r   r\   rq   r   rT   rZ   rW   r  r  w  s    H rZ   r  c                     \ rS rSr% SrSr\R                  rS\	S'   Sr
\R                  rS\	S'   S	\	S
'   SrSrS\	S'   SrS\	S'   SrS\	S'   Sr          S"S jrS#S jr\S$S j5       r\SSS.       S%S jj5       rS&S jr\SS.       S'S jj5       r S(     S)S jjr\R6                  S*S j5       r\R6                    S+S j5       r\  S,       S-S jj5       r\S.S j5       r \S/S  j5       r!S!r"g)0ri   i  zDForm the base for ``INSERT``, ``UPDATE``, and ``DELETE`` statements.update_basez5util.immutabledict[Tuple[_DMLTableElement, str], str]_hintsFr3   _label_styler   ru   Nz+Optional[Tuple[_ColumnsClauseElement, ...]]_return_defaults_columns_supplemental_returningrT   z!Tuple[_ColumnsClauseElement, ...]
_returningTc                X   ^^^ UR                  UUU4S jU R                   5       5        g )Nc              3  j   >#    U  H(  n[        U5      (       d  M  UR                  TTTS 9v   M*     g7f))primary_keyforeign_keysN)r   _make_proxy).0r   r  
fromclauser  s     rW   	<genexpr>AUpdateBase._generate_fromclause_column_proxies.<locals>.<genexpr>  s;      (
 2 %	COO,   2s   33)_populate_separate_keysr}   )rn   r  columnsr  r  s    ` ``rW   #_generate_fromclause_column_proxies.UpdateBase._generate_fromclause_column_proxies  s(     	'' (
 11	(
 	
rZ   c                    [        S5      e)zSet the parameters for the statement.

This method raises ``NotImplementedError`` on the base class,
and is overridden by :class:`.ValuesBase` to provide the
SET/VALUES clause of UPDATE and INSERT.

zparams() is not supported for INSERT/UPDATE/DELETE statements. To set the values for an INSERT or UPDATE statement, use stmt.values(**parameters).rl   )rn   argrp   s      rW   paramsUpdateBase.params  s     "*
 	
rZ   c                (    U R                  U5        U $ )zAdd dialect options to this INSERT/UPDATE/DELETE object.

e.g.::

    upd = table.update().dialect_options(mysql_limit=10)

.. versionadded: 1.4 - this method supersedes the dialect options
   associated with the constructor.


)_validate_dialect_kwargs)rn   opts     rW   with_dialect_optionsUpdateBase.with_dialect_options  s     	%%c*rZ   )supplemental_colssort_by_parameter_orderc                  U R                   (       ae  U R                  (       aL  U(       aE  [        [        R                  " U R                  5      R                  S U 5       5      5      U l        OSU l        O[        S U 5       5      U l        SU l         U(       a.  U R                  (       d  [        R                  " S5      eSU l	        U(       av  S U 5       nU R                  c&  [        [        R                  " U5      5      U l
        U $ [        [        R                  " U R                  [        U5      -   5      5      U l
        U $ )a  Make use of a :term:`RETURNING` clause for the purpose
of fetching server-side expressions and defaults, for supporting
backends only.

.. deepalchemy::

    The :meth:`.UpdateBase.return_defaults` method is used by the ORM
    for its internal work in fetching newly generated primary key
    and server default values, in particular to provide the underyling
    implementation of the :paramref:`_orm.Mapper.eager_defaults`
    ORM feature as well as to allow RETURNING support with bulk
    ORM inserts.  Its behavior is fairly idiosyncratic
    and is not really intended for general use.  End users should
    stick with using :meth:`.UpdateBase.returning` in order to
    add RETURNING clauses to their INSERT, UPDATE and DELETE
    statements.

Normally, a single row INSERT statement will automatically populate the
:attr:`.CursorResult.inserted_primary_key` attribute when executed,
which stores the primary key of the row that was just inserted in the
form of a :class:`.Row` object with column names as named tuple keys
(and the :attr:`.Row._mapping` view fully populated as well). The
dialect in use chooses the strategy to use in order to populate this
data; if it was generated using server-side defaults and / or SQL
expressions, dialect-specific approaches such as ``cursor.lastrowid``
or ``RETURNING`` are typically used to acquire the new primary key
value.

However, when the statement is modified by calling
:meth:`.UpdateBase.return_defaults` before executing the statement,
additional behaviors take place **only** for backends that support
RETURNING and for :class:`.Table` objects that maintain the
:paramref:`.Table.implicit_returning` parameter at its default value of
``True``. In these cases, when the :class:`.CursorResult` is returned
from the statement's execution, not only will
:attr:`.CursorResult.inserted_primary_key` be populated as always, the
:attr:`.CursorResult.returned_defaults` attribute will also be
populated with a :class:`.Row` named-tuple representing the full range
of server generated
values from that single row, including values for any columns that
specify :paramref:`_schema.Column.server_default` or which make use of
:paramref:`_schema.Column.default` using a SQL expression.

When invoking INSERT statements with multiple rows using
:ref:`insertmanyvalues <engine_insertmanyvalues>`, the
:meth:`.UpdateBase.return_defaults` modifier will have the effect of
the :attr:`_engine.CursorResult.inserted_primary_key_rows` and
:attr:`_engine.CursorResult.returned_defaults_rows` attributes being
fully populated with lists of :class:`.Row` objects representing newly
inserted primary key values as well as newly inserted server generated
values for each row inserted. The
:attr:`.CursorResult.inserted_primary_key` and
:attr:`.CursorResult.returned_defaults` attributes will also continue
to be populated with the first row of these two collections.

If the backend does not support RETURNING or the :class:`.Table` in use
has disabled :paramref:`.Table.implicit_returning`, then no RETURNING
clause is added and no additional data is fetched, however the
INSERT, UPDATE or DELETE statement proceeds normally.

E.g.::

    stmt = table.insert().values(data="newdata").return_defaults()

    result = connection.execute(stmt)

    server_created_at = result.returned_defaults["created_at"]

When used against an UPDATE statement
:meth:`.UpdateBase.return_defaults` instead looks for columns that
include :paramref:`_schema.Column.onupdate` or
:paramref:`_schema.Column.server_onupdate` parameters assigned, when
constructing the columns that will be included in the RETURNING clause
by default if explicit columns were not specified. When used against a
DELETE statement, no columns are included in RETURNING by default, they
instead must be specified explicitly as there are no columns that
normally change values when a DELETE statement proceeds.

.. versionadded:: 2.0  :meth:`.UpdateBase.return_defaults` is supported
   for DELETE statements also and has been moved from
   :class:`.ValuesBase` to :class:`.UpdateBase`.

The :meth:`.UpdateBase.return_defaults` method is mutually exclusive
against the :meth:`.UpdateBase.returning` method and errors will be
raised during the SQL compilation process if both are used at the same
time on one statement. The RETURNING clause of the INSERT, UPDATE or
DELETE statement is therefore controlled by only one of these methods
at a time.

The :meth:`.UpdateBase.return_defaults` method differs from
:meth:`.UpdateBase.returning` in these ways:

1. :meth:`.UpdateBase.return_defaults` method causes the
   :attr:`.CursorResult.returned_defaults` collection to be populated
   with the first row from the RETURNING result. This attribute is not
   populated when using :meth:`.UpdateBase.returning`.

2. :meth:`.UpdateBase.return_defaults` is compatible with existing
   logic used to fetch auto-generated primary key values that are then
   populated into the :attr:`.CursorResult.inserted_primary_key`
   attribute. By contrast, using :meth:`.UpdateBase.returning` will
   have the effect of the :attr:`.CursorResult.inserted_primary_key`
   attribute being left unpopulated.

3. :meth:`.UpdateBase.return_defaults` can be called against any
   backend. Backends that don't support RETURNING will skip the usage
   of the feature, rather than raising an exception, *unless*
   ``supplemental_cols`` is passed. The return value
   of :attr:`_engine.CursorResult.returned_defaults` will be ``None``
   for backends that don't support RETURNING or for which the target
   :class:`.Table` sets :paramref:`.Table.implicit_returning` to
   ``False``.

4. An INSERT statement invoked with executemany() is supported if the
   backend database driver supports the
   :ref:`insertmanyvalues <engine_insertmanyvalues>`
   feature which is now supported by most SQLAlchemy-included backends.
   When executemany is used, the
   :attr:`_engine.CursorResult.returned_defaults_rows` and
   :attr:`_engine.CursorResult.inserted_primary_key_rows` accessors
   will return the inserted defaults and primary keys.

   .. versionadded:: 1.4 Added
      :attr:`_engine.CursorResult.returned_defaults_rows` and
      :attr:`_engine.CursorResult.inserted_primary_key_rows` accessors.
      In version 2.0, the underlying implementation which fetches and
      populates the data for these attributes was generalized to be
      supported by most backends, whereas in 1.4 they were only
      supported by the ``psycopg2`` driver.


:param cols: optional list of column key names or
 :class:`_schema.Column` that acts as a filter for those columns that
 will be fetched.
:param supplemental_cols: optional list of RETURNING expressions,
  in the same form as one would pass to the
  :meth:`.UpdateBase.returning` method. When present, the additional
  columns will be included in the RETURNING clause, and the
  :class:`.CursorResult` object will be "rewound" when returned, so
  that methods like :meth:`.CursorResult.all` will return new rows
  mostly as though the statement used :meth:`.UpdateBase.returning`
  directly. However, unlike when using :meth:`.UpdateBase.returning`
  directly, the **order of the columns is undefined**, so can only be
  targeted using names or :attr:`.Row._mapping` keys; they cannot
  reliably be targeted positionally.

  .. versionadded:: 2.0

:param sort_by_parameter_order: for a batch INSERT that is being
 executed against multiple parameter sets, organize the results of
 RETURNING so that the returned rows correspond to the order of
 parameter sets passed in.  This applies only to an :term:`executemany`
 execution for supporting dialects and typically makes use of the
 :term:`insertmanyvalues` feature.

 .. versionadded:: 2.0.10

 .. seealso::

    :ref:`engine_insertmanyvalues_returning_order` - background on
    sorting of RETURNING rows for bulk INSERT

.. seealso::

    :meth:`.UpdateBase.returning`

    :attr:`_engine.CursorResult.returned_defaults`

    :attr:`_engine.CursorResult.returned_defaults_rows`

    :attr:`_engine.CursorResult.inserted_primary_key`

    :attr:`_engine.CursorResult.inserted_primary_key_rows`

c              3  l   #    U  H*  n[         R                  " [        R                  U5      v   M,     g 7frS   r   r   r   ColumnsClauseRoler  r   s     rW   r  -UpdateBase.return_defaults.<locals>.<genexpr>  s.      I!%A "(()@)@!DD!%   24rT   c              3  l   #    U  H*  n[         R                  " [        R                  U5      v   M,     g 7frS   r-  r/  s     rW   r  r0    s)      2FJ	  !8!8!<<dr1  Tz]The 'sort_by_parameter_order' argument to return_defaults() only applies to INSERT statementsc              3  l   #    U  H*  n[         R                  " [        R                  U5      v   M,     g 7frS   r-  r/  s     rW   r  r0    s-      $*A   !8!8!<<*r1  )_return_defaultsr  r   r   
OrderedSetunion	is_insertr9   ArgumentError_sort_by_parameter_orderr  unique_list)rn   r)  r*  colssupplemental_col_tups        rW   return_defaultsUpdateBase.return_defaults  s.   n    ,,05OOD$A$ABHH I!%I 1- 13-,1 2FJ2 -D) !%">>''J  -1D)$*$ 
 ++3/4$$%9:0,  05$$44 4560, rZ   c                    g)zReturn ``True`` if this :class:`.ReturnsRows` is
'derived' from the given :class:`.FromClause`.

Since these are DMLs, we dont want such statements ever being adapted
so we return False for derives.

FrT   )rn   r  s     rW   is_derived_fromUpdateBase.is_derived_from  s     rZ   r*  c               .   U(       a  [        SU5      eU R                  (       a  [        R                  " S5      eU =R                  [        S U 5       5      -  sl        U(       a.  U R                  (       d  [        R                  " S5      eSU l        U $ )a:  Add a :term:`RETURNING` or equivalent clause to this statement.

e.g.:

.. sourcecode:: pycon+sql

    >>> stmt = (
    ...     table.update()
    ...     .where(table.c.data == "value")
    ...     .values(status="X")
    ...     .returning(table.c.server_flag, table.c.updated_timestamp)
    ... )
    >>> print(stmt)
    {printsql}UPDATE some_table SET status=:status
    WHERE some_table.data = :data_1
    RETURNING some_table.server_flag, some_table.updated_timestamp

The method may be invoked multiple times to add new entries to the
list of expressions to be returned.

.. versionadded:: 1.4.0b2 The method may be invoked multiple times to
 add new entries to the list of expressions to be returned.

The given collection of column expressions should be derived from the
table that is the target of the INSERT, UPDATE, or DELETE.  While
:class:`_schema.Column` objects are typical, the elements can also be
expressions:

.. sourcecode:: pycon+sql

    >>> stmt = table.insert().returning(
    ...     (table.c.first_name + " " + table.c.last_name).label("fullname")
    ... )
    >>> print(stmt)
    {printsql}INSERT INTO some_table (first_name, last_name)
    VALUES (:first_name, :last_name)
    RETURNING some_table.first_name || :first_name_1 || some_table.last_name AS fullname

Upon compilation, a RETURNING clause, or database equivalent,
will be rendered within the statement.   For INSERT and UPDATE,
the values are the newly inserted/updated values.  For DELETE,
the values are those of the rows which were deleted.

Upon execution, the values of the columns to be returned are made
available via the result set and can be iterated using
:meth:`_engine.CursorResult.fetchone` and similar.
For DBAPIs which do not
natively support returning values (i.e. cx_oracle), SQLAlchemy will
approximate this behavior at the result level so that a reasonable
amount of behavioral neutrality is provided.

Note that not all databases/DBAPIs
support RETURNING.   For those backends with no support,
an exception is raised upon compilation and/or execution.
For those who do support it, the functionality across backends
varies greatly, including restrictions on executemany()
and other statements which return multiple rows. Please
read the documentation notes for the database in use in
order to determine the availability of RETURNING.

:param \*cols: series of columns, SQL expressions, or whole tables
 entities to be returned.
:param sort_by_parameter_order: for a batch INSERT that is being
 executed against multiple parameter sets, organize the results of
 RETURNING so that the returned rows correspond to the order of
 parameter sets passed in.  This applies only to an :term:`executemany`
 execution for supporting dialects and typically makes use of the
 :term:`insertmanyvalues` feature.

 .. versionadded:: 2.0.10

 .. seealso::

    :ref:`engine_insertmanyvalues_returning_order` - background on
    sorting of RETURNING rows for bulk INSERT (Core level discussion)

    :ref:`orm_queryguide_bulk_insert_returning_ordered` - example of
    use with :ref:`orm_queryguide_bulk_insert` (ORM level discussion)

.. seealso::

  :meth:`.UpdateBase.return_defaults` - an alternative method tailored
  towards efficient fetching of server-side defaults and triggers
  for single-row INSERTs or UPDATEs.

  :ref:`tutorial_insert_returning` - in the :ref:`unified_tutorial`

zUpdateBase.returning()z9return_defaults() is already configured on this statementc              3  l   #    U  H*  n[         R                  " [        R                  U5      v   M,     g 7frS   r-  r/  s     rW   r  'UpdateBase.returning.<locals>.<genexpr>)  s)      !
BFQIU44a88$r1  zWThe 'sort_by_parameter_order' argument to returning() only applies to INSERT statementsT)	r   r4  r9   r   r  r   r7  r8  r9  )rn   r*  r;  _UpdateBase__kws       rW   	returningUpdateBase.returning  s    ~  !94@@  ))K  	5 !
BF!
 
 	
 #>>''8  -1D)rZ   c                4    U R                   R                  XS9$ )N)require_embedded)exported_columnscorresponding_column)rn   columnrJ  s      rW   rL  UpdateBase.corresponding_column5  s%     $$99 : 
 	
rZ   c                V    [        U R                  5       Vs/ s H  oPM     sn$ s  snf rS   )r    r  )rn   r   s     rW   r}    UpdateBase._all_selected_columns<  s%    ,T__=>=a=>>>s   &c                V    [        S U R                   5       5      R                  5       $ )z`Return the RETURNING columns as a column collection for this
statement.

.. versionadded:: 1.4

c              3  b   #    U  H%  n[        U5      (       d  M  UR                  U4v   M'     g 7frS   )r   r~   r/  s     rW   r  .UpdateBase.exported_columns.<locals>.<genexpr>J  s)       
/ # QUUAJ/s   //)r!   r}   as_readonlyr   s    rW   rK  UpdateBase.exported_columns@  s-        
// 
 
 +-		rZ   c                    Uc  U R                   nO%[        R                  " [        R                  U5      nU R
                  R                  X#4U05      U l        U $ )ab  Add a table hint for a single table to this
INSERT/UPDATE/DELETE statement.

.. note::

 :meth:`.UpdateBase.with_hint` currently applies only to
 Microsoft SQL Server.  For MySQL INSERT/UPDATE/DELETE hints, use
 :meth:`.UpdateBase.prefix_with`.

The text of the hint is rendered in the appropriate
location for the database backend in use, relative
to the :class:`_schema.Table` that is the subject of this
statement, or optionally to that of the given
:class:`_schema.Table` passed as the ``selectable`` argument.

The ``dialect_name`` option will limit the rendering of a particular
hint to a particular backend. Such as, to add a hint
that only takes effect for SQL Server::

    mytable.insert().with_hint("WITH (PAGLOCK)", dialect_name="mssql")

:param text: Text of the hint.
:param selectable: optional :class:`_schema.Table` that specifies
 an element of the FROM clause within an UPDATE or DELETE
 to be the subject of the hint - applies only to certain backends.
:param dialect_name: defaults to ``*``, if specified as the name
 of a particular dialect, will apply these hints only when
 that dialect is in use.
)ru   r   r   r   DMLTableRoler  r6  )rn   text
selectabledialect_names       rW   	with_hintUpdateBase.with_hintP  sO    H J"))%*<*<jIJkk''*)CT(JKrZ   c                P    [         R                  U 5      R                  nU" U 5      $ )a  Return a :term:`plugin-enabled` description of the table and/or
entity which this DML construct is operating against.

This attribute is generally useful when using the ORM, as an
extended structure which includes information about mapped
entities is returned.  The section :ref:`queryguide_inspection`
contains more background.

For a Core statement, the structure returned by this accessor
is derived from the :attr:`.UpdateBase.table` attribute, and
refers to the :class:`.Table` being inserted, updated, or deleted::

    >>> stmt = insert(user_table)
    >>> stmt.entity_description
    {
        "name": "user_table",
        "table": Table("user_table", ...)
    }

.. versionadded:: 1.4.33

.. seealso::

    :attr:`.UpdateBase.returning_column_descriptions`

    :attr:`.Select.column_descriptions` - entity information for
    a :func:`.select` construct

    :ref:`queryguide_inspection` - ORM background

)rQ   r   rx   rn   meths     rW   entity_descriptionUpdateBase.entity_description{  s%    B ((.EEDzrZ   c                P    [         R                  U 5      R                  nU" U 5      $ )a  Return a :term:`plugin-enabled` description of the columns
which this DML construct is RETURNING against, in other words
the expressions established as part of :meth:`.UpdateBase.returning`.

This attribute is generally useful when using the ORM, as an
extended structure which includes information about mapped
entities is returned.  The section :ref:`queryguide_inspection`
contains more background.

For a Core statement, the structure returned by this accessor is
derived from the same objects that are returned by the
:attr:`.UpdateBase.exported_columns` accessor::

    >>> stmt = insert(user_table).returning(user_table.c.id, user_table.c.name)
    >>> stmt.entity_description
    [
        {
            "name": "id",
            "type": Integer,
            "expr": Column("id", Integer(), table=<user>, ...)
        },
        {
            "name": "name",
            "type": String(),
            "expr": Column("name", String(), table=<user>, ...)
        },
    ]

.. versionadded:: 1.4.33

.. seealso::

    :attr:`.UpdateBase.entity_description`

    :attr:`.Select.column_descriptions` - entity information for
    a :func:`.select` construct

    :ref:`queryguide_inspection` - ORM background

)rQ   r   r   r^  s     rW   returning_column_descriptions(UpdateBase.returning_column_descriptions  s-    T ((

+
+ 	 DzrZ   )r  r4  r  r9  r  )
r  r/   r  z.ColumnCollection[str, KeyedColumnElement[Any]]r  r"   r  zSet[KeyedColumnElement[Any]]r   r   )r!  r   rp   r   r   r
   )r&  r   r   r:   )r;  r>   r)  z&Optional[Iterable[_DMLColumnArgument]]r*  r   r   r:   )r  zOptional[FromClause]r   r   )r;  _ColumnsClauseArgument[Any]r*  r   rF  r   r   ri   r   )rM  zKeyedColumnElement[Any]rJ  r   r   Optional[ColumnElement[Any]])r   rN   )r   z;ReadOnlyColumnCollection[Optional[str], ColumnElement[Any]])N*)rX  strrY  zOptional[_DMLTableArgument]rZ  rh  r   r:   )r   r   )r   r   )#r   r   r   r   __doc__r   r   
EMPTY_DICTr  r   named_with_columnr3   LABEL_STYLE_DISAMBIGUATE_ONLYr  r4  r  r  r  is_dmlr  r"  r   r'  r=  r@  rG  rL  ro_memoized_propertyr}   rK  r[  r   r`  rc  r   rT   rZ   rW   ri   ri     s3    O"N 	 A   	66 "   I  LPHO46J16F

 @
 	

 3
 


    EI(-	d!d Bd "&	d
 
d dL  ).n*n "&n 	n
 
n nb IN
-
AE
	%
 
? ? 
	D   37	(( 0( 	(
 
( (T ! !F , ,rZ   ri   c                      \ rS rSr% SrSrSrSrS\S'    Sr	S\S	'    Sr
S
\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SS jr\\" SSSSS.S9      SS j5       5       rSrg)r   i  zPSupplies support for :meth:`.ValuesBase.values` to
INSERT and UPDATE constructs.values_baseFNzOptional[Select[Any]]selectzOptional[ClauseElement]_post_values_clausez4Optional[util.immutabledict[_DMLColumnElement, Any]]r   rT   zRTuple[Union[Sequence[Dict[_DMLColumnElement, Any]], Sequence[Sequence[Any]]], ...]r   re   rf   zOptional[List[str]]r   r   _inlinec                T    [         R                  " [        R                  XS9U l        g Napply_propagate_attrsr   r   r   rW  ru   rn   ru   s     rW   rq   ValuesBase.__init__      %%

rZ   z,This construct already inserts from a SELECT1This statement already has ordered values present)r   rf   )msgsc                P   U(       Gaa  US   nU(       a  [         R                  " S5      e[        U5      S:  a  [         R                  " S5      e[        U[        R
                  5      (       a  U(       aU  [        US   [        5      (       a=  [        R                  U 5      R                  nU =R                  U" X5      4-  sl
        U $ U(       a6  [        US   [        [        45      (       a  U =R                  U4-  sl
        U $ [        (       a  [        U [        5      (       d   e[        U R                   R"                  U5       VVs0 s H  u  pVUR$                  U_M     nnnO)['        SU5      nU(       a  [         R                  " S5      e[        R                  U 5      R(                  n[        U" XR+                  5       S5      5      nU R,                  (       a"  U R,                  R/                  U5      U l        U $ [0        R2                  " U5      U l        U $ s  snnf )a  Specify a fixed VALUES clause for an INSERT statement, or the SET
clause for an UPDATE.

Note that the :class:`_expression.Insert` and
:class:`_expression.Update`
constructs support
per-execution time formatting of the VALUES and/or SET clauses,
based on the arguments passed to :meth:`_engine.Connection.execute`.
However, the :meth:`.ValuesBase.values` method can be used to "fix" a
particular set of parameters into the statement.

Multiple calls to :meth:`.ValuesBase.values` will produce a new
construct, each one with the parameter list modified to include
the new parameters sent.  In the typical case of a single
dictionary of parameters, the newly passed keys will replace
the same keys in the previous construct.  In the case of a list-based
"multiple values" construct, each new list of values is extended
onto the existing list of values.

:param \**kwargs: key value pairs representing the string key
  of a :class:`_schema.Column`
  mapped to the value to be rendered into the
  VALUES or SET clause::

        users.insert().values(name="some name")

        users.update().where(users.c.id == 5).values(name="some name")

:param \*args: As an alternative to passing key/value parameters,
 a dictionary, tuple, or list of dictionaries or tuples can be passed
 as a single positional argument in order to form the VALUES or
 SET clause of the statement.  The forms that are accepted vary
 based on whether this is an :class:`_expression.Insert` or an
 :class:`_expression.Update` construct.

 For either an :class:`_expression.Insert` or
 :class:`_expression.Update`
 construct, a single dictionary can be passed, which works the same as
 that of the kwargs form::

    users.insert().values({"name": "some name"})

    users.update().values({"name": "some new name"})

 Also for either form but more typically for the
 :class:`_expression.Insert` construct, a tuple that contains an
 entry for every column in the table is also accepted::

    users.insert().values((5, "some name"))

 The :class:`_expression.Insert` construct also supports being
 passed a list of dictionaries or full-table-tuples, which on the
 server will render the less common SQL syntax of "multiple values" -
 this syntax is supported on backends such as SQLite, PostgreSQL,
 MySQL, but not necessarily others::

    users.insert().values(
        [
            {"name": "some name"},
            {"name": "some other name"},
            {"name": "yet another name"},
        ]
    )

 The above form would render a multiple VALUES statement similar to:

 .. sourcecode:: sql

        INSERT INTO users (name) VALUES
                        (:name_1),
                        (:name_2),
                        (:name_3)

 It is essential to note that **passing multiple values is
 NOT the same as using traditional executemany() form**.  The above
 syntax is a **special** syntax not typically used.  To emit an
 INSERT statement against multiple rows, the normal method is
 to pass a multiple values list to the
 :meth:`_engine.Connection.execute`
 method, which is supported by all database backends and is generally
 more efficient for a very large number of parameters.

   .. seealso::

       :ref:`tutorial_multiple_parameters` - an introduction to
       the traditional Core method of multiple parameter set
       invocation for INSERTs and other statements.

  The UPDATE construct also supports rendering the SET parameters
  in a specific order.  For this feature refer to the
  :meth:`_expression.Update.ordered_values` method.

   .. seealso::

      :meth:`_expression.Update.ordered_values`


r   z;Can't pass positional and kwargs to values() simultaneouslyr   zWOnly a single dictionary/tuple or list of dictionaries/tuples is accepted positionally.zDict[_DMLColumnArgument, Any]T)r9   r8  lenr   r   r   r  rQ   r   r   r   r   r   r   r   r   ru   r   r~   r   r   r   r   r6  r   immutabledict)	rn   argskwargsr!  multi_kv_generatorr   r   kv_generatorcoerced_args	            rW   r   ValuesBase.values  s   h  q'C''%  TQ''D 
 C!9!9:::c!fd33)1)B)B*.. ' &&+=d+H*JJ&K:c!ftUm<<&&3&0&K = &dF3333 58

c4JK4Jquue|4JK
 6?C''D   006II<iik4@A<<<<--k:DL   --k:DL1 Ls   H")r   ru   ru   r@   )r  z/Union[_DMLColumnKeyMapping[Any], Sequence[Any]]r  r   r   r:   )r   r   r   r   ri  r   _supports_multi_parametersrq  r   rr  r   r   rf   r   rs  rq   r   r   r   r   rT   rZ   rW   r   r     s    % #N!&$(F!(43707) EIGAH 	    FJOBI)-M&-GT

 K 
g
g g 
g grZ   r   c                  B  ^  \ rS rSr% SrSrSrSrSrSr	S\
S'   SrS	\
S
'   S
\R                  4S\R                  4S\R                  4S\R                   4S\R"                  4S\R                  4S\R                  4S\R$                  4S\R&                  4S\R                  4S\R$                  4S\R                  4/\R*                  -   \R.                  -   \R2                  -   \R6                  -   rS$U 4S jjr\S%S j5       r\ S&       S'S jj5       r \!(       a  \"SS.     S(S jj5       r#\"SS.       S)S jj5       r#\"SS.         S*S jj5       r#\"SS.           S+S jj5       r#\"SS.             S,S jj5       r#\"SS.               S-S jj5       r#\"SS.                 S.S jj5       r#\"SS.                   S/S  jj5       r#\"SS.       S0S! jj5       r#SS.       S0S" jjr#S#r$U =r%$ S#r$U =r%$ )1r   i  zRepresent an INSERT construct.

The :class:`_expression.Insert` object is created using the
:func:`_expression.insert()` function.

r   TNFr   r9  r4   ru   rs  r   r   r   rq  rr  r  r  r4  r  c                $   > [         TU ]  U5        g rS   superrq   rn   ru   	__class__s     rW   rq   Insert.__init__      rZ   c                    SU l         U $ )a;  Make this :class:`_expression.Insert` construct "inline" .

When set, no attempt will be made to retrieve the
SQL-generated default values to be provided within the statement;
in particular,
this allows SQL expressions to be rendered 'inline' within the
statement without the need to pre-execute them beforehand; for
backends that support "returning", this turns off the "implicit
returning" feature for the statement.


.. versionchanged:: 1.4 the :paramref:`_expression.Insert.inline`
   parameter
   is now superseded by the :meth:`_expression.Insert.inline` method.

Trs  r   s    rW   inlineInsert.inline  s    $ rZ   c           	     @   U R                   (       a  [        R                  " S5      eU Vs/ s H'  n[        R                  " [
        R                  USS9PM)     snU l        SU l        X0l	        [        R                  " [
        R                  U5      U l        U $ s  snf )aS  Return a new :class:`_expression.Insert` construct which represents
an ``INSERT...FROM SELECT`` statement.

e.g.::

    sel = select(table1.c.a, table1.c.b).where(table1.c.c > 5)
    ins = table2.insert().from_select(["a", "b"], sel)

:param names: a sequence of string column names or
 :class:`_schema.Column`
 objects representing the target columns.
:param select: a :func:`_expression.select` construct,
 :class:`_expression.FromClause`
 or other construct which resolves into a
 :class:`_expression.FromClause`,
 such as an ORM :class:`_query.Query` object, etc.  The order of
 columns returned from this FROM clause should correspond to the
 order of columns sent as the ``names`` parameter;  while this
 is not checked before passing along to the database, the database
 would normally raise an exception if these column lists don't
 correspond.
:param include_defaults: if True, non-server default values and
 SQL expressions as specified on :class:`_schema.Column` objects
 (as documented in :ref:`metadata_defaults_toplevel`) not
 otherwise specified in the list of names will be rendered
 into the INSERT and SELECT statements, so that these values are also
 included in the data to be inserted.

 .. note:: A Python-side default that uses a Python callable function
    will only be invoked **once** for the whole statement, and **not
    per row**.

z0This construct already inserts value expressionsTr   )r   r9   r   r   r   r   r   r   rs  #include_insert_from_select_defaultsDMLSelectRolerq  )rn   namesrq  include_defaultsrt   s        rW   from_selectInsert.from_select  s    R <<))B  
 U00$tD
 3C0&&u':':FC
s   .BrB  c                   g rS   rT   )rn   _Insert__ent0r*  s      rW   rG  Insert.returning'       +.rZ   c                   g rS   rT   )rn   r  _Insert__ent1r*  s       rW   rG  r  ,  s     03rZ   c                   g rS   rT   )rn   r  r  _Insert__ent2r*  s        rW   rG  r  5  s     58rZ   c                   g rS   rT   )rn   r  r  r  _Insert__ent3r*  s         rW   rG  r  ?  s     :=rZ   c                   g rS   rT   )rn   r  r  r  r  _Insert__ent4r*  s          rW   rG  r  J  s     ?BrZ   c                   g rS   rT   )rn   r  r  r  r  r  _Insert__ent5r*  s           rW   rG  r  V  s	     DGrZ   c                   g rS   rT   )	rn   r  r  r  r  r  r  _Insert__ent6r*  s	            rW   rG  r  c  s	     ILrZ   c	                   g rS   rT   )
rn   r  r  r  r  r  r  r  _Insert__ent7r*  s
             rW   rG  r  q  s     rZ   c                   g rS   rT   rn   r*  r;  _Insert__kws       rW   rG  r    s     $'rZ   c                   g rS   rT   r  s       rW   rG  r    s    
 $'rZ   )rs  r   r  rq  r  r   r:   )T)r  zSequence[_DMLColumnArgument]rq  rP   r  r   r   r:   )r  
_TCCA[_T0]r*  r   r   zReturningInsert[Tuple[_T0]])r  r  r  
_TCCA[_T1]r*  r   r   z ReturningInsert[Tuple[_T0, _T1]])
r  r  r  r  r  
_TCCA[_T2]r*  r   r   z%ReturningInsert[Tuple[_T0, _T1, _T2]])r  r  r  r  r  r  r  
_TCCA[_T3]r*  r   r   z*ReturningInsert[Tuple[_T0, _T1, _T2, _T3]])r  r  r  r  r  r  r  r  r  
_TCCA[_T4]r*  r   r   z/ReturningInsert[Tuple[_T0, _T1, _T2, _T3, _T4]])r  r  r  r  r  r  r  r  r  r  r  
_TCCA[_T5]r*  r   r   z4ReturningInsert[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])r  r  r  r  r  r  r  r  r  r  r  r  r  
_TCCA[_T6]r*  r   r   z9ReturningInsert[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  
_TCCA[_T7]r*  r   r   z>ReturningInsert[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])r;  re  r*  r   r  r   r   zReturningInsert[Any])&r   r   r   r   ri  r   r  rq  r  r9  r   r7  r7   dp_clauseelement
dp_booleandp_string_listdp_dml_valuesdp_dml_multi_valuesdp_clauseelement_tupledp_table_hint_listr1    _has_prefixes_traverse_internalsr$   "_dialect_kwargs_traverse_internalsr%   _executable_traverse_internalsr0   _has_ctes_traverse_internals_traverse_internalsrq   r   r  r  r   r   rG  r   __classcell__r  s   @rW   r   r     s    N!%F*/'%*d*I '889)445/>>?)778/CCD(99:"$5$F$FG,CCD(;;<!2!=!=>*!88 ():)E)EF	
" 
6
6#	7$ 
:
:%	;& 
3
3'	4( 
-
-)	. 0   ( 
 "&	4+4 4 	4
 
4 4l  
IN	.$	.BF	.(	. 
	. 
 -2	3	3 	3
 &*	3 .	3 
	3 
 -2	8	8 	8 		8 &*	8 3	8 
	8 
 -2	=	= 	= 		=
 	= &*	= 8	= 
	= 
 -2		B		B 		B 			B
 		B 		B &*		B =		B 
		B 
 -2
	G
	G 
	G 	
	G
 
	G 
	G 
	G &*
	G B
	G 

	G 
 -2	L	L 	L 		L
 	L 	L 	L 	L &*	L G	L 
	L 
 -2		 	 		
 	 	 	 	 	 &*	
	 
	$ 
 -2	'.	' &*	' 		'
 "	' 
	' -2	'.	' &*	' 		'
 "	' 	'W rZ   r   c                      \ rS rSrSrSrg)ReturningInserti  zTyping-only class that establishes a generic type form of
:class:`.Insert` which tracks returned column types.

This datatype is delivered when calling the
:meth:`.Insert.returning` method.

.. versionadded:: 2.0

rT   Nr   r   r   r   ri  r   rT   rZ   rW   r  r        rZ   r  c                  t    \ rS rSr% S\S'   SrS\S'   \SS j5       rSS jrSS	 jr	SS
 jr
\SS j5       rSrg)r   i  r   ru   rT   zTuple[ColumnElement[Any], ...]r   c                    U H<  n[         R                  " [        R                  X S9nU =R                  U4-  sl        M>     U $ )ap  Return a new construct with the given expression(s) added to
its WHERE clause, joined to the existing clause via AND, if any.

Both :meth:`_dml.Update.where` and :meth:`_dml.Delete.where`
support multiple-table forms, including database-specific
``UPDATE...FROM`` as well as ``DELETE..USING``.  For backends that
don't have multiple-table support, a backend agnostic approach
to using multiple tables is to make use of correlated subqueries.
See the linked tutorial sections below for examples.

.. seealso::

    :ref:`tutorial_correlated_updates`

    :ref:`tutorial_update_from`

    :ref:`tutorial_multi_table_deletes`

rv  )r   r   r   WhereHavingRoler   )rn   whereclause	criterionwhere_criterias       rW   whereDMLWhereBase.where  sF    , %I1:1A1A%%y2N   ^$55 	 %
 rZ   c                     U R                   " U6 $ )zRA synonym for the :meth:`_dml.DMLWhereBase.where` method.

.. versionadded:: 1.4

)r  )rn   criterias     rW   filterDMLWhereBase.filter  s     zz8$$rZ   c                    U R                   $ rS   ru   r   s    rW   _filter_by_zeroDMLWhereBase._filter_by_zero  s    zzrZ   c                    U R                  5       nUR                  5        VVs/ s H  u  p4[        X#5      U:H  PM     nnnU R                  " U6 $ s  snnf )zGapply the given filtering criterion as a WHERE clause
to this select.

)r  r   r   r  )rn   r  from_entityr~   r   clausess         rW   	filter_byDMLWhereBase.filter_by  s\    
 **, %lln
,
 "+3u<, 	 
 {{G$$	
s   Ac                B    [         R                  " U R                  5      $ )zReturn the completed WHERE clause for this :class:`.DMLWhereBase`
statement.

This assembles the current collection of WHERE criteria
into a single :class:`_expression.BooleanClauseList` construct.


.. versionadded:: 1.4

)r(   _construct_for_whereclauser   r   s    rW   r  DMLWhereBase.whereclause  s      !;;  
 	
rZ   N)r  z_ColumnExpressionArgument[bool]r   r:   )r  z roles.ExpressionElementRole[Any]r   r:   r   )r  r   r   r:   )r   rf  )r   r   r   r   r   r   r   r  r  r  r  r   r  r   rT   rZ   rW   r   r     sH    68O38 8%% 
 
rZ   r   c            
      V  ^  \ rS rSrSrSrSrS\R                  4S\R                  4S\R                  4S\R                  4S	\R                  4S
\R                  4S\R                  4S\R                  4S\R                  4/	\R                  -   \R"                  -   \R&                  -   \R*                  -   rSU 4S jjr\SS j5       r\SS j5       r\(       a  \    SS j5       r\      S S j5       r\        S!S j5       r\          S"S j5       r\            S#S j5       r\              S$S j5       r\                S%S j5       r\                  S&S j5       r\      S'S j5       r      S'S jrSrU =r$ SrU =r$ )(r  i  zRepresent an Update construct.

The :class:`_expression.Update` object is created using the
:func:`_expression.update()` function.

r   Tru   r   rs  rf   r   r  r  r4  r  c                $   > [         TU ]  U5        g rS   r  r  s     rW   rq   Update.__init__  r  rZ   c                    U R                   (       a  [        R                  " S5      eU R                  (       a  [        R                  " S5      e[        R                  U 5      R                  nU" XS5      U l        U $ )aU  Specify the VALUES clause of this UPDATE statement with an explicit
parameter ordering that will be maintained in the SET clause of the
resulting UPDATE statement.

E.g.::

    stmt = table.update().ordered_values(("name", "ed"), ("ident", "foo"))

.. seealso::

   :ref:`tutorial_parameter_ordered_updates` - full example of the
   :meth:`_expression.Update.ordered_values` method.

.. versionchanged:: 1.4 The :meth:`_expression.Update.ordered_values`
   method
   supersedes the
   :paramref:`_expression.update.preserve_parameter_order`
   parameter, which will be removed in SQLAlchemy 2.0.

z)This statement already has values presentr|  T)r   r9   r8  rf   rQ   r   r   )rn   r  r  s      rW   ordered_valuesUpdate.ordered_values  sn    , <<##;  !!##C   006II+D=rZ   c                    SU l         U $ )a  Make this :class:`_expression.Update` construct "inline" .

When set, SQL defaults present on :class:`_schema.Column`
objects via the
``default`` keyword will be compiled 'inline' into the statement and
not pre-executed.  This means that their values will not be available
in the dictionary returned from
:meth:`_engine.CursorResult.last_updated_params`.

.. versionchanged:: 1.4 the :paramref:`_expression.update.inline`
   parameter
   is now superseded by the :meth:`_expression.Update.inline` method.

Tr  r   s    rW   r  Update.inline3  s      rZ   c                    g rS   rT   )rn   _Update__ent0s     rW   rG  Update.returningL  r  rZ   c                    g rS   rT   )rn   r  _Update__ent1s      rW   rG  r  Q       03rZ   c                    g rS   rT   )rn   r  r  _Update__ent2s       rW   rG  r  V       58rZ   c                    g rS   rT   )rn   r  r  r  _Update__ent3s        rW   rG  r  [       :=rZ   c                    g rS   rT   )rn   r  r  r  r  _Update__ent4s         rW   rG  r  d       ?BrZ   c                    g rS   rT   )rn   r  r  r  r  r  _Update__ent5s          rW   rG  r  n  	     DGrZ   c                    g rS   rT   )rn   r  r  r  r  r  r  _Update__ent6s           rW   rG  r  y  	     ILrZ   c	                    g rS   rT   )	rn   r  r  r  r  r  r  r   _Update__ent7s	            rW   rG  r         rZ   c                    g rS   rT   rn   r;  _Update__kws      rW   rG  r         $'rZ   c                    g rS   rT   r  s      rW   rG  r        #&rZ   )rs  rf   r  )r  zTuple[_DMLColumnArgument, Any]r   r:   r  )r  r  r   zReturningUpdate[Tuple[_T0]])r  r  r  r  r   z ReturningUpdate[Tuple[_T0, _T1]])r  r  r  r  r  r  r   z%ReturningUpdate[Tuple[_T0, _T1, _T2]])
r  r  r  r  r  r  r  r  r   z*ReturningUpdate[Tuple[_T0, _T1, _T2, _T3]])r  r  r  r  r  r  r  r  r  r  r   z/ReturningUpdate[Tuple[_T0, _T1, _T2, _T3, _T4]])r  r  r  r  r  r  r  r  r  r  r  r  r   z4ReturningUpdate[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])r  r  r  r  r  r  r  r  r  r  r  r  r   r  r   z9ReturningUpdate[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r   z>ReturningUpdate[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])r;  re  r  r   r   zReturningUpdate[Any]) r   r   r   r   ri  r   	is_updater7   r  r  r  dp_dml_ordered_valuesr  r  r1   r  r$   r  r%   r  r0   r  r  rq   r   r  r  r   r   rG  r   r  r  s   @rW   r  r    s    NI '889 1 H HI)445 1 G GH)778,CCD(;;<!2!=!=>*!88	
 
6
6	7 
:
:	;  
3
3!	4" 
-
-#	. *     D  $  
	.$	.(	. 
	. 
	3$	3.8	3-	3 
	3 
	8$	8.8	8BL	82	8 
	8 
	=	= 	= 		=
 	= 8	= 
	= 
	B	B 	B 		B
 	B 	B =	B 
	B 
	G	G 	G 		G
 	G 	G 	G B	G 
	G 
		L		L 		L 			L
 		L 		L 		L 		L G		L 
		L 
		 	 		
 	 	 	 	 	
	 
	  
	'4	'>A	'!	' 
	'	'4	'>A	'!	' 	'k rZ   r  c                      \ rS rSrSrSrg)ReturningUpdatei  zTyping-only class that establishes a generic type form of
:class:`.Update` which tracks returned column types.

This datatype is delivered when calling the
:meth:`.Update.returning` method.

.. versionadded:: 2.0

rT   Nr  rT   rZ   rW   r  r    r  rZ   r  c                     \ rS rSrSrSrSrS\R                  4S\R                  4S\R                  4S\R                  4/\R                  -   \R                  -   \R                   -   \R$                  -   rSS	 jr\(       a  \    SS
 j5       r\      SS j5       r\        SS j5       r\          SS j5       r\            SS j5       r\              SS j5       r\                SS j5       r\                  SS j5       r\      SS j5       r      SS jrSrgSrg) r  i  zRepresent a DELETE construct.

The :class:`_expression.Delete` object is created using the
:func:`_expression.delete()` function.

r  Tru   r   r  r  c                T    [         R                  " [        R                  XS9U l        g ru  rx  ry  s     rW   rq   Delete.__init__  r{  rZ   c                    g rS   rT   )rn   _Delete__ent0s     rW   rG  Delete.returning  r  rZ   c                    g rS   rT   )rn   r  _Delete__ent1s      rW   rG  r    r  rZ   c                    g rS   rT   )rn   r  r  _Delete__ent2s       rW   rG  r    r  rZ   c                    g rS   rT   )rn   r  r  r  _Delete__ent3s        rW   rG  r    r  rZ   c                    g rS   rT   )rn   r  r  r  r  _Delete__ent4s         rW   rG  r    r  rZ   c                    g rS   rT   )rn   r  r  r  r  r  _Delete__ent5s          rW   rG  r    r  rZ   c                    g rS   rT   )rn   r  r  r  r  r  r  _Delete__ent6s           rW   rG  r    r  rZ   c	                    g rS   rT   )	rn   r  r  r  r  r  r  r   _Delete__ent7s	            rW   rG  r  	  r  rZ   c                    g rS   rT   rn   r;  _Delete__kws      rW   rG  r    r  rZ   c                    g rS   rT   r$  s      rW   rG  r    r
  rZ   r  Nr  )r  r  r   zReturningDelete[Tuple[_T0]])r  r  r  r  r   z ReturningDelete[Tuple[_T0, _T1]])r  r  r  r  r  r  r   z%ReturningDelete[Tuple[_T0, _T1, _T2]])
r  r  r  r  r  r  r  r  r   z*ReturningDelete[Tuple[_T0, _T1, _T2, _T3]])r  r  r  r  r  r  r  r  r  r  r   z/ReturningDelete[Tuple[_T0, _T1, _T2, _T3, _T4]])r  r  r  r  r  r  r  r  r  r  r  r  r   z4ReturningDelete[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]])r  r  r  r  r  r  r  r  r  r  r  r  r   r  r   z9ReturningDelete[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]])r  r  r  r  r  r  r  r  r  r  r  r  r   r  r"  r  r   z>ReturningDelete[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]])r;  re  r%  r   r   zReturningDelete[Any])r   r   r   r   ri  r   	is_deleter7   r  r  r  r1   r  r$   r  r%   r  r0   r  r  rq   r   r   rG  r   rT   rZ   rW   r  r    sM    NI '889 1 H HI,CCD(;;<		
 
6
6	7 
:
:	; 
3
3	4 
-
-		. 

  
	.$	.(	. 
	. 
	3$	3.8	3-	3 
	3 
	8$	8.8	8BL	82	8 
	8 
	=	= 	= 		=
 	= 8	= 
	= 
	B	B 	B 		B
 	B 	B =	B 
	B 
	G	G 	G 		G
 	G 	G 	G B	G 
	G 
		L		L 		L 			L
 		L 		L 		L 		L G		L 
		L 
		 	 		
 	 	 	 	 	
	 
	  
	'4	'>A	'!	' 
	'	'4	'>A	'!	'k rZ   r  c                      \ rS rSrSrSrg)ReturningDeletei$  zTyping-only class that establishes a generic type form of
:class:`.Delete` which tracks returned column types.

This datatype is delivered when calling the
:meth:`.Delete.returning` method.

.. versionadded:: 2.0

rT   Nr  rT   rZ   rW   r)  r)  $  r  rZ   r)  )rV   rQ   r   zTypeGuard[UpdateDMLState])rV   rQ   r   zTypeGuard[DeleteDMLState])rV   rQ   r   zTypeGuard[InsertDMLState])uri  
__future__r   collections.abcabcr   operatortypingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r    r   r   r   r   _typingr   r   r   r   baser   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   elementsr(   r)   r*   r+   r,   rY  r-   r.   r/   r0   r1   r2   r3   r4   r5   sqltypesr6   visitorsr7   r9   util.typingr:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   _TCCArJ   ro   rK   rL   rM   rN   rO   rP   rX   r\   r^   
attrgetterr_   rh  _DMLColumnElementr   rQ   
plugin_forr   r   r  DMLRoleri   r   r   r  r   r  r  r  r)  rT   rZ   rW   <module>r;     s  
 # )       !                # & ) ' $   # "      ! ' # " #   - "  #  ( # (  '    #2/+-*<.%,1+"&AAA "":.H"":.H"":.H T#|C001 eT12 R
| R
j H-C@X C@ .C@L H-%X % .%P H-
 X 
  .
 G		MM
G	TS Sll'Z l'^	f.s3 	I
 I
Xq'\: q'h	f.s3 	u'\: u'p	f.s3 	rZ   