o
    gJ                    @  s  d Z ddlm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	Z	ddl	m
Z
 ddl	mZ ddl	mZ ddl	mZ dd	l	mZ dd
l	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddl	mZ ddlZddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddl&m'Z' ddl&m(Z( d d!lm)Z) d d"lm*Z* d d#lm+Z+ d d$lm,Z, d d%l-m.Z. d d&l-m/Z/ d d'l-m0Z0 d d(l-m1Z1 d d$l-m,Z2 d d)l3m4Z4 d d*l5m6Z6 d d+l7m8Z8 d d,l7m9Z9 d d-l7m:Z: d d.l;m<Z< d d/l=m>Z> d d0l=m?Z? e	jrdd1l@mAZA dd2lmBZB dd3lmCZC dd4lmDZD dd5lmEZE dd6lmFZF dd7lmGZG dd8lmHZH dd9lmIZI dd:lmJZJ dd;lmKZK dd<lmLZL dd=lMmNZN dd>lOmPZP d d?l)mQZQ d d@l+mRZR d dAl+mSZS d dBl-mTZT d dCl7mUZU d dDl7mVZV d dEl7mWZW d dFlXmYZY d dGlXmZZZ d dHl;m[Z[ d dIl\m]Z] d dJl^m_Z_ d dKl^m`Z` d dLl^maZa ebdMejcejdB Zeefe!\ZgZhZiZjZkG dNdO dOe#ZlG dPdQ dQelZmG dRdS dSe%Znenel_odS )Ta  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.

    )annotationsN)perf_counter)Any)Callable)cast)Dict)List)Mapping)MutableMapping)MutableSequence)Optional)Sequence)Set)Tuple)Type)TYPE_CHECKING)Union   )characteristics)cursor)
interfaces)
Connection)
CacheStats)DBAPICursor)Dialect)ExecuteStyle)ExecutionContext)
ObjectKind)ObjectScope   )event)exc)pool)util)compiler)dml)
expression)type_api)is_tuple_type)_NoArg)DDLCompiler)InsertmanyvaluesSentinelOpts)SQLCompiler)quoted_name)Final)Literal)
ModuleType)Engine)ResultFetchStrategy)_CoreMultiExecuteParams)_CoreSingleExecuteParams)_DBAPICursorDescription)_DBAPIMultiExecuteParams)_ExecuteOptions)_MutableCoreSingleExecuteParams)_ParamStyle)DBAPIConnection)IsolationLevel)Row)URL)_ListenerFnType)Pool)PoolProxiedConnection)
Executable)Compiled)Linting)ResultColumnsEntry)DMLState)
UpdateBase)BindParameter)Column)_BindProcessorType)_ResultProcessorType)
TypeEnginez	\s*SELECTc                   @  sz  e Zd ZU 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jjZdZded< dZded< 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,dZ-dZ.dZ/dZ0dZ1dZ2e34e56 e57 d	Z8e34e3j9e3:d
e3:d
e3j9e3j9e3j9e3j;dZ<ded< dZ=dZ>dZ?dZ@ded< dZAded< dZBded< dZCded< dZDdZEi ZFded< dZGdZH	 dZI	 dZJ	 dZK	 dZLdZMded< dZNded< eOjPZQded< dZRd ed!< d"ZSdZTdZUdZVdZWdZXdZYded#< dZZdZ[dZ\d$Z]e3j^d%d&d'ddddddde_j`deaejbdfdd9d:Zcede3ed;d<d=d> Zfe3jgd?d@ Zhe3jgdAdB ZidZjdZke3jgddEdFZle3jgdGdH ZmdIdJ Zne3jgdKdL Zoe3jgdMdN ZpeddOdP ZqeddQdR ZresddVdWZtddXdYZuesdZd[ Zvdd]d^Zwd_d` Zxdadb Zydcdd Zzdedf Z{dgdh Z|ddidjZ}ddpdqZ~drds Zdtdu Zdvdw Zdd|d}Zdd~dZdd Zdd Zdd Zdd Zdd Zdd Zdd Ze3jgdd ZdddZdddZdd Zdd Zdd Zdd Zdd ZdddZdddZdddZdd Ze3jdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZddÄ Zddń ZddǄ ZdS )DefaultDialectz!Default implementation of DialectTFNzOptional[Set[Any]]include_set_input_sizesexclude_set_input_sizesr   )isolation_levellogging_tokendebug)pool_timeoutecho	echo_poolpool_recycle	pool_sizemax_overflowfutureMapping[str, Any]engine_config_typesdefaulti'  Optional[int]#_user_defined_max_identifier_lengthzOptional[str]rO   max_index_name_lengthmax_constraint_name_lengthz<MutableMapping[Type[TypeEngine[Any]], Type[TypeEngine[Any]]]colspecsnamedDEFAULTbooluse_insertmanyvalues!use_insertmanyvalues_wo_returningr+   "insertmanyvalues_implicit_sentineli  intinsertmanyvalues_page_sizei  default_schema_namezutf-8)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.)rj   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.)empty_in_strategyserver_side_cursors
paramstyleOptional[_ParamStyle]Optional[IsolationLevel]dbapiOptional[ModuleType]implicit_returningLiteral[True]supports_native_booleanOptional[bool]max_identifier_lengthlabel_lengthUnion[_NoArg, int]compiler_lintingrC   rl   kwargsr   c                 K  s0  |r| j std|  d| _t| ddr tdd tjj	| _
d| _d | _|| _|d ur1|| _n| jd ur<| jj| _n| j| _| jdv | _| | | _|| _t| dd }|d urctttj | j}n| j}||  | _| _|d uru|| _|| _| jr| j| _|| _|
| _|	d ur|	| _|t j!ur|| _"d S d S )	Nz/Dialect %s does not support server side cursorsTuse_setinputsizesFzoThe dialect-level use_setinputsizes attribute is deprecated.  Please use bind_typing = BindTyping.SETINPUTSIZES2.0)qmarkformatnumericnumeric_dollartype_compiler)#supports_server_side_cursorsr!   ArgumentErrorrl   getattrr#   warn_deprecatedr   
BindTypingSETINPUTSIZESbind_typing
positional_ischemarp   rm   default_paramstyleprepareridentifier_preparer_on_connect_isolation_levelr   r   r$   GenericTypeCompilerr   type_compiler_clstype_compiler_instancert   r]   rv   rw   ry   rd   r)   NO_ARGrh   )selfrm   rO   rp   rr   rt   rv   rw   rh   rd   ry   rl   rz   legacy_tt_callablett_callable r   [/var/www/html/ecg_monitoring/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py__init__  sX   $



zDefaultDialect.__init__r|   z]full_returning is deprecated, please use insert_returning, update_returning, delete_returningc                 C  s   | j o| jo| jS N)insert_returningupdate_returningdelete_returningr   r   r   r   full_returningu  s
   zDefaultDialect.full_returningc                 C     | j o| jS )a  Default implementation for insert_executemany_returning, if not
        otherwise overridden by the specific dialect.

        The default dialect determines "insert_executemany_returning" is
        available if the dialect in use has opted into using the
        "use_insertmanyvalues" feature. If they haven't opted into that, then
        this attribute is False, unless the dialect in question overrides this
        and provides some other implementation (such as the Oracle Database
        dialects).

        r   rd   r   r   r   r   insert_executemany_returning  s   z+DefaultDialect.insert_executemany_returningc                 C  r   )a  Default implementation for
        insert_executemany_returning_deterministic_order, if not otherwise
        overridden by the specific dialect.

        The default dialect determines "insert_executemany_returning" can have
        deterministic order only if the dialect in use has opted into using the
        "use_insertmanyvalues" feature, which implements deterministic ordering
        using client side sentinel columns only by default.  The
        "insertmanyvalues" feature also features alternate forms that can
        use server-generated PK values as "sentinels", but those are only
        used if the :attr:`.Dialect.insertmanyvalues_implicit_sentinel`
        bitflag enables those alternate SQL forms, which are disabled
        by default.

        If the dialect in use hasn't opted into that, then this attribute is
        False, unless the dialect in question overrides this and provides some
        other implementation (such as the Oracle Database dialects).

        r   r   r   r   r   4insert_executemany_returning_sort_by_parameter_order  s   zCDefaultDialect.insert_executemany_returning_sort_by_parameter_orderreturnr0   c                 C  s"   | j d u rtd|  d| j S )NDialect z\ does not have a Python DBAPI established and cannot be used for actual database interaction)rp   r!   InvalidRequestErrorr   r   r   r   loaded_dbapi  s
   

zDefaultDialect.loaded_dbapic                 C  s   | j tjju S r   )r   r   r   RENDER_CASTSr   r   r   r   _bind_typing_render_casts     z(DefaultDialect._bind_typing_render_castsc                 C  s$   t |tstdtt|f d S )NzThe argument passed to Dialect.has_table() should be a %s, got %s. 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!   r   type)r   argr   r   r   _ensure_has_table_connection  s   

z+DefaultDialect._ensure_has_table_connectionc                 C  s:   | j jdd }|d u rtjd| j| jf dd t|S )Nsupports_statement_cachea  Dialect %s:%s 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#   warnnamedriverrc   )r   sscr   r   r   _supports_statement_cache  s   
	
z(DefaultDialect._supports_statement_cachec                 C  s   t  S r   )weakrefWeakKeyDictionaryr   r   r   r   _type_memos     zDefaultDialect._type_memosc                 C  s   | j d | j S )N+)r   r   r   r   r   r   dialect_description  s   z"DefaultDialect.dialect_descriptionc                 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_rowcountr   r   r   r    supports_sane_rowcount_returning  s   	z/DefaultDialect.supports_sane_rowcount_returningurlr=   
Type[Pool]c                 C  s   t | dtjS )N	poolclass)r   r"   	QueuePool)clsr   r   r   r   get_pool_class  r   zDefaultDialect.get_pool_classc                 C  
   |  |S r   )r   )r   r   r   r   r   get_dialect_pool_class     
z%DefaultDialect.get_dialect_pool_classc                 C  sB   d | jddd }z	t|d  W d S  ty    Y d S w )N.r   z
.provision)join
__module__split
__import__ImportError)r   packager   r   r   load_provisioning  s   z DefaultDialect.load_provisioningOptional[_ListenerFnType]c                   s    j d ur fdd}|S d S )Nc                   s     |  j d S r   )_assert_and_set_isolation_levelr   )
dbapi_connconn_recr   r   r   builtin_connect  s   z:DefaultDialect._builtin_onconnect.<locals>.builtin_connect)r   )r   r   r   r   r   _builtin_onconnect  s   
z!DefaultDialect._builtin_onconnectc                 C  s   z|  || _W n ty   d | _Y nw z| || _W n ty)   d | _Y nw z
| |jj| _W n ty@   d | _Y nw | j	sN| 
|}|rN|| _| jrb| j| jkrdtd| j| jf d S d S )NzQLabel 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_nameri   get_default_isolation_level
connectiondbapi_connectiondefault_isolation_levelr]   _check_max_identifier_lengthrv   rw   r!   r   )r   r   max_ident_lengthr   r   r   
initialize  sF   







zDefaultDialect.initializec                 C     d S r   r   r   r   r   r   
on_connect*  s   zDefaultDialect.on_connectc                 C     dS )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   r   r   r   r   r   r   .  s   
z+DefaultDialect._check_max_identifier_lengthc                 C  r   )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r   r   r   r   r   r   :  s   
z*DefaultDialect.get_default_isolation_levelc                 C  s   t || 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_typer`   )r   typeobjr   r   r   type_descriptorJ  s   	zDefaultDialect.type_descriptorc                 K  sP   | j ||fd|i|sdS | j||fd|i|D ]}|d |kr% dS qdS )NschemaFr   T)	has_tableget_indexes)r   r   
table_name
index_namer   kwidxr   r   r   	has_indexU  s   
zDefaultDialect.has_indexr   r   schema_namestrr   c                 K  s   || j |fi |v S r   )get_schema_names)r   r   r   r   r   r   r   
has_schema`  s   zDefaultDialect.has_schemac                 C  s&   t || jkrtd|| jf d S )Nz7Identifier '%s' exceeds maximum length of %d characters)lenrv   r!   IdentifierError)r   identr   r   r   validate_identifiere  s   z"DefaultDialect.validate_identifierc                 O  s   | j j|i |S r   )r   connect)r   cargscparamsr   r   r   r   l  s   zDefaultDialect.connectc                 C  s   |  }||j g |fS r   )translate_connect_argsupdatequery)r   r   optsr   r   r   create_connect_argsp  s   z"DefaultDialect.create_connect_argsenginer1   r  Nonec                   sN   t j}|r%tfdd|D  t|d fdd}d S d S )Nc                 3      | ]	}| | fV  qd S r   r   .0r   r  r   r   	<genexpr>}      
z>DefaultDialect.set_engine_execution_options.<locals>.<genexpr>engine_connectc                   s    |   d S r   )_set_connection_characteristics)r   )r   r   r   r   set_connection_characteristics  s   zSDefaultDialect.set_engine_execution_options.<locals>.set_connection_characteristics)setconnection_characteristicsintersectionr#   immutabledictr    listens_for)r   r  r  supported_namesr  r   )r   r  r   r   set_engine_execution_optionsv  s   

z+DefaultDialect.set_engine_execution_optionsc                   s@   t | j }|rt fdd|D }| || d S d S )Nc                 3  r  r   r   r	  r  r   r   r    r  zBDefaultDialect.set_connection_execution_options.<locals>.<genexpr>)r  r  r  r#   r  r  )r   r   r  r  r   r   r  r    set_connection_execution_options  s   
z/DefaultDialect.set_connection_execution_optionsc           	        s    fdd|  D }| r'dd |D }|r'tdddd |D  |jj}|D ]\}}}| ||| q-|jjj	
t j| d S )Nc                   s    g | ]\}}| j | |fqS r   )r  )r
  r   valuer   r   r   
<listcomp>  s    zBDefaultDialect._set_connection_characteristics.<locals>.<listcomp>c                 S  s    g | ]\}}}|j r||fqS r   )transactional)r
  r   obj_r   r   r   r    s    zThis connection has already initialized a SQLAlchemy Transaction() object via begin() or autobegin; %s may not be altered unless rollback() or commit() is called first., c                 s  s    | ]\}}|V  qd S r   r   )r
  r   r  r   r   r   r    s    zADefaultDialect._set_connection_characteristics.<locals>.<genexpr>)itemsin_transactionr!   r   r   r   r   set_connection_characteristic_connection_recordfinalize_callbackappend	functoolspartial_reset_characteristics)	r   r   r   characteristic_values
trans_objsr   r  characteristicr  r   r   r   r    s*   

z.DefaultDialect._set_connection_characteristicsc                 C  s$   |D ]}| j | }|| | qd S r   )r  reset_characteristic)r   r   r   characteristic_namer*  r   r   r   r'    s   z%DefaultDialect._reset_characteristicsc                 C  r   r   r   r   r   r   r   r   do_begin     zDefaultDialect.do_beginc                 C     |   d S r   )rollbackr-  r   r   r   do_rollback     zDefaultDialect.do_rollbackc                 C  r0  r   )commitr-  r   r   r   	do_commit  r3  zDefaultDialect.do_commitc                 C  s   |  | d S r   )do_closer-  r   r   r   do_terminate     zDefaultDialect.do_terminatec                 C  r0  r   )closer-  r   r   r   r6    r3  zDefaultDialect.do_closec                 C  s   t tdj| dS )Nr   dialect)r   r&   selectcompiler   r   r   r   _dialect_specific_select_one  s   z+DefaultDialect._dialect_specific_select_oner   r:   c                 C  s   z|  |W S  | jjyK } z7| ||d }| jr=ztj|| |ddd W n tjy< } z	|j	}W Y d }~nd }~ww |rFW Y d }~dS  d }~ww )NFT)is_disconnectinvalidate_pool_on_disconnectis_pre_ping)
do_pingr   Errorr?  _has_eventsr   $_handle_dbapi_exception_noconnectionr!   StatementErrorconnection_invalidated)r   r   errr?  new_errr   r   r   _do_ping_w_event  s,   
zDefaultDialect._do_ping_w_eventc                 C  s2   d }|  }z|| j W |  dS |  w )NT)r   executer>  r9  )r   r   r   r   r   r   rB    s   
zDefaultDialect.do_pingc                 C  s   dt ddd  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randintr   r   r   r   
create_xid  s   zDefaultDialect.create_xidc                 C     | t| d S r   )rK  r&   SavepointClauser   r   r   r   r   r   do_savepoint     zDefaultDialect.do_savepointc                 C  rP  r   )rK  r&   RollbackToSavepointClauserR  r   r   r   do_rollback_to_savepoint  rT  z'DefaultDialect.do_rollback_to_savepointc                 C  rP  r   )rK  r&   ReleaseSavepointClauserR  r   r   r   do_release_savepoint  rT  z#DefaultDialect.do_release_savepointc                 #  s   t t|}t t|j}d d d}|j}	|j}
|
d usJ t|j}|j	dj
}|jr6|j	di }nd }|rCg }||_|
j}nd}d }||||	||||D ]}|V  |rNz||}W n" ty } z|j|t|j|jd |dd W Y d }~nd }~ww |d usJ |
jrI|jsI|
jdk}|
jr|rJ |t|tdd	 qR|
jsJ |
jsJ |
j|s|rЇfd
dt|
j|j  d  D  n|
jd j!"|j d d d}|r fdd|D nrfdd|D ndd |D t#t#|j$krt%&dt#|j$ dt# dzfdd|j'D }W n t(yB } zt%&d|j)d d|d }~ww || qR|| qRd S )Nr   Frh   schema_translate_mapT)is_sub_execr   r   )keyc                   s"   g | ]\}}|j  |d  qS )r   )r   _cached_result_processor)r
  colcursor_descr   r   r   r  \  s    zDDefaultDialect._deliver_insertmanyvalues_batches.<locals>.<listcomp>r   c                   s0   i | ]}t d d t| d  D |qS )c                 s  s$    | ]\}}|r||n|V  qd S r   r   )r
  valprocr   r   r   r  s  s
    
zNDefaultDialect._deliver_insertmanyvalues_batches.<locals>.<dictcomp>.<genexpr>N)tuplezipr
  row)_composite_sentinel_proc_nscr   r   
<dictcomp>r  s    zDDefaultDialect._deliver_insertmanyvalues_batches.<locals>.<dictcomp>c                   s   i | ]	} |d  |qS r   r   rc  )_scalar_sentinel_procr   r   rg  |      c                 S  s   i | ]}|d  |qS rh  r   rc  r   r   r   rg        zASentinel-keyed result set did not produce correct number of rows z; produced zP.  Please ensure the sentinel column is fully unique and populated in all cases.c                   s   g | ]} | qS r   r   )r
  sentinel_keys)rows_by_sentinelr   r   r    s    zACan't match sentinel values in result set to parameter sets; key aT   was not found. There may be a mismatch between the datatype passed to the DBAPI driver vs. that which it returns in a result row.  Ensure the given Python value matches the expected result type *exactly*, taking care to not rely upon implicit conversions which may occur such as when using strings in place of UUID or integer values, etc. )*r   DefaultExecutionContextr,   compiledcompiled_parameters_insertmanyvaluesrc   effective_returningexecution_optionsr   rh   rY  _insertmanyvalues_rowssort_by_parameter_order!_deliver_insertmanyvalues_batchesfetchall_for_returningBaseException_handle_dbapi_exceptionsql_util_long_statementreplaced_statementreplaced_parametersnum_sentinel_columnsis_downgradedimplicit_sentinelextendsortedoperator
itemgettersentinel_param_keyssentinel_columnsrb  descriptionr   r\  r   batchr!   r   sentinel_valuesKeyErrorargs)r   r   r   	statement
parametersgeneric_setinputsizescontextro  _sentinel_proc_initializedrp  imvis_returning
batch_sizerY  resultru  	imv_batchrowsbecomposite_sentinelordered_rowsker   )re  rf  ri  rm  r   r   rv    s   
	
	




	
	


z0DefaultDialect._deliver_insertmanyvalues_batchesc                 C     | || d S r   )executemanyr   r   r  r  r  r   r   r   do_executemany     zDefaultDialect.do_executemanyc                 C  r  r   rK  r  r   r   r   
do_execute  r  zDefaultDialect.do_executec                 C  s   | | d S r   r  )r   r   r  r  r   r   r   do_execute_no_params  r8  z#DefaultDialect.do_execute_no_paramsc                 C  r   )NFr   )r   er   r   r   r   r   r?    r/  zDefaultDialect.is_disconnectc                 C  sj   z	t | |}W n
 ty   Y d S w dd |D }||kr1td| jdtt|| t|S )Nc                 S  s   g | ]
}| d d qS )r   )replaceupper)r
  levelr   r   r   r    s    z@DefaultDialect._gen_allowed_isolation_levels.<locals>.<listcomp>r   zi get_isolation_level_values() method should return names as UPPERCASE using spaces, not underscores; got )	listget_isolation_level_valuesr   
ValueErrorr   r  r  
differencera  )r   r   
raw_levelsnormalized_levelsr   r   r   _gen_allowed_isolation_levels  s   
z,DefaultDialect._gen_allowed_isolation_levelsc              
   C  sZ   | dd }| |}|r%||vr%td|d| jdd| | || d S )Nr  r  zInvalid value z1 for isolation_level. Valid isolation levels for z are r  )r  r  r  r!   r   r   r   set_isolation_level)r   r   r  _allowed_isolation_levelsr   r   r   r     s   z.DefaultDialect._assert_and_set_isolation_levelc                 C  sV   | j d ur| j dks| j | jksJ | || j  d S | jd us"J | || j d S )N
AUTOCOMMIT)r   r   r   r   r   r   r   reset_isolation_level  s   

z$DefaultDialect.reset_isolation_levelc                 C  sX   |d u rd S |  }| }||kr|S ||kr | j|s |S ||kr*t|ddS |S )NT)quote)lowerr  r   _requires_quotesr-   r   r   
name_lower
name_upperr   r   r   normalize_name  s   zDefaultDialect.normalize_namec                 C  sD   |d u rd S |  }| }||kr|S ||kr | j|s |}|S r   )r  r  r   r  r  r   r   r   denormalize_name  s   zDefaultDialect.denormalize_namec                 C  s   |S r   r   r   r   r   r   get_driver_connection  r/  z$DefaultDialect.get_driver_connectionc                 C  s   t t| |jt t|juS r   )r   r   __code__rL   )r   methodr   r   r   _overrides_default  s   
z!DefaultDialect._overrides_defaultc                 k  s   g }g }	t j|v r|| j |	| j t j|v r'|| j |	| j t j|v r2|| j	 |
di }
|rG|tju rG|t ju rG|}n9g }d|i|}g }tj|v r[|| tj|v re||	 |D ]}z|||fi | W qg ty   Y qgw |rt|}|D ]A}|r||v r||f}z||||fd|i|fV  W q tjy } z||
vr||
|< W Y d }~qd }~w tjy   Y qw qd S )Nunreflectabler   )r   TABLEr$  get_table_namesget_temp_table_namesVIEWget_view_namesget_temp_view_namesMATERIALIZED_VIEWget_materialized_view_namespopr   ANYrb   r  	TEMPORARYr   r  r!   UnreflectableTableErrorNoSuchTableError)r   single_tbl_methodr   kindr   filter_namesscoper   	names_fnstemp_names_fnsr  namesname_kwfnsfntabler[  rH  r   r   r   _default_multi_reflect   sl   





	




z%DefaultDialect._default_multi_reflectc                 K     | j | j|fi |S r   )r  get_table_optionsr   r   r   r   r   r   get_multi_table_optionsi  
   z&DefaultDialect.get_multi_table_optionsc                 K  r  r   )r  get_columnsr  r   r   r   get_multi_columnsn     z DefaultDialect.get_multi_columnsc                 K  r  r   )r  get_pk_constraintr  r   r   r   get_multi_pk_constraintq  r  z&DefaultDialect.get_multi_pk_constraintc                 K  r  r   )r  get_foreign_keysr  r   r   r   get_multi_foreign_keysv  r  z%DefaultDialect.get_multi_foreign_keysc                 K  r  r   )r  r   r  r   r   r   get_multi_indexes{  r  z DefaultDialect.get_multi_indexesc                 K  r  r   )r  get_unique_constraintsr  r   r   r   get_multi_unique_constraints~  r  z+DefaultDialect.get_multi_unique_constraintsc                 K  r  r   )r  get_check_constraintsr  r   r   r   get_multi_check_constraints  r  z*DefaultDialect.get_multi_check_constraintsc                 K  r  r   )r  get_table_commentr  r   r   r   get_multi_table_comment  r  z&DefaultDialect.get_multi_table_comment)rm   rn   rO   ro   rp   rq   rr   rs   rt   ru   rv   r\   rw   r\   rh   rx   rd   ru   ry   rC   rl   rc   rz   r   )r   r0   )r   r=   r   r   )r   r   r   )r   r   r   r   r   r   r   rc   )r  r1   r  rY   r   r  )r   r   r  rY   r   r  )r   r:   r   rc   )__name__r   __qualname____doc__r$   r,   statement_compilerr*   ddl_compilerr   r   IdentifierPreparerr   supports_altersupports_commentssupports_constraint_commentsinline_commentsr   div_is_floordivr   r   NONEr   rM   __annotations__rN   default_sequence_basera  execute_sequence_formatsupports_schemassupports_viewssupports_sequencessequences_optional"preexecute_autoincrement_sequencessupports_identity_columnspostfetch_lastrowidfavor_returning_over_lastrowid#insert_null_pk_still_autoincrementsr   r   update_returning_multifromdelete_returning_multifromr   cte_follows_insertsupports_native_enumrt   supports_native_uuidreturns_native_bytes#non_native_boolean_check_constraintsupports_simple_order_by_labeltuple_in_valuesr#   r  r   IsolationLevelCharacteristicLoggingTokenCharacteristicr  asintbool_or_strasboolrZ   supports_native_decimalr   rv   r]   rO   r^   r_   r   supports_sane_multi_rowcountr`   r   supports_default_valuessupports_default_metavaluedefault_metavalue_tokensupports_empty_insertsupports_multivalues_insertrd   re   r+   NOT_SUPPORTEDrf   rh   insertmanyvalues_max_parameterssupports_is_distinct_fromr   rl   supports_for_update_ofr   ri   requires_name_normalizeis_asynchas_terminate$_legacy_binary_type_literal_encodingdeprecated_paramsr)   r   rg   
NO_LINTINGr   property
deprecatedr   memoized_propertyr   r   update_executemany_returningdelete_executemany_returningr   r   r   r   r   r   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r'  r.  r2  r5  r7  r6  r>  rJ  rB  rO  rS  rV  rX  rv  r  r  r  r?  memoized_instancemethodr  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   rL   s   sv  
 
	R










$







	 
-


IrL   c                   @  sP   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dZdZdS )StrCompileDialectTFN)r  r   r  r$   StrSQLCompilerr  r*   r  StrSQLTypeCompilerr   r  r   r   r   r   r   r   r  r  r  rt   r  r  r   r   r   r   r*    s     r*  c                   @  s  e Zd ZU dZdZdZdZdZdZe	j
Zded< dZded< dZded< dZd	ed
< ejZded< ejZdZded< dZdZdZdZdZdZded< dZded< e Zded< 	 e Z!ded< ded< ded< ded< ded< ded < d!ed"< d#ed$< e"d%ejZ#dZ$d&ed'< d(Z%d)ed*< e&dd1d2Z'e&e(j)fdd8d9Z*e&dd;d<Z+e&dd=d>Z,dd?d@Z-e.dAdB Z/ej0dCdD Z1ej0dEdF Z2ej0ddHdIZ3ej0ddJdKZ4ej0dLdM Z5ddNdOZ6ej0dPdQ Z7dRdS Z8dTdU Z9dVdW Z:dXdY Z;dZd[ Z<d\d] Z=d^d_ Z>d`da Z?dbdc Z@ddde ZAdfdg ZBejCddhdiZDe.djdk ZEdldm ZFdndo ZGdpdq ZHdrds ZIdtdu ZJej0dvdw ZKdxdy ZLdzd{ ZMd|d} ZNd~d ZOdddZPdd ZQdd ZRdZSded< 	 dddZTdd ZUdd ZVdd ZWdS )rn  Fr   execute_styleNzOptional[Compiled]ro  zAOptional[Tuple[List[ResultColumnsEntry], bool, bool, bool, bool]]result_column_structzOptional[Sequence[Row[Any]]]returned_default_rowsr7   rs  zOptional[Executable]invoked_statementr\   	_rowcountzOptional[Callable[[str], str]]_translate_colnamezMapping[str, List[str]]_expanded_parametersr   root_connectionr@   _dbapi_connectionr   r;  r   unicode_statementr   r   z%List[_MutableCoreSingleExecuteParams]rp  r6   r  &Optional[Sequence[BindParameter[Any]]]extracted_parametersrY   zOptional[List[Tuple[Any, ...]]]rt  r   rg   _num_sentinel_colsr   r   compiled_ddlr*   r   r   c           
      C  s   |  | }||_||_|j|_| |_}d|_||_t||_|j	r4|j
di }|jj}	|	|j||_|j|_| |_g |_|jrK| g|_|S |jg|_|S )zKInitialize execution context for an ExecutableDDLElement
        construct.TrY  )__new__r4  r5  r;  ro  isddlrs  r   r6  rY  r   r   _render_schema_translatesr  create_cursorr   rp  r   r  r  _empty_dict_params)
r   r;  r   r   rs  r:  r   ro  rY  rstr   r   r   	_init_ddl  s0   




z!DefaultExecutionContext._init_ddlr,   r3   rA   	cache_hitr   c
                   s  |  | }
||
_||
_|j|
_|
_||
_ |
_|	|
_||
_ j	 j
 j j jf|
_ j |
_} j |
_} j |
_} j|
_|sG|sG|rш jj}trTt|tsTJ d|
_t|j |
_}t j |
_}|ro|jrod|
_ |ru|ruJ |sy|rш j!r|r|
jj"st#$d|
jj% d|r|j&r|
jj'st#$d|
jj% d|r|
jj(r j)st#$d|r|
jj*st#$d|
jj% d|r|
jj+st#$d|
jj% d|s݈ j,dd	g|
_-n2 fd
dt.|D |
_-t/|dkr|
jr j)rt0j1|
_2 j)}|j3dur
|j4|
_5nt0j6|
_2 j7|
_8|
9 |
_:|
jj;s"|
jj<r&|
=   j>}| j?s3 j@rZ|
jAr<t#$d B|
j-d }|j|
_8|jC|
_DtE|F|jG |jH}n jIrc|
jjH}nd} jJr{|
jKdi } jLjM}||
j8||
_8|
j8|
_ jIrg }|dusJ |
j-D ]fdd|D }|N|O| q||
_P|
S g } jQ|
j-D ]!rÇfddD }n
fddD }|N| q||
_P|
S )z6Initialize execution context for a Compiled construct.Tr   z] with current server capabilities does not support INSERT..RETURNING when executemany is usedz} with current server capabilities does not support INSERT..RETURNING with deterministic row ordering when executemany is usedznStatement does not have "insertmanyvalues" enabled, can't use INSERT..RETURNING with executemany in this case.z] with current server capabilities does not support UPDATE..RETURNING when executemany is usedz] with current server capabilities does not support DELETE..RETURNING when executemany is usedF)r8  escape_namesc                   s"   g | ]\}} j |d |dqS )F)rC  _group_numberr8  )construct_params)r
  grpm)ro  r8  r   r   r  u  s    z:DefaultExecutionContext._init_compiled.<locals>.<listcomp>r   NzL'literal_execute' or 'expanding' parameters can't be used with executemany()r   rY  c                   ,   g | ]}|v r|  | n | qS r   r   r
  r[  compiled_paramsflattened_processorsr   r   r        c                   s6   i | ]} |||v r|  | n | qS r   )r   rI  )rK  escaped_namesrL  r   r   rg    s    
z:DefaultExecutionContext._init_compiled.<locals>.<dictcomp>c                   .   i | ]}||v r|  | n | qS r   r   rI  rJ  r   r   rg        )Rr;  r4  r5  r;  r8  r0  ro  rB  rs  _result_columns_ordered_columns_textual_ordered_columns_ad_hoc_textual_loose_column_name_matchingr.  isinsertisupdateisdeleteisplaintextis_textcompile_stater  r   r   rF   is_crudrc   
_returning_is_explicit_returningrr   _is_implicit_returning_supplemental_returning_is_supplemental_returningfor_executemanyr   r!   r   r   _sort_by_parameter_orderr   rd   rq  r&  r'  rE  rp  	enumerater   r   INSERTMANYVALUESr-  r  r~  r9  EXECUTEMANYstringr6  r>  r   insert_prefetchupdate_prefetch_process_execute_defaults_bind_processorsliteral_execute_paramspost_compile_paramsr  #_process_parameters_for_postcompileparameter_expansionr3  dictr  
processorspositiontupr   rY  r   r   r=  r$  r  r  escaped_bind_names)r   r;  r   r   rs  ro  r  r0  r8  rB  r   iiiuid_dml_statementieriirr  rq  expanded_staterr  rY  r@  core_positional_parametersl_paramcore_dict_parametersd_paramr   )ro  rK  rN  r8  rL  r   _init_compiled  s  






#
		z&DefaultExecutionContext._init_compiledr  c                   s   |  | }||_||_|j|_d|_||_|s(|jjr"  g|_n'|j	g|_n!t
|d  jr4||_nt
|d tr?||_n
 fdd|D |_t|dkrStj|_| |_|_| |_|S )z8Initialize execution context for a string SQL statement.Tr   c                   s   g | ]}  |qS r   )r  )r
  pr:  r   r   r    s    
z;DefaultExecutionContext._init_statement.<locals>.<listcomp>r   )r;  r4  r5  r;  rZ  rs  r   r  r  r?  r   rp  r   r   rf  r-  r  r6  r>  r   )r   r;  r   r   rs  r  r  r   r   r:  r   _init_statement  s,   


z'DefaultExecutionContext._init_statementc                 C  s2   |  | }||_||_|j|_||_| |_|S )z;Initialize execution context for a ColumnDefault construct.)r;  r4  r5  r;  rs  r>  r   )r   r;  r   r   rs  r   r   r   r   _init_default  s   


z%DefaultExecutionContext._init_defaultc                 C  s   | j d u rdS t }| j}| j j}|d usJ |tu r"d|| f S |tu r-d|| f S |tu r8d|| f S |tu rSd| jv rLd| jd || f S d|| f S |t	u rdd| j
j| j
j|| f S d	S )
Nzraw sqlzno key %.5fszcached since %.4gs agozgenerated in %.5fs_cache_disable_reasonzcaching disabled (%s) %.5fs zcaching disabled %.5fsz,dialect %s+%s does not support caching %.5fsunknown)ro  r   rB  	_gen_timeNO_CACHE_KEY	CACHE_HIT
CACHE_MISSCACHING_DISABLEDrs  NO_DIALECT_SUPPORTr;  r   r   )r   nowchgen_timer   r   r   _get_cache_stats2  s4   

z(DefaultExecutionContext._get_cache_statsc                 C  s   | j tjtjfv S r   )r-  r   rf  re  r   r   r   r   r  T  s   z#DefaultExecutionContext.executemanyc                 C  s4   | j r| j jS d| jv r| jj| jd S | jjS )NrY  )ro  r   rs  r;  r   _with_schema_translater   r   r   r   r   [  s   
z+DefaultExecutionContext.identifier_preparerc                 C     | j jS r   )r4  r  r   r   r   r   r  f  r   zDefaultExecutionContext.engineOptional[Sequence[Column[Any]]]c                 C  s   t r
t| jts
J | jjS r   )r   r   ro  r,   	postfetchr   r   r   r   postfetch_colsj  s   z&DefaultExecutionContext.postfetch_colsc                 C  s4   t r
t| jts
J | jr| jjS | jr| jjS dS )Nr   )r   r   ro  r,   rV  rh  rW  ri  r   r   r   r   prefetch_colsp  s   z%DefaultExecutionContext.prefetch_colsc                 C  s   | j ddS )Nno_parametersF)rs  r   r   r   r   r   r  {  r   z%DefaultExecutionContext.no_parametersc           
      C  s   | j }d| jv r| jdi }| jj}|||}|s&| jjr$| j }ni }|j| j	||| d | j	
 }|dur>|d }nd}|durW|| j| j	jd d }	|	rW|	|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.

        rY  )r  Nr   r   )r4  rs  r   r   r=  r;  r   r  _cursor_executer   fetchoner\  r  )
r   stmttype_r  connrY  r@  rd  rr`  r   r   r   _execute_scalar  s.   




z'DefaultExecutionContext._execute_scalarc                 C  r   r   )r4  r   r   r   r   r     s   z"DefaultExecutionContext.connectionc                 C  sx   | j jsdS | j jr3| jddo0| jrt| jjtj	p0| j p't| jjtj
o0| jo0t| j}|S | jdd}|S )NFstream_resultsT)r;  r   rl   rs  r   ro  r   r  r&   
Selectable
TextClauser6  SERVER_SIDE_CURSOR_REmatch)r   use_server_sider   r   r   _use_server_side_cursor  s.   

z/DefaultExecutionContext._use_server_side_cursorc                 C  sB   | j jr| jdds| j jr|  rd| _|  S d| _|  S )Nr  FT)	r;  r   rs  r   rl   r  _is_server_sidecreate_server_side_cursorcreate_default_cursorr   r   r   r   r>    s   z%DefaultExecutionContext.create_cursorc                 C  s   |  S r   )fetchall)r   r   r   r   r   rw       z.DefaultExecutionContext.fetchall_for_returningc                 C  s
   | j  S r   )r5  r   r   r   r   r   r    r   z-DefaultExecutionContext.create_default_cursorc                 C  s   t  r   r   r   r   r   r   r    s   z1DefaultExecutionContext.create_server_side_cursorc                 C  r   r   r   r   r   r   r   pre_exec  r/  z DefaultExecutionContext.pre_execc                 C  s   t d)Nz,This dialect does not support OUT parametersr  )r   r  r   r   r   get_out_parameter_values  s   z0DefaultExecutionContext.get_out_parameter_valuesc                 C  r   r   r   r   r   r   r   	post_exec  r/  z!DefaultExecutionContext.post_execc                 C  s   | | 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;  )r   r  colnamecoltyper   r   r   get_result_processor  s   z,DefaultExecutionContext.get_result_processorc                 C  r  )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   	lastrowidr   r   r   r   get_lastrowid  s   z%DefaultExecutionContext.get_lastrowidc                 C  r   r   r   )r   r  r   r   r   handle_dbapi_exception  r/  z.DefaultExecutionContext.handle_dbapi_exceptionc                 C  s   | j d ur| j S | jjS r   )r1  r   rowcountr   r   r   r   r    s   
z DefaultExecutionContext.rowcountc                 C  s
   | j d uS r   )r1  r   r   r   r   _has_rowcount  s   
z%DefaultExecutionContext._has_rowcountc                 C  r  r   )r;  r   r   r   r   r   r     r  z.DefaultExecutionContext.supports_sane_rowcountc                 C  r  r   )r;  r  r   r   r   r   r    r  z4DefaultExecutionContext.supports_sane_multi_rowcountc                 C  s   | j }| jd u r|ddr| jj| _| js| jr"|  }d }}n6|dd }| jp0|dd}| j	}|rC|t
ju rCt
| j| j }|jpI| jj}|d u rQt
j}t
| ||}| j}|rk| jsktt|jrk| | |j| _|rv||}|S )Npreserve_rowcountF	yield_perr  )rs  r1  r   r   r  r\  rZ  _setup_dml_or_text_resultr  cursor_fetch_strategy_cursor_DEFAULT_FETCHBufferedRowCursorFetchStrategyalternate_cursor_descriptionr  _NO_CURSOR_DQLCursorResultro  r<  r   r,   has_out_parameters_setup_out_parameters_soft_closedr  )r   exec_optr  ypsrstrategycursor_descriptionro  r   r   r   _setup_result_proxy   s>   




z+DefaultExecutionContext._setup_result_proxyc                 C  s   t t| j}dd |j D }i }tdd |D | dd |D D ](\}}|j}|| j	}|
| j	j}	|| j	|	}
|
d urG|
|}|||j< q$||_d S )Nc                 S  s   g | ]\}}|j r||fqS r   )
isoutparamr
  paramr   r   r   r   r  M  s    zADefaultExecutionContext._setup_out_parameters.<locals>.<listcomp>c                 S  s   g | ]\}}|qS r   r   r  r   r   r   r  U      c                 S  s   g | ]\}}|qS r   r   r  r   r   r   r  W  r  )r   r,   ro  
bind_namesr  rb  r  r   dialect_implr;  get_dbapi_typer   result_processorr[  out_parameters)r   r  ro  out_bindparamsr  	bindparam	raw_valuer  	impl_type
dbapi_typer  r   r   r   r  J  s*   
z-DefaultExecutionContext._setup_out_parametersc                 C  s  t t| j}| j}| jr(| jtju r |jr t	j
| j| j|jd}|jr(|  | _| jr8|t	ju r8t	| j| j}|t	ju r@d }n|jpF| jj}|d u rOt	j}n| jrb| jtju sZJ |d| j  }t	| ||}| jr| jr| }|| _| ||| _|jjsJ | jr| | |S |!  |S | j"s|!  |S | jr| }|r|| _t#|| _$| jr| | n|!  |jjsJ |S |jjs| j$d u r| jj%| _$|!  |S | j&s| j'r| j$d u r| jj%| _$|S )N)initial_bufferalternate_descriptionr   )(r   r,   ro  r  rV  r-  r   re  rr  r   FullyBufferedCursorFetchStrategyr   rt  r  r  _setup_ins_pk_from_lastrowidinserted_primary_key_rowsr  r  r  rs  _NO_CURSOR_DMLr  r9  r  r_  allr/  %_setup_ins_pk_from_implicit_returning	_metadatareturns_rowsra  _rewind_soft_closer^  r   r1  r  rW  rX  )r   ro  r  r  r  r  r   r   r   r  f  s   




%#!




z1DefaultExecutionContext._setup_dml_or_text_resultc                 C  s   |   S r   )_setup_ins_pk_from_emptyr   r   r   r   r    s   z1DefaultExecutionContext.inserted_primary_key_rowsc                 C  s(   t t| jj}|  }||| jd gS )Nr   )r   r,   ro  +_inserted_primary_key_from_lastrowid_getterr  rp  )r   getterr  r   r   r   r    s   z4DefaultExecutionContext._setup_ins_pk_from_lastrowidc                   s"   t t| jj  fdd| jD S )Nc                   s   g | ]} d |qS r   r   )r
  r  r  r   r   r    rk  zDDefaultExecutionContext._setup_ins_pk_from_empty.<locals>.<listcomp>)r   r,   ro  r  rp  r   r   r  r   r    s   z0DefaultExecutionContext._setup_ins_pk_from_emptyc                   s4   |sg S t t| jj | j} fddt||D S )Nc                   s   g | ]	\}} ||qS r   r   )r
  rd  r  r  r   r   r    rj  zQDefaultExecutionContext._setup_ins_pk_from_implicit_returning.<locals>.<listcomp>)r   r,   ro  +_inserted_primary_key_from_returning_getterrp  rb  )r   r  r  rK  r   r  r   r    s   
z=DefaultExecutionContext._setup_ins_pk_from_implicit_returningc                 C  s   | j s| jottt| jjS r   )rV  rW  rc   r   r,   ro  r  r   r   r   r   lastrow_has_defaults  s   z,DefaultExecutionContext.lastrow_has_defaults0Optional[List[Tuple[str, Any, TypeEngine[Any]]]]c                   s~  | j s| jrdS tt| j }|du rdS | j}|jr/t|}|j	
|| j| j| j|  jr6jnd|jrHfddjpDdD }n
dd j D }g }|D ]f\}  jv r`qV|| jv rt jrt jj|  | fddt| j| D  qV| d| fdd| j| D  qV| ddur||n|}|| jf qV|S )	a  Given a cursor and ClauseParameters, prepare arguments
        in order to 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 set the
        :attr:`.Dialect.bind_typing` attribute to
        :attr:`.BindTyping.SETINPUTSIZES`.  Python-oracledb and cx_Oracle are
        the only DBAPIs that requires setinputsizes(); pyodbc offers it as an
        option.

        Prior to SQLAlchemy 2.0, the setinputsizes() approach was also used
        for pg8000 and asyncpg, which has been changed to inline rendering
        of casts.

        Nc                   s   g | ]	}| j | fqS r   )bindsrI  )ro  r   r   r  +  s    zDDefaultExecutionContext._prepare_set_input_sizes.<locals>.<listcomp>r   c                 S  s   g | ]\}}||fqS r   r   )r
  r  r[  r   r   r   r  0  s    c                 3  sF    | ]\}}d ur ||n||   jj|  fV  qd S r   )r   r   types)r
  r   	paramname)r  dbtypesrs  numr   r   r  >  s    


zCDefaultExecutionContext._prepare_set_input_sizes.<locals>.<genexpr>c                 3  s0    | ]}d ur ||n| jfV  qd S r   )r   r   )r
  r  )r  dbtypers  r   r   r  N  s    

)r<  rZ  r   r,   ro  _get_set_input_sizes_lookupr;  rD  rp  dispatchdo_setinputsizesr   r  r  rs  r   rr  r  r  rl  r3  r(   r   r   r  r  rd  r   r$  )r   
inputsizesr;  r  generic_inputsizesr[  escaped_namer   )r  ro  r  r  rs  r  r   _prepare_set_input_sizes  s`   








z0DefaultExecutionContext._prepare_set_input_sizesc                 C  sB   |j r	| ||S |jr|| _|| S |jr| |||S |jS r   )is_sequencefire_sequenceis_callablecurrent_columnr   is_clause_element_exec_default_clause_element)r   columnr[   r  r   r   r   _exec_defaulti  s   
z%DefaultExecutionContext._exec_defaultc                   s   |j st|j|}n|j}t|j| jd}|  |j|j	r4| j
 fdd|jp/dD }n
 fdd D }| jt|||dS )Nr:  c                   rH  r   r   rI  rK  rq  r   r   r    rM  zHDefaultExecutionContext._exec_default_clause_element.<locals>.<listcomp>r   c                   rO  r   r   rI  r  r   r   rg    rP  zHDefaultExecutionContext._exec_default_clause_element.<locals>.<dictcomp>)r  )_arg_is_typedr&   type_coercer   r<  r=  r;  rE  rk  r   r  rr  r  r   )r   r  r[   r  default_argro  r  r   r  r   r  x  s$   
z4DefaultExecutionContext._exec_default_clause_elementz"Optional[_CoreSingleExecuteParams]current_parametersTc                   s   z| j | j}W n ty   tdw |dusJ dus!J tdtt| jj}|dus1J |rrt	
|rr|jrr|jrM|jd  |jj|j i}n
|j|j i}d |jdus^J |j }| fdd|D  |S S )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 functionNrE   r   r   c                 3  s$    | ]}|d | f  fV  qdS )z%s_m%dNr   rI  indexr  r   r   r    s    
zADefaultExecutionContext.get_current_parameters.<locals>.<genexpr>)r  r  AttributeErrorr!   r   r   r,   ro  r[  r%   rV  _has_multi_parameters_is_multiparam_columnr  originalr[  _dict_parameterskeysr  )r   isolate_multiinsert_groupsr  r[  dr
  r   r  r   get_current_parameters  s@   !


z.DefaultExecutionContext.get_current_parametersc                 C      |j d u rd S | ||j |jS r   )r[   r  r   r   r  r   r   r   get_insert_default     
z*DefaultExecutionContext.get_insert_defaultc                 C  r  r   )onupdater  r   r  r   r   r   get_update_default	  r  z*DefaultExecutionContext.get_update_defaultc                   s   t tj}|j d}|jr fdd|jD }n|jr) fdd|jD }ng }jD ]<}|_|D ]4\}}\}}}	}
}|
rJ|||< |d7 }q5|rQ|||< q5|	r]|_|||< q5||}|d uri|||< q5q.`d S )Nr   c                       g | ]}| ||j jfqS r   )_default_description_tupler  r
  c
key_getterr   r   r   r  	      zEDefaultExecutionContext._process_execute_defaults.<locals>.<listcomp>c                   r  r   )_onupdate_description_tupler  r  r  r   r   r  	  r  r   )	r   r,   ro  _within_exec_param_key_getterrh  ri  rp  r  r  )r   ro  sentinel_counterprefetch_recsr  r  	param_keyr   	is_scalarr  is_sentinelfallbackr_  r   r  r   rj  	  sD   	




z1DefaultExecutionContext._process_execute_defaults)r;  r   r   r   r   r@   rs  r7   r:  r*   r   r   )r;  r   r   r   r   r@   rs  r7   ro  r,   r  r3   r0  rA   r8  r7  rB  r   r   r   )r;  r   r   r   r   r@   rs  r7   r  r   r  r6   r   r   )
r;  r   r   r   r   r@   rs  r7   r   r   )r   r   )r   r  r   )r   rg   )r   r  )T)Xr  r   r  rV  rW  rX  r\  rZ  r<  r   EXECUTEr-  r  ro  r.  r/  r#   
EMPTY_DICTrs  r  r  r  r0  r_  r^  ra  r  r  r1  r2  r  r3  r  rB  r   r?  rt  r9  r(  rA  r   r  r  r  r  r  r#  r  r%  r   r  r  r  r  r  r   r  r>  rw  r  r  r  r  r  r  r  r  non_memoized_propertyr  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rj  r   r   r   r   rn    s   
 
, f)
"






)


*r

k'
Drn  )pr  
__future__r   r%  r  rM  retimer   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r    r   r   r  r   baser   r   r   r   r   r   
reflectionr   r   r    r!   r"   r#   sqlr$   r%   r&   r'   rz  sql._typingr(   sql.baser)   sql.compilerr*   r+   r,   sql.elementsr-   util.typingr.   r/   r  r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   rd  r<   r   r=   r>   r?   r@   rA   rB   rC   rD   sql.dmlrE   rF   rG   
sql.schemarH   sql.type_apirI   rJ   rK   r=  IUNICODEr  r  r  r  r  r  r  rL   r*  rn  execution_ctx_clsr   r   r   r   <module>   s   	        #         
"