
    +h                    :   d Z ddlZddlZddlZddlZddl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j2                  dej4                  ej6                  z        Z ej2                  dej4                  ej6                  z        Z ej<                  d      Z ej<                  d      Z  ej<                  d      Z! ej<                  d      Z" ej<                  d      Z# G d de
jH                        Z% G d de&      Z' G d de'ejP                        Z) G d d e'ejT                        Z+ G d! d"e'ejX                        Z- G d# d$e%      Z. G d% d&e
j^                        Z0e0e%_1        y)'a  Default implementations of per-dialect sqlalchemy.engine classes.

These are semi-private implementation classes which are only of importance
to database dialect authors; dialects will usually use the classes here
as the base class for their own corresponding classes.

    N   )characteristics)cursor)
interfaces)
Connection   )event)exc)pool)
processors)types)util)compiler)
expression)quoted_namez-\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER)z	\s*SELECT	CACHE_HIT
CACHE_MISSCACHING_DISABLEDNO_CACHE_KEYNO_DIALECT_SUPPORTc                   T   e Zd ZdZej
                  Zej                  Zej                  Z
ej                  ZdZdZdZdZdZdZeZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$ e%jL                  d e'jP                         i      Z) e%jL                  d e%jT                  d      fde%jV                  fd	 e%jT                  d
      fd e%jT                  d
      fde%jV                  fde%jV                  fde%jV                  fde%jX                  fg      Z-dZ.e%j^                  rdZ0dZ1e2jf                  jh                  Z5dZ6ndZ0dZ1e2jf                  jn                  Z5dZ6dZ8dZ9dZ:dZ;dZ<dZ=dZ>dZ?i Z@dZAdZB	 dZC	 dZD	 dZEdZFdZGdZHdZIdZJdZKdZL	 dZMdZN e%jL                         ZO	 dZPeQZQeRZReSZSeTZTeUZUdZV e%j                  dddd      ddddddddd eXej                        dfd       ZZd Z[e%j                  d        Z]e%j                  d        Z^e_d         Z`e_d!        Zaebd"        Zcd# Zdebd$        Zed% Zfd& Zgd' Zhd( ZidGd)Zjd* Zkd+ ZldGd,Zmd- Znd. Zod/ Zpd0 Zqd1 Zrd2 Zsd3 Ztd4 Zud5 Zvd6 Zwd7 Zxd8 Zye%j                  d9        Zzd: Z{d; Z|d< Z}d= Z~d> ZdGd?ZdGd@ZdGdAZdB ZdC ZdD ZdE ZdF Zy)HDefaultDialectz!Default implementation of DialectTFr   isolation_levelconvert_unicodeforcepool_timeoutechodebug	echo_poolpool_recycle	pool_sizemax_overflowfutureNuse_encodingdefaulti'  named )z1.3zThe :paramref:`_sa.create_engine.convert_unicode` parameter and corresponding dialect-level parameters are deprecated, and will be removed in a future release.  Modern DBAPIs support Python Unicode natively and this parameter is unnecessary.)1.4a  The :paramref:`_sa.create_engine.empty_in_strategy` keyword is deprecated, and no longer has any effect.  All IN expressions are now rendered using the "expanding parameter" strategy which renders a set of boundexpressions, or an "empty set" SELECT, at statement executiontime.)r(   zThe :paramref:`_sa.create_engine.case_sensitive` parameter is deprecated and will be removed in a future release. Applications should work with result column names in a case sensitive fashion.)r(   zThe :paramref:`_sa.create_engine.server_side_cursors` parameter is deprecated and will be removed in a future release.  Please use the :paramref:`_engine.Connection.execution_options.stream_results` parameter.)r   empty_in_strategycase_sensitiveserver_side_cursorszutf-8c                    t        | dd      s"t        j                  d| j                  z         |r+| j                  st        j                  d| z        d| _        || _        || _	        d| _
        d | _        || _        ||| _        n9| j                  | j                  j                  | _        n| j                  | _        ||| _        | j                  dv | _
        | j!                  |       | _        | j%                  |       | _        ||| _        || _        || _        | j*                  r| j*                  | _        |	| _        |
| _        | j2                  dk(  rt5        j6                  |      | _        n0| j2                  $t5        j6                  | j2                        | _        t;        j<                  | j                        | _        t5        j6                  | j                        | _         y )Nported_sqla_06Tz2The %s dialect is not yet ported to the 0.6 formatz/Dialect %s does not support server side cursorsF)qmarkformatnumericr$   )!getattrr   warnnamesupports_server_side_cursorsr
   ArgumentErrorr+   r   encoding
positional_ischemadbapi
paramstyledefault_paramstyleimplicit_returningprepareridentifier_preparertype_compilersupports_native_booleanr*   #_user_defined_max_identifier_lengthmax_identifier_lengthlabel_lengthcompiler_lintingdescription_encodingr   to_unicode_processor_factory_description_decodercodecs
getencoder_encoder_decoder)selfr   r6   r:   r9   r<   r*   r@   rB   rC   rD   r+   kwargss                L/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py__init__zDefaultDialect.__init__   s   f t-t4IID))
 44''EL  ,0(. 
!(DOZZ#"jj33DO"55DO)&8D#//-KK#'==#6 !//5".+BD(,3H03388 & ) 0$$677)D% &&277''))D% ))$--8"??N    c                 v    t        |t              s)t        j                  dt        dt	        |      d      y )Nz7The argument passed to Dialect.has_table() should be a z, got z. Additionally, the Dialect.has_table() method is for internal dialect use only; please use ``inspect(some_engine).has_table(<tablename>>)`` for public API use.)
isinstancer   r
   r5   type)rL   args     rN   _ensure_has_table_connectionz+DefaultDialect._ensure_has_table_connectionS  s5    #z*## *4T#Y@  +rP   c                     | j                   j                  j                  dd       }|2t        j                  d| j
                  d| j                  dd       t        |      S )Nsupports_statement_cachezDialect :a   will not make use of SQL compilation caching as it does not set the 'supports_statement_cache' attribute to ``True``.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Dialect maintainers should seek to set this attribute to True after appropriate development and testing for SQLAlchemy 1.4 caching support.   Alternatively, this attribute may be set to False which will disable this warning.cprf)code)	__class____dict__getr   r2   r3   driverbool)rL   sscs     rN   _supports_statement_cachez(DefaultDialect._supports_statement_cache`  sU    nn%%))*DdK;II #ii	6  CyrP   c                 *    t        j                         S N)weakrefWeakKeyDictionaryrL   s    rN   _type_memoszDefaultDialect._type_memost  s    ((**rP   c                 :    | j                   dz   | j                  z   S )N+)r3   r^   rf   s    rN   dialect_descriptionz"DefaultDialect.dialect_descriptionx  s    yy3,,rP   c                     | j                   S )zTrue if this dialect supports sane rowcount even if RETURNING is
        in use.

        For dialects that don't support RETURNING, this is synonymous with
        ``supports_sane_rowcount``.

        )supports_sane_rowcountrf   s    rN    supports_sane_rowcount_returningz/DefaultDialect.supports_sane_rowcount_returning|  s     ***rP   c                 8    t        | dt        j                        S )N	poolclass)r1   r   	QueuePool)clsurls     rN   get_pool_classzDefaultDialect.get_pool_class  s    sK88rP   c                 $    | j                  |      S rc   )rs   )rL   rr   s     rN   get_dialect_pool_classz%DefaultDialect.get_dialect_pool_class  s    ""3''rP   c                     dj                  | j                  j                  d      dd       }	 t        |dz          y # t        $ r Y y w xY w)N.r   z
.provision)join
__module__split
__import__ImportError)rq   packages     rN   load_provisioningz DefaultDialect.load_provisioning  sJ    ((3>>//4Qr:;	w-. 		s   > 	A
	A
c                 8   	 | j                  |      | _        	 | j                  |      | _        	 | j                  |j                        | _        | j                  t        j                  j                  u r;t        j                  rt        j                  d      | j!                  |      | _        | j"                  | j%                  |      rd x| _        | _        | j(                  s| j+                  |      }|r|| _        | j.                  rH| j.                  | j,                  kD  r.t        j0                  d| j.                  | j,                  fz        y y # t        $ r d | _        Y Rw xY w# t        $ r d | _        Y Rw xY w# t        $ r d | _        Y Hw xY w)Nz*RETURNS_UNKNOWN is unsupported in Python 3zQLabel length of %d is greater than this dialect's maximum identifier length of %d)_get_server_version_infoserver_version_infoNotImplementedError_get_default_schema_namedefault_schema_nameget_default_isolation_level
connectiondefault_isolation_levelreturns_unicode_stringssqltypesStringRETURNS_UNKNOWNr   py3kr
   InvalidRequestError_check_unicode_returnsrE   _check_unicode_descriptionrG   rA   _check_max_identifier_lengthrB   rC   r5   )rL   r   max_ident_lengths      rN   
initializezDefaultDialect.initialize  s   	,'+'D'D(D$
	,'+'D'D(D$	0+/+K+K%%,D( ''8??+J+JJyy--@  ,0+F+F,D(
 %%1//
;DHHD%(A77#@@L-=* !!D$>$>>##3$$d&@&@AB  ? K # 	,'+D$	, # 	,'+D$	, # 	0+/D(	0s3   E E.  F E+*E+.FFFFc                      y rc   r'   rf   s    rN   
on_connectzDefaultDialect.on_connect  s    rP   c                      y)zPerform a connection / server version specific check to determine
        the max_identifier_length.

        If the dialect's class level max_identifier_length should be used,
        can return None.

        .. versionadded:: 1.3.9

        Nr'   rL   r   s     rN   r   z+DefaultDialect._check_max_identifier_length  s     rP   c                 $    | j                  |      S )a  Given a DBAPI connection, return its isolation level, or
        a default isolation level if one cannot be retrieved.

        May be overridden by subclasses in order to provide a
        "fallback" isolation level for databases that cannot reliably
        retrieve the actual isolation level.

        By default, calls the :meth:`_engine.Interfaces.get_isolation_level`
        method, propagating any exceptions raised.

        .. versionadded:: 1.3.22

        )get_isolation_levelrL   
dbapi_conns     rN   r   z*DefaultDialect.get_default_isolation_level  s     ''
33rP   c                     t         j                  r j                  st         j                  nt         j                   j
                  r j                         ni  fd}t        j                  t        j                  d      t        j                  d            t        j                  t        j                  d      t        j                  d            g}|r||z  }|D ch c]
  } ||       }}|j                  ddg      rt        j                  j                  S |dhk(  rt        j                  j                   S t        j                  j"                  S c c}w )Nc                     t        j                  |       j                              }	 j                  j	                         }j                  ||       |j                         }|j                          t        |d   t        j                        S # t        j                  $ r"}t        j                  d|z         Y d }~yd }~ww xY w)Ndialectr   z2Exception attempting to detect unicode returns: %rF)r   selectcompiler   r   _cursor_executefetchonecloserR   r   	text_typer
   
DBAPIErrorr2   )	test	statementr   rowdecast_tor   
parametersrL   s	        rN   check_unicodez<DefaultDialect._check_unicode_returns.<locals>.check_unicode  s    
 1 1$ 7 ? ? ? MNI:#..557**69jIoo' "#a&$..99 >>  		1356 s   AB C+CCz'test plain returns'<   z'test unicode returns'TF)r   py2ksupports_unicode_statementsbinary_typer   r7   execute_sequence_formatr   castliteral_columnr   VARCHARUnicode
issupersetr   RETURNS_CONDITIONALRETURNS_UNICODERETURNS_BYTES)	rL   r   additional_testsr   testsr   resultsr   r   s	   ``     @@rN   r   z%DefaultDialect._check_unicode_returns  s'    99T==&&GnnG??557JJ	:( OO))*@A  $ OO))*BC  $
 %%E3894=&99tUm,??666 tf$ // __22 :s   ,E$c           	         t         j                  r| j                  st         j                  }nt         j                  }|j
                  j                         }	 |j                   |t        j                  t        j                  d      j                  d            j                  |                    t        |j                  d   d   t         j                        |j                          S # |j                          w xY w)Nz'x'
some_labelr   r   )r   r   r   r   r   r   r   executer   r   r   labelr   rR   descriptionr   )rL   r   r   r   s       rN   r   z)DefaultDialect._check_unicode_description$  s     99T==&&GnnG&&--/
	NN%%"11%8>>|Lgdg+ f003A6GLLNFLLNs   BC/ /Dc                 B    t        j                  || j                        S )a)  Provide a database-specific :class:`.TypeEngine` object, given
        the generic object which comes from the types module.

        This method looks for a dictionary called
        ``colspecs`` as a class or instance-level variable,
        and passes on to :func:`_types.adapt_type`.

        )r   
adapt_typecolspecs)rL   typeobjs     rN   type_descriptorzDefaultDialect.type_descriptor9  s     ""7DMM::rP   c                 t    | j                  |||      sy| j                  |||      D ]  }|d   |k(  s y y)N)schemaFr3   T)	has_tableget_indexes)rL   r   
table_name
index_namer   idxs         rN   	has_indexzDefaultDialect.has_indexD  sL    ~~j*V~D##J
6#J 	C6{j(	 rP   c                 |    t        |      | j                  kD  r$t        j                  d|| j                  fz        y )Nz7Identifier '%s' exceeds maximum length of %d characters)lenrB   r
   IdentifierError)rL   idents     rN   validate_identifierz"DefaultDialect.validate_identifierM  sB    u:222%%I$4456  3rP   c                 :     | j                   j                  |i |S rc   )r9   connect)rL   cargscparamss      rN   r   zDefaultDialect.connectT  s    !tzz!!54G44rP   c                 `    |j                         }|j                  |j                         g |gS rc   )translate_connect_argsupdatequery)rL   rr   optss      rN   create_connect_argsz"DefaultDialect.create_connect_argsX  s*    ))+CIIDzrP   c                      t         j                        j                        }|r>t        j                  fd|D              t        j                  |d       fd       }y y )Nc              3   ,   K   | ]  }||   f  y wrc   r'   .0r3   r   s     rN   	<genexpr>z>DefaultDialect.set_engine_execution_options.<locals>.<genexpr>c        1'+tDz"1   engine_connectc                 0    |sj                  |        y y rc   )_set_connection_characteristics)r   branchr   rL   s     rN   set_connection_characteristicszSDefaultDialect.set_engine_execution_options.<locals>.set_connection_characteristicsg  s    88"O rP   )setconnection_characteristicsintersectionr   immutabledictr	   listens_for)rL   enginer   supported_namesr   r   s   ` `  @rN   set_engine_execution_optionsz+DefaultDialect.set_engine_execution_options^  sj    d==>KK
 "00 1/>1 O v'78 9 rP   c                     t        | j                        j                        }|r1t        j                  fd|D              }| j                  ||       y y )Nc              3   ,   K   | ]  }||   f  y wrc   r'   r   s     rN   r   zBDefaultDialect.set_connection_execution_options.<locals>.<genexpr>s  r   r   )r   r   r   r   r   r   )rL   r   r   r   r   s     `  rN    set_connection_execution_optionsz/DefaultDialect.set_connection_execution_optionsn  sZ    d==>KK
 "00 1/>1 O 00_M	 rP   c                     |j                          D cg c]  \  }}|| j                  |   |f }}}|j                         r|D cg c]  \  }}}|j                  r||f }}}}|rh|j                  r.t        j                  ddj                  d |D              z        t        j                  ddj                  d |D              z         |j                  j                  }|D ]  \  }}	}|	j                  | ||        |j                  j                  j                  j                  t!        j"                  | j$                  |             y c c}}w c c}}}w )NzThis connection has already initialized a SQLAlchemy Transaction() object via begin() or autobegin; %s may not be altered unless rollback() or commit() is called first.z, c              3   &   K   | ]	  \  }}|  y wrc   r'   r   r3   objs      rN   r   zADefaultDialect._set_connection_characteristics.<locals>.<genexpr>       $FidCT$F   zConnection is already established with a Transaction; setting %s may implicitly rollback or commit the existing transaction, or have no effect until next transactionc              3   &   K   | ]	  \  }}|  y wrc   r'   r   s      rN   r   zADefaultDialect._set_connection_characteristics.<locals>.<genexpr>  r   r   )itemsr   in_transactiontransactional
_is_futurer
   r   ry   r   r2   r   dbapi_connectionset_characteristic_connection_recordfinalize_callbackappend	functoolspartial_reset_characteristics)
rL   r   r   r3   valuecharacteristic_valuesr   
trans_objsr  characteristics
             rN   r   z.DefaultDialect._set_connection_characteristicsx  su     5446!
e 42248%@!
 !

 $$& )> $D#u$$ sJ 
 ((11+  99$F:$FF	H  II+  99$F:$FFH &00AA+@ 	M'D.%--d4DeL	M00BBIId99?K	
E!
s   E
Ec                 T    |D ]#  }| j                   |   }|j                  | |       % y rc   )r   reset_characteristic)rL   r   r  characteristic_namer  s        rN   r  z%DefaultDialect._reset_characteristics  s:    #2 	H!<<#N //6FG		HrP   c                      y rc   r'   rL   r  s     rN   do_beginzDefaultDialect.do_begin      rP   c                 $    |j                          y rc   )rollbackr  s     rN   do_rollbackzDefaultDialect.do_rollback  s    !!#rP   c                 $    |j                          y rc   )commitr  s     rN   	do_commitzDefaultDialect.do_commit  s    !rP   c                 &    | j                  |       y rc   )do_closer  s     rN   do_terminatezDefaultDialect.do_terminate  s    &'rP   c                 $    |j                          y rc   )r   r  s     rN   r  zDefaultDialect.do_close  s     rP   c                 ^    t        t        j                  d      j                  |             S )Nr   r   )strr   r   r   rf   s    rN   _dialect_specific_select_onez+DefaultDialect._dialect_specific_select_one  s&    :$$Q'///=>>rP   c                     d }	 |j                         }	 |j                  | j                         |j                          y# |j                          w xY w# | j                  j
                  $ r}| j                  |||      rY d }~y d }~ww xY w)NTF)r   r   r   r   r9   Erroris_disconnect)rL   r  r   errs       rN   do_pingzDefaultDialect.do_ping  s~    	%,,.Ft@@A  zz 	!!#'7@		s3   A A A AA B/BBBc                 :    dt        j                  dddz        z  S )zCreate a random two-phase transaction ID.

        This id will be passed to do_begin_twophase(), do_rollback_twophase(),
        do_commit_twophase().  Its format is unspecified.
        z	_sa_%032xr   r      )randomrandintrf   s    rN   
create_xidzDefaultDialect.create_xid  s     V^^AqCx888rP   c                 L    |j                  t        j                  |             y rc   )r   r   SavepointClauserL   r   r3   s      rN   do_savepointzDefaultDialect.do_savepoint  s    :55d;<rP   c                 L    |j                  t        j                  |             y rc   )r   r   RollbackToSavepointClauser-  s      rN   do_rollback_to_savepointz'DefaultDialect.do_rollback_to_savepoint  s    :??EFrP   c                 L    |j                  t        j                  |             y rc   )r   r   ReleaseSavepointClauser-  s      rN   do_release_savepointz#DefaultDialect.do_release_savepoint  s    :<<TBCrP   c                 (    |j                  ||       y rc   )executemanyrL   r   r   r   contexts        rN   do_executemanyzDefaultDialect.do_executemany  s    9j1rP   c                 (    |j                  ||       y rc   r   r7  s        rN   
do_executezDefaultDialect.do_execute  s    y*-rP   c                 &    |j                  |       y rc   r;  )rL   r   r   r8  s       rN   do_execute_no_paramsz#DefaultDialect.do_execute_no_params  s    y!rP   c                      y)NFr'   )rL   er   r   s       rN   r#  zDefaultDialect.is_disconnect  s    rP   c                 <    | j                  || j                         y rc   )set_isolation_levelr   r   s     rN   reset_isolation_levelz$DefaultDialect.reset_isolation_level  s     	  T-I-IJrP   c                 8   |y t         j                  r+t        |t              r|j	                  | j
                        }|j                         }|j                         }||k(  r|S ||k(  r| j                  j                  |      s|S ||k(  rt        |d      S |S )NT)quote)r   r   rR   r  decoder6   lowerupperr>   _requires_quotesr   rL   r3   
name_lower
name_uppers       rN   normalize_namezDefaultDialect.normalize_name  s    <99$${{4==1ZZ\
ZZ\
# K4$$55
&)
 4 t400 KrP   c                 &   |y |j                         }|j                         }||k(  r|S ||k(  r| j                  j                  |      s|}t        j
                  r4| j                  s|j                  | j                        }|S t        |      }|S rc   )
rG  rH  r>   rI  r   r   supports_unicode_bindsencoder6   unicoderJ  s       rN   denormalize_namezDefaultDialect.denormalize_name  s    <ZZ\
ZZ\
# K4$$55
&) D99..{{4==1  t}rP   c                     |S rc   r'   r   s     rN   get_driver_connectionz$DefaultDialect.get_driver_connection!  s    rP   rc   )__name__rz   __qualname____doc__r   SQLCompilerstatement_compilerDDLCompilerddl_compilerGenericTypeCompilerr?   IdentifierPreparerr=   supports_altersupports_commentsinline_commentsuse_setinputsizesrW   default_sequence_basetupler   supports_schemassupports_viewssupports_sequencessequences_optional"preexecute_autoincrement_sequencessupports_identity_columnspostfetch_lastrowidr<   full_returninginsert_executemany_returningcte_follows_insertsupports_native_enumr@   #non_native_boolean_check_constraintsupports_simple_order_by_labeltuple_in_valuesr   r   r   IsolationLevelCharacteristicr   bool_or_strasintasboolengine_config_typessupports_native_decimalr   r   rO  r   r   r   r   rE   r   r3   rB   rA   r   max_index_name_lengthmax_constraint_name_lengthrl   supports_sane_multi_rowcountr   r;   supports_default_valuessupports_default_metavaluesupports_empty_insertsupports_multivalues_insertsupports_is_distinct_fromr4   r+   supports_for_update_ofr   r   construct_argumentsrequires_name_normalizereflection_optionsdbapi_exception_translation_mapis_asyncr   r   r   r   r   has_terminatedeprecated_paramsint
NO_LINTINGrO   rU   memoized_propertyra   rg   propertyrj   rm   classmethodrs   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r   r%  r*  r.  r1  r4  r9  r<  r>  r#  rC  rM  rR  rT  r'   rP   rN   r   r   3   sj   +!--''L00M**HNO#  $N).& %N#(  #*.'%)"O!3!3!3	HOHHJK" -$,, 0 0 0 9:TZZ(%T%%g./*$**734TZZ($**%TZZ(t{{#		
  $yy&*#!%"*//"A"A#&+#!&"*//"A"A-D !*.'O
 !!%!#' H #:!&< !."' $#(  #"R $&8d&8&8&:# HIJ'L+MT



1 F  $" X001!DOC BDOL 
 & 
+ + - - + + 9 9(  1f
4 9v*	;5 N&
PH$"(! 
? ? 9=GD2."K:,rP   r   c                       e Zd Zd Zy)_RendersLiteralc                     d }|S )Nc                     d| z  S )Nz'%s'r'   )r	  s    rN   processz2_RendersLiteral.literal_processor.<locals>.process'  s    E>!rP   r'   )rL   r   r  s      rN   literal_processorz!_RendersLiteral.literal_processor&  s    	" rP   N)rU  rz   rV  r  r'   rP   rN   r  r  %  s    rP   r  c                       e Zd Zy)_StrDateTimeNrU  rz   rV  r'   rP   rN   r  r  -      rP   r  c                       e Zd Zy)_StrDateNr  r'   rP   rN   r  r  1  r  rP   r  c                       e Zd Zy)_StrTimeNr  r'   rP   rN   r  r  5  r  rP   r  c                       e Zd Zej                  Zej                  Zej                  Z	ej                  ZdZdZdZdZdZdZdZdZdZej,                  eej0                  eej4                  eiZy)StrCompileDialectTFN)rU  rz   rV  r   StrSQLCompilerrY  rZ  r[  StrSQLTypeCompilerr?   r]  r=   rW   ri  rf  rg  rh  r<   r@   r~  rp  r   DateTimer  Dater  Timer  r   r'   rP   rN   r  r  9  s    !00''L//M**H# $).&""&%)" 	<xxHrP   r  c                      e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZ ej                         ZdZdZej(                  ZdZdZdZdZdZdZdZdZ ej                         ZeZ e!d        Z"e!e#fd       Z$e!d        Z%e!d        Z&d Z'ejP                  d        Z)ejP                  d	        Z*ejP                  d
        Z+ejP                  d        Z,ejP                  d        Z-ejP                  d        Z.ejP                  d        Z/d/dZ0e1d        Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9d Z:d Z;d Z<d Z=e1d        Z>d Z?d Z@d ZAd  ZBd! ZCejP                  d"        ZDd# ZEd$ ZFd% ZGd& ZHd' ZId( ZJd) ZKdZL	 d0d*ZMd+ ZNd, ZOd- ZPd. ZQy)1DefaultExecutionContextFNc                    | j                  |       }||_        ||_        |j                  |_        |x|_        }d|_        ||_        |j                  xs |j                  j                  dd      |_	        t        j                  |      |_        |j                  rJ|j                  j                  di       }|j                  j                  }	 |	|j                  |      |_        |j                   s$|j#                  |j                        d   |_        n|j                  |_        |j'                         |_        g |_        |j,                  r|j/                         g|_        |S i g|_        |S )z8Initialize execution context for a DDLElement construct.Tfuture_resultFschema_translate_mapr   )__new__root_connection_dbapi_connectionr   compiledisddlexecution_optionsr   r]   _is_future_resultr   r   unicode_statementr  r=   _render_schema_translatesr   rJ   r   create_cursorr   compiled_parametersr7   r   r   )
rq   r   r   r  r  compiled_ddlrL   r  r  rsts
             rN   	_init_ddlz!DefaultExecutionContext._init_ddl{  s]    {{3)!1!))#//
!2 !! B%%))/5A 	
 "&!9((#'#9#9#=#=&$  ##==C%(&&(<&D" 22$--d.D.DEaHDN!33DN((*#% &>>@ADO   "dDOrP   c
           
         | j                  |       }
||
_        ||
_        |j                  |
_        ||
_        ||
_        ||
_        |	|
_        ||
_        |j                  xs |
j                  j                  dd      |
_        |j                  |j                  |j                  |j                  |j                   f|
_        |j$                  |
_        |j&                  |
_        |j(                  |
_        |j*                  |
_        |
j$                  s|
j&                  s|
j(                  r^d|
_        t1        |j2                  j4                        |
_        t1        |j8                  xr |j2                  j4                         |
_        |s|j=                  |d      g|
_        nItA        |      D cg c]  \  }}|j=                  |d||       c}}|
_        tC        |      dkD  |
_"        tF        jH                  r%tG        jJ                  |jL                        |
_'        n|jL                  |
_'        |
jQ                         |
_)        |
j                  jT                  s|
j                  jV                  r-|
jD                  r|
jY                          n|
j[                          |j\                  }|j^                  s|j`                  r|
jD                  rtc        jd                  d      |jg                  |
j>                  d         }|j2                  |
_'        |jh                  |
_5        tm        |      } |jn                  |jp                         |jr                  }n"|jt                  r|
j                  jr                  }|jv                  rJ|
j                  j                  d	i       }|jx                  jz                  } ||
jN                  |      |
_'        |j|                  s5|
jN                  j                  |
j                  j                        |
_        n|
jN                  |
_        g }|jt                  rW|
j>                  D ]F  }D cg c]  }||v r ||   ||         n||    }}|j                  |j                  |             H n|j|                   }|r|j                  }|
j>                  D ]  }|j                  }|rp|r?|D ci c]3  } |j                  ||            d   ||v r ||   ||         n||   5 }}n|D ci c]#  } |      d   ||v r ||   ||         n||   % }}n]|r6|D ci c]*  }|j                  ||      ||v r ||   ||         n||   , }}n%|D ci c]  }|||v r ||   ||         n||    }}|j                  |        |j                  |      |
_E        |
S c c}}w c c}w c c}w c c}w c c}w c c}w )
z6Initialize execution context for a Compiled construct.r  FT)extracted_parametersescape_names)r  _group_numberr  r   zL'literal_execute' or 'expanding' parameters can't be used with executemany()r   r  )Fr  r  r  r   r  invoked_statementr  	cache_hitr  r   r]   r  _result_columns_ordered_columns_textual_ordered_columns_ad_hoc_textual_loose_column_name_matchingresult_column_structisinsertisupdateisdeleteisplaintextis_textis_crudr_   r   
_returning_is_explicit_returning	returning_is_implicit_returningconstruct_paramsr  	enumerater   r6  r   r   r   stringr  r  r   insert_prefetchupdate_prefetch_process_executemany_defaults_process_executesingle_defaults_bind_processorsliteral_execute_paramspost_compile_paramsr
   r   #_process_parameters_for_postcompileparameter_expansion_expanded_parametersdictr   r   positiontupr7   r  r=   r  r   rP  r6   r  r   rJ   escaped_bind_namesr   )rq   r   r   r  r  r  r   r  r  r  rL   grpmr   expanded_stater  r  r  compiled_paramskeyparamrP  encoderr  s                           rN   _init_compiledz&DefaultExecutionContext._init_compiled  s    {{3)!1!))$8!!2 "!2 !! B%%))/5A 	 $$%%--$$00%
! !)) )) ))++==DMMT]]DL*.x/A/A/L/L*MD'*.""H8+=+=+H+H'H+D' )))=!& * (D$ (
3( C ))!&"%)=	 * (D$  #:2D 99%)^^HOO%DD"%-__D"((*==((DMM,I,I224446..
**h.J.J--. 
 &II((+N
 &4%=%=D" )7(J(JD%j)JJn778(44K  --33K((#'#9#9#=#=&$  ##==C%(&&(<&D" 22!33::%%DN "33DN
 
#'#;#; J
  +	  j( $JsOOC$89(-.  !!'"A"A%"HIJ !<<<F!**#'#;#; ()%-%@%@") (7! !$ $$6$:$:3$DE !  #j0  /z#s/CD!0!5	6! ! (7! !$ $CLO  #j0 .=Z_ / 4. "1!5	6! ! * (7! !$ /223<  #j0 ?Njo / 4? "1!5	6! ! (7	! !$  "j0 "1C1E!F!0!56! ! !!%(Q()T "99*EG(X !!!!s$   1V8V>8W(W6/W,Wc           
         | j                  |       }||_        ||_        |j                  |_        d|_        ||_        |j                  xs |j
                  j                  dd      |_        |s6|j                  j                  r|j                         g|_        ni g|_        nt        |d   |j                        r||_        nt        |d   t              rU|j                  r||_        ne|D 	cg c](  }|D 	ci c]  }	|j                  |	      d   ||	    c}	* c}	}xs i g|_        n$|D 
cg c]  }
|j                  |
       c}
|_        t!        |      dkD  |_        |j                  s;t        |t$        j&                        r!||_        |j                  |      d   |_        n|x|_        |_        |j-                         |_        |S c c}	w c c}	}w c c}
w )z8Initialize execution context for a string SQL statement.Tr  Fr   r   )r  r  r  r   r  r  r   r]   r  r7   r   r   rR   r  r   rJ   r   r6  r   r   r  r   r  r   )rq   r   r   r  r  r   r   rL   dkps              rN   _init_statementz'DefaultExecutionContext._init_statementn  s    {{3)!1!))!2 !! B%%))/5A 	
 ||&&#*#B#B#D"E#%$
1w'F'FG(DO
1t,22", (# <==aW%%a(+QqT1=# # T  =G78//2DO z?Q.22zt~~8
 &/D"$--i8;DN6??DNT3((*' >#
s   3	G<GG3GGc                     | j                  |       }||_        ||_        |j                  |_        ||_        |j
                  xs |j                  j                  dd      |_        |j                         |_	        |S )z;Initialize execution context for a ColumnDefault construct.r  F)
r  r  r  r   r  r   r]   r  r  r   )rq   r   r   r  r  rL   s         rN   _init_defaultz%DefaultExecutionContext._init_default  s}     {{3)!1!))!2 !! B%%))/5A 	
 ((*rP   c                 $   | j                   yt        j                         }| j                  }|t        u rd|| j                   j
                  z
  fz  S |t        u rd|| j                   j
                  z
  fz  S |t        u rd|| j                   j
                  z
  fz  S |t        u rd|| j                   j
                  z
  fz  S |t        u rGd| j                  j                  | j                  j                  || j                   j
                  z
  fz  S y)Nzraw sqlzno key %.5fszcached since %.4gs agozgenerated in %.5fszcaching disabled %.5fsz,dialect %s+%s does not support caching %.5fsunknown)r  r   perf_counterr  r   	_gen_timer   r   r   r   r   r3   r^   )rL   nowchs      rN   _get_cache_statsz(DefaultExecutionContext._get_cache_stats  s   == !^^!S4==+B+B%B$DDD9_+sT]]5L5L/L.NNN:'31H1H+H*JJJ##+sT]]5L5L/L.NNN%%A!!##dmm---E   rP   c                     | j                   r| j                   j                  S d| j                  v r2| j                  j                  j                  | j                  d         S | j                  j                  S )Nr  )r  r=   r  r   r>   _with_schema_translaterf   s    rN   r>   z+DefaultExecutionContext.identifier_preparer  se    ====)))#t'='==<<33JJ&&'=>  <<333rP   c                 .    | j                   j                  S rc   )r  r   rf   s    rN   r   zDefaultExecutionContext.engine  s    ##***rP   c                 .    | j                   j                  S rc   )r  	postfetchrf   s    rN   postfetch_colsz&DefaultExecutionContext.postfetch_cols  s    }}&&&rP   c                     | j                   r| j                  j                  S | j                  r| j                  j                  S y)Nr'   )r  r  r  r  r  rf   s    rN   prefetch_colsz%DefaultExecutionContext.prefetch_cols  s3    ====000]]==000rP   c                 0    | j                   j                   y rc   )r  r  rf   s    rN   returning_colsz&DefaultExecutionContext.returning_cols  s    rP   c                 :    | j                   j                  dd      S )Nno_parametersF)r  r]   rf   s    rN   r  z%DefaultExecutionContext.no_parameters  s    %%))/5AArP   c                     | j                   j                  d| j                   xr | j                  xr t        j
                  xs d      }|t        j
                  u r| j                  | j                        S |S )N
autocommitF)r  r]   r  r   r   PARSE_AUTOCOMMITshould_autocommit_textr  )rL   r  s     rN   should_autocommitz)DefaultExecutionContext.should_autocommit  sv    ++// ,,++ 

 444..t/E/EFFrP   c                    | j                   }t        |t        j                        r4| j                  j
                  s| j                  j                  |      d   }d| j                  v r;| j                  j                  di       }| j                  j                  } |||      }|s3| j                  j                  r| j                  j                         }ni }|j                  | j                  |||        | j                  j                         d   }|@|j!                  | j                  | j                  j"                  d   d         }|r ||      S |S )a  Execute a string statement on the current cursor, returning a
        scalar result.

        Used to fire off sequences, default phrases, and "select lastrowid"
        types of statements individually or in the context of a parent INSERT
        or UPDATE statement.

        r   r  )r8  r   )r  rR   r   r   r   r   rJ   r  r]   r>   r  r7   r   r   r   r   _cached_result_processorr   )	rL   stmttype_r   connr  r  rprocs	            rN   _execute_scalarz'DefaultExecutionContext._execute_scalar	  s,    ##tT^^,LL<<<<((.q1D!T%;%;;#'#9#9#=#=&$  **DDCt12D||&&!\\AAC

T[[$
DIKK  "1%11dkk55a8;D AwrP   c                 V    | j                   }|j                  r|S |j                         S rc   )r  r   _branch)rL   r  s     rN   r   z"DefaultExecutionContext.connection3  s%    ##??K<<>!rP   c                 ,    t         j                  |      S rc   )AUTOCOMMIT_REGEXPmatch)rL   r   s     rN   r   z.DefaultExecutionContext.should_autocommit_text;  s     &&y11rP   c                 ,   | j                   j                  sy| j                   j                  r| j                  j	                  dd      xr | j
                  xr. t        | j
                  j                  t        j                        xsl | j
                   xs. t        | j
                  j                  t        j                        xr- | j                  xr t        j                  | j                        }|S | j                  j	                  dd      }|S )NFstream_resultsT)r   r4   r+   r  r]   r  rR   r   r   
Selectable
TextClauser  SERVER_SIDE_CURSOR_REr  )rL   use_server_sides     rN   _use_server_side_cursorz/DefaultExecutionContext._use_server_side_cursor>  s    ||88<<++"4488 $  MM "//1F1F !%- ) $ 7 79N9N P !22P 2778N8NO! 2 	 #4488 %O rP   c                    | j                   j                  rY| j                  j                  dd      s&| j                   j                  r'| j                         rd| _        | j                         S d| _        | j                         S )Nr  FT)	r   r4   r  r]   r+   r  _is_server_sidecreate_server_side_cursorcreate_default_cursorrf   s    rN   r  z%DefaultExecutionContext.create_cursor_  sq     LL55&&**+;UCLL44446 $(D 1133#(D --//rP   c                 6    | j                   j                         S rc   )r  r   rf   s    rN   r  z-DefaultExecutionContext.create_default_cursorq  s    %%,,..rP   c                     t               rc   r   rf   s    rN   r  z1DefaultExecutionContext.create_server_side_cursort  s    !##rP   c                      y rc   r'   rf   s    rN   pre_execz DefaultExecutionContext.pre_execw  r  rP   c                     t        d      )Nz,This dialect does not support OUT parametersr  )rL   namess     rN   get_out_parameter_valuesz0DefaultExecutionContext.get_out_parameter_valuesz  s    !:
 	
rP   c                      y rc   r'   rf   s    rN   	post_execz!DefaultExecutionContext.post_exec  r  rP   c                 :    |j                  | j                  |      S )zReturn a 'result processor' for a given type as present in
        cursor.description.

        This has a default implementation that dialects can override
        for context-sensitive result type handling.

        )r  r   )rL   r  colnamecoltypes       rN   get_result_processorz,DefaultExecutionContext.get_result_processor  s     --dllGDDrP   c                 .    | j                   j                  S )a  return self.cursor.lastrowid, or equivalent, after an INSERT.

        This may involve calling special cursor functions, issuing a new SELECT
        on the cursor (or a new one), or returning a stored value that was
        calculated within post_exec().

        This function will only be called for dialects which support "implicit"
        primary key generation, keep preexecute_autoincrement_sequences set to
        False, and when no explicit id value was bound to the statement.

        The function is called once for an INSERT statement that would need to
        return the last inserted primary key for those dialects that make use
        of the lastrowid concept.  In these cases, it is called directly after
        :meth:`.ExecutionContext.post_exec`.

        )r   	lastrowidrf   s    rN   get_lastrowidz%DefaultExecutionContext.get_lastrowid  s    " {{$$$rP   c                      y rc   r'   )rL   r@  s     rN   handle_dbapi_exceptionz.DefaultExecutionContext.handle_dbapi_exception  r  rP   c                 .    | j                   j                  S rc   )r   rowcountrf   s    rN   r.  z DefaultExecutionContext.rowcount  s    {{###rP   c                 .    | j                   j                  S rc   )r   rl   rf   s    rN   rl   z.DefaultExecutionContext.supports_sane_rowcount  s    ||222rP   c                 .    | j                   j                  S rc   )r   rz  rf   s    rN   rz  z4DefaultExecutionContext.supports_sane_multi_rowcount  s    ||888rP   c                 p   | j                   }| j                  s| j                  r| j                         }dx}}n|j	                  dd       }| j
                  xs |j	                  dd      }| j                  }|r<|t        j                  u r*t        j                  | j                  | j                         }|j                  xs | j                  j                  }|t        j                  }| j                  rC| j                  j                   rt#        j$                  d      t        j&                  | ||      }nt        j(                  | ||      }| j*                  r3| j,                  s'| j*                  j.                  r| j1                  |       |j2                  | _        |r|j5                  |      }|S )NF	yield_perr  z3can't use future_result=True with close_with_result)r  r  r  _setup_dml_or_text_resultr]   r  cursor_fetch_strategy_cursor_DEFAULT_FETCHBufferedRowCursorFetchStrategyr   alternate_cursor_descriptionr   _NO_CURSOR_DQLr  r  should_close_with_resultr
   r   CursorResultLegacyCursorResultr  r  has_out_parameters_setup_out_parameters_soft_closedr2  )rL   exec_optresultypsrstrategycursor_descriptions          rN   _setup_result_proxyz+DefaultExecutionContext._setup_result_proxy  s   ))<<4<<335FOBk40B%%N6F)NB11Hh'"8"88"AAKK!7!7 55 +;;**  ")"11%%''@@11M  !--($6 !33($6
 MMJJ00&&v."//%%b)FrP   c                 V   | j                   j                  j                         D cg c]  \  }}|j                  r||f }}}i }t	        |D cg c]  \  }}|	 c}}| j                  |D cg c]  \  }}|	 c}}            D ]  \  }}|j                  }|j                  | j                        }	|	j                  | j                  j                        }
|	j                  | j                  |
      }| ||      }|||j                  <    ||_        y c c}}w c c}}w c c}}w rc   )r  
bind_namesr   
isoutparamzipr!  rS   dialect_implr   get_dbapi_typer9   result_processorr  out_parameters)rL   rA  r  r3   out_bindparamsrN  	bindparam	raw_valuer  	impl_type
dbapi_typerM  s               rN   r>  z-DefaultExecutionContext._setup_out_parameters  s!     $}}77==?
t DM
 

 $'&45{udU5)))78+%8%
 	6 Iy NNE**4<<8I"11$,,2D2DEJ(99j   +,Y7	,5N9==)	6" !/1
 68s   DD
0D%c                 2   | j                   r+| j                  j                  r| j                         | _        | j
                  }| j                  r<|t        j                  u r*t        j                  | j                  | j                        }|j                  xs | j                  j                  }|t        j                  }| j                  rt        j                   | ||      }nt        j"                  | ||      }| j                   r| j$                  rX|j'                         }|| _        | j+                  ||      | _        |j,                  j.                  sJ |j1                          |S | j2                  s|j1                          |S | j4                  rN| j$                  rB|j7                         }|g| _        |j1                          |j,                  j.                  sJ |S |j,                  j.                  s|j8                   |j1                          |S rc   )r  r  rj  _setup_ins_pk_from_lastrowidinserted_primary_key_rowsr4  r  r5  r6  r7  r   r  r8  r   _NO_CURSOR_DMLr  r;  r<  r  allreturned_default_rows%_setup_ins_pk_from_implicit_returning	_metadatareturns_rows_soft_closer  r  r   r.  )rL   rD  rE  rA  rowsr   s         rN   r3  z1DefaultExecutionContext._setup_dml_or_text_result  s   ==}}00557 . --H0F0F$F==T33H 11LT[[5L5L 	 %--H!!))$:LMF//h 2F ==**zz|-1* >>vtL . ''4444""$2 1 00""$.  ]]t:://#C*-D&  ##0000  !!.. OO rP   c                 "    | j                         S rc   )_setup_ins_pk_from_emptyrf   s    rN   rV  z1DefaultExecutionContext.inserted_primary_key_rows>  s    
 ,,..rP   c                 |    | j                   j                  }| j                         } ||| j                  d         gS Nr   )r  +_inserted_primary_key_from_lastrowid_getterr*  r  )rL   getterr)  s      rN   rU  z4DefaultExecutionContext._setup_ins_pk_from_lastrowidE  s:    JJ&&(	y$":":1"=>??rP   c                 z    | j                   j                  }| j                  D cg c]  } |d |       c}S c c}w rc   )r  rc  r  )rL   rd  r  s      rN   r`  z0DefaultExecutionContext._setup_ins_pk_from_emptyK  s2    JJ151I1IJtU#JJJs   8c                     |sg S | j                   j                  }| j                  }t        ||      D cg c]  \  }} |||       c}}S c c}}w rc   )r  +_inserted_primary_key_from_returning_getterr  rJ  )rL   rA  r^  rd  r  r   r  s          rN   rZ  z=DefaultExecutionContext._setup_ins_pk_from_implicit_returningO  sU    IJJ22 25T?1K
#-3F3
 	
 
s   Ac                 x    | j                   xs | j                  xr t        | j                  j                        S rc   )r  r  r_   r  r  rf   s    rN   lastrow_has_defaultsz,DefaultExecutionContext.lastrow_has_defaults[  s0    . 
DMM##5
 	
rP   c                   	
 | j                   s| j                  ry| j                  j                  | j                  | j
                        }|y| j                  j                  rRt        |      }| j                  j                  j                  || j                  | j                  | j                  |        t        | j                  j                        r| j                  j                  
| j                  j                   r=| j                  j"                  D cg c]  }|| j                  j$                  |   f }}n8| j                  j&                  j)                         D cg c]	  \  }}||f }}}g }|D ]  \  }| j                  j*                  v r || j,                  v rj.                  j0                  rYt3        j.                  j4                        |   	|j7                  	
fdt9        | j,                  |         D               |j;                  d      |j7                  
fd| j,                  |   D               |j;                  d      r
j;                  ||      n|}|j=                  |j.                  f       " 	 | j                  j?                  | j                  ||        yc c}w c c}}w # t@        $ r)}| jB                  jE                  |ddd|        Y d}~yd}~ww xY w)a:  Given a cursor and ClauseParameters, call the appropriate
        style of ``setinputsizes()`` on the cursor, using DB-API types
        from the bind parameter's ``TypeEngine`` objects.

        This method only called by those dialects which require it,
        currently cx_oracle, asyncpg and pg8000.

        N)include_typesexclude_typesc              3      K   | ]@  \  }}rj                  ||      n||z     j                  j                  |z     f B y wrc   )r]   rS   r   )r   r   	paramnamerP  dbtypesr  has_escaped_namesnums      rN   r   z;DefaultExecutionContext._set_input_sizes.<locals>.<genexpr>  s[      . +C $5 !3 6 6y) L%.#C#I.%NN00s;.s   AA	c              3   d   K   | ]'  }rj                  ||      n|j                  f ) y wrc   )r]   rS   )r   rn  rP  dbtyper  rp  s     rN   r   z;DefaultExecutionContext._set_input_sizes.<locals>.<genexpr>  s?      . & $5 !3 6 6y) L%."%NN.s   -0)#r  r  r  _get_set_input_sizes_lookupinclude_set_input_sizesexclude_set_input_sizesr   _has_eventsr  dispatchdo_setinputsizesr   r   r   r_   r  r7   r  bindsrH  r   r  r  rS   _is_tuple_typer   r   extendr  r]   r  do_set_input_sizesBaseExceptionr  _handle_dbapi_exception)rL   
inputsizesr  r   rP  generic_inputsizesescaped_namer@  rs  ro  r  rp  rq  s       `   @@@@@rN   _set_input_sizesz(DefaultExecutionContext._set_input_sizes`  s    ::]]>>6666 ? 


 <<##j)JLL!!22DKK$ !!A!AB!%!A!A<<""  ==44 dmm))#./E  '+mm&>&>&D&D&F"Is i E 
  # /	NCDMM@@@d///>>00inn223C(3G&-- . /8 55c:/.  (^^It<F&-- . *.)B)B3)G.  $	48 ) '**34  #))!69>>:[/	`	LL++/y
t  	  884tT 	s$   !"K-K&'K 	L"LLc                     |j                   r| j                  ||      S |j                  r|| _        |j	                  |       S |j
                  r| j                  |||      S |j                  S rc   )is_sequencefire_sequenceis_callablecurrent_columnrT   is_clause_element_exec_default_clause_element)rL   columnr%   r  s       rN   _exec_defaultz%DefaultExecutionContext._exec_default  sf    %%gu55  "(D;;t$$&&44VWeLL;;rP   c           	      >  	
 |j                   s!t        j                  |j                  |      }n|j                  }t        j                  |      j                  | j                        }|j                         	|j                  
|j                  rK|j                  }| j                  j                  |D cg c]  }|
v r 
|   	|         n	|    c}      }nt        	
fd	D              }| j                  t        j                  |      ||      S c c}w )Nr   c              3   P   K   | ]  }||v r |   |         n|   f  y wrc   r'   )r   r  r  r   s     rN   r   zGDefaultExecutionContext._exec_default_clause_element.<locals>.<genexpr>  sE        j( $JsOOC$89(-	s   #&)r   )_arg_is_typedr   type_coercerT   r   r   r   r  r  r7   r  r   r  r	  r   r   )rL   r  r%   r  default_argr  r  r  r   r  r   s            @@rN   r  z4DefaultExecutionContext._exec_default_clause_element  s    $$$00eDK!++K$$[199$,,9O"335..
"..K==
  +	  j( $JsOOC$89(-.J   + J ##NN8$e
 $ 
 	
#s   8Dc                 
   	 | j                   | j                  }| j
                  j                  }|r| j                  r|j                  r|j                  r5|j                  dz   |j                  j                  |j                     i}n|j                  |j                     i}d|j                  j                         }|j                  fd|D               |S S # t        $ r t        j                  d      w xY w)ai  Return a dictionary of parameters applied to the current row.

        This method can only be used in the context of a user-defined default
        generation function, e.g. as described at
        :ref:`context_default_functions`. When invoked, a dictionary is
        returned which includes entries for each column/value pair that is part
        of the INSERT or UPDATE statement. The keys of the dictionary will be
        the key value of each :class:`_schema.Column`,
        which is usually synonymous
        with the name.

        :param isolate_multiinsert_groups=True: indicates that multi-valued
         INSERT constructs created using :meth:`_expression.Insert.values`
         should be
         handled by returning only the subset of parameters that are local
         to the current column default invocation.   When ``False``, the
         raw parameters of the statement are returned including the
         naming convention used in the case of multi-valued INSERT.

        .. versionadded:: 1.2  added
           :meth:`.DefaultExecutionContext.get_current_parameters`
           which provides more functionality over the existing
           :attr:`.DefaultExecutionContext.current_parameters`
           attribute.

        .. seealso::

            :attr:`.DefaultExecutionContext.current_parameters`

            :ref:`context_default_functions`

        zdget_current_parameters() can only be invoked in the context of a Python side column default functionr   r   c              3   6   K   | ]  }|d |fz     f  yw)z%s_m%dNr'   )r   r  indexr   s     rN   r   zADefaultExecutionContext.get_current_parameters.<locals>.<genexpr>E  s)      ?BjS%L!89:s   )current_parametersr  AttributeErrorr
   r   r  compile_stater  _has_multi_parameters_is_multiparam_columnr  originalr  _dict_parameterskeysr   )rL   isolate_multiinsert_groupsr  r  r  r  r  r   s         @@rN   get_current_parametersz.DefaultExecutionContext.get_current_parameters  s    B	00J((F 33&33++q(__((*VZZ*@AZZFJJ!78 11668DHH FJ  H1  	))C 	s   C# #Dc                 j    |j                   y | j                  ||j                   |j                        S rc   )r%   r  rS   rL   r  s     rN   get_insert_defaultz*DefaultExecutionContext.get_insert_defaultL  s,    >>!%%ffnnfkkJJrP   c                 j    |j                   y | j                  ||j                   |j                        S rc   )onupdater  rS   r  s     rN   get_update_defaultz*DefaultExecutionContext.get_update_defaultR  s,    ??"%%ffoov{{KKrP   c                    | j                   j                  }i }| j                   j                  }| j                   j                  }|D ]V  }|j                  s|j                  j
                  r'|j                  j                  s>|j                  j                  ||<   X |D ]?  }|j                  s|j                  j                  s'|j                  j                  ||<   A | j                  D ]i  }|| _
        |D ]+  }||v r||   }n| j                  |      }|!|| ||      <   - |D ]+  }||v r||   }n| j                  |      }|!|| ||      <   - k | `
y rc   )r  _within_exec_param_key_getterr  r  r%   r  	is_scalarrT   r  r  r  r  r  )rL   
key_getterscalar_defaultsr  r  cr  vals           rN   r  z5DefaultExecutionContext._process_executemany_defaultsX  s]   ]]@@
--77--77
 ! 	3Ayy!6!6199;N;N%&YY]]"	3 ! 	4Azzajj22%&ZZ^^"	4 -- 	/E&+D#$ /')!,C11!4C?+.E*Q-(/ % /')!,C11!4C?+.E*Q-(/	/" #rP   c                    | j                   j                  }| j                  d   x| _        }| j                   j                  D ]p  }|j
                  rC|j
                  j                  s-|j
                  j                  r|j
                  j                  }n| j                  |      }|f|| ||      <   r | j                   j                  D ]!  }| j                  |      }||| ||      <   # | `y rb  )r  r  r  r  r  r%   r  r  rT   r  r  r  )rL   r  r  r  r  s        rN   r  z7DefaultExecutionContext._process_executesingle_defaults~  s    ]]@@
 $$Q'	( .. 	9Ayy!6!6199;N;Niimm--a058#JqM2	9 .. 	9A))!,C58#JqM2		9
 #rP   rc   )T)RrU  rz   rV  r  r  r  r  r  r  r6  r  r   r  rY  r   r   r  ru  rv  r5  r6  r4  cache_statsr  r  r  r  r  r?  _translate_colnamer  r   r  r  r  r   r  r  r  r  r  r>   r   r  r  r  r  r  r	  r  r   r   r  r  r  r  r  r!  r#  r'  r*  r,  r.  rl   rz  rF  r>  r3  rV  rU  r`  rZ  ri  r  r  r  r  r  r  r  r  r  r'   rP   rN   r  r  U  s   HHHGGEKHI ***,""#22K""OL
 -4--/I1 1f  #| || 7 7r  (2 
4 4 
+ + 
' ' 
  
    
B B 
 (T " "2B0$/$

E%& $ $39.`/8DL 
/ /@K



aF	%
N 0<|KL$$L$rP   r  )2rW  rH   r  r(  rerd    r   r   r5  r   baser   r	   r
   r   r   r   r   r   sqlr   r   sql.elementsr   r   IUNICODEr  r  symbolr   r   r   r   r   Dialectr   objectr  r  r  r  r  r  r  r  ExecutionContextr  execution_ctx_clsr'   rP   rN   <module>r     sa      	               &BJJ4bddRZZ6G 
 #

<

1BC  DKK$	T[[&
4;;12 t{{>* T[[!56 oZ'' odf 	?H$5$5 		 		 	 8}$j99 }$@" $;  rP   