o znh@s&dZddlZddlZddlZddlZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Zdd lmZddlmZddlmZddlmZddlmZedejejBZedejejBZGdddejZGdddeZGdddejZee_ dS)aDefault 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) interfaces) reflection)result)event)exc)pool) processors)types)util)compiler) expression)schema) quoted_namez-\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER)z \s*SELECTc @seZdZdZejZejZej Z ej Z dZ dZdZdZeZdZdZdZdZdZdZdZdZdZdZdZdZdZe !de "dfde j#fde "d fd e "d fd e j#fd e j#fd e j#fde j$fgZ%dZ&e j'rodZ(dZ)dZ*dZ+ndZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1iZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9 dZ:dZ;e !Z< e j=dd           daddZ>e j?ddZ@eAddZBeAdd ZCeDd!d"ZEd#d$ZFd%d&ZGd'd(ZHdbd)d*ZId+d,ZJd-d.ZKd/d0ZLdbd1d2ZMd3d4ZNd5d6ZOd7d8ZPd9d:ZQd;d<ZRd=d>ZSd?d@ZTdAdBZUdCdDZVdEdFZWe j?dGdHZXdIdJZYdKdLZZdMdNZ[dOdPZ\dQdRZ]dbdSdTZ^dbdUdVZ_dbdWdXZ`dYdZZad[d\Zbd]d^Zcd_d`ZddS)cDefaultDialectz!Default implementation of DialectTFrconvert_unicodeforce pool_timeoutechodebug echo_pool pool_recycle pool_size max_overflowpool_threadlocalN use_encodingdefaulti'named)z1.3zThe :paramref:`.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.)rutf-8staticc Ks`t|ddstd|j||_||_d|_d|_||_|dur%||_ n|jdur0|jj |_ n|j |_ |dur;||_ |j dv|_| ||_ |||_|durT||_|dur[||_||_| |_| dkrid|_n| dvrvd|_| dk|_ntd | |_|jr|j|_| |_|jd krt||_n |jdurt|j|_t|j|_ t|j|_!dS) Nported_sqla_06Tz2The %s dialect is not yet ported to the 0.6 formatF)qmarkformatnumericr!)dynamic dynamic_warnr'z?empty_in_strategy may be 'static', 'dynamic', or 'dynamic_warn'r)"getattrr warnnamerencoding positional_ischemadbapi paramstyledefault_paramstyleimplicit_returningprepareridentifier_preparer type_compilersupports_right_nested_joinssupports_native_booleancase_sensitiveempty_in_strategy_use_static_in_warn_on_empty_inr ArgumentError#_user_defined_max_identifier_lengthmax_identifier_length label_lengthdescription_encodingr to_unicode_processor_factory_description_decodercodecs getencoder_encoder_decoder) selfrr+r/r.r1r5r7r6r8r=r>kwargsrrD/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/default.py__init__sh         zDefaultDialect.__init__cCstSN)weakrefWeakKeyDictionaryrFrrrH _type_memoszDefaultDialect._type_memoscCs|jd|jS)N+)r*driverrMrrrHdialect_descriptionsz"DefaultDialect.dialect_descriptioncCs|jS)zTrue if this dialect supports sane rowcount even if RETURNING is in use. For dialects that don't support RETURNING, this is synomous with supports_sane_rowcount. )supports_sane_rowcountrMrrrH supports_sane_rowcount_returnings z/DefaultDialect.supports_sane_rowcount_returningcCst|dtjS)N poolclass)r(r QueuePool)clsurlrrrHget_pool_class%zDefaultDialect.get_pool_classcCsz|||_Wn tyd|_Ynwz|||_Wn ty)d|_Ynwz ||j|_Wn ty?d|_Ynw|||_ |j durV| |rVd|_ |_ |j sc||}|rc||_|jrw|j|jkrytd|j|jfdSdS)NzQLabel length of %d is greater than this dialect's maximum identifier length of %d)_get_server_version_infoserver_version_infoNotImplementedError_get_default_schema_namedefault_schema_nameget_isolation_level connectiondefault_isolation_level_check_unicode_returnsreturns_unicode_stringsr?_check_unicode_descriptionrAr<_check_max_identifier_lengthr=r>rr;)rFramax_ident_lengthrrrH initialize)sP            zDefaultDialect.initializecCdS)areturn a callable which sets up a newly created DBAPI connection. This is used to set dialect-wide per-connection options such as isolation modes, unicode modes, etc. If a callable is returned, it will be assembled into a pool listener that receives the direct DBAPI connection, with all wrappers removed. If None is returned, no listener will be generated. NrrMrrrH on_connectUs zDefaultDialect.on_connectcCri)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)rFrarrrHrfcs z+DefaultDialect._check_max_identifier_lengthcstjr js tjntjjrnifddtt dt dtt dt dg}|r>||7}fdd|D}| dd grPd S|dhkS) Nc st|gjd}zj}|||}|Wntj y=}zt d|WYd}~dSd}~wwt |dt j S)Ndialectz2Exception attempting to detect unicode returns: %rFr)rselectcompileracursor_cursor_executefetchonecloser DBAPIErrorr r) isinstance text_type)test statementrorowde)cast_tora parametersrFrrH check_unicodezs$   z.check_unicodez'test plain returns'<z'test unicode returns'csh|]}|qSrr).0rv)r|rrH sz8DefaultDialect._check_unicode_returns..TF conditional)r py2ksupports_unicode_statements binary_typerur,execute_sequence_formatrcastliteral_columnsqltypesVARCHARUnicode issuperset)rFraadditional_teststestsresultsr)rzr|rar{rFrHrcos,   z%DefaultDialect._check_unicode_returnscCsztjr |js tj}ntj}|j}z%||t t d dgj |dt |jddtjW|S|w)Nz'x' some_labelrkr)r rrrruraroexecuterrmrlabelrnrt descriptionrr)rFrarzrorrrHres  z)DefaultDialect._check_unicode_descriptioncCst||jS)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_typecolspecs)rFtypeobjrrrHtype_descriptors zDefaultDialect.type_descriptorcKs$tj|}|j||||fi|SrJ)r Inspector from_engine reflecttable)rFratableinclude_columnsexclude_columns resolve_fksoptsinsprrrHrs zDefaultDialect.reflecttablecKsd|j||fd|i|iS)zCompatibility method, adapts the result of get_primary_keys() for those dialects which don't implement get_pk_constraint(). constrained_columnsr)get_primary_keys)rFconn table_namerkwrrrHget_pk_constraintsz DefaultDialect.get_pk_constraintcCs&t||jkrtd||jfdS)Nz7Identifier '%s' exceeds maximum length of %d characters)lenr=rIdentifierError)rFidentrrrHvalidate_identifiersz"DefaultDialect.validate_identifiercOs|jj|i|SrJ)r.connect)rFcargscparamsrrrHrszDefaultDialect.connectcCs|}||jg|gSrJ)translate_connect_argsupdatequery)rFrXrrrrHcreate_connect_argss z"DefaultDialect.create_connect_argscsfd|vr|dt|dfdd}d|vr1t|d|_t|dfdd}dSdS)Nisolation_levelengine_connectcs|s |dSdSrJ)_set_connection_isolationrabranch)rrFrrH set_isolationszBDefaultDialect.set_engine_execution_options..set_isolationschema_translate_mapcs |_dSrJ)schema_for_objectr)getterrrHset_schema_translate_map zMDefaultDialect.set_engine_execution_options..set_schema_translate_map)r listens_forr_schema_getterr)rFenginerrrr)rrrFrHset_engine_execution_optionss  z+DefaultDialect.set_engine_execution_optionscCs<d|vr |||dd|vrt|d}||_dSdS)Nrr)rrrr)rFrarrrrrH set_connection_execution_optionss  z/DefaultDialect.set_connection_execution_optionscCs6|r td||j||jjj|jdS)NzConnection is already established with a Transaction; setting isolation_level may implicitly rollback or commit the existing transaction, or have no effect until next transaction) in_transactionr r)set_isolation_levelra_connection_recordfinalize_callbackappendreset_isolation_level)rFralevelrrrHr s z(DefaultDialect._set_connection_isolationcCdSrJrrFdbapi_connectionrrrHdo_beginzDefaultDialect.do_begincC |dSrJ)rollbackrrrrH do_rollback zDefaultDialect.do_rollbackcCrrJ)commitrrrrH do_commitrzDefaultDialect.do_commitcCrrJ)rrrrrrHdo_closerzDefaultDialect.do_closecCsttdgj|dS)Nrrk)strrrmrnrMrrrH_dialect_specific_select_one"sz+DefaultDialect._dialect_specific_select_onec Cspd}z|}z||jW|WdS|w|jjy7}z||||r2WYd}~dSd}~ww)NFT)rorrrrr.Error is_disconnect)rFrroerrrrrHdo_ping&s  zDefaultDialect.do_pingcCsdtdddS)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_%032xrr)randomrandintrMrrrH create_xid6szDefaultDialect.create_xidcC|t|dSrJ)rrSavepointClauserFrar*rrrH do_savepoint?zDefaultDialect.do_savepointcCrrJ)rrRollbackToSavepointClauserrrrHdo_rollback_to_savepointBrz'DefaultDialect.do_rollback_to_savepointcCrrJ)rrReleaseSavepointClauserrrrHdo_release_savepointErz#DefaultDialect.do_release_savepointcC|||dSrJ) executemanyrFrorwr{contextrrrHdo_executemanyHzDefaultDialect.do_executemanycCrrJrrrrrH do_executeKrzDefaultDialect.do_executecCs||dSrJr)rFrorwrrrrHdo_execute_no_paramsNz#DefaultDialect.do_execute_no_paramscCri)NFr)rFerarorrrHrQrzDefaultDialect.is_disconnectcCs|||jdSrJ)rrb)rF dbapi_connrrrHrTsz$DefaultDialect.reset_isolation_levelcCst|durdStjrt|tr||j}|}|}||kr"|S||kr.|j |s.|S||kr8t |ddS|S)NT)quote) r rrtrdecoder+lowerupperr3_requires_quotesrrFr* name_lower name_upperrrrHnormalize_nameZs$   zDefaultDialect.normalize_namecCsh|durdS|}|}||kr|S||kr |j|s |}tjr2|js.||j}|St |}|SrJ) rrr3rr rsupports_unicode_bindsencoder+unicoderrrrHdenormalize_namews$ zDefaultDialect.denormalize_name) Fr NNNNTNr!NNrJ)e__name__ __module__ __qualname____doc__r SQLCompilerstatement_compiler DDLCompiler ddl_compilerGenericTypeCompilerr4IdentifierPreparerr2supports_altersupports_commentsinline_commentsdefault_sequence_basetuplersupports_viewssupports_sequencessequences_optional"preexecute_autoincrement_sequencespostfetch_lastrowidr1r5cte_follows_insertsupports_native_enumr6#non_native_boolean_check_constraintsupports_simple_order_by_labeltuple_in_valuesr immutabledict bool_or_strasintasboolengine_config_typessupports_native_decimalpy3krrrdr?r*r=r<max_index_name_lengthrSsupports_sane_multi_rowcountrr0supports_default_valuessupports_empty_insertsupports_multivalues_insertsupports_server_side_cursorsr\construct_argumentsrequires_name_normalizereflection_optionsdbapi_exception_translation_mapdeprecated_paramsrImemoized_propertyrNpropertyrRrT classmethodrYrhrjrfrcrerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHr,s   )  J    , 7         rc@s<eZdZejZejZejZ ej Z dZ dZ dZdZdZdZdS)StrCompileDialectTFN)rrrr StrSQLCompilerrrrStrSQLTypeCompilerr4rr2rrrr1r6rrrrrHr-sr-c@seZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZeZeddZeddZddZed d Zed d Zejd dZejddZejddZejddZejddZejddZ ddZ!e"ddZ#ddZ$dd Z%d!d"Z&d#d$Z'd%d&Z(d'd(Z)d)d*Z*d+d,Z+d-d.Z,d/d0Z-e"d1d2Z.d3d4Z/d5d6Z0d7d8Z1d9d:Z2d;d<Z3d=d>Z4d?d@Z5 dPdAdBZ6dCdDZ7dZ8 dQdFdGZ9dHdIZ:dJdKZ;dLdMZt ||_ ||j d|_n t ||_|_ ||_g|_|jrZ|g|_|Sig|_|S)z8Initialize execution context for a DDLElement construct.Tr)__new__root_connection_dbapi_connectionrlcompiledisddlexecution_options_execution_optionsdictrrr ruunicode_statementrDrw create_cursorrocompiled_parametersr,rr{)rWrlrar compiled_ddlrFr4rrrH _init_ddls*      z!DefaultExecutionContext._init_ddlc s@||}||_||_|j|_|_jsJj|j|_j j j f|_ t |_js;|j|jj|_n|j|_j|_j|_j|_j|_|sXg|_nfddt|D|_t|dk|_||_|jsy|jsy|jrd|_ t!jj"|_#t!j$ojj" |_%|jj&s|jj'r|jr|(n|)j*j+rt,|-}nj.r|jj/}g}j.r|jD](g}|D]} | vr|0| | q|0| q|01|qn,j } |jD]$| rt,fddD}n t,fddD}|0|q1||_2|S)z6Initialize execution context for a Compiled construct.csg|] \}}j||dqS)) _group_number)construct_params)r~grpm)r4rrH s z:DefaultExecutionContext._init_compiled..rTc3s>|]}|d|vr||n|fVqdS)rNrDr~key)compiled_paramsrlr rrH 1s  z9DefaultExecutionContext._init_compiled..c3s4|]}||vr||n|fVqdSrJrrD)rFr rrHrG;s )3r1r2r3rlr4 can_executer6unionr7_result_columns_ordered_columns_textual_ordered_columnsresult_column_structr rur9rrr+rwisinsertisupdateisdelete isplaintextis_textr?r; enumeraterrr:rois_crudbool _returning_is_explicit_returning returning_is_implicit_returninginsert_prefetchupdate_prefetch_process_executemany_defaults_process_executesingle_defaults_bind_processorscontains_expanding_parametersr8_expand_in_parametersr, positiontuprrr{) rWrlrarr4r{rFraparamrErr)r4rFrlr rH_init_compileds           z&DefaultExecutionContext._init_compiledc sjrtdjjrjjrtdi_jd}|jr"g}nd}ii}|jr/jj njj D]jj }|j rvrG|no| }|seg|<j |jr]|jn|jg<nQt|dttfrfddt|dD|<jjrdnd d fd d t|D<nfd dt|dD|<d fdd D<|fdd D|jr|dd DddDj<q3|jr|q3fdd}td|j_|S)zhandle special 'expanding' parameters, IN tuples that are rendered on a per-parameter basis for an otherwise fixed SQL statement string. z7'expanding' parameters can't be used with executemany()zQ'expanding' bind parameters not supported with 'numeric' paramstyle at this time.rNcs6g|]\}}t|dD] \}}d||f|fq qS)rz%s_%s_%s)rS)r~i tuple_elementjvaluer*rrHrBszADefaultExecutionContext._expand_in_parameters..rzVALUES , c3s:|]\ddfddtDVqdS)z(%s)rjc3s8|]\}}jjdt|diVqdS)r*rN)r4 bindtemplater)r~rfrg)rdrF to_updatererrHrGs zJDefaultExecutionContext._expand_in_parameters...N)joinrSr~)rFrl)rdrerHrGs  z@DefaultExecutionContext._expand_in_parameters..cs g|] \}}d|f|fqS)z%s_%sr)r~rdrgrhrrHrBsc3s$|] \}}jjd|iVqdS)r*N)r4rkr~rErgrMrrHrGs  c3s(|]\}}vr|fVqdSrJrro)r*r rrHrGs css|]\}}|VqdSrJr)r~r*rgrrrHrGscSsg|]\}}|qSrr)r~ expand_keyrgrrrHrBscs|dS)Nr)group)rA)replacement_expressionsrrHprocess_expandingrzHDefaultExecutionContext._expand_in_parameters..process_expandingz\[EXPANDING_(\S+)\])rrInvalidRequestErrorr4r,_numeric_bindsr]_expanded_parametersr;rabinds expandingpopvisit_empty_set_expr_expanding_in_typestypertr listrSrlrrmrextendrresubrw) rFr4r rFrato_update_sets parametervaluesrsr)r*r rrrFrlrHr`Ks            z-DefaultExecutionContext._expand_in_parameterscs||}||_||_|j|_d|_|j|_|s(|jjr#g|_ n7ig|_ n2t |djr4||_ n&t |dt rPj rB||_ nfdd|DpMig|_ n fdd|D|_ t |dk|_j svt |tjrv||_|d|_n||_|_||_|S)z8Initialize execution context for a string SQL statement.Trcs g|] fddDqS)cs i|] }|d|qS)rrC)r~k)drlrrH s zFDefaultExecutionContext._init_statement...rrnrk)rrHrBz;DefaultExecutionContext._init_statement..csg|]}|qSr)r)r~prkrrHrBs r)r1r2r3rlrRr7r6r,rr{rtr8rrrr rur9rDrwr:ro)rWrlrarrwr{rFrrkrH_init_statements@      z'DefaultExecutionContext._init_statementcCs4||}||_||_|j|_|j|_||_|S)z;Initialize execution context for a ColumnDefault construct.)r1r2r3rlr7r6r:ro)rWrlrarrFrrrH _init_defaults  z%DefaultExecutionContext._init_defaultcC|jjSrJ)r2rrMrrrHrrOzDefaultExecutionContext.enginecCrrJ)r4 postfetchrMrrrHpostfetch_colsrOz&DefaultExecutionContext.postfetch_colscCs |jr|jjS|jr|jjSdS)Nr)rNr4rZrOr[rMrrrH prefetch_colss z%DefaultExecutionContext.prefetch_colscCs |jjdSrJ)r4rXrMrrrHreturning_colss z&DefaultExecutionContext.returning_colscCs|jddS)N no_parametersF)r6getrMrrrHr rZz%DefaultExecutionContext.no_parameterscCs<|jd|j r|jrtjpd}|tjur||jS|S)N autocommitF)r6rr4rwrPARSE_AUTOCOMMITshould_autocommit_textr9)rFrrrrHshould_autocommits  z)DefaultExecutionContext.should_autocommitcCs|j}t|tjr|jjs|j|d}|jjr|j}ni}|j |j |||d|j d}|durI| |j|j j dd}|rI||S|S)aExecute 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)rNr)r2rtr rurlrrDr,rrprorq_cached_result_processorr)rFstmttype_rdefault_paramsrprocrrrH_execute_scalars$  z'DefaultExecutionContext._execute_scalarcCs |jSrJ)r2_branchrMrrrHra>rz"DefaultExecutionContext.connectioncCs t|SrJ)AUTOCOMMIT_REGEXPmatch)rFrwrrrHrBs z.DefaultExecutionContext.should_autocommit_textcCsx|jjsdS|jjr3|jddo0|jrt|jjtj p0|j p't|jjtj o0|jo0t |j}|S|jdd}|S)NFstream_resultsT) rlr$server_side_cursorsr6rr4rtrwr Selectable TextClauseSERVER_SIDE_CURSOR_REr)rFuse_server_siderrrH_use_server_side_cursorEs2   z/DefaultExecutionContext._use_server_side_cursorcCs&|r d|_|Sd|_|jS)NTF)r_is_server_sidecreate_server_side_cursorr3rorMrrrHr:es  z%DefaultExecutionContext.create_cursorcCstrJ)r]rMrrrHrmsz1DefaultExecutionContext.create_server_side_cursorcCrrJrrMrrrHpre_execprz DefaultExecutionContext.pre_execcCrrJrrMrrrH post_execsrz!DefaultExecutionContext.post_execcCs||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. )rrl)rFrcolnamecoltyperrrHget_result_processorvsz,DefaultExecutionContext.get_result_processorcCr)areturn 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, directly after post_exec() and before the transaction is committed or ResultProxy is generated. If the post_exec() method assigns a value to `self._lastrowid`, the value is used in place of calling get_lastrowid(). Note that this method is *not* equivalent to the ``lastrowid`` method on ``ResultProxy``, which is a direct proxy to the DBAPI ``lastrowid`` accessor in all cases. )ro lastrowidrMrrrH get_lastrowidsz%DefaultExecutionContext.get_lastrowidcCrrJr)rFrrrrHhandle_dbapi_exceptionrz.DefaultExecutionContext.handle_dbapi_exceptioncCs|jrt|St|SrJ)rrBufferedRowResultProxy ResultProxyrMrrrHget_result_proxys  z(DefaultExecutionContext.get_result_proxycCrrJ)rorowcountrMrrrHrrOz DefaultExecutionContext.rowcountcCrrJ)rlrSrMrrrHrSz.DefaultExecutionContext.supports_sane_rowcountcCrrJ)rlr rMrrrHr rz4DefaultExecutionContext.supports_sane_multi_rowcountcCs|jr|js|js|jjs|jjr|n|js|| }|jrH|jr<| }||_ | || d|_|S|jsF| d|_|S|jr^|jr^| }||_ | d|_|S|jdurj|j| |SrJ)rNrrYr4inlinerlr_setup_ins_pk_from_lastrowid_setup_ins_pk_from_emptyrrqreturned_defaults%_setup_ins_pk_from_implicit_returning _soft_close _metadatarWrOr)rFrrxrrrH_setup_crud_result_proxysB     z0DefaultExecutionContext._setup_crud_result_proxycs|jjd|jjj}|jd|dur?|jdur/j|j d}|dur/|fdd|j D|_ dSfdd|j D|_ dS)Nrrcs(g|]}|ur n|dqSrJrr~c autoinc_colrF key_getterrrrHrBs zHDefaultExecutionContext._setup_ins_pk_from_lastrowid..cg|] }|dqSrJrrrFrrrHrBs) r4_key_getters_for_crud_columnrwrr;r_autoincrement_columnr|rrl primary_keyinserted_primary_key)rFrrrrrHrs$     z4DefaultExecutionContext._setup_ins_pk_from_lastrowidcs<|jjd|jjj}|jdfdd|jD|_dS)NrrcrrJrrrrrHrBszDDefaultExecutionContext._setup_ins_pk_from_empty..)r4rrwrr;rr)rFrrrrHrs     z0DefaultExecutionContext._setup_ins_pk_from_emptycs\dur d|_dS|jjd|jjj}|jdfddfdd|jDD|_dS)Nrrcs$g|]\}}|dur|n|qSrJr)r~colrg)rxrrHrBszQDefaultExecutionContext._setup_ins_pk_from_implicit_returning..cs g|] }||dfqSrJr)r~rrrrHrBr)rr4rrwrr;r)rFrxrr)rFrrxrHrs      z=DefaultExecutionContext._setup_ins_pk_from_implicit_returningcCs|js|jo t|jjSrJ)rNrOrUr4rrMrrrHlastrow_has_defaults sz,DefaultExecutionContext.lastrow_has_defaultsc sBt|jdsdSi}|jjD]5}|j|j}t|}||jjdur?|r0|vr?||vr?|r:|vs:||vr?||<qd||<q|jjrV|jj ||j |j |j ||jjrg}|jjD]*} |jj| }||ddur| |jvr|gt|j| q`|q`z |j j|WdSty} z|j| ddd|WYd} ~ dSd} ~ wwi} |jjD];\}} ||ddur|r|| | } |jjs|j| d} | |jvr| fdd|j| Dq| | <qz |j jdi| WdSty } z|j| ddd|WYd} ~ dSd} ~ ww)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. bind_namesNrc3s|]}|fVqdSrJr)r~rpdbtyperrHrG[s  z:DefaultExecutionContext.set_input_sizes..r)hasattrr4rr|_unwrapped_dialect_implrlget_dbapi_typer. _has_eventsdispatchdo_setinputsizesrorwr{r,rarwrrvr~rr setinputsizes BaseExceptionr2_handle_dbapi_exceptionitemsrrDr) rF translate include_types exclude_types inputsizes bindparam dialect_impldialect_impl_clspositional_inputsizesrErkeyword_inputsizesrrrHset_input_sizess               z'DefaultExecutionContext.set_input_sizescCs||jr |||S|jr||_||S|jr;|j}|js%t |j|}n|j}t |gj |d}| |di S|jS)N)bindr) is_sequence fire_sequence is_callablecurrent_columnargis_clause_elementra _arg_is_typedr type_coercermrn_execute_compiledscalar)rFcolumnrrr default_argrrrrH _exec_defaulths  z%DefaultExecutionContext._exec_defaultTcsz|j|j}Wn tytdw|rS|jrS|jjjrS|j r1|j d|j j |j i}n |j |j i}d|jjj d}|fdd|D|SS)aFReturn 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:`.Column`, which is usually synonymous with the name. :param isolate_multiinsert_groups=True: indicates that multi-valued INSERT constructs created using :meth:`.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 functionrrc3s$|] }|d|ffVqdS)z%s_m%dNrrDindexr{rrHrGs zADefaultExecutionContext.get_current_parameters..)current_parametersrAttributeErrorrrtrNr4rw_has_multi_parameters_is_multiparam_columnroriginalrEr{keysr)rFisolate_multiinsert_groupsrrrrrrHget_current_parameterss2   z.DefaultExecutionContext.get_current_parameterscC |jdurdS|||j|jSrJ)rrr|rFrrrrHget_insert_default z*DefaultExecutionContext.get_insert_defaultcCrrJ)onupdaterr|rrrrHget_update_defaultrz*DefaultExecutionContext.get_update_defaultcCs|jjd}i}|jj}|jj}|D]}|jr!|jjr!|jj||<q|D]}|jr3|jjr3|jj||<q$|jD]?}||_ |D]}||vrI||}n| |}|durX||||<q>|D]}||vrf||}n| |}|duru||||<q[q7|` dS)Nr) r4rrZr[r is_scalarrrr;rrr)rFrscalar_defaultsrZr[rrbvalrrrHr\s<          z5DefaultExecutionContext._process_executemany_defaultscCs|jjd}|jd|_}|jjD]!}|jr$|jjs$|jjr$|jj}n| |}|dur3||||<q|jj D]}| |}|durI||||<q8|`dS)Nrr) r4rr;rrZrrrrrr[r)rFrr;rrrrrHr]s"        z7DefaultExecutionContext._process_executesingle_defaults)NNN)T)>rrrrNrOrPrTrRr5rr4rwrMrrYrW_translate_colnamer rrvr,r=rcr`rrr*rrrrrrrr+rarrr:rrrrrrrrrSr rrrrrrrrrrrr\r]rrrrHr0s  un /       !    ' X : %r0)!rrBrrrKrirrrrrr r r rr sqlr rr sql.elementsrrnIUNICODErrDialectrr-ExecutionContextr0execution_ctx_clsrrrrHsH              f |