o znhl@sdZddlZddlZddlZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z d d lm Z d dlmZegdZedejZedejZddeddDdgZedejZedejZedejZedejZedejZddddddZiejd ej d!ej!d"ej"d#ej#d$ej$d%ej%d&ej&d%ej'd'ej(d(ej)d)ej*d*ej+d+ej,d,ej-d-ej.d.ej/d/iej0d0ej1d1ej2d2ej3d3ej4d4ej5d5ej6d6ej7d7ej8d8ej9d9ej:d:ej;d;ejd>ej?d?ej@d@ejAdAejBdBejCdCiZDejEdDejFdEejGdFejHdGejIdHejJdIejKdJejLdKejMdLejNdMejOdNejPdOejQdPejRdQiZSdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`daZTe jUjVdbe jUjWdce jUjXdde jUjYdee jUjZdfe jUj[dgiZ\Gdhdidie]Z^Gdjdkdke_ej`e]ZaGdldmdme jbZcGdndodoedZeGdpdqdqe^ZfGdrdsdsefZgGdtdudue^ZhGdvdwdweaZiGdxdydyeiZjGdzd{d{e]ZkdS)|a]Base SQL and DDL compiler implementations. Classes provided include: :class:`.compiler.SQLCompiler` - renders SQL strings :class:`.compiler.DDLCompiler` - renders DDL (data definition language) strings :class:`.compiler.GenericTypeCompiler` - renders type specification strings. To generate user-defined SQL strings, see :doc:`/ext/compiler`. N)crud)elements) functions) operators)schema) selectable)sqltypes)visitors)exc)util)^allanalyseanalyzeandanyarrayasasc asymmetric authorizationbetweenbinarybothcasecastcheckcollatecolumn constraintcreatecross current_date current_role current_timecurrent_timestamp current_userdefault deferrabledescdistinctdoelseendexceptfalseforforeignfreezefromfullgrantgrouphavingilikein initiallyinner intersectintoisisnulljoinleadingleftlikelimit localtimelocaltimestampnaturalnewnotnotnullnulloffoffsetoldononlyororderouteroverlapsplacingprimary referencesrightselect session_usersetsimilarsome symmetrictablethentotrailingtrueunionuniqueuserusingverbosewhenwherez ^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$cCsh|]}t|qS)str).0xrlrlB/usr/local/lib/python3.10/dist-packages/sqlalchemy/sql/compiler.py rq $z5^(?:RESTRICT|CASCADE|SET NULL|NO ACTION|SET DEFAULT)$z^(?:DEFERRED|IMMEDIATE)$z%(? z >= z = z IS DISTINCT FROM z IS NOT DISTINCT FROM z || z MATCH z NOT MATCH z IN z NOT IN , z FROM  AS z IS z IS NOT z COLLATE zEXISTS DISTINCT zNOT zANY zALL z DESCz ASCz NULLS FIRSTz NULLS LASTcoalesce CURRENT_DATE CURRENT_TIMECURRENT_TIMESTAMP CURRENT_USER LOCALTIMELOCALTIMESTAMPrandomsysdate SESSION_USERUSERCUBEROLLUPz GROUPING SETSmonthdayyearsecondhourdoyminutequarterdowweekepoch milliseconds microseconds timezone_hourtimezone_minute)rrrrrrrrrrrrrrrUNIONz UNION ALLEXCEPTz EXCEPT ALL INTERSECTz INTERSECT ALLc@seZdZdZdZeZ ddefddZe ddddZ d d Z e d d Z d dZddZdddZe ddZddZddZdS)CompiledaRepresent a compiled SQL or DDL expression. The ``__str__`` method of the ``Compiled`` object should produce the actual text of the statement. ``Compiled`` objects are specific to their underlying database dialect, and also may or may not be specific to the columns referenced within a particular set of bind parameters. In no case should the ``Compiled`` object be dependent on the actual values of those bind parameters, even though it may reference those values as defaults. NcCsj||_||_|jj|_|r|j||_|dur3||_|j|_|jr&|j|_ |j |jfi||_ dSdS)aqConstruct a new :class:`.Compiled` object. :param dialect: :class:`.Dialect` to compile against. :param statement: :class:`.ClauseElement` to be compiled. :param bind: Optional Engine or Connection to compile this statement against. :param schema_translate_map: dictionary of schema names to be translated when forming the resultant SQL .. versionadded:: 1.1 .. seealso:: :ref:`schema_translating` :param compile_kwargs: additional kwargs that will be passed to the initial call to :meth:`.Compiled.process`. N) dialectbindidentifier_preparerpreparer_with_schema_translate statementsupports_execution can_execute_execution_optionsexecution_optionsprocessstring)selfrrrschema_translate_mapcompile_kwargsrlrlrp__init__s  zCompiled.__init__z0.7zThe :meth:`.Compiled.compile` method is deprecated and will be removed in a future release. The :class:`.Compiled` object now runs its compilation within the constructor, and this method does nothing.cCdS)zDProduce the internal string representation of this element. NrlrrlrlrpcompileAs zCompiled.compilecCs |jr ||||St|jN)r_execute_compiledr ObjectNotExecutableErrorr)r connection multiparamsparamsrlrlrp_execute_on_connectionMs zCompiled._execute_on_connectioncCt)zReturn a Compiled that is capable of processing SQL expressions. If this compiler is one, it would likely just return 'self'. NotImplementedErrorrrlrlrp sql_compilerSzCompiled.sql_compilercK|j|fi|Sr_compiler_dispatch)robjkwargsrlrlrpr]zCompiled.processcCs |jpdS)z3Return the string text of the generated SQL or DDL.)rrrlrlrp__str__` zCompiled.__str__cCr)zReturn the bind params for this compiled object. :param params: a dict of string/object pairs whose values will override bind values compiled in to the statement. rrrrlrlrpconstruct_paramserzCompiled.construct_paramscCs|S)z0Return the bind params for this compiled object.rrrlrlrproszCompiled.paramscOs*|j}|durtjddd||||S)zExecute this compiled object.Nz>This Compiled object is not bound to any Engine or Connection.2aficode)rr UnboundExecutionErrorr)rrrerlrlrpexecutetszCompiled.executecOs|j|i|S)zJExecute this compiled object and return the result's scalar value.)rscalar)rrrrlrlrprszCompiled.scalarr)__name__ __module__ __qualname____doc___cached_metadatar immutabledictrr deprecatedrrpropertyrrrrrrrrlrlrlrprs0   /      rc@s$eZdZdZdZddZddZdS) TypeCompilerz2Produces DDL specification for TypeEngine objects.z visit_\w+cCs ||_dSr)r)rrrlrlrpr zTypeCompiler.__init__cKrrrrtype_kwrlrlrprrzTypeCompiler.processN)rrrr ensure_kwargrrrlrlrlrprs  rc@sBeZdZdZdZdZdddZeddZed d Z d d Z d S) _CompileLabelz;lightweight label object which acts as an expression.Label.label)elementnamerlcCs||_||_|f||_dSr)rr _alt_names)rcolr alt_namesrlrlrprsz_CompileLabel.__init__cC|jjSr)r proxy_setrrlrlrprz_CompileLabel.proxy_setcCrr)rtyperrlrlrprrz_CompileLabel.typecK|Srrl)rrrlrlrp self_groupz_CompileLabel.self_groupN)rl) rrrr__visit_name__ __slots__rrrrrrlrlrlrprs    rc@seZdZdZddZdS)prefix_anon_mapacA map that creates new keys for missing key access. Considers keys of the form " " to produce new symbols "_", where "index" is an incrementing integer corresponding to . Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which is otherwise usually used for this type of operation. cCsD|dd\}}||d}|d||<|dt|}|||<|S)N r_)splitgetrm)rkeyidentderivedanonymous_countervaluerlrlrp __missing__s   zprefix_anon_map.__missing__N)rrrrrrlrlrlrprs rc@sLeZdZdZeZeZdZZ Z dZ dZ dZ dZ dZ dZ dZ dZ dZ dZ dZZ dddZedd Zejd d Zejd d ZddZ ej!ddZ"ddZ#eddZ$dddZ%eddZ&e'dddZ(ddZ)ddd Z* dd!d"Z+ dd#d$Z,    dd%d&Z-d'd(Z. dd)d*Z/d+d,Z0d-d.Z1d/d0Z2d1d2Z3d3d4Z4d5d6Z5d7d8Z6 dd9d:Z7d;d<Z8d=d>Z9d?d@Z:dAdBZ;dCdDZdIdJZ?dKdLZ@dMdNZAdOdPZBdQdRZCddSdTZDdUdVZEdWdXZFdYdZZG [d d\d]ZHd^d_ZId`daZJdbdcZKdddeZLdfdgZMdhdiZNdjdkZOdldmZPdndoZQ ddpdqZRdrdsZSdtduZTdvdwZUdxdyZVdzd{ZW dd|d}ZXd~dZYddZZej!ddZ[ddZ\ddZ]ddZ^ddZ_ddZ`ddZaddZbddZcddZdddZeddZfddZg   d ddZhddZiddZjddZkddZlddZm dddZn    d ddZo    d ddZpddZqdddZrddZsddZt   d ddZuddZvddZwddZxddZyddZzddÄZ{ddńZ|e}de~fde~fgZdddɄZ    [   ddd˄Zdd̈́ZddτZddфZddӄZddՄZddׄZddلZddۄZdd݄Zdd߄ZddZddZ     dddZdddZddZdddZddZddZddZdddZej!ddZddZddZdddZddZddZddZdS( SQLCompilerzsDefault implementation of :class:`.Compiled`. Compiles :class:`.ClauseElement` objects into SQL strings. FNTrlcKs||_|p t|dd|_i|_t|_g|_g|_|j |_ |j r*g|_ |j dk|_ t |j |_d|_|jp8|j|_t|_i|_tj|||fi||jsU|jsU|jr\|jr\|j|_|j rh|j rj|dSdSdS)aConstruct a new :class:`.SQLCompiler` object. :param dialect: :class:`.Dialect` to be used :param statement: :class:`.ClauseElement` to be compiled :param column_keys: a list of column names to be compiled into an INSERT or UPDATE statement. :param inline: whether to generate INSERT statements as "inline", e.g. not formatted to return any generated defaults :param kwargs: additional keyword arguments to be consumed by the superclass. inlineFryN) column_keysgetattrrbindsr column_dict bind_namesstack_result_columns positional positiontup paramstyle_numeric_bindsBIND_TEMPLATES bindtemplatectes label_lengthmax_identifier_lengthranon_maptruncated_namesrrisinsertisupdateisdelete _returning returning_apply_numbered_params)rrrrrrrlrlrprs:      zSQLCompiler.__init__cCst|j|jSr)listinsert_prefetchupdate_prefetchrrlrlrpprefetchWzSQLCompiler.prefetchcCs*t|_i|_d|_|jri|_dSdS)zInitialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise. FN)r OrderedDictr  ctes_by_namectes_recursivercte_positionalrrlrlrp_init_cte_state[s  zSQLCompiler._init_cte_statec cs|j|j}}gd|_|_z'|jr|jd}d|d<nd}|j|jfVW|r.|d|||_|_dS|r>|d|||_|_w)z;special API to support the use case of 'nested result sets'FTneed_result_map_for_nestedN)r_ordered_columnsrpop)rresult_columnsordered_columnsentryrlrlrp_nested_resultis*     zSQLCompiler._nested_resultcs(tdtdfdd|j|_dS)Nrz \[_POSITION\]csttSr)rmr nextmposcountrlrpsz4SQLCompiler._apply_numbered_params..) itertoolscountresubrrrlr*rprs  z"SQLCompiler._apply_numbered_paramscs"tddfddjDDS)Ncss$|] \}}|dur||fVqdSrrl)rnrrrlrlrp sz/SQLCompiler._bind_processors..c3s(|]}j||jjfVqdSr)rr_cached_bind_processorr)rn bindparamrrlrpr1s  )dictrrrlrrp_bind_processorss  zSQLCompiler._bind_processorscCst|jdkSNr)lenrrrlrlrp is_subqueryzSQLCompiler.is_subquerycCrrrlrrlrlrprzSQLCompiler.sql_compilercCs|rTi}|jD]J}|j|}|j|vr||j||<q||vr&||||<q|rC|jrC|r9tjd|j|fddtjd|jdd|jrL|j||<q|j||<q|Si}|jD]3}|rx|jrx|rntjd|j|fddtjd|jdd|jr|j||j|<qY|j||j|<qY|S)z5return a dictionary of bind parameter keys and valuesz@A value is required for bind parameter %r, in parameter group %dcd3xrz)A value is required for bind parameter %r)rrrequiredr InvalidRequestErrorcallableeffective_valuer)rr _group_number_checkpdr3rrlrlrprs\        zSQLCompiler.construct_paramscCs |jddS)zoReturn the bind param dictionary embedded into this compiled object, for those values that are present.F)rArrrlrlrprs zSQLCompiler.paramszsqlalchemy.engine.resultcCs|j|jS)z(utility method used for unit tests only.)ResultMetaData_create_result_mapr)rresultrlrlrprDszSQLCompiler._create_result_mapcCr)zCalled when a SELECT statement has no froms, and no FROM clause is to be appended. Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output. rrlrrlrlrp default_fromszSQLCompiler.default_fromcKsd|jj|fi|dS)N()rr)rgroupingasfromrrlrlrpvisit_groupingszSQLCompiler.visit_groupingc Ks|jr6|jjr6|jdd}|j\}}}|r|}n|}|jj} | dur6| j|vr6| || jr6|jj|d<|j|jfd|i|S)Nrrrender_label_as_labelwithin_columns_clause) rrsupports_simple_order_by_label_label_resolve_dictr_order_by_label_elementrshares_lineager) rrrNrr with_cols only_froms only_cols resolve_dict order_by_elemrlrlrpvisit_label_references0  z!SQLCompiler.visit_label_referencec Ks|js ||jS|jdd}|j\}}}z|r||j}n||j}Wnty8t|jtj dYdSw||d<|j|fd|i|S)NrrzECan't resolve label reference for ORDER BY / GROUP BY / DISTINCT etc.rMrN) rr _text_clauserPrKeyErrorr_no_text_coercionr CompileError) rrrNrrrSrTrUrrlrlrpvisit_textual_label_reference s0      z)SQLCompiler.visit_textual_label_referencec Ks|o| }||u}|s |rt|jtjr|d|j} n|j} |rL|dur3|| |j|| f|j|j|jj|fddd|t t j |j || S|rU|j || S|jj|fddi|S)NcolidentT)rNwithin_label_clauserNF) isinstancerr_truncated_label_truncated_identifierrrrr OPERATORSras_r format_label) rradd_to_result_mapr_rNrMrrender_label_with_asrender_label_only labelnamerlrlrp visit_label(sJ    zSQLCompiler.visit_labelcC td)Nz:Cannot compile Column object until its 'name' is assigned.r r\rrrlrlrp_fallback_column_nameYz!SQLCompiler._fallback_column_namec Ks|j}}|dur||}|j}|st|tjr|d|}|dur/||||||jf|j|r7| |}n|j |}|j }|dusI|rI|j sK|S|j |} | r\|j | d} nd} |j} t| tjrm|d| } | |j | d|S)Nr^.ralias)rrn is_literalr`rrarbrrescape_literal_columnrquoter`named_with_columnschema_for_object quote_schema) rrrf include_tablerr orig_namerrr`effective_schema schema_prefix tablenamerlrlrp visit_column^s2        zSQLCompiler.visit_columncKs|j|jSr)rformat_collation collation)rrrrlrlrpvisit_collationr9zSQLCompiler.visit_collationcK|jSrr)r fromclauserrlrlrpvisit_fromclausezSQLCompiler.visit_fromclausecKrrr)rindexrrlrlrp visit_indexrzSQLCompiler.visit_indexcKs ||d<|jjj|jfi|S)Ntype_expression)r type_compilerrr)r typeclauserrlrlrpvisit_typeclauseszSQLCompiler.visit_typeclausecC|jjr |dd}|SN%%%r_double_percentsreplacertextrlrlrppost_process_text zSQLCompiler.post_process_textcCrrrrrlrlrprsrz!SQLCompiler.escape_literal_columnc s<fdd}jsd_tddt|jS)Ncs>|d}|jvrjj|fiSj|fiSr6)r7 _bindparamsrbindparam_string)r)rrr textclauserlrp do_bindparams  z2SQLCompiler.visit_textclause..do_bindparamTcSs |dSr6)r7r(rlrlrpr,s z.SQLCompiler.visit_textclause..)r isplaintextBIND_PARAMS_ESCr0 BIND_PARAMSrr)rrrrrlrrpvisit_textclauses zSQLCompiler.visit_textclausec Ks|j }|r |jn|jd}|p|dko|ddp|dd}|r8|j|_|_|jD] } |j| d|jdq,|j|j fi|} |rJ|rJd| } | S) Nrrneed_result_map_for_compoundFr TrNrf(%s)) r_default_stack_entryrrr!_textual_ordered_columns column_argsr_add_to_result_mapr) rtafcompound_indexrKparensrtoplevelr%populate_result_mapcrrlrlrpvisit_text_as_froms,    zSQLCompiler.visit_text_as_fromcKr)NNULLrlrexprrrlrlrp visit_nullrzSQLCompiler.visit_nullcK|jjrdSdS)Nrd1rsupports_native_booleanrrlrlrp visit_truezSQLCompiler.visit_truecKr)Nr00rrrlrlrp visit_falserzSQLCompiler.visit_falsec s^|j}|dur d}nt|j}|ddfdd|jDD}|jr-jjr-d|}|S)Nrcss|]}|r|VqdSrrlrnsrlrlrpr1s z/SQLCompiler.visit_clauselist..c3s"|] }|jfiVqdSrrrnrrrrlrpr1s zVALUES )operatorrcrAclauses _tuple_valuesrtuple_in_values)r clauselistrseprrlrrpvisit_clauselists   zSQLCompiler.visit_clauselistcKsd}|jdur||jj|fi|d7}|jD]\}}|d|j|fi|d|j|fi|d7}q|jdurL|d|jj|fi|d7}|d7}|S)NzCASE rzWHEN z THEN zELSE END)rrwhenselse_)rclauserrocondrErlrlrp visit_cases*  zSQLCompiler.visit_casecK|jj|fi|Sr)typed_expressionr)r type_coercerrlrlrpvisit_type_coercezSQLCompiler.visit_type_coercecK,d|jj|fi||jj|fi|fS)NzCAST(%s AS %s))rrr)rrrrlrlrp visit_castzSQLCompiler.visit_castc Ksd|dtjur dn2|dtjurdn)|ddkr,d|jtt|dfi|fnd|jt|dfi|f|dtjurGdfS|dtjurRdfS|ddkrmd|jtt|dfi|ffSd|jt|dfi|ffS) Nz %s AND %srzUNBOUNDED PRECEDINGz CURRENT ROWz %s PRECEDINGz %s FOLLOWINGrzUNBOUNDED FOLLOWING)rRANGE_UNBOUNDED RANGE_CURRENTrliteralabs)rrange_rrlrlrp_format_frame_clause s6     z SQLCompiler._format_frame_clausec s|jrdj|jfi}n|jr dj|jfi}nd}d|jjfidfddd|jfd|jffD|rD|gngfS) NzRANGE BETWEEN %szROWS BETWEEN %sz %s OVER (%s)rcs:g|]\}}|durt|rd||jfifqS)Nz%s BY %s)r7r)rnwordrrrrlrp 3sz*SQLCompiler.visit_over.. PARTITIONORDER)rrrowsrrrA partition_byorder_by)roverrrrlrrp visit_over$s2    zSQLCompiler.visit_overcKr)Nz%s WITHIN GROUP (ORDER BY %s))rrr)r withingrouprrlrlrpvisit_withingroup@rzSQLCompiler.visit_withingroupcKr)Nz%s FILTER (WHERE %s))funcr criterion)r funcfilterrrlrlrpvisit_funcfilterFrzSQLCompiler.visit_funcfiltercKs.|j|j|j}d||jj|fi|fS)NzEXTRACT(%s FROM %s)) extract_maprfieldrr)rextractrrrlrlrp visit_extractLs zSQLCompiler.visit_extractc s|dur||j|jd|jtd|jd}|r#||fi|St|jdr4|jr3d7n|jj sCt t j rIj nddfdd|jDgdj|fi|iS)Nrlz visit_%s_funcz%(expr)srpcs4g|]}j|sttjrj|n|qSrl)r_requires_quotes_illegal_charsr`r quoted_namert)rntokrrrlrpris  z.SQLCompiler.visit_function..r)rrrlower FUNCTIONSr __class__ _has_argsrrr`rrrtrA packagenamesfunction_argspec)rrrfrdisprlrrpvisit_functionSs6     zSQLCompiler.visit_functioncKs ||jSr)visit_sequencesequence)r next_valuerrlrlrpvisit_next_value_funcu z!SQLCompiler.visit_next_value_funccKtd|jj)Nz2Dialect '%s' does not support sequence increments.rrr)rrrrlrlrprx zSQLCompiler.visit_sequencecKrr) clause_exprr)rrrrlrlrpr~rzSQLCompiler.function_argspecrc  s,j }|r jnjd}|p|dko|dd}j|d|d||dj|j} d| dfd d t|jD} | j |fit dd i7} | j |fi7} | |j dusm|j durvj|fipwd 7} jr|r| } jdr|rd | dS| S)NrrrFcorrelate_froms asfrom_froms)rrrrrc3s.|]\}}|jfd|dVqdS)F)rKrrNr)rnirrKrrrlrpr1s z4SQLCompiler.visit_compound_select..rKrrGrHrl)rrrappendcompound_keywordskeywordrA enumerateselectsgroup_by_clauser4order_by_clause _limit_clause_offset_clause limit_clauser _render_cte_clauser") rcsrKrrrrr%need_result_maprrrlrrpvisit_compound_selectsB  $     z!SQLCompiler.visit_compound_selectcCs(d|j||r d|ndf}t||dS)Nz visit_%s_%s%srr)rr)r operator_ qualifier1 qualifier2attrnamerlrlrp_get_operator_dispatchs  z"SQLCompiler._get_operator_dispatchcKs|jr,|jr td||jdd}|r|||jfi|S|j|t|jfi|S|jrP||jdd}|rC|||jfi|S|j|t|jfi|Std)NzFUnary expression does not support operator and modifier simultaneouslyunaryrmodifierz,Unary expression has no operator or modifier)rrr r\r _generate_generic_unary_operatorrc _generate_generic_unary_modifier)rrrrrlrlrp visit_unarys:  zSQLCompiler.visit_unarycKs:|js|jjr|j|jfi|Sd|j|jfi|S)Nz%s = 1_is_implicitly_booleanrrrrrrrrrlrlrpvisit_istrue_unary_operators z'SQLCompiler.visit_istrue_unary_operatorcKs>|js|jjrd|j|jfi|Sd|j|jfi|S)NNOT %sz%s = 0rr rlrlrpvisit_isfalse_unary_operators z(SQLCompiler.visit_isfalse_unary_operatorcKsd|j|tjdS)Nr")override_operator) visit_binaryrmatch_oprrrrrlrlrpvisit_notmatch_op_binarysz$SQLCompiler.visit_notmatch_op_binarycCstddS)NzThe IN-predicate was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate. Consider alternative strategies for improved performance.)r warnrrlrlrp_emit_empty_in_warningsz"SQLCompiler._emit_empty_in_warningcKs.|jjrdS|jjr|||j|jkS)Nz1 != 1r_use_static_in_warn_on_empty_inr*rrCr'rlrlrpvisit_empty_in_op_binary z$SQLCompiler.visit_empty_in_op_binarycKs.|jjrdS|jjr|||j|jkS)Nz1 = 1r+r'rlrlrpvisit_empty_notin_op_binaryr/z'SQLCompiler.visit_empty_notin_op_binarycCr)Nz3Dialect '%s' does not support empty set expression.r)r element_typesrlrlrpvisit_empty_set_expr rz SQLCompiler.visit_empty_set_exprcKs|jrt|jtjrt|jtjrd|d<|p|j}||dd}|r,|||fi|Szt|}Wn t y?t ||w|j ||fi|S)NT literal_bindsr) ansi_bind_rulesr`rCr BindParameterrYrrrcrZr UnsupportedCompilationError_generate_generic_binary)rrr$eager_groupingrrropstringrlrlrpr%s"      zSQLCompiler.visit_binarycKs|j|jfi|Sr)r sql_functionr rlrlrp&visit_function_as_comparison_op_binary)rz2SQLCompiler.visit_function_as_comparison_op_binarycKs`|jjr|j|jfi|d|j|jfi|S|j|jfi|d|j|jfi|S)Nz %% r{)rrrrCrYr'rlrlrpvisit_mod_binary,szSQLCompiler.visit_mod_binarycKs(|j|d<|j|d|jdfi|S)Nr8r)r8r7r9r rlrlrpvisit_custom_op_binary:s z"SQLCompiler.visit_custom_op_binarycKs|j||jdfi|SNr)rr9r rlrlrpvisit_custom_op_unary_operator@  z*SQLCompiler.visit_custom_op_unary_operatorcKs|j|d|jfi|Sr>)rr9r rlrlrpvisit_custom_op_unary_modifierEr@z*SQLCompiler.visit_custom_op_unary_modifiercKs\|dd}d|d<|jj|fd|i|||jj|fd|i|}|r,|r,d|}|S)N _in_binaryFTr8r)rrCrrY)rrr9r8rrBrrlrlrpr7Js.  z$SQLCompiler._generate_generic_binarycKs||jj|fi|SrrIrrr9rrlrlrpr_z,SQLCompiler._generate_generic_unary_operatorcKs|jj|fi||SrrIrCrlrlrprbrDz,SQLCompiler._generate_generic_unary_modifiercCstjdtjdS)Nz'%')r)rliteral_columnr STRINGTYPErrlrlrp_like_percent_literalerz!SQLCompiler._like_percent_literalcK6|}|j}||j||_|j||fi|Sr_clonerG__add__rYvisit_like_op_binaryrrrrpercentrlrlrpvisit_contains_op_binaryiz$SQLCompiler.visit_contains_op_binarycKrHrrJrGrKrYvisit_notlike_op_binaryrMrlrlrpvisit_notcontains_op_binaryorPz'SQLCompiler.visit_notcontains_op_binarycK0|}|j}||j|_|j||fi|Sr)rJrG__radd__rYrLrMrlrlrpvisit_startswith_op_binaryuz&SQLCompiler.visit_startswith_op_binarycKrTr)rJrGrUrYrRrMrlrlrpvisit_notstartswith_op_binary{rWz)SQLCompiler.visit_notstartswith_op_binarycKrTrrIrMrlrlrpvisit_endswith_op_binaryrWz$SQLCompiler.visit_endswith_op_binarycKrTrrQrMrlrlrpvisit_notendswith_op_binaryrWz'SQLCompiler.visit_notendswith_op_binarycKV|jdd}d|jj|fi||jj|fi|f|r(d||tjSdS)Nescapez %s LIKE %s ESCAPE r modifiersrrCrrYrender_literal_valuer rFrrrrr\rlrlrprLsz SQLCompiler.visit_like_op_binarycKr[)Nr\z%s NOT LIKE %sr]rr^rarlrlrprRz#SQLCompiler.visit_notlike_op_binarycKr[)Nr\zlower(%s) LIKE lower(%s)r]rr^rarlrlrpvisit_ilike_op_binaryrbz!SQLCompiler.visit_ilike_op_binarycKr[)Nr\zlower(%s) NOT LIKE lower(%s)r]rr^rarlrlrpvisit_notilike_op_binaryrbz$SQLCompiler.visit_notilike_op_binarycK*|jdd}|j||rdndfi|S)Nr_Fz BETWEEN SYMMETRIC z BETWEEN r_rr7rrrrr_rlrlrpvisit_between_op_binarys  z#SQLCompiler.visit_between_op_binarycKre)Nr_Fz NOT BETWEEN SYMMETRIC z NOT BETWEEN rfrgrlrlrpvisit_notbetween_op_binarys z&SQLCompiler.visit_notbetween_op_binaryc Ks$|s|j|j}|jr||}|j|fd||d|S|s%|rB|jrB|jdur7|jdur7t d|j |j |fddi|S| |}||jvr{|j|} | |ur{| js[|jrj| j|jsjt d|j | jsp|jr{t d|j |j f||j|j <|j|<|j|fd|ji|S)NT)skip_bind_expressionrNr3z@Bind parameter '%s' without a renderable value not allowed here.rNzIBind parameter '%s' conflicts with unique bind parameter of the same namezbindparam() name '%s' is reserved for automatic usage in the VALUES or SET clause of this insert/update statement. Please use a name other than column name when using bindparam() with insert() or update() (for example, 'b_%s'). expanding)r dialect_implr_has_bind_expressionbind_expressionrr4rr>r r\rrender_literal_bindparam_truncate_bindparamrrfr intersection_is_crudrrk) rr3rNr3rjrimplrnrexistingrlrlrpvisit_bindparamsp         zSQLCompiler.visit_bindparamcKs|j}|||jSr)r?r`r)rr3rrrlrlrprosz$SQLCompiler.render_literal_bindparamcCs$||j}|r ||Std|)aRender the value of a bind parameter as a quoted literal. This is used for statement sections that do not accept bind parameters on the target driver/database. This should be implemented by subclasses using the quoting services of the DBAPI. z(Don't know how to literal-quote value %r)_cached_literal_processorrr)rrr processorrlrlrpr` s z SQLCompiler.render_literal_valuecCs@||jvr |j|S|j}t|tjr|d|}||j|<|S)Nr3)rrr`rrarb)rr3 bind_namerlrlrprps     zSQLCompiler._truncate_bindparamcCs||f|jvr|j||fS||j}t||jdkrB|j|d}|dt|jdddt|dd}|d|j|<n|}||j||f<|S)Nrrrr )r apply_mapr r7r rmaxhex)r ident_classranonnamecounter truncnamerlrlrprb*s z!SQLCompiler._truncated_identifiercCs ||jSr)r rrrlrlrp _anonymize=rzSQLCompiler._anonymizecKsF|jr|dur ||n|j||rd|_d|S|jd|iS)NTz([EXPANDING_%s])r)rrrcontains_expanding_parametersr )rrpositional_namesrkrrlrlrpr@s  zSQLCompiler.bindparam_stringc s||d<t|jtjrd|j}n|j}d}d} |jvrIj|} || u} || jvs5|| ur8d}n| |jvrBj| =nt d||sM|rj|j durf|j } |j j} t| tjred| } n|} d} |r&|j|<d|j j vrdjvrjd|j j di_| jvrj| fi|| s&|jvr&|jrd_j||} |jrt|jtjr|j}nt|jtjr|jjd}nJdd t|jD}| d d fd d |D7} jrg|d<j|<| dj ||j!fi||jj"fddi|f7} |j#r!| dj ||j#fi|7} | j|<|r]|s6| r6j||S| rVj|| } j$|rMj%|}| &|7} | Sj||SdS)N visiting_cterqTFz5Multiple, unrelated CTEs found with the same name: %r autocommitrcSg|]}|dur|qSrrlrrlrlrprs z)SQLCompiler.visit_cte..rr}c3s|] }j|VqdSr)r format_column)rnrrrlrpr1s  z(SQLCompiler.visit_cte..rz AS %s %srKr)'rr`rrrarbr _restatesr r r\ _cte_aliasrrrre visit_cte recursiverr format_aliasoriginalrSelectCompoundSelectr r unique_list inner_columnsrArr_generate_prefixes _prefixesr _suffixes_requires_quotesrtget_render_as_alias_suffix)rcterKashint fromhintsrrcte_name is_new_cteembedded_in_current_named_cte existing_cte pre_alias_ctecte_pre_alias_namer col_source recur_colsrlrrprNs               zSQLCompiler.visit_ctec Ks|s|rt|jtjr|d|j}n|j}|r|j||S|rI|jj|fddi|| |j||}|rG||vrG| |||||}|S|jj|fi|S)NrqrKT) r`rrrarbrrrrrformat_from_hint_text) rrqrKriscrudrr alias_nameretrlrlrp visit_aliass0    zSQLCompiler.visit_aliascKsd|d<d|j|fi|S)NTlateralz LATERAL %s)r)rrrrlrlrp visit_lateralszSQLCompiler.visit_lateralcKsZd|j|fddi||j|fi|f}|jdur+|d|jj|fi|7}|S)Nz%s TABLESAMPLE %srKTz REPEATABLE (%s))r _get_methodrseed)r tablesamplerKrrrlrlrpvisit_tablesamples zSQLCompiler.visit_tablesamplecCsd|S)Nr~rl)ralias_name_textrlrlrprsz&SQLCompiler.get_render_as_alias_suffixcCs|j||||fdSr)rr)rkeynamerobjectsrrlrlrprrDzSQLCompiler._add_to_result_mapc sjj} | jr |s|r | } |rfdd} n d} n } |r(j} nd} |s/| } nttjrG| urDt | j j fd} nm| } nj|durW|rWt | |j fd} nZ|r|ttj r|js|jdur|tjtjs|t | tj jfd} n5ttjsttjrjrtdrttjrt | j} n| urt | tj jfd} n| } |j|| d| jfi|S)z.produce labeled columns present in a select().cs||f||dSr)r)rrrrrrrlrprfsz;SQLCompiler._label_select_column..add_to_result_mapN)rrr)rrlr_has_column_expressioncolumn_expressionrr`rLabelrrr _key_label ColumnClauserrr`rr _as_truncatedr TextClauseUnaryExpressionwraps_column_expressionhasattrrFunction anon_labelupdater) rrZrrrKcolumn_clause_argsrrNneed_column_expressionsrscol_exprrf result_exprrlrrp_label_select_columns~               z SQLCompiler._label_select_columncCs |||}|r|d|7}|Sr>)get_from_hint_text)rsqltextr`hintrhinttextrlrlrpr^s  z!SQLCompiler.format_from_hint_textcCdSrrl)rbyfromsrlrlrpget_select_hint_textdrz SQLCompiler.get_select_hint_textcCrrrlrr`rrlrlrprgrzSQLCompiler.get_from_hint_textcCrrrlrrlrlrpget_crud_hint_textjrzSQLCompiler.get_crud_hint_textcCs d|Sr>rA)r hint_textsrlrlrpget_statement_hint_textmrz#SQLCompiler.get_statement_hint_textcs"iigfdd|S)zRewrite any "a JOIN (b JOIN c)" expression as "a JOIN (select * from b JOIN c) AS anon", to support databases that can't parse a parenthesized join correctly (i.e. sqlite < 3.7.16). c s|dvr d|S|vr|S|}|<|jr|jrt|jtjr||jfi||_|jfi|}tj |j gdd }|j D] }|j |_|j|_qNtt|jj j |j }|||j j<|||j j<|||jj j<|||jj j<tdD]\}}||vr||d|<qd|||_|jfi||_|S|jrd|d<|jddi||S|jr|jr|dddk} | rՈid|d<|jddi|| rd=|S|jddi||S) NrT) use_labelsselect_containertransform_clueclone inside_selectrl)rJ is_selectable_is_joinr`rYr FromGrouping_reset_exportedrCrrrqrrrr_labelr4zipritemsronclause_is_from_container_copy_internals _is_selectrr) rrnewelemrY selectable_rtranslate_dictkvbarrier_selectclonedcolumn_translatevisitrlrprzsj         z=SQLCompiler._transform_select_for_nested_joins..visitrl)rrZrlrrp"_transform_select_for_nested_joinspsQz.SQLCompiler._transform_select_for_nested_joinscsFtdd|jDtfdd|jDfdd|jD|_dS)Ncss|]}|j|fVqdSrrrrlrlrpr1  zESQLCompiler._transform_result_map_for_nested_joins..c3s|] }|j|fVqdSrrr) inner_colrlrpr1c2g|]\}}}}||tfdd|D|fqS)csg|]}||qSrlr)rnrdrlrprzQSQLCompiler._transform_result_map_for_nested_joins...tuple)rnrrobjstyprrlrpr zFSQLCompiler._transform_result_map_for_nested_joins..)r4rr)rrZtransformed_selectrl)rrrp&_transform_result_map_for_nested_joinss  z2SQLCompiler._transform_result_map_for_nested_joinsrrc Cs^|j }|r |jn|jd}|d}|d}|r&|s&|j||dd}|S|j||d}|S)Nrrrrlexplicit_correlate_fromsimplicit_correlate_froms)rr_get_display_froms difference) rrZrKrrr%rrfromsrlrlrp_display_froms_for_selects" z%SQLCompiler._display_froms_for_selectc  sjjo| oj ojj } | r%} j| f|||dd| } j } | r.jnjd}| p@|ddp@|dd|dkrIdsRd| vrR| d=| r^r\| | S ||}|  ddd d } j r \}}|r| |d 7} nd}jr| jjfi| 7} | jfi| 7} d d fdd jDD}r|durttdd jDdd |jDfdd jD_| |||| } jrfdd jD}|r| d |7} jr | r | } jr| d jjfi| 7} jds*|r3|r3d| dS| S)NT)rKrrrnested_join_translationrrFr rrf)r_rNzSELECT rcSrrrlrrlrlrprHs   z,SQLCompiler.visit_select..c s(g|]\}}j||dqS))rrr)rnrr)rKrrrrZrrlrprJs cSg|]\}}|qSrlrlrnrrrlrlrpr_rrcSrrlrlrrlrlrpr`scr)c3s|] }||VqdSrr)rno translaterlrpr1hsz6SQLCompiler.visit_select...r)rnrrrrrrlrprgrcs$g|]\}}|djjfvr|qS*rr)rn dialect_namehtrrlrprqs rGrH)rrrsupports_right_nested_joinsr visit_selectrrr_setup_select_stackcopyr_hints_setup_select_hintsrrget_select_precolumns_columns_plus_namesr4rr_compose_select_body_statement_hintsrr rrr")rrZrKrrrrselect_wraps_forrrneeds_nested_translationrrrr%r hint_textbyfromr per_dialectrl)rKrrrrZrrrprs             zSQLCompiler.visit_selectcs.tfdd|jD}|}||fS)Nc s>g|]\\}}}|djjfvr||d|jddifqS)r rT)rrrr)rnfrom_rrrrlrprs z3SQLCompiler._setup_select_hints..)r4rrr)rrZrrrlrrprs  zSQLCompiler._setup_select_hintsc Csp|d}|d}|r|s|j||dd}n|j||d}ttj|}||} || |d} |j| |S)Nrrrlr)rrr)rrr\r _from_objectsrerr) rrZr%rKrrrrnew_correlate_fromsall_correlate_froms new_entryrlrlrprs*  zSQLCompiler._setup_select_stackcsT|d|7}|r1|d7}|jr!|dfdd|D7}n|dfdd|D7}n|7}|jdurN|jjfi}|rN|d|7}|jjr]|j|fi7}|jdurt|jjfi}|rt|d|7}|j jr|j |fi7}|j dus|j dur|j |fi7}|jdur|j|fi7}|S)Nr}z FROM cs$g|]}|jfddqS)TrKrrrnfrrrrlrprsz4SQLCompiler._compose_select_body..cs"g|] }|jfddiqS)rKTrr$rrlrprsz WHERE z HAVING )rArrF _whereclauser_group_by_clauserr _having_order_by_clauser r rr_for_update_argfor_update_clause)rrrZrrrrtrlr&rprsB         z SQLCompiler._compose_select_bodyc s*dfdd|D}|r|d7}|S)Nrc3s:|]\}}|dus|jjkr|jfiVqdSrr)rnprefixr rrlrpr1sz1SQLCompiler._generate_prefixes..r)rstmtprefixesrrrlrrprs zSQLCompiler._generate_prefixescsbjrtfddjDgj_jd}|dddjD7}|d7}|S)Ncsg|]}j|qSrl)r)rnrrrlrprsz2SQLCompiler._render_cte_clause..r, cSsg|]}|qSrlrl)rntxtrlrlrprsz )rsumr rget_cte_preamblerrAvalues)rcte_textrlrrprszSQLCompiler._render_cte_clausecCs |rdSdS)NzWITH RECURSIVEWITHrl)rrrlrlrpr4szSQLCompiler.get_cte_preamblecKs|jrdpdS)zcCalled when building a ``SELECT`` statement, position is just before column list. rr) _distinctrrZrrlrlrpr sz!SQLCompiler.get_select_precolumnscK$|jj|fi|}|rd|SdS)z5allow dialects to customize how GROUP BY is rendered.z GROUP BY r)r(r)rrZrgroup_byrlrlrpr  zSQLCompiler.group_by_clausecKr:)z5allow dialects to customize how ORDER BY is rendered.z ORDER BY r)r*r)rrZrrrlrlrpr  r<zSQLCompiler.order_by_clausecKr)Nz FOR UPDATErlr9rlrlrpr, rzSQLCompiler.for_update_clausecCrk)Nz@RETURNING is not supported by this dialect's statement compiler.rl)rr/returning_colsrlrlrpreturning_clause! rozSQLCompiler.returning_clausecKsfd}|jdur|d|j|jfi|7}|jdur1|jdur#|d7}|d|j|jfi|7}|S)Nrz LIMIT z LIMIT -1z OFFSET )r rr)rrZrrrlrlrpr' s   zSQLCompiler.limit_clausec Ksr|s|r7|j|}|r|r|j|d|j|j} n|j|j} |r5||vr5|| ||||} | SdS)Nrpr)rrvrwrtrr) rr`rKrrr use_schemarrzrrlrlrp visit_table1 s      zSQLCompiler.visit_tablecKsh|jrd}n|jr d}nd}|jj|fddi|||jj|fddi|d|jj|fi|S)Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN rKTz ON )r5isouterrCrrYr)rrArKr join_typerlrlrp visit_joinN szSQLCompiler.visit_joincsFtfdd|jD}|j|vr||j||jd}||fS)Ncs,g|]\\}}}|djjfvr||fqSr r )rnr`rrrrlrpr_ s  z1SQLCompiler._setup_crud_hints..T)r4rrr`r)rr/ table_text dialect_hintsrlrrp_setup_crud_hints] s  zSQLCompiler._setup_crud_hintsc s|j }|jtt|dtj||tjfi|}|s/|jjs/|jjs/t d|jj |j rD|jj s?t d|jj |d}n|}|j|jj}d}|jr_||j||jfi|7}|d7}|j} |jrt||| \} } || 7}|s||s|ddfd d |D7}|js|jr|||jp|j} |jr|d | 7}nd} |jdur|j|jfi|} |jr|r|jjr|d || f7}n8|d | 7}n1|s|r|d7}n(|j r|dddd|D7}nddd |D} |d| 7}|r| |_ |j!dur|j|j!fi|}|r|d |7}| r)|js)|d | 7}|jr;|r;|jjs;||}|j"d|rJd|dS|S)NrrrzWThe '%s' dialect with current database version settings does not support empty inserts.zcThe '%s' dialect with current database version settings does not support in-place multirow inserts.rzINSERT zINTO z (%s)r}csg|] }|dqS)r)rrrrlrpr sz,SQLCompiler.visit_insert..rz %s%sz %sz DEFAULT VALUESz VALUES %scss(|]}dddd|DVqdS)rr}css|]}|dVqdS)rNrlrrlrlrpr1 sz5SQLCompiler.visit_insert...Nr)rncrud_param_setrlrlrpr1  z+SQLCompiler.visit_insert..cSsg|]}|dqS)rrlrrlrlrpr rrz VALUES (%s)rrGrH)#rrr\r_setup_crud_paramsISINSERTrsupports_default_valuessupports_empty_insertr r\r_has_multi_parameterssupports_multivalues_insertrrr format_tabler`rrFrArrr>returning_precedes_valuesrZr_insert_from_selectr cte_follows_insertrinsert_single_values_expr_post_values_clauser")r insert_stmtrKrr crud_paramscrud_params_singlerMrrDrr> select_textrUpost_values_clauserlrHrp visit_insertk s               zSQLCompiler.visit_insertcCr)z3Provide a hook for MySQL to add LIMIT to the UPDATENrl)r update_stmtrlrlrpupdate_limit_clause r:zSQLCompiler.update_limit_clausecKsd|d<|j|fddi|S)z|Provide a hook to override the initial table clause in an UPDATE statement. MySQL overrides this. TrKrr)rr] from_table extra_fromsrrlrlrpupdate_tables_clause sz SQLCompiler.update_tables_clausecKtd)z~Provide a hook to override the generation of an UPDATE..FROM clause. MySQL and MSSQL override this. zCThis backend does not support multiple-table criteria within UPDATErrr]r_r` from_hintsrrlrlrpupdate_from_clause s zSQLCompiler.update_from_clausec sj }|j}t|}|r$tt|jfdd|D}|}ng}|jh}j|||dd} |j rF| j ||j fi|7} j ||j|fi|} t j |t jfi|} |jrj|| \} } nd} | | 7} | d7} |oxj| dfdd| D7} js|jrjr| d |jp|j7} |rj||j|| fi|} | r| d | 7} |jdur͈j|jfi|}|r| d |7} |}|r| d |7} js|jrjs| d |jp|j7} jr|r| } jd |r d | d S| S)Ncsg|]}|vr|qSrlrlr$) main_fromsrlrpr sz,SQLCompiler.visit_update..rGzUPDATE z SET r}c3s.|]}|djdd|dVqdS)r)rx=rNrr)rxrrlrpr1+ s z+SQLCompiler.visit_update..r WHERE rrGrH)r _extra_fromsboolr\rrr`rerrrrarrKISUPDATErrF'render_table_with_column_in_update_fromrArrrRr>rer'rr^r rr")rr]rKrrr` is_multitablerender_extra_fromsrrrDrXrEextra_from_textr-rrl)rxrfrrp visit_update s               zSQLCompiler.visit_updatecCst||jSr)r_key_getters_for_crud_columnrrrlrlrprq] sz(SQLCompiler._key_getters_for_crud_columncKrb)zProvide a hook to override the generation of an DELETE..FROM clause. This can be used to implement DELETE..USING for example. MySQL and MSSQL override this. zCThis backend does not support multiple-table criteria within DELETErrcrlrlrpdelete_extra_from_clausea s z$SQLCompiler.delete_extra_from_clausecCs|j|dddS)NT)rKrr)r delete_stmtr_r`rlrlrpdelete_table_clauseq zSQLCompiler.delete_table_clausec Ks~|j }tj||tjfi||j}|jh|}|j|||dd}|jr6||j ||jfi|7}|d7}| ||j|}|j rN| ||\} }nd} ||7}|j re|jre|d|||j 7}|r||j||j|| fi|} | r||d| 7}|jdur|jj|fi|} | r|d| 7}|j r|js|d|||j 7}|jr|r||}|jd|rd|dS|S) NrGzDELETE FROM rrhrrGrH)rrrKISDELETErir`rerrrrtrrFrrRr>rrr'rr rr") rrsrKrrr`rrrDrEror-rlrlrp visit_deletet sr         zSQLCompiler.visit_deletecCd|j|S)Nz SAVEPOINT %srformat_savepointrsavepoint_stmtrlrlrpvisit_savepoint ruzSQLCompiler.visit_savepointcCry)NzROLLBACK TO SAVEPOINT %srzr|rlrlrpvisit_rollback_to_savepoint z'SQLCompiler.visit_rollback_to_savepointcCry)NzRELEASE SAVEPOINT %srzr|rlrlrpvisit_release_savepoint rz#SQLCompiler.visit_release_savepoint)NF)NNTF)NFFN)NT)NFTr)FTr)FFF)FFNN)FFFNNTF)FTNrFNF)FFFNT)rrrr EXTRACT_MAPrCOMPOUND_KEYWORDSrrrrrrrRrlrr4rr!rrUrrrrrr memoized_instancemethodr contextlibcontextmanagerr&rmemoized_propertyr5r8rrr dependenciesrDrFrLrXr]rjrnr}rrrrrrsrrrrrrrrrrrrrrrrrrrrrr!r#r(r*r.r0r2r%r;r<r=r?rAr7rrrGrOrSrVrXrYrZrLrRrcrdrhriruror`rprbrrrrrrrrrrrrrrrrr frozensetrrrrrrrrr4rr r r,r>rr@rCrFr\r^rarerprqrrrtrxr~rrrlrlrlrprs  H       8    #  1 (   " 3            =    !    \]  6       p f  Jrc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)StrSQLCompilerawA :class:`.SQLCompiler` subclass which allows a small selection of non-standard SQL features to render into a string value. The :class:`.StrSQLCompiler` is invoked whenever a Core expression element is directly stringified without calling upon the :meth:`.ClauseElement.compile` method. It can render a limited set of non-standard SQL constructs to assist in basic stringification, however for more substantial custom or dialect-specific SQL constructs, it will be necessary to make use of :meth:`.ClauseElement.compile` directly. .. seealso:: :ref:`faq_sql_expression_string` cCr)Nzrlrmrlrlrprn rz$StrSQLCompiler._fallback_column_namecKs,d|j|jfi||j|jfi|fS)Nz%s[%s])rrCrYr'rlrlrpvisit_getitem_binary rz#StrSQLCompiler.visit_getitem_binarycK|j||fi|Srrr'rlrlrpvisit_json_getitem_op_binary rz+StrSQLCompiler.visit_json_getitem_op_binarycKrrrr'rlrlrp!visit_json_path_getitem_op_binary rz0StrSQLCompiler.visit_json_path_getitem_op_binarycKry)Nz)rformat_sequence)rseqrrlrlrpr ruzStrSQLCompiler.visit_sequencecs&fddt|D}dd|S)Nc sg|] }d|ddiqSrrrrrlrpr sz3StrSQLCompiler.returning_clause..z RETURNING r})r_select_iterablesrA)rr/r=columnsrlrrpr> s zStrSQLCompiler.returning_clausec s ddfdd|DS)Nrvr}c3(|]}|jfddVqdSTr#Nrrnr-rdrrrlrpr1 rJz4StrSQLCompiler.update_from_clause..rrcrlrrpre  z!StrSQLCompiler.update_from_clausec s ddfdd|DS)Nr}c3rrrrrrlrpr1 rJz:StrSQLCompiler.delete_extra_from_clause..rrcrlrrprr rz'StrSQLCompiler.delete_extra_from_clauseN) rrrrrnrrrrr>rerrrlrlrlrpr s rc@sNeZdZejddZejddZdNddZdd Zd d Z d d Z ddZ dOddZ dNddZ ddZddZddZ dPddZddZdOd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dS)Q DDLCompilercCs|j|jdSr)rstatement_compilerrrlrlrpr rzDDLCompiler.sql_compilercCrr)rrrrlrlrpr rzDDLCompiler.type_compilerNcCrrrlrrlrlrpr rzDDLCompiler.construct_paramscKs|j}t|jtjrD|}|j}||j}t|dkr%|dd}}n |d|d}}| d|| d|| d| |j|j |j |S)Nrrrrr`rfullname)contextr`targetrTablerrformat_table_seqr7 setdefaultrQrrr)rddlrrrpathr`schrlrlrp visit_ddl s    zDDLCompiler.visit_ddlcCs|j|j}d|S)NzCREATE SCHEMA )r format_schemar)rr!rrlrlrpvisit_create_schema( szDDLCompiler.visit_create_schemacCs(|j|j}d|}|jr|d7}|S)Nz DROP SCHEMA  CASCADE)rrrcascade)rdroprrrlrlrpvisit_drop_schema, s zDDLCompiler.visit_drop_schemac CsJ|j}|j}d}|jr|d|jd7}|d||d7}||}|r-||d7}|d7}d}d}|jD]O}|j} z"|j|| joF| d} | durY||7}d}|d | 7}| jr^d }Wq8t j y} zt t t d |j| j| jd fWYd} ~ q8d} ~ ww|j||jd } | r||d | 7}|d||7}|S)Nz CREATE rzTABLE rG Ffirst_pkr1 Tz (in table '%s', column '%s'): %sr) _include_foreign_key_constraintsz )%s )rrrrArQcreate_table_suffixrr primary_keyr r\r raise_from_causeu descriptionrargscreate_table_constraintsinclude_foreign_key_constraintspost_create_table) rr!r`rrr separatorr create_columnr processedceconstrlrlrpvisit_create_table3 sV     zDDLCompiler.visit_create_tableFcsL|j}|jrdSj||d}dfdd|jD}|r$|d|7}|S)Nrrc3s|]}|VqdSr)rrnr rrlrpr1k rz2DDLCompiler.visit_create_column..)rsystemget_column_specificationrA constraints)rr!rrrrrlrrpvisit_create_columnd s zDDLCompiler.visit_create_columncstg}jr |jj}|dur||nt|fddjDdddfdd|DDS)Ncs"g|] }|jur|vr|qSrl)rr) omit_fkcsr`rlrpr s z8DDLCompiler.create_table_constraints..z, css|] }|dur|VqdSrrl)rnprlrlrpr1 s  z7DDLCompiler.create_table_constraints..c3sB|]}|jdus|rjjrt|dds|VqdS)N use_alterF) _create_rulersupports_alterrrrrrlrpr1 s  )rrforeign_key_constraintsrr\extend_sorted_constraintsrA)rr`rrall_fkcsrl)rrr`rprs s"     z$DDLCompiler.create_table_constraintscCd|j|jS)Nz DROP TABLE rrQrrrrlrlrpvisit_drop_table rzDDLCompiler.visit_drop_tablecCr)Nz DROP VIEW rrrlrlrpvisit_drop_view rzDDLCompiler.visit_drop_viewcCs|jdur td|jdS)Nz,Index '%s' is not associated with any table.)r`r r\rrrrlrlrp_verify_index_table s zDDLCompiler._verify_index_tableTc s~|j}|j}d}|jr|d7}|jdurtd|dj||d|j|j |dd fdd |j Df7}|S) NzCREATE zUNIQUE z0CREATE INDEX requires that the index have a namezINDEX %s ON %s (%s)include_schemar?r}c3s"|] }jj|dddVqdS)FTrxr3N)rr)rnrrrlrpr1 s z1DDLCompiler.visit_create_index..) rrrrfrr r\_prepared_index_namerQr`rA expressions)rr!rinclude_table_schemarrrrlrrpvisit_create_index s(    zDDLCompiler.visit_create_indexcCs,|j}|jdur tdd|j|ddS)Nz.DROP INDEX requires that the index have a namez DROP INDEX Tr)rrr r\r)rrrrlrlrpvisit_drop_index s zDDLCompiler.visit_drop_indexcCsX|jdur |j|j}nd}|r|r|j|}nd}|j|}|r*|d|}|SNrp)r`rrvrw format_index)rrrrz schema_name index_namerlrlrpr s   z DDLCompiler._prepared_index_namecCs d|j|jj||jfS)NzALTER TABLE %s ADD %s)rrQrr`rrr!rlrlrpvisit_add_constraint s z DDLCompiler.visit_add_constraintcCs(d|j|j|j|jjtfS)NzCOMMENT ON TABLE %s IS %s)rrQrrr`commentr Stringrrlrlrpvisit_set_table_comment s   z#DDLCompiler.visit_set_table_commentcCd|j|jS)NzCOMMENT ON TABLE %s IS NULLrrrlrlrpvisit_drop_table_comment sz$DDLCompiler.visit_drop_table_commentcCs.d|jj|jddd|j|jjtfS)NzCOMMENT ON COLUMN %s IS %sT) use_tabler?)rrrrr`rr rrrlrlrpvisit_set_column_comment s z$DDLCompiler.visit_set_column_commentcCsd|jj|jddS)NzCOMMENT ON COLUMN %s IS NULLT)r)rrrrrlrlrpvisit_drop_column_comment sz%DDLCompiler.visit_drop_column_commentcCsd|j|j}|jjdur|d|jj7}|jjdur%|d|jj7}|jjdur3|d|jj7}|jjdurA|d|jj7}|jjdurK|d7}|jjdurU|d7}|jj durc|d|jj 7}|jj d urm|d 7}|jj durw|d 7}|S) NzCREATE SEQUENCE %sz INCREMENT BY %dz START WITH %dz MINVALUE %dz MAXVALUE %dz NO MINVALUEz NO MAXVALUEz CACHE %dTz ORDERz CYCLE) rrr incrementstartminvaluemaxvalue nominvalue nomaxvaluecacherScycle)rr!rrlrlrpvisit_create_sequence s,         z!DDLCompiler.visit_create_sequencecCr)NzDROP SEQUENCE %s)rrrrrlrlrpvisit_drop_sequence rzDDLCompiler.visit_drop_sequencecCs^|j}|jdur|j|}nd}|durtd|jd|j|jj||jr+dp,dfS)Nz.) r7rrrrA_implicit_generatedcolumns_autoinc_firstrrr rlrrpvisit_primary_key_constraintk s     z(DDLCompiler.visit_primary_key_constraintc s|jd}|jdur|j|}|dur|d|7}t|jdjj}|ddfdd|jD|||dfdd|jDf7}|| |7}|| |7}|| |7}|S) Nrrrz"FOREIGN KEY(%s) REFERENCES %s (%s)r}c3|] }|jjVqdSr)rtparentrr$rHrlrpr1  z;DDLCompiler.visit_foreign_key_constraint..c3rr)rtrrr$rHrlrpr1 r) rrrrrrr`rAdefine_constraint_remote_tabledefine_constraint_matchdefine_constraint_cascadesr)rr rr remote_tablerlrHrpvisit_foreign_key_constraint s,    z(DDLCompiler.visit_foreign_key_constraintcCs ||S)z=Format the remote table clause of a CREATE CONSTRAINT clause.)rQ)rr r`rrlrlrpr rz*DDLCompiler.define_constraint_remote_tablecspt|dkrdSd}|jdurj|}|dur|d|7}|ddfdd|D7}||7}|S)Nrrrz UNIQUE (%s)r}c3r rrrrrlrpr1 rz6DDLCompiler.visit_unique_constraint..)r7rrrrArr rlrrpvisit_unique_constraint s    z#DDLCompiler.visit_unique_constraintcCsLd}|jdur|d|j|jt7}|jdur$|d|j|jt7}|S)Nrz ON DELETE %sz ON UPDATE %s)ondeletervalidate_sql_phrase FK_ON_DELETEonupdate FK_ON_UPDATErr rrlrlrpr s    z&DDLCompiler.define_constraint_cascadescCsLd}|jdur|jr|d7}n|d7}|jdur$|d|j|jt7}|S)Nrz DEFERRABLEz NOT DEFERRABLEz INITIALLY %s)r)r;rr FK_INITIALLYr rlrlrpr s    z+DDLCompiler.define_constraint_deferrabilitycCs d}|jdur|d|j7}|S)Nrz MATCH %s)matchr rlrlrpr s z#DDLCompiler.define_constraint_matchcCsDd|jj|jddd}|jdur|d7}|S|jdur |d7}|S)NzGENERATED ALWAYS AS (%s)FTrz STOREDz VIRTUAL)rrr persisted)r generatedrrlrlrpvisit_computed_column s  z!DDLCompiler.visit_computed_columnrr)FT)*rrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrr r rrrrrrrr%rlrlrlrpr sT    1 )        rc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUS)VGenericTypeCompilercKr)NFLOATrlrrlrlrp visit_FLOAT rzGenericTypeCompiler.visit_FLOATcKr)NREALrlrrlrlrp visit_REAL rzGenericTypeCompiler.visit_REALcK8|jdurdS|jdurdd|jiSd|j|jdS)NNUMERICzNUMERIC(%(precision)s) precisionz!NUMERIC(%(precision)s, %(scale)s)r-scaler.rrlrlrp visit_NUMERIC   z!GenericTypeCompiler.visit_NUMERICcKr+)NDECIMALzDECIMAL(%(precision)s)r-z!DECIMAL(%(precision)s, %(scale)s)r.r.rrlrlrp visit_DECIMAL r1z!GenericTypeCompiler.visit_DECIMALcKr)NINTEGERrlrrlrlrp visit_INTEGER rz!GenericTypeCompiler.visit_INTEGERcKr)NSMALLINTrlrrlrlrpvisit_SMALLINT rz"GenericTypeCompiler.visit_SMALLINTcKr)NBIGINTrlrrlrlrp visit_BIGINT rz GenericTypeCompiler.visit_BIGINTcKr)N TIMESTAMPrlrrlrlrpvisit_TIMESTAMP rz#GenericTypeCompiler.visit_TIMESTAMPcKr)NDATETIMErlrrlrlrpvisit_DATETIME rz"GenericTypeCompiler.visit_DATETIMEcKr)NDATErlrrlrlrp visit_DATE rzGenericTypeCompiler.visit_DATEcKr)NTIMErlrrlrlrp visit_TIME rzGenericTypeCompiler.visit_TIMEcKr)NCLOBrlrrlrlrp visit_CLOB rzGenericTypeCompiler.visit_CLOBcKr)NNCLOBrlrrlrlrp visit_NCLOB rzGenericTypeCompiler.visit_NCLOBcCs0|}|jr |d|j7}|jr|d|j7}|S)N(%d)z COLLATE "%s")lengthr)rrrrrlrlrp_render_string_type s z'GenericTypeCompiler._render_string_typecK ||dS)NCHARrHrrlrlrp visit_CHAR rzGenericTypeCompiler.visit_CHARcKrI)NNCHARrKrrlrlrp visit_NCHAR rzGenericTypeCompiler.visit_NCHARcKrI)NVARCHARrKrrlrlrp visit_VARCHAR rz!GenericTypeCompiler.visit_VARCHARcKrI)NNVARCHARrKrrlrlrpvisit_NVARCHAR rz"GenericTypeCompiler.visit_NVARCHARcKrI)NTEXTrKrrlrlrp visit_TEXT! rzGenericTypeCompiler.visit_TEXTcKr)NBLOBrlrrlrlrp visit_BLOB$ rzGenericTypeCompiler.visit_BLOBcKd|jr d|jp dS)NBINARYrFrrGrrlrlrp visit_BINARY' rDz GenericTypeCompiler.visit_BINARYcKrW)N VARBINARYrFrrYrrlrlrpvisit_VARBINARY* rDz#GenericTypeCompiler.visit_VARBINARYcKr)NBOOLEANrlrrlrlrp visit_BOOLEAN- rz!GenericTypeCompiler.visit_BOOLEANcK|j|fi|Sr)rVrrlrlrpvisit_large_binary0 rz&GenericTypeCompiler.visit_large_binarycKr_r)r^rrlrlrp visit_boolean3 rz!GenericTypeCompiler.visit_booleancKr_r)rArrlrlrp visit_time6 rzGenericTypeCompiler.visit_timecKr_r)r=rrlrlrpvisit_datetime9 rz"GenericTypeCompiler.visit_datetimecKr_r)r?rrlrlrp visit_date< rzGenericTypeCompiler.visit_datecKr_r)r9rrlrlrpvisit_big_integer? rz%GenericTypeCompiler.visit_big_integercKr_r)r7rrlrlrpvisit_small_integerB rz'GenericTypeCompiler.visit_small_integercKr_r)r5rrlrlrp visit_integerE rz!GenericTypeCompiler.visit_integercKr_r)r*rrlrlrp visit_realH rzGenericTypeCompiler.visit_realcKr_r)r(rrlrlrp visit_floatK rzGenericTypeCompiler.visit_floatcKr_r)r0rrlrlrp visit_numericN rz!GenericTypeCompiler.visit_numericcKr_rrPrrlrlrp visit_stringQ rz GenericTypeCompiler.visit_stringcKr_rrkrrlrlrp visit_unicodeT rz!GenericTypeCompiler.visit_unicodecKr_rrTrrlrlrp visit_textW rzGenericTypeCompiler.visit_textcKr_rrnrrlrlrpvisit_unicode_textZ rz&GenericTypeCompiler.visit_unicode_textcKr_rrkrrlrlrp visit_enum] rzGenericTypeCompiler.visit_enumcKstd|)NzKCan't generate DDL for %r; did you forget to specify a type on this Column?rlrrlrlrpr` s zGenericTypeCompiler.visit_nullcKs|j||jfi|Sr)r type_enginerrrlrlrpvisit_type_decoratorg sz(GenericTypeCompiler.visit_type_decoratorcKs|jdi|S)Nrl) get_col_specrrlrlrpvisit_user_definedj ruz&GenericTypeCompiler.visit_user_definedN)-rrrr(r*r0r3r5r7r9r;r=r?rArCrErHrLrNrPrRrTrVrZr\r^r`rarbrcrdrerfrgrhrirjrlrmrorprqrrsrurlrlrlrpr& sV    r&c@seZdZddZddZdS)StrSQLTypeCompilercCs|dr|jSt|)Nvisit_) startswith_visit_unknownAttributeError)rrrlrlrp __getattr__o s zStrSQLTypeCompiler.__getattr__cKs d|jjS)Nz%s)rrrrlrlrpryu rz!StrSQLTypeCompiler._visit_unknownN)rrrr{ryrlrlrlrprvn s rvc@seZdZdZeZeZeZ e dZ     d5ddZ dd Zd d Zd d ZddZddZddZddZd6ddZd6ddZddZd7ddZd6ddZd6d d!Zd6d"d#Zed$d%d&Zd'd(Zd8d)d*Z d+d,Z!    d9d-d.Z"d7d/d0Z#ej$d1d2Z%d3d4Z&dS):IdentifierPreparerz@Handle quoting and case-folding of identifiers based on options.N"TFcCsN||_||_|p |j|_||_|jd|_||_||_i|_|jjdv|_ dS)asConstruct a new ``IdentifierPreparer`` object. initial_quote Character that begins a delimited identifier. final_quote Character that ends a delimited identifier. Defaults to `initial_quote`. omit_schema Prevent prepending schema name. Useful for databases that do not support schemae. r )rxrvN) r initial_quote final_quote escape_quoteescape_to_quote omit_schemaquote_case_sensitive_collations_stringsrr)rrr~rrrrrlrlrpr s  zIdentifierPreparer.__init__cCs,|j|j}|j|jt||_|Sr)r__new____dict__rr_schema_getterrv)rrpreprlrlrpr s z)IdentifierPreparer._with_schema_translatecCs&||j|j}|jr|dd}|S)zEscape an identifier. Subclasses should override this to provide database-dependent escaping behavior. rr)rrrrrrrlrlrp_escape_identifier s z%IdentifierPreparer._escape_identifiercCs||j|jS)zCanonicalize an escaped identifier. Subclasses should override this to provide database-dependent unescaping behavior that reverses _escape_identifier. )rrrrrlrlrp_unescape_identifier sz'IdentifierPreparer._unescape_identifiercCs*|dur||std||jf|S)zkeyword sequence filter. a filter for elements that are intended to represent keyword sequences, such as "INITIALLY", "INITIALLY DEFERRED", etc. no special characters should be present. .. versionadded:: 1.3 Nz/Unexpected SQL phrase: %r (matching against %r))r"r r\pattern)rrregrlrlrpr s z&IdentifierPreparer.validate_sql_phrasecCs|j|||jS)z~Quote an identifier. Subclasses should override this to provide database-dependent quoting behavior. )r~rrrrlrlrpquote_identifier s z#IdentifierPreparer.quote_identifiercCs<|}||jvp|d|jvp|jt| p||kS)z5Return True if the given identifier requires quoting.r)rreserved_wordsillegal_initial_characterslegal_charactersr"r text_type)rrlc_valuerlrlrpr s  z#IdentifierPreparer._requires_quotescCs|jt| S)zjReturn True if the given identifier requires quoting, but not taking case convention into account.)rr"r rrrlrlrpr sz1IdentifierPreparer._requires_quotes_illegal_charscCs|dur td||S)aConditionally quote a schema name. The name is quoted if it is a reserved word, contains quote-necessary characters, or is an instance of :class:`.quoted_name` which includes ``quote`` set to ``True``. Subclasses can override this to provide database-dependent quoting behavior for schema names. :param schema: string schema name :param force: unused .. deprecated:: 0.9 The :paramref:`.IdentifierPreparer.quote_schema.force` parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the :meth:`.IdentifierPreparer.quote` method; please refer to :class:`.quoted_name`. NzThe IdentifierPreparer.quote_schema.force parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().)r warn_deprecatedrt)rrforcerlrlrprw s  zIdentifierPreparer.quote_schemacCs||dur tdt|dd}|dur5||jvr|j|S||r+|||j|<n||j|<|j|S|r<||S|S)aConditionally quote an identfier. The identifier is quoted if it is a reserved word, contains quote-necessary characters, or is an instance of :class:`.quoted_name` which includes ``quote`` set to ``True``. Subclasses can override this to provide database-dependent quoting behavior for identifier names. :param ident: string identifier :param force: unused .. deprecated:: 0.9 The :paramref:`.IdentifierPreparer.quote.force` parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the :meth:`.IdentifierPreparer.quote` method; please refer to :class:`.quoted_name`. NzThe IdentifierPreparer.quote.force parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().rt)r rrrrr)rrrrlrlrprts       zIdentifierPreparer.quotecCs|jr||S|Sr)rrt)rcollation_namerlrlrpr~Is z#IdentifierPreparer.format_collationcCs>||j}||}|js|r|dur||d|}|Sr)rtrrvrrw)rrr?rrzrlrlrprOs  z"IdentifierPreparer.format_sequencecC||p|jSrrtr)rrrrlrlrpre\ruzIdentifierPreparer.format_labelcCrrr)rrqrrlrlrpr_ruzIdentifierPreparer.format_aliascCs"|p|j}||r||}|Sr)rrr)r savepointrrrlrlrpr{bs   z#IdentifierPreparer.format_savepointzsqlalchemy.sql.namingcCst|jtjr|||j}|durt|jtjrdS|j}n|j}t|tjrT|jdkr6|j j p4|j j }n|j j }t ||krS|d|ddt |dd}n|j |||S)Nrrr)r`rr _defer_name_constraint_name_for_tabler`_defer_none_namerarrmax_index_name_lengthr r7r md5_hexvalidate_identifierrt)rnamingr rmax_rlrlrprks*   &  z$IdentifierPreparer.format_constraintcC ||Sr)rrrlrlrprrzIdentifierPreparer.format_indexcCsF|dur|j}||}||}|js!|r!|r!||d|}|S)z'Prepare a quoted table and schema name.Nrp)rrtrvrrw)rr`r?rrErzrlrlrprQs  zIdentifierPreparer.format_tablecCr)zPrepare a quoted schema name.)rtrrlrlrprrz IdentifierPreparer.format_schemacCsj|dur|j}t|dds$|r|j|j||dd||S||S|r3|j|j||dd|S|S)zPrepare a quoted column name.NrrF)r?rrp)rrrQr`rt)rrrr table_namer?rlrlrprs.   z IdentifierPreparer.format_columncCs@||}|js|r|r|||j|ddfS|j|ddfS)z(Format table name and schema as a tuple.Fr)rvrrwrQ)rr`r?rzrlrlrprs  z#IdentifierPreparer.format_table_seqcCs@dd|j|j||jfD\}}}td|||d}|S)NcSsg|]}t|qSrl)r/r\rrlrlrprz5IdentifierPreparer._r_identifiers..zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)initialfinalescaped)r~rrr/r)rrr escaped_finalrrlrlrp_r_identifierss   z!IdentifierPreparer._r_identifierscs(j}fdddd||DDS)z:Unpack 'schema.table.column'-like strings into components.csg|]}|qSrl)r)rnrrrlrprrz;IdentifierPreparer.unformat_identifiers..cSsg|]\}}|p |qSrlrl)rnabrlrlrprr)rfindall)r identifiersrrlrrpunformat_identifierss z'IdentifierPreparer.unformat_identifiers)r}Nr}TFr)T)TN)FNNF)'rrrrRESERVED_WORDSrLEGAL_CHARACTERSrILLEGAL_INITIAL_CHARACTERSrrrrvrrrrrrrrrwrtr~rrerr{r rrrrQrrrrrrrlrlrlrpr|y sP  $     %2       &  r|)lrrr-r/rrrrrrrr r r r r\rrIrLEGAL_CHARACTERS_PLUS_SPACErangererrrr!UNICODErrrand_or_addmulr0divmodtruedivnegltlenegtgeeqis_distinct_fromisnot_distinct_from concat_opr& notmatch_opin_opnotin_opcomma_oprrdis_isnotrexists distinct_opinvany_opall_opdesc_opasc_op nullsfirst_op nullslast_oprcrr#r%r&r'rFrGrrr[rgcuberollup grouping_setsrrrr UNION_ALLr EXCEPT_ALLr INTERSECT_ALLrobjectrwith_metaclassEnsureKWArgTyper Visitablerr4rrrrr&rvr|rlrlrlrpsf          c       !"#%&,   !=N