g}4UdZddlmZddlZddlmZddlZddlm Z ddl Z ddl Z ddl Z ddl Z ddlmZddlZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*dd l&m+Z+dd!l&m,Z,dd"l&m-Z-dd#l&m.Z.dd$l&m/Z/dd%l&m0Z0dd&l&m1Z2dd'l3m4Z4dd(l3m5Z5dd)l'm6Z6dd*l'm7Z7dd+l'm8Z8dd,l'm9Z9dd-l'm:Z:dd.l'm;Z;dd/l*mZ>dd2l0m?Z?dd3l@mAZAdd4lBmCZCdd5lBmDZDd6d7l&mEZEd6d&l&m1Z1d6d8l1mFZFd6d9lGmHZHd6d:lGmIZId6d;lGmJZJejHrddl'mNZNdd?lOmPZPdd@lQmRZRddAlSmTZTddBlSmUZUddClSmVZVddDl*mWZWddEl*mXZXddFl*mYZYddGl*mZZZddHl*m[Z[ddIl+m\Z\ddJl.m]Z]ddKl/m^Z^ddLl/m_Z_ddMl/m`Z`ddNl/maZaddOl/mbZbddPl/mcZcddQl/mdZdddRl/meZeddSl@mfZfd6dTlgmhZhd6dUlimjZjd6dVlimkZkd6dWlimlZld6dXlimmZmd6dYlimnZnd6dZlimoZod6d[limpZpd6d\limqZqd6d]limrZred^esfZthd_Zue jd`e jZxe jdae jZyezddbDchc] }es| c}jdcgZ|e jdde jZ}e jdde jZ~e jdee jZe jdfe jZe jdge jZdhZedidjdkdldmdnZie,j doe,j dpe,jdqe,jdre,jdse,jdte,jdue,jdve,jdwe,jdxe,jdye,j dze,j"d{e,j$d|e,j&d}e,j(d~e,j*die,j,de,j.de,j0de,j2de,j4de,j6de,j8de,j:de,j<de,j>de,j@de,jBde,jDde,jFde,jHde,jJde,jLde,jNde,jPde,jRde,jTde,jVde,jXde,jZdiZe+j^de+j`de+jbde+jdde+jfde+jhde+jjde+jlde+jnde+jpde+jrde+jtde+jvde+jxdiZded<ddddddddddddddddZe/jjde/jjde/jjde/jjde/jjde/jjdiZGddeZGddeIZdZded<dZded<d6Zded<dZded<Gd˄deJZGd̈́dedϬЫZGdфdeZGdӄdeZGdՄdeZGdׄdeFZGdلde ZGdۄde Zeeի\ZZZZGd݄dejdddgZGddZGdde1jZGdde-jee*jZGdde-jee*jZGddeݫZGddeZGddeݫZGdde߫ZGddeZGddeIZGddeIZGddZycc}w)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`. ) annotationsN)IntEnum) perf_counter)Any)Callable)cast)ClassVar)Dict) FrozenSet)Iterable)Iterator)List)Mapping)MutableMapping) NamedTuple)NoReturn)Optional)Pattern)Sequence)Set)Tuple)Type) TYPE_CHECKING)Union)base) coercions)crud)elements) functions) operators)roles)schema) selectable)sqltypes)util)is_column_element)is_dml) _de_clone) _from_objects) _NONE_NAME) _SentinelDefaultCharacterization) Executable)NO_ARG) ClauseElement) quoted_name)Column) TupleType) TypeEngine)prefix_anon_map) Visitable)exc) FastIntFlag)Literal)Protocol) TypedDict)_AnnotationDict)_AmbiguousTableNameMap) CompileState)CacheKey)ExecutableDDLElement)Insert) UpdateBase) ValuesBase)_truncated_label) BindParameter) ColumnClause) ColumnElement)Label)Function)Table)AliasedReturnsRows)CompoundSelectState)CTE) FromClause)NamedFromClause) ReturnsRows)Select) SelectState)_BindProcessorType)CursorResultMetaData)_CoreSingleExecuteParams)_DBAPIAnyExecuteParams)_DBAPIMultiExecuteParams)_DBAPISingleExecuteParams)_ExecuteOptions)_GenericSetInputSizesType)_MutableCoreSingleExecuteParams)Dialect)SchemaTranslateMapTyperN>^asdoinisonortoallandanyascendfornewnotoffoldsetbothcaserdescelsefromfullintojoinleftlikenullonlysomethentrueuserwhenarraycheckcrossfalsegrantgroupilikeinnerlimitorderouterrighttableunionusingwherebinarycolumncreateexceptfreezehavingisnulloffsetselectuniqueanalyseanalyzebetweencollatedefaultforeignleadingnaturalnotnullplacingprimarysimilarverbosedistinctoverlapstrailing initially intersect localtime symmetric asymmetric constraint deferrable references current_date current_role current_time current_user session_user authorizationlocaltimestampcurrent_timestampz ^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$ $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 ,  FROM  AS  IS z IS NOT z COLLATE zEXISTS DISTINCT zNOT zANY zALL z DESCz ASCz NULLS FIRSTz NULLS LASTz ^ z | z & ~z << z >> coalesce CURRENT_DATE CURRENT_TIMECURRENT_TIMESTAMP CURRENT_USER LOCALTIMELOCALTIMESTAMPrandomsysdate SESSION_USERUSERCUBEROLLUPz GROUPING SETSzDict[Type[Function[Any]], str] FUNCTIONSmonthdayyearsecondhourdoyminutequarterdowweekepoch milliseconds microseconds timezone_hourtimezone_minute)rrrrrrrrrrrrrrrUNIONz UNION ALLEXCEPTz EXCEPT ALL INTERSECTz INTERSECT ALLc@eZdZUdZded< ded< ded< ded<y ) ResultColumnsEntryaTracks a column expression that is expected to be represented in the result rows for this statement. This normally refers to the columns clause of a SELECT statement but may also refer to a RETURNING clause, as well as for dialect-specific emulations. strkeynamenameTuple[Any, ...]objectsTypeEngine[Any]typeN__name__ __module__ __qualname____doc____annotations__H/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/compiler.pyrr[s1L; I%  rrc(eZdZ ddZy)_ResultMapAppendercyNrselfrrrtype_s r__call__z_ResultMapAppender.__call__{s rN) rrrrrz Sequence[Any]rrreturnNonerrrrrrrrrzs7     rrz Literal[0]RM_RENDERED_NAMEz Literal[1]RM_NAMEz Literal[2] RM_OBJECTSz Literal[3]RM_TYPEc,eZdZUded<ded<ded<y)_BaseCompilerStackEntryzSet[FromClause] asfrom_fromscorrelate_fromsrPr$Nrrrrrrrrrs!!$$rrc@eZdZUded<ded<ded<ded<ded <y ) _CompilerStackEntryr> compile_stateboolneed_result_map_for_nestedneed_result_map_for_compoundrPselect_0 Select[Any]insert_from_selectNrrrrrrs  $$"&&##rrF)totalcreZdZUdZded< ded< ded< ded < d ed < edd Zedd Zy) ExpandedStatearepresents state to use when producing "expanded" and "post compile" bound parameters for a statement. "expanded" parameters are parameters that are generated at statement execution time to suit a number of parameters passed, the most prominent example being the individual elements inside of an IN expression. "post compile" parameters are parameters where the SQL literal value will be rendered into the SQL statement at execution time, rather than being passed as separate parameters to the driver. To create an :class:`.ExpandedState` instance, use the :meth:`.SQLCompiler.construct_expanded_state` method on any :class:`.SQLCompiler` instance. r statementrU parameters%Mapping[str, _BindProcessorType[Any]] processorsOptional[Sequence[str]] positiontupzMapping[str, List[str]]parameter_expansioncjtjdtfdjDS)zrTuple of positional parameters, for statements that were compiled using a positional paramstyle. z.statement does not use a positional paramstylec3<K|]}j|ywrr!).0keyrs r z6ExpandedState.positional_parameters..sF5EcT__S)5Es)r%r7InvalidRequestErrortuplers`rpositional_parametersz#ExpandedState.positional_parameterss@    #))@ FT5E5EFFFrc|jS)z.synonym for :attr:`.ExpandedState.parameters`.r)r/s radditional_parametersz#ExpandedState.additional_parameterssrN)rr)rrU)rrrrrpropertyr0r2rrrrrsi"N=((65+((10 G GrrceZdZUdZded< ded< ded< ded < d Zded < d Zded < d Zded< dZded< d Z ded< d Z ded< d Z ded<y )_InsertManyValuesarepresents state to use for executing an "insertmanyvalues" statement. The primary consumers of this object are the :meth:`.SQLCompiler._deliver_insertmanyvalues_batches` and :meth:`.DefaultDialect._deliver_insertmanyvalues_batches` methods. .. versionadded:: 2.0 ris_default_exprrsingle_values_exprList[crud._CrudParamElementStr]insert_crud_paramsintnum_positional_params_countedFsort_by_parameter_orderincludes_upsert_behaviorsNOptional[Sequence[Column[Any]]]sentinel_columnsrnum_sentinel_columnsr$sentinel_param_keysimplicit_sentinelembed_values_counter) rrrrrr<r=r?r@rArBrCrrrr5r5s 87M#&& %*T)',t+9=5<!"#!4807 $t# "'$& rr5cveZdZUdZded<ded<ded<ded <d ed <d ed <d ed<d ed<ded<ded<y)_InsertManyValuesBatchasrepresents an individual batch SQL statement for insertmanyvalues. This is passed through the :meth:`.SQLCompiler._deliver_insertmanyvalues_batches` and :meth:`.DefaultDialect._deliver_insertmanyvalues_batches` methods out to the :class:`.Connection` within the :meth:`.Connection._exec_insertmany_context` method. .. versionadded:: 2.0.10 rreplaced_statementrVreplaced_parameters#Optional[_GenericSetInputSizesType]processed_setinputsizesz#Sequence[_DBAPISingleExecuteParams]batchzSequence[Tuple[Any, ...]]sentinel_valuesr:current_batch_sizebatchnum total_batchesr rows_sorted is_downgradedNrrrrrErENsD //@@ ....MrrEcBeZdZdZdZdZdZdZeezezZeezZ dZ dZ y) InsertmanyvaluesSentinelOptszcbitflag enum indicating styles of PK defaults which can work as implicit sentinel columns rr6@N) rrrr NOT_SUPPORTED AUTOINCREMENTIDENTITYSEQUENCEANY_AUTOINCREMENT_SUPPORTED_OR_NOTUSE_INSERT_FROM_SELECTRENDER_SELECT_COL_CASTSrrrrRrRgsE MMHH%08;%(99 rrRceZdZdZ dZ dZy) CompilerStaterrr6N)rrr COMPILINGSTRING_APPLIED NO_STATEMENTrrrr`r`ys I=N Lrr`c,eZdZdZdZ dZ dZ eezZy)Lintingzrepresent preferences for the 'SQL linting' feature. this feature currently includes support for flagging cartesian products in SQL statements. rrr6N)rrrr NO_LINTINGCOLLECT_CARTESIAN_PRODUCTS WARN_LINTING FROM_LINTINGrrrreres5J!"L2- .s#NIDTdjj&6"67I") fromsroedgesremovepop collectionsdequepopleftdiscard extendleftdifference_update) rstartrsrtthe_rest start_withstackrp to_removerqs @rlintzFromLinter.lints DJJu:  J OOJ '!J!!:,/==?D   T " +0@%$44<%I@   NIN N  # #I . Z' 'As  C Ccj\}}|rX|}|rSd}djfd|D}|j||j|}t j |yyy)Nz{stmt_type} statement has a cartesian product between FROM element(s) {froms} and FROM element "{start}". Apply join condition(s) between each element to resolve.rc3DK|]}dj|dyw)"N)rs)r*from_rs rr,z"FromLinter.warn..s(&:?a 5)*!,% ) stmt_typersr})rrwrrsr&warn)rrr~rrstemplate froms_strmessages` rrzFromLinter.warns#yy{* E7 !II&:?& #//'#**Z0*  '"! rr)SELECT)rrrrrrrrrrkrks#J#rrkrsrtceZdZUdZdZded< dZded< ded < d Zd ZdZ d ed <dZ d ed<dZ ded<e jZded< ded<e jZded<dZded< dZded< dZded< ded< dd e j&f d(dZd)fd Zed Zd!Zd"Zed#Zd*d$Zd+d%Z d, d-d&Zed'ZxZ S).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. NOptional[ClauseElement]r rstringr`stateFzOptional[CursorResultMetaData]_cached_metadataz"Optional[List[ResultColumnsEntry]]_result_columns Optional[SchemaTranslateMapType]schema_translate_maprYexecution_optionsIdentifierPreparerpreparerr< _annotationszOptional[CompileState]rdml_compile_stateOptional[CacheKey] cache_keyfloat _gen_timec||_|jj|_|r'||_|jj ||_|t j |_||_|j|_ |j|_ |jr)trt|tsJ|j|_|j"|jfi||_|r+|jj'|j$||_t j(|_nt j*|_t-|_y)aConstruct a new :class:`.Compiled` object. :param dialect: :class:`.Dialect` to compile against. :param statement: :class:`_expression.ClauseElement` to be compiled. :param schema_translate_map: dictionary of schema names to be translated when forming the resultant SQL .. seealso:: :ref:`schema_translating` :param compile_kwargs: additional kwargs that will be passed to the initial call to :meth:`.Compiled.process`. N)dialectidentifier_preparerrr_with_schema_translater`rarr supports_execution can_executerr isinstancer-_execution_optionsrprocessr_render_schema_translatesrbrcrrrrr rrender_schema_translatecompile_kwargss r__init__zCompiled.__init__;s4  88 ( >rc Btj|t||rr7UnsupportedCompilationErrorrrelementerrkws rvisit_unsupported_compilationz&Compiled.visit_unsupported_compilations--dDMBKrct)zReturn a Compiled that is capable of processing SQL expressions. If this compiler is one, it would likely just return 'self'. NotImplementedErrorr/s r sql_compilerzCompiled.sql_compilers "##rc (|j|fi|Sr_compiler_dispatch)robjkwargss rrzCompiled.processs%s%%d5f55rcT|jtjur |jSy)z3Return the string text of the generated SQL or DDL.r)rr`rbrr/s r__str__zCompiled.__str__s# ::55 5;; rct)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. rrparamsextracted_parameters escape_namess rconstruct_paramszCompiled.construct_paramss "##rc"|jS)z0Return the bind params for this compiled object.rr/s rrzCompiled.paramss$$&&r) rr\r rrrrrrMapping[str, Any])rr)rr5rrrr)rrNNTr"Optional[_CoreSingleExecuteParams]r&Optional[Sequence[BindParameter[Any]]]rrrz)Optional[_MutableCoreSingleExecuteParams])!rrrrr rris_sqlis_ddlrrrr& EMPTY_DICTrrrrr immutabledictrr classmethodrrrr3rrrrr __classcell__rs@rrrs *.I&-FC4 - F F7;4;:>O7>=A:A)-8 ! $(OOL/3,0M)0 15-4 %)I!( BF(-,>D,>,>,@ 6(6(+6(? 6( "& 6( * 6(p+  ?L$$66:GK! $2 $E $ $ 3 $''rrc<eZdZdZdZddZddZ d dZy) TypeCompilerz2Produces DDL specification for TypeEngine objects.z visit_\w+c||_yr)r)rrs rrzTypeCompiler.__init__s  rc |jrE|jj|jvr#|j|jj}|j|fi|Sr)_variant_mappingrrrrrrs rrzTypeCompiler.processsU  " " !!U%;%;;**4<<+<+<=E'u''333rc 0tj|||r)r7rrs rrz*TypeCompiler.visit_unsupported_compilations--dG<#ErN)rr\)rrrrrr)rrr Exceptionrrrr)rrrr ensure_kwargrrrrrrrrs><L4FF!*F25F FrrcFeZdZdZdZdZd dZedZedZ dZ y) _CompileLabelz;lightweight label object which acts as an expression.Label.labelrr _alt_namesc6||_||_|f|z|_yrr)rcolr alt_namess rrz_CompileLabel.__init__s  &9,rc.|jjSrr proxy_setr/s rrz_CompileLabel.proxy_set||%%%rc.|jjSrrrr/s rrz_CompileLabel.type||   rc |Srrrrs r self_groupz_CompileLabel.self_group rN)r) rrrr__visit_name__ __slots__rr3rrrrrrrrsDFN/I- &&!!rrcJeZdZdZdZdZdZedZedZ dZ dZ y ) ilike_case_insensitiveaproduce a wrapping element for a case-insensitive portion of an ILIKE construct. The construct usually renders the ``lower()`` function, but on PostgreSQL will pass silently with the assumption that "ILIKE" is being used. .. versionadded:: 2.0 ilike_case_insensitive_operandr comparatorc4||_|j|_yrr)rrs rrzilike_case_insensitive.__init__s !,,rc.|jjSrrr/s rrz ilike_case_insensitive.proxy_setrrc.|jjSrrr/s rrzilike_case_insensitive.typerrc |Srrrs rrz!ilike_case_insensitive.self_grouprrcJt|jj|Sr)rr_with_binary_element_type)rrs rr z0ilike_case_insensitive._with_binary_element_types!% LL 2 25 9  rN) rrrrrrrr3rrrr rrrrrsJ 6N'I-&&!! rrc HeZdZUdZeZejdddddddddZde d < d e d <de d <d Z e Z dZ de d<dZde d<dZde d< de d< dZde d< dZde d< dZde d< dZde d<de d< de d < d!e d"< dZde d#< dZde d$< dZde d%< d&e d'< d&e d(< d&e d)< d*e d+< dZde d,< dZde d-< d Zde d.< dZde d/< dZde d0< dZde d1< dZd2e d3< dZd4e d5< dZd6e d7<dZ d8e d9<dZ!d:e d;<e"Z#d< ejJZ&d?e d@< dZ' dZ( dZ)dAe dB< dZ*d6e dC< dZ+d6e dD<dZ,d6e dE<dZ-de dF<dGe dH<dIe dJ<dKe dL<de dM<e.j^dNZ0e.j^dOZ1e.j^e1jddPe0jdZ3e4dQZ5e4dRZ6ddde7df ddTZ8e9ddUZ:ejvddVZe9dYZ?ejddZZAejd d[ZCeDjd\ZFd]ZGd^ZHej d d_ZId`ZJe9daZK d d dbZL d ddcZMejddZNe9deZO d ddfZPejdgdhZRdie dj<ejddkZSejejdldmZTejejdldnZUdoZVdpZWddqZXdrZY ddsZZ ddtZ[ dduZ\dvZ]dwZ^ d ddxZ_dyZ`dzZad{Zbd|Zcd}Zdd~ZeddZf ddZgdZhdZidZjdZkdZldZmdZndZodZpdZqdZrdZsdZtdZudZvdZwdZx d ddZydZzdZ{dZ| ddZ}dZ~dZ ddZdZdZdZdZdZdZdZdZ ddZdZ ddZdZdZdZdZdZ ddZdZdZejdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd„ZdÄZ ddĄZdńZedfdƄZdDŽZdȄZ ddɄZddʄZ d dd˄Zd̄Zdddddejldf d d̈́Zd΄ZdτZ d!dЄZdфZd҄ZddӄZdԄZddՄZdքZdׄZ d"d؄Z ddلZ d#dڄZdۄZd܄Zd݄ZdބZd߄Zde d<eʐjs"ejde"fde"fgZ ddZdZdSe d< d$dZ d%dZdZdZdZ ddZdZdZdZdZdZ d&dZdZ d'dZ d(dZݐddZdZejejejejejejejejejejejiZejejejiZ d)dZ d*dZ d+dZdZdZdZdZddZdZdZddZdZdZdZy(, SQLCompilerz~Default implementation of :class:`.Compiled`. Compiles :class:`_expression.ClauseElement` objects into SQL strings. PAZC_)%():.[] zClassVar[Mapping[str, str]]bindname_escape_characterszClassVar[Pattern[str]]_bind_translate_re_bind_translate_charsTFrisdeleteisinsertisupdatezOptional[List[Column[Any]]] postfetchrzSequence[Column[Any]]insert_prefetchupdate_prefetchN&Optional[Sequence[ColumnElement[Any]]]implicit_returning isplaintextzDict[str, BindParameter[Any]]bindszDict[BindParameter[Any], str] bind_nameszList[_CompilerStackEntry]rreturning_precedes_values'render_table_with_column_in_update_fromansi_bind_rulesr bindtemplatecompilation_bindtemplate_numeric_binds_identifier_charzList[ResultColumnsEntry]r_textual_ordered_columns_ad_hoc_textual_ordered_columns_loose_column_name_matching_numeric_binds_render_postcompilezOptional[ExpandedState]_post_compile_expanded_state Optional[str]_pre_expanded_stringOptional[List[str]]_pre_expanded_positiontupzOptional[_InsertManyValues]_insertmanyvaluesz!Optional[crud._CrudParamSequence]_insert_crud_paramszFrozenSet[BindParameter[Any]]literal_execute_paramspost_compile_paramszutil.immutabledict[str, str]escaped_bind_nameszbOptional[Tuple[Dict[BindParameter[Any], List[BindParameter[Any]]], Dict[str, BindParameter[Any]]]]_cache_key_bind_matchr%_values_bindparam_visited_bindparaminlinez"Optional[MutableMapping[CTE, str]]cteszDict[Tuple[int, str], CTE]ctes_by_level_namez/Dict[CTE, Tuple[int, str, selectable._CTEOpts]]level_name_by_ctectes_recursivez"__\[POSTCOMPILE_(\S+?)(~~.+?~~)?\]z%\(([^)]+?)\)s|c$|jyr)_init_bind_translaters rrzSQLCompiler._init_compiler_cls2s   "rctjdj|j}tjd|d|_|j|_y)Nrrr)reescaperwrcompilerr)rregs rrJz SQLCompiler._init_bind_translate6sFii > >?@!#auAJ!7$'$B$B!rrc >||_||_|r:|dD cic]} | j| } } |dD cic]} | | g} } | | f|_||_||_i|_tj|_ g|_ g|_ |j|_ |jrH|jjdx|_} | r|jdk(rdnd|_t"|_nt&|j|_d|_|j*xs |j,|_t/|_i|_i|_t7j8|||fi||j:s|j<s |j>rt@rtC|tDsJ|j:s |j<rmt@rtC|tFsJ|jHrd|_%nA|jr5|j:r"|jLjNr|jPrd|_%t&|j|_)|rK|jTjW|jTjYD cic] \} }| dvr| |c}} |jZt\j^urm|jr-|jr|jan|jc|jdr'|jgd d }|ji|d yyycc} wcc} wcc}} w) aConstruct a new :class:`.SQLCompiler` object. :param dialect: :class:`.Dialect` to be used :param statement: :class:`_expression.ClauseElement` to be compiled :param column_keys: a list of column names to be compiled into an INSERT or UPDATE statement. :param for_executemany: whether INSERT / UPDATE statements should expect that they are to be invoked in an "executemany" style, which may impact how the statement will be expected to return the values of defaults and autoincrement / sequences and similar. Depending on the backend and driver in use, support for retrieving these values may be disabled which means SQL expressions may be rendered inline, RETURNING may not be rendered, etc. :param kwargs: additional keyword arguments to be consumed by the superclass. rrrrrNT>rrr positionalr-r4r.Fr_no_postcompile)_populate_self)5 column_keysrr+r@for_executemanylintingr(r& column_dictr)rrrQ paramstyle startswithr4r/_pyformat_templater.BIND_TEMPLATESrD label_lengthmax_identifier_lengthr4anon_maptruncated_names_truncated_countersrrr r!rrrrBrC_inlinerCrinsert_executemany_returning_return_defaultsr-__dict__updateitemsrr`rb_process_numeric_process_positionalr5r#_process_parameters_for_postcompile)rrr rrUrVrW_supporting_againstrbcksmckbmnbkvr!s rrzSQLCompiler.__init__<s@'" &/l3lAEE1HlD3$-aL1LqAsFLD1*.D & /  **, !",, ??'.'9'9'D'DY'O OD ""--1AACs3-?D ),:7;M;M,ND )   AG$A$A  () <>35 $=f= ==DMMT]]!)Z888}}  %i<<<$$"&DK))  AA%66#'DK*7+=+=>  MM !4 < < B B D  D1 qD D  " ::55 5&&))+,,.''!22!&$(3 88t9 ( 6y41V sL L,L cH|jy|jjS)aWhen an INSERT is compiled with a single set of parameters inside a VALUES expression, the string is assigned here, where it can be used for insert batching schemes to rewrite the VALUES expression. .. versionadded:: 1.3.8 .. versionchanged:: 2.0 This collection is no longer used by SQLAlchemy's built-in dialects, in favor of the currently internal ``_insertmanyvalues`` collection that is used only by :class:`.SQLCompiler`. N)r;r7r/s rinsert_single_values_exprz%SQLCompiler.insert_single_values_exprs%  ! ! )))<< >,B===A$Q'= sA*c|jS)zVbackwards compatibility; returns the effective_returning collection. )rwr/s r returningzSQLCompiler.returnings '''rcb |jddS#t$r}td|d}~wwxYw)aReturn the current 'executable' that is being compiled. This is currently the :class:`_sql.Select`, :class:`_sql.Insert`, :class:`_sql.Update`, :class:`_sql.Delete`, :class:`_sql.CompoundSelect` object that is being compiled. Specifically it's assigned to the ``self.stack`` list of elements. When a statement like the above is being compiled, it normally is also assigned to the ``.statement`` attribute of the :class:`_sql.Compiler` object. However, all SQL constructs are ultimately nestable, and this attribute should never be consulted by a ``visit_`` method, as it is not guaranteed to be assigned nor guaranteed to correspond to the current statement being compiled. .. versionadded:: 1.3.21 For compatibility with previous versions, use the following recipe:: statement = getattr(self, "current_executable", False) if statement is False: statement = self.stack[-1]["selectable"] For versions 1.4 and above, ensure only .current_executable is used; the format of "self.stack" may change. r$z$Compiler does not have a stack entryN)r IndexError)ries rcurrent_executablezSQLCompiler.current_executables;< M::b>,/ / MCD" L Ms . ).cXt|jt|jzSr)listr#r$r/s rprefetchzSQLCompiler.prefetch%s#D(()D1E1E,FFFrciSrrr/s r_global_attributeszSQLCompiler._global_attributes)s rcftj}||_i|_i|_d|_|S)zInitialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise. F)r& OrderedDictrDrErFrG)rrDs r_init_cte_statezSQLCompiler._init_cte_state-s:*.)9)9); #%"$# rc#hK|j|j}}gdc|_|_ |jr|jd}d|d<nd}|j|jf|r|jd||c|_|_y#r|jd||c|_|_wxYww)z;special API to support the use case of 'nested result sets'Fr{TrN)rr2rrv)rresult_columnsordered_columnsentrys r_nested_resultzSQLCompiler._nested_resultEs   ! !(79%3d3 zz 26:23&&(=(== = 67 8D $"7 67 8D $"7s(B2=B (#B2 $B//B2c  |jrJ|jtjusJ|jrJ|j j dk(rdn|j j dk(sJdg d  fd }tj|j||j|_ |jrv|jjDcic]\}}|| }}}t|jt|k(sJ Dcgc]}|j||c}|_n |_|jrg tj|j||jj }|jj"Dcgc]3}|d|dtj|j||d|d f5}}|jj%|| |_yycc}}wcc}wcc}w) Nr%srrc|jd}|rj|Sj|jd|jdS)Nrr6r)rappend)m normal_bind placeholder positionss r find_positionz6SQLCompiler._process_positional..find_positionjsM''!*K  -""  ,wwqz!rrrr6r r7r9)rz re.Match[str]rr)r%rr`rbr4rrYrLsub_positional_patternrr?rglengetr;r7r9_replace) rrrprqreverse_escaperr7r9rrs @@rrizSQLCompiler._process_positional]s####zz]99999&&&& << " "h .K<<**g5 55K  "ff  $ $mT[[    " "/3/F/F/L/L/NO/Ntq!ad/NNOt../3~3FF FF;D ;D4""4.9 D  )D   ! !I!#((&&99" //BB"CA aDaDFF433]AaDIaD  C "&*%;%;%D%D#5#5&E&D "% "P "s G1G78G<ct jsJjtjusJd}i jr\j Pt jfdjjDjj}njj}|D]R}| vrj|}|jvs|jvrd |<9j|}|dz }| |<T|_t _j"rYt% } j'Dcic]"\}}j"j)|||$c}} t% |k(sJj*j- fdj._jrljj0 z} jj2D cgc]} | d| dd| df} } jj5| | _yycc}}wcc} w)Nrc3>K|]}|jvr|ywr)rA)r*rrs rr,z/SQLCompiler._process_numeric..s' 84#9#99 8c,|jdSNrrr param_poss rz.SQLCompiler._process_numeric..si +rrrr r)r4rr`rbr;rA itertoolschainr)valuesr(r>r=r/next_numeric_posrr%r?rrgr_pyformat_patternrrr7r9r) rnumr bind_namebindph len_beforerposr7rqr9rs ` @rrhzSQLCompiler._process_numericsN""""zz]99999$&  ! !d&<&<&HOO $ 6 6 8 &&( EOO**,EII%::i(D0004666(, )$;;Z/ //,,00 +T[[    ! !&&99 //BB"BA1qtT1Q4(B " &*%;%;%D%D#5#5 &E&D " "$"s 'H/3H5cffdjDDcic] \}}||| c}}Scc}}w)Nc 3K|]}j||jjs%|jjjn5t fdt t|jjDfyw)c3TK|]}|jj!ywr)_cached_bind_processorr)r* elem_typers rr,z9SQLCompiler._bind_processors...s,#.$ &<.s"1IOOI. )~~<<"==dllK"#-1 )9>>.#e.$# "1sB B )r))rr+values` r_bind_processorszSQLCompiler._bind_processorssL"&  U  # J   s-c2t|jdkDSr)rrr/s r is_subqueryzSQLCompiler.is_subquerys4::""rc|Srrr/s rrzSQLCompiler.sql_compilers rcL|j||d}|j|S)aRReturn a new :class:`.ExpandedState` for a given parameter set. For queries that use "expanding" or other late-rendered parameters, this method will provide for both the finalized SQL string as well as the parameters that would be used for a particular parameter set. .. versionadded:: 2.0.0rc1 TrR)rrj)rrrr!s rconstruct_expanded_statez$SQLCompiler.construct_expanded_states:** % + 77   rc|jrF|sD|jJ|st|jjSt j d|xrt |j}|rq|jt jd|jd}|j} | J| \} } t||D cic]\} } | | D]}|| }} } }nd}|ri}|jjD]\}}|r|jj||n|}|j|vr||j||<G||vr ||||<T|rX|j rL|r&t j d|j|fzdt j d|jzd|r|j||}n|}|j"r|j$||<|j&||<|Si}|jjD]\}}|r|jj||n|}|rX|j rL|r&t j d|j|fzdt j d|jzd|r|j||}n|}|j"r|j$||<|j&||<|Scc}} } w) z5return a dictionary of bind parameter keys and valuesNzcan't construct new parameters when render_postcompile is used; the statement is hard-linked to the original parameters. Use construct_expanded_state to generate a new statement and parameters.zcThis compiled object has no original cache key; can't pass extracted_parameters to construct_paramsrz@A value is required for bind parameter %r, in parameter group %dcd3x)codez)A value is required for bind parameter %r)r5r6dictr!r7r-rr?r CompileErrorr@zipr)rgrr+requiredcallableeffective_valuer)rrrr _group_number_checkrShas_escaped_namesorig_extracted ckbm_tuplernrrl extractedrresolved_extractedpdrr escaped_name value_params rrzSQLCompiler.construct_paramss?  # #O44@ @@D==HHII--4)JT$2I2I-J ~~%&&J "&!233J) )) GD!%(8L$M"$MLAy GDi#$M " "&  B#'??#8#8#: 4)++//d; ==F*'-imm'.lookup_typesH009HHOF""*fM.I"*f .E r) rinclude_set_input_sizesexclude_set_input_sizesrr=r)rrrr2r) rr inputsizesr=rrrrrrs @@@@r_get_set_input_sizes_lookupz'SQLCompiler._get_set_input_sizes_lookups,,77 77    !%!DD)D $D) 9% )4INN(C 9%))sC c&|jdS)zReturn the bind param dictionary embedded into this compiled object, for those values that are present. .. seealso:: :ref:`faq_sql_expression_string` - includes a usage example for debugging use cases. F)rrr/s rrzSQLCompiler.paramss$$E$22rci}|j}| |j}|jrg}|j}||j}ndx}}|j }t d|t d|i}ii} d} |jr||} |jrg} n|jj} |j} | D]| r| jn} |j}||jvr*| vr%|j||j| | <a||j vr| vr| | }d}n3|j}|j#| ||}|\}}|| | <|| <|j$r|j'||j(j*r*|J|j'fdt-|dDn|j'fd|D| | j/d|Dn||j/d |D|Dcgc]\}}| c}}|<w|{|j1fd }t3j4|j6||}| l|Jt-| |j8Dcic]\}}||j:|c}}|j<j5fd |}|j/| t?|||||}|rR||_||_|j@|_|jrtC|jxsd nd|_||_"|Scc}}wcc}}w) ahandle special post compile parameters. These include: * "expanding" parameters -typically IN tuples that are rendered on a per-parameter basis for an otherwise fixed SQL statement string. * literal_binds compiled with the literal_execute flag. Used for things like SQL Server "TOP N" where the driver does not accommodate N as a bound parameter. Nr"z/Mapping[str, Sequence[_BindProcessorType[Any]]]render_literal_valuec3K|]?\}}t|dD]+\}}vr"|dz d|d||dz f-Ayw)rNr) enumerate)r*i tuple_elementjrrtuple_processorss rr,zBSQLCompiler._process_parameters_for_postcompile..=sy . 5I 0=(1-(C1#'77 0 6q1u = I /3Aq 9 0 6q1u = )D 5IsAArc3:K|]\}}vr |fywrr)r*r+rrsingle_processorss rr,zBSQLCompiler._process_parameters_for_postcompile..Hs1.*3Q#'88!"3D"9:*3c3&K|] \}}| ywrrr*rrs rr,zBSQLCompiler._process_parameters_for_postcompile..Ns309WT1D c3&K|] \}}| ywrrrs rr,zBSQLCompiler._process_parameters_for_postcompile..Us.M9at9rc|jd}|}|jdrU|jdjd}|d|dcdjfd|jdD}|S)Nrr6~~r rc3.K|] }|ywrr)r*expbe_leftbe_rights rr,z]SQLCompiler._process_parameters_for_postcompile..process_expanding..es !/!(h7/s)rsplitrw)rr+exprtokrrreplacement_expressionss @@rprocess_expandingzJSQLCompiler._process_parameters_for_postcompile..process_expanding\s~''!*C*3/Dwwqzggaj&&t,$'FCF!yy!#zz$/!Krc,|jdSrrrs rrzASQLCompiler._process_parameters_for_postcompile..ys)AGGAJ/rr)#r8rrQr:r%rrr4r)rr?rr(r=render_literal_bindparamrvr>$_literal_execute_expanding_parameterliteral_executerfrrrextendrrLr_post_compile_patternrr/rrr rr6)rr!rTexpanded_parameterspre_expanded_stringnew_positiontuppre_expanded_positiontupr#new_processorsto_update_setsnumeric_positiontupnamesebnr parameter to_updaterleep_resreplacement_expr expand_keyrrr rr+expanded_staterrrrrs @@@@@rrjz/SQLCompiler._process_parameters_for_postcompiles$!#77  &"&++  ?? O'+'E'E $'/+/+;+;(:> =O6**  3Z  =z >@24)+48 ??7C#;E""&(#OO**,E%%D253774.4L 4(ID777'>>55%1; 1M6,L9 D444#:: .| fa4H . '--.*3. +6+223093)4(...M9.MM8A18A}z1 1'-!,&&t,SV FF  & &(9;N   *". ..!*')>)>!!HC;;._autoinc_getters)",..i"HK". +* )(rcjfdDSfdDS)agiven cursor.lastrowid value and the parameters used for INSERT, return a "row" that represents the primary key, either by using the "lastrowid" or by extracting values from the parameters that were sent along with the INSERT. c34K|]\}}|ywrr)r*rrr!s rr,zWSQLCompiler._inserted_primary_key_from_lastrowid_getter..get..sLG[VSfZ0Gc3VK|] \}}|ur  n n|"ywrr)r*rr autoinc_colautoinc_getterrr!s rr,zWSQLCompiler._inserted_primary_key_from_lastrowid_getter..get..sL (/ +- .9+9jA!*$J/ 0(/&)r)rr!r'r(getterslastrowid_processorrow_fns``rrzDSQLCompiler._inserted_primary_key_from_lastrowid_getter..getsH#./ :  LGLLL (/   r)r&r engine_resultrrr rrrAr primary_keyoperator methodcaller_autoincrement_columnr_cached_result_processorrr( result_tupler+)rresultparam_key_getterr rrr"rr'r(r!r*r+r,s @@@@@@r+_inserted_primary_key_from_lastrowid_getterz7SQLCompiler._inserted_primary_key_from_lastrowid_gettersM--==!!---&&00 i0 00(( ( " "5*:3*? F L(  11  ""-"2"2"K"K d# +;7Kdjj( )"1#' $$9J9J%K9J#cgg9J%KL  4 G N&Ls &EEc  tjrddlm}ntj j }|jJ|jj}trt|tsJ|j}|j}|j}|Jt|Dcic]\}}|| }}}td|j Dcgc]?}||vrt#j$||dfnt#j&d||ddfAc} |j)|j Dcgc]}|j*c} fd} | Scc}}wcc}wcc}w)Nr6)r4z'List[Tuple[Callable[[Any], Any], bool]]TrFc,fdDS)Nc3HK|]\}}|r|n|ywrr)r*ruse_rowr!rows rr,zWSQLCompiler._inserted_primary_key_from_returning_getter..get.." s-'.OFG 's F:,>>'.rrr)r;r!r*r,s``rrzDSQLCompiler._inserted_primary_key_from_returning_getter..get! s'. r)typingrenginer4r&rr-rr rrArrr&rrr.r/ itemgetterr0r3r+) rr4r r5rryidxrretrr*r,s @@r+_inserted_primary_key_from_returning_getterz7SQLCompiler._inserted_primary_key_from_returning_gettersk    '^^11F!!---&&00 i0 00==++ $$$(1)(<=( &Ls& E AE .Ecy)zCalled when a SELECT statement has no froms, and no FROM clause is to be appended. Gives Oracle Database a chance to tack on a ``FROM DUAL`` to the string output. rrr/s r default_fromzSQLCompiler.default_from) src |jj|fi|}|jD]C}||jvr|j|}|j |j|j dd}|j |}|x|j|<|j|<||j |<|j j|d||jvr|xj|hzc_||jvr|xj|hzc_ |j}|s|\} } |jD]4}|j | vs| |j } | | j|6F|S)aSQL compile the nested element of an _OverrideBinds with bindparams swapped out. The _OverrideBinds is not normally expected to be compiled; it is meant to be used when an already cached statement is to be used, the compilation was already performed, and only the bound params should be swapped in at execution time. However, there are test cases that exericise this object, and additionally the ORM subquery loader is known to feed in expressions which include this construct into new queries (discovered in #11173), so it has to do the right thing at compile time as well. TF) maintain_keyrN) rr translater( _with_valuer+r)rvr>r=r@ _cloned_setr) roverride_bindsrsqltextrpbpnew_bprrrnrmcbs rvisit_override_bindsz SQLCompiler.visit_override_binds3 s`"<.((;;DGBG ))A "AB^^((0!$F ??2&D/5 5DJJqMDJJt,&*DOOF # OO  D )T---((VH4(T000++x7+33J' d..Bvv~!"&&\R/)?*Hrc Hd|jj|fi|zdzSNrrrr)rgroupingasfromrs rvisit_groupingzSQLCompiler.visit_groupings +8X%%88HHH3NNrc Hd|jj|fi|zdzSrPrQ)rrRrs rvisit_select_statement_groupingz+SQLCompiler.visit_select_statement_groupingv rUrc |jr|jjr td|jdd}|j\}}}|r|} n|} |jj} | E| j| vr7| j| | jr|jj|d<|j|jfd|i|S#t$r}t j d|d}~wwxYw)N'Union[SelectState, CompoundSelectState]r{rECan't resolve label reference for ORDER BY / GROUP BY / DISTINCT etc.render_label_as_labelwithin_columns_clause) rrsupports_simple_order_by_labelrKeyErrorr7r_label_resolve_dictr_order_by_label_elementrshares_lineager) rrr\rrke with_cols only_froms only_cols resolve_dict order_by_elems rvisit_label_referencez!SQLCompiler.visit_label_referencey s ::$,,EE  $=JJrN?3! 11  $) ( $OOCCM)!&&,6!00 !3!34 OO;;./t|| OO "7   A &&/ sC C7C22C7c >|js|j|jS td|jdd}j\}}} |r||j} n||j} | |d<|j| fd|i|S#t$r;}t j |jdtj|Yd}~d}~wwxYw#t$r;} t j |jdtj| Yd} ~ yd} ~ wwxYw)NrYr{rrZ)extraexc_clsrr[r\) rr _text_clauserr^r_no_text_coercionrr7rr_) rrr\rrrbrcrdrerrs rvisit_textual_label_referencez)SQLCompiler.visit_textual_label_reference s*zz<< 4 45 5  9 2/M,9+L+L( :y $ 10/2F* +4<<+@DJ ;   ' '/((   "   ' '/((   s/B!C C1CC D!1DDc H|xr| }||u} | s|rMt|jtjr|j d|j} n |j} |r|1| |j|| f|j z|z|j |jj|fddd|ttjz|jj| zS| r|jj| S|jj|fddi|S)NcolidentT)r\within_label_clauser\F)rrrrD_truncated_identifierrrrr OPERATORSr!as_r format_label) rradd_to_result_maprqr\r[result_map_targetsrrender_label_with_asrender_label_only labelnames r visit_labelzSQLCompiler.visit_label s? " =*=&= 2U:  4%**h&?&?@ 66z5::N !JJ  ,!JJI&)9)99? ==--eY? ?35==33,157 rc,tjd)Nz:Cannot compile Column object until its 'name' is assigned.r7rrrs r_fallback_column_namez!SQLCompiler._fallback_column_name s H  rc @|j}|j|fi|Sr) _resolvedr)rrr sql_elements rvisit_lambda_elementz SQLCompiler.visit_lambda_element s#'' t||K.2..rc Z|jx}}||j|}|j} | s,t|tj r|j d|}|C|||jf|z} |jr| |jfz } |||| |j| r|j|}n|jj|}|j} | |r | js|S|jj| } | r|jj!| dz} nd} t"rt| t$sJ| j}| s |r ||vr||}t|tj r|j d|}| |jj|zdz|zS)Nrprralias)rr is_literalrrrDrrr+ _tq_labelrescape_literal_columnrquoternamed_with_columnschema_for_object quote_schemarrO)rrrv include_tablerwambiguous_table_name_maprr orig_namertargetsreffective_schema schema_prefix tablenames r visit_columnzSQLCompiler.visit_column s";;&y <--f5D&& jx/H/HI--j$?D  (tVZZ03EEGF,,.. dIw D --d3D==&&t,D  = U5L5LK#}}>>uE MM../?@3F!# !%999 I%,!994Y? )X%>%>? 66w J  4==#6#6y#AACG$N Nrc L|jj|jSr)rformat_collation collationrrrs rvisit_collationzSQLCompiler.visit_collationJ s}}--g.?.?@@rc |jSrr)r fromclausers rvisit_fromclausezSQLCompiler.visit_fromclauseM s rc |jSrr)rrors r visit_indexzSQLCompiler.visit_indexP s zzrc ||d<|j|d<|jjj|jfi|S)Ntype_expressionr)rrtype_compiler_instancerr)r typeclausers rvisit_typeclausezSQLCompiler.visit_typeclauseS sJ * $(MM !:t||22:: OO !  rcV|jjr|jdd}|SNr%%r_double_percentsreplacertexts rpost_process_textzSQLCompiler.post_process_textZ $ == ) )<<T*D rcV|jjr|jdd}|Srrrs rrz!SQLCompiler.escape_literal_column_ rrc fd}jsd_|r|ddftjtj dt j |jjS)Nc|jd}|jvr jj|fiSj|fiSr)r _bindparamsrbindparam_string)rrrr textclauses r do_bindparamz2SQLCompiler.visit_textclause..do_bindparame sW771:Dz---#t||J$:$:4$@GBGG,t,,T8R88rTc$|jdSrr)rs rrz.SQLCompiler.visit_textclause..w s aggajr) rr'r%NULLTYPEBIND_PARAMS_ESCr BIND_PARAMSrr)rrrvrrs`` ` rvisit_textclausezSQLCompiler.visit_textclaused sl 9zz#D   dD:-9J9J K"" OOd44Z__E   rc "|j }|r |jn|jd}tt|d}|jj||jr|j |||xs-|dk(xr|j ddxs|j dd}|rp|jx|_|_ |j xrt|j|_ |jD] } |j| d|j"|j|jfi|} |j r.|st#|jnd} |j%| | z} |jj'd| S) Nr{rrr$rrFrT)r\rv nesting_level)r_default_stack_entryror_independent_ctes_dispatch_independent_ctesrrQr2r0r column_argsr3r_add_to_result_maprrDr_render_cte_clauserv) rtafcompound_indexrSrtoplevelr new_entrypopulate_result_maprvrrs rvisit_textual_selectz SQLCompiler.visit_textual_select} s{zz>-5))4::b> #uE* )$   + +C 4  >!#EII yy5u=   D !D$A 47>>/A0dGD ,__ *.&*&=&=%t||CKK.2. 993;C OM***G$ND r rc yNNULLrrrrs r visit_nullzSQLCompiler.visit_null rc 2|jjryy)Nr~1rsupports_native_booleanrs r visit_truezSQLCompiler.visit_true s << / /rc 2|jjryy)Nr0rrs r visit_falsezSQLCompiler.visit_false s << / /rc J|jdfd|DDS)Nc3$K|]}|r| ywrrr*ss rr,z7SQLCompiler._generate_delimited_list.. s I Ic3DK|]}|jfiywrrr*rvrrs rr,z7SQLCompiler._generate_delimited_list.. s%I1*a**4626rrw)rr separatorrs` `r_generate_delimited_listz$SQLCompiler._generate_delimited_list s&~~ II   rc ttjjtjtj j tjj |\}}|dk(r|djfiSttj}|jdfd|DDS)Nrrc3$K|]}|r| ywrrrs rr,z;SQLCompiler._generate_delimited_and_list.. s"LALrc3DK|]}|jfiywrrrs rr,z;SQLCompiler._generate_delimited_and_list.. s%LGq.!..t:r:Gr) rBooleanClauseList_process_clauses_for_booleanr!and_True_ _singletonFalse_rrsrw)rclausesrlccrs` ` r_generate_delimited_and_listz(SQLCompiler._generate_delimited_and_list s11NN NN NN % % OO & &   W !8071:00<< <!)..1I>>"LGL" rc .d|j|fi|zSN(%s))visit_clauselist)r clauselistrs r visit_tuplezSQLCompiler.visit_tuple s ---j?B???rc |j}|d}nt|j}|j|j|fi|SNr)r/rsrr)rrrseps rrzSQLCompiler.visit_clauselist sG!! ;CJ//0C,t,,Z-?-?KKKrc |j}|j|dd}|r |||fi|S t|}d|d<|j|j|fi|S#t $r}t j|||d}~wwxYw)Nexpression_clauselistT_in_operator_expression)r/_get_operator_dispatchrsrrr^r7r)rrr operator_dispopstringrs rvisit_expression_clauselistz'SQLCompiler.visit_expression_clauselist s'' ** .   I44 4  +H-1B( )0400""H02   L11$ B K Ls A A>"A99A>c dd}|j#||jj|fi|dzz }|jD]8\}}|d|j|fi|zdz|j|fi|zdzz }:|j&|d|jj|fi|zdzz }|dz }|S)NzCASE rzWHEN z THEN zELSE END)rrwhenselse_)rclauserxcondr4s r visit_casezSQLCompiler.visit_case s  << # 000@@3F FA"LLLD& )$))$9&9:,&++D;F;<  A) << # 9&,,99$I&IICO A U rc <|jj|fi|Sr)typed_expressionr)r type_coercers rvisit_type_coercezSQLCompiler.visit_type_coerce s >{++>>tJrJJrc |jj|fi|}tjd|}d|jj|fi|d|r|j dn|d|r|j dSdS)Nz(.*)( COLLATE .*)zCAST(rrrr6r)rrrLmatchrr)rrr type_clauser s r visit_castzSQLCompiler.visit_cast s8doo88HH ,k: *DKK * *4 :6 :#EKKN 4#EKKN +  *, +  rc p|dtjurdn|dtjurdnh|ddkr5|jtjt |dfi|dn+|jtj|dfi|dd|dtjurdS|dtjurdS|ddkr7|jtjt |dfi|dS|jtj|dfi|dS) NrzUNBOUNDED PRECEDINGz CURRENT ROWz PRECEDINGz FOLLOWINGrrzUNBOUNDED FOLLOWING)rRANGE_UNBOUNDED RANGE_CURRENTrliteralabs)rrange_rs r_format_frame_clausez SQLCompiler._format_frame_clause s}!9 8 88&ayH$:$::""!9q= )DLL ( 0 0VAY @DF(4<<(8(8(CJrJM(!9 8 88&+' ' 2ayH$:$::"+' ' B"!9q= )DLL ( 0 0VAY @DF +' ' F(4<<(8(8(CJrJM+' ' rc |jj|fi|}|jr!d|j|jfi|z}n/|jr!d|j|jfi|z}nd}|ddj d|j fd|jffDcgc]*\}}|#t|r|d|j|fi|,c}}|r|gngzdScc}}w) NzRANGE BETWEEN %szROWS BETWEEN %sz OVER (r PARTITIONORDERz BY r) rrrrrowsrw partition_byorder_byr)roverrrrwordrs r visit_overzSQLCompiler.visit_over@ s .t||..t>v> ;;'*C$*C*C +%+FYY&)B)B)B *#*FF  HH %d&7&78 $--0)) f)c&k 6V66tFvFH) &F82 /   s'/C)c ~|jj|fi|d|jj|fi|dS)Nz WITHIN GROUP (ORDER BY r)rrr)r withingrouprs rvisit_withingroupzSQLCompiler.visit_withingroup] sB 2K   2 24 B6 B 3K 3 3D CF C  rc ~|jj|fi|d|jj|fi|dS)Nz FILTER (WHERE r)funcr criterion)r funcfilterrs rvisit_funcfilterzSQLCompiler.visit_funcfilterc s@ .JOO . .t >v > 3J 3 3D CF C  rc |jj|j|j}d|d|jj|fi|dS)NzEXTRACT(rr) extract_maprfieldrr)rextractrr*s r visit_extractzSQLCompiler.visit_extracti sH  $$W]]GMMB  +GLL + +D ;F ;  rc r|j|jfi|}|j|fi|}d|d|S)Nrz).)visit_functionfnr)rrr compiled_fn compiled_cols rvisit_scalar_function_columnz(SQLCompiler.visit_scalar_function_columnp s?)d))'**;; (t((7B7 '66rc x|4||j|j|jf|jt|d|jjzd}|r ||fi|}n8tj |j jd}|r|jri|dz }nc|j}|jj|st|tjr|jj|n|}|dz}dj|j Dcgc]T}|jj|st|tjr|jj|n|Vc}|gzd|j"|fi|iz}|j$r|dz }|Scc}w)Nz visit_%s_funcz%(expr)srrz WITH ORDINALITY)rrgetattrlowerrr _deannotater _has_argsr_requires_quotes_illegal_charsrrr0rrw packagenamesfunction_argspec_with_ordinality)rr$rvrrrrrs rr.zSQLCompiler.visit_functionu s  ( diiTYYL$)) Lt_tyy/@@$G ''D==!1!1!3!=!=tDD>>J&Dyy}}CCDI!$(<(<=MM''-  j(88 $00 1  ==GGL%dH,@,@A ++C0!! 1&  ...t>v>? @D  & &D s*AF7c 8|j|jSr)visit_sequencesequence)r next_valuers rvisit_next_value_funcz!SQLCompiler.visit_next_value_func s"":#6#677rc Ftd|jjz)Nz2Dialect '%s' does not support sequence increments.rrrrr>rs rr=zSQLCompiler.visit_sequence s$! @ll   rc <|jj|fi|Sr) clause_exprr)rr$rs rr:zSQLCompiler.function_argspec s 2t224B6BBrc j }|j|fi}|rjs|_|j}|r jnjd}|xs| xr|j dd} |dk(r||d<jj |d|d||| d|jrj|j|j} d | zd zjfd t|jD} dd <| j|fitdd iz } | j |fiz } |j"r| j$|fiz } j&r/|st)jnd} j+| d | z} jj-d| S)Nr{rFrrrr)rrr$rrrc3PK|]\}}|jf|dyw))rSrNr)r*rrvrSrrs rr,z4SQLCompiler.visit_compound_select.. sC 2DAq%$$!'=C2s#&rrSTrinclude_following_stackr)r_compile_state_factoryrr rrrrrcompound_keywordskeywordrwrselectsgroup_by_clauserorder_by_clause_has_row_limiting_clause_row_limit_clauserDrrrv) rcsrSrrrr compound_stmtrneed_result_maprLrrs ` ` ` rvisit_compound_selectz!SQLCompiler.visit_compound_select szz>111"dEfE D..!.D %// -5))4::b>"   A 8%@  Q  "E*  #():#; %n 5 !.0?     * *  + +M6 B((4g #)) &bjj1   #( $$$RI4+Hv+H+HII $$$R2622 & & *D**288 8D 993;C OM''"/,0(   r rc f|j|j|fi|S|j|fi|Sr) _fetch_clause fetch_clause limit_clause)rrRrs rrQzSQLCompiler._row_limit_clause s>   '$4$$R262 2$4$$R262 2rcRd|jd||rd|znd}t||dS)Nvisit_rr)rr4)rr qualifier1 qualifier2attrnames rrz"SQLCompiler._get_operator_dispatch s5     *C*  2  tXt,,rc "|||fz }||d<||d<|jry|jrtjd|j |jdd}|r|||jfi|S|j |t |jfi|S|jrX|j |jdd}|r|||jfi|S|j|t |jfi|Stjd)NrvrwzFUnary expression does not support operator and modifier simultaneouslyunaryr/modifierz,Unary expression has no operator or modifier)r/rar7rr _generate_generic_unary_operatorrs _generate_generic_unary_modifier)rr`rvrwrrs r visit_unaryzSQLCompiler.visit_unary s8  ( 5( * &7B" #'9B# $ >>~~&&2..DE5>>8R88>8R88 rc |jjr|j|jfi|dz|jt j |j |j jjtjur|j jntjfi|zS|j|jfi|dz|j|j fi|zS)N / ) rdiv_is_floordivrrxrCastrr_type_affinityr%Numericrrr/rs rvisit_truediv_binaryz SQLCompiler.visit_truediv_binary$ s << ' ' V[[/B/$,,MM  &||00??'// 0#LL--"*!1!1!3     ( V[[/B/$,,v||2r23 rc |jjrn|jjjt j ur>|j|jfi|dz|j|jfi|zSd|j|jfi|dz|j|jfi|zzS)Nrfz FLOOR(%s)) rrgrrrir%Integerrrxrks rvisit_floordiv_binaryz!SQLCompiler.visit_floordiv_binary? s LL ( ( !!00H4D4DD V[[/B/$,,v||2r23   V[[/B/$,,v||2r23 rc |js|jjr|j|jfi|Sd|j|jfi|zS)Nz%s = 1_is_implicitly_booleanrrrrrrr/rs rvisit_is_true_unary_operatorz(SQLCompiler.visit_is_true_unary_operatorP sQ  * *||334<<626 6ldll7??AbAA Arc |js|jjr d|j|jfi|zSd|j|jfi|zS)NNOT %sz%s = 0rqrss rvisit_is_false_unary_operatorz)SQLCompiler.visit_is_false_unary_operatorY sV  * *||33ldll7??AbAA Aldll7??AbAA Arc Jd|j|tjzS)Nrv)override_operator) visit_binaryr!match_oprks rvisit_not_match_op_binaryz%SQLCompiler.visit_not_match_op_binaryb s,$++ i&8&8,   rc >d|j|t|fi|zSr)_generate_generic_binaryrsrks rvisit_not_in_op_binaryz"SQLCompiler.visit_not_in_op_binaryg s3555 Ih' +-   rc |tjur*t|dkDrddjd|DzSy|tjur*t|dkDrddjd|DzSy|j |S) Nrz(%s)) OR (1 = 1rc3 K|]}dywrNrr*rs rr,z6SQLCompiler.visit_empty_set_op_expr..s :EfE zNULL) OR (1 = 1z(%s)) AND (1 != 1c3 K|]}dywrrrs rr,z6SQLCompiler.visit_empty_set_op_expr..z rrzNULL) AND (1 != 1)r! not_in_oprrwin_opvisit_empty_set_expr)rr expand_oprs rvisit_empty_set_op_exprz#SQLCompiler.visit_empty_set_op_expro s  ++ +5zA~(II:E::) )// )5zA~*II:E::+,,U3 3rc Ftd|jjz)Nz3Dialect '%s' does not support empty set expression.rBr element_typesrs rrz SQLCompiler.visit_empty_set_expr s$! All   rc jjj}|s|jrOjjrdndj jj jz}d|fSj jgj}d|fS|jsB|jrt|dtjrst|dttfsZ|jr tdjjrdnddj!fdt#|Dz}d|fS|rj$}|j'|}|r|j)dsJd|j)dj+d }|d |d c dj! fd |D}d|fSdj!fd |D}d|fS)NVALUES rrz?bind_expression() on TupleType not supported with literal_bindsrc 3K|]B\}}ddjfdt|jjDzDyw)rrc3HK|]\}}j||ywrr)r*r param_typers rr,z[SQLCompiler._literal_execute_expanding_parameter_literal_binds... s/2-E:11%D2rrN)rwrrr)r*rrr rs rr,zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.. sT ):$A}II14)9>>+?+?2):sAA r6)unexpected format for expanding parameterrrr c3bK|]&}j|j(ywrrr)r*rrrr rs rr,zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.. s93"(  11%H  "(s,/c3VK|] }j|j"ywrr)r*rr rs rr,zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.. s*3!'--eY^^D!'r)r)rrrrtuple_in_valuesrrr_isnullrcollections_abcrrbytes_has_bind_expressionrrwrrsearchrr) rr rbind_expression_templatetyp_dialect_implreplacement_expressionpost_compile_patternrrrrs `` @@r2_literal_execute_expanding_parameter_literal_bindsz>SQLCompiler._literal_execute_expanding_parameter_literal_binds s%>>AA$,,O  ..!%!=!=I200NN(()*=*=*&z)))m*.)E)E^^$i&9&9*&l)))e , ,  $ $6!9o&>&>?vay3,744)$ "\\99 r )2&(9   & "N)))1('+'A'A$(//0HIQWW?>?ggaj&&t,$'FCF!)-3"(3*&))) *.3!'3*& )))rc p jrj|Sj}jj | j r j n j jjr jr  fd n fd |smg jr4jjjj} |fSjjgj} |fS jsB jrt|dt j"rt|dt$t&fs j(rJt+|dD cgc]%\}}t+|dD]\}} |d|d|| f'c} }}} |j,rdnddj/ fd t+|Dz} |fSt+|dD cgc]\}} |d|| fc} } dj/ fd  D} |fScc} }}}wcc} }w) NcHjjd|izSNr)render_bind_castr)r bind_templater rrs r_render_bindtemplatezNSQLCompiler._literal_execute_expanding_parameter.._render_bindtemplate s,,,NN$!VTN2rcd|izSrr)rrs rrzNSQLCompiler._literal_execute_expanding_parameter.._render_bindtemplate s$~55rrrrrrrc3zK|]0\ddjfdtDz2yw)rrc3^K|]$\}}tz|zd&yw)rN)r)r*rrrrr rs rr,zMSQLCompiler._literal_execute_expanding_parameter... sD)AHAu-%a#m*<&. sG ):$A}II)2-(@ ):s6;c34K|]\}}|ywrr)r*r+rrs rr,zCSQLCompiler._literal_execute_expanding_parameter.. s/>AA'J    99M --M LL 2 2 11   6I..)-)E)ENN(()*=*=*&V000O*.)E)E^^$i&9&9*&N000G , ,  $ $6!9o&>&>?vay3,7'11 11)2&!(<(<$A} )- ;HAu $Q*E2 ;3(<I%44 " )2&(9   & ".000 !*&! 4 4HAu!!$e, 4I&*YY/(>?6<<)?)?@$(B !%8 **9hE  0R0 0 $Y/5t44!,(;    P55dIFCO Ps F.. G7GGc <|j|jfi|Sr)r sql_functionrss r&visit_function_as_comparison_op_binaryz2SQLCompiler.visit_function_as_comparison_op_binaryX st||G007B77rc &|jjr>|j|jfi|dz|j|jfi|zS|j|jfi|dz|j|jfi|zS)Nz %% r)rrrrxrrks rvisit_mod_binaryzSQLCompiler.visit_mod_binary[ s == ) ) V[[/B/$,,v||2r23  V[[/B/$,,v||2r23 rc |j|d<|j|d|j|jzdzfi|S)Nrr)rr~rrrss rvisit_custom_op_binaryz"SQLCompiler.visit_custom_op_binaryi sS'66 ,t,,  $,,X->->? ?# E   rc b|j||j|jdzfi|Sr)rbrrrss rvisit_custom_op_unary_operatorz*SQLCompiler.visit_custom_op_unary_operatorq s:4t44 T//0A0ABSH LN  rc b|j|d|j|jzfi|Sr)rcrrrss rvisit_custom_op_unary_modifierz*SQLCompiler.visit_custom_op_unary_modifierv s:4t44 S455h6G6GHH LN  rc |jdd}d|d<|j|d<|jj|fd|i||z|jj|fd|i|z}|r|rd|z}|S)NrFT _binary_oprr)rr/rxrr)rrrrrrrs rr~z$SQLCompiler._generate_generic_binary{ s#%&&)BE"J(, $%!??< *FKK * * %3 79  .fll--%379    #~D=D rc B||jj|fi|zSrrQrr`rrs rrbz,SQLCompiler._generate_generic_unary_operator s$:%--::4F2FFFrc B|jj|fi||zSrrQrs rrcz,SQLCompiler._generate_generic_unary_modifier s#/u}}//;;hFFrcLtjdtjS)Nz'%')r)rliteral_columnr% STRINGTYPEr/s r_like_percent_literalz!SQLCompiler._like_percent_literal s&&uH4G4GHHrc Dd|jj|fi|dS)Nzlower(rrQrs r$visit_ilike_case_insensitive_operandz0SQLCompiler.visit_ilike_case_insensitive_operand s):::4F2FGqIIrc |j}|j}|j|jj||_|j||fi|Sr_clonerconcatrvisit_like_op_binaryrrr/rpercents rvisit_contains_op_binaryz$SQLCompiler.visit_contains_op_binary sQ,,~~fll3::7C (t((@R@@rc |j}|j}|j|jj||_|j||fi|Srrrrrvisit_not_like_op_binaryrs rvisit_not_contains_op_binaryz(SQLCompiler.visit_not_contains_op_binary sQ,,~~fll3::7C ,t,,VXDDDrc |j}|j}t|j|_|j t|j j ||_|j ||fi|Srrrrrxrrvisit_ilike_op_binaryrs rvisit_icontains_op_binaryz%SQLCompiler.visit_icontains_op_binary sl,,,V[[9 ~~ "6<< 0 &/  *t))&(AbAArc |j}|j}t|j|_|j t|j j ||_|j ||fi|Srrrrrxrrvisit_not_ilike_op_binaryrs rvisit_not_icontains_op_binaryz)SQLCompiler.visit_not_icontains_op_binary sl,,,V[[9 ~~ "6<< 0 &/  .t--fhE"EErc |j}|j}|j|j|_|j||fi|Sr)rr_rconcatrrrs rvisit_startswith_op_binaryz&SQLCompiler.visit_startswith_op_binary sH,,'' 5 (t((@R@@rc |j}|j}|j|j|_|j||fi|Sr)rrrrrrs rvisit_not_startswith_op_binaryz*SQLCompiler.visit_not_startswith_op_binary sH,,'' 5 ,t,,VXDDDrc |j}|j}t|j|_|j t|j |_|j ||fi|Sr)rrrrxrrrrs rvisit_istartswith_op_binaryz'SQLCompiler.visit_istartswith_op_binary s^,,,V[[9 ''(>v||(LM )t))&(AbAArc |j}|j}t|j|_|j t|j |_|j ||fi|Sr)rrrrxrrrrs rvisit_not_istartswith_op_binaryz+SQLCompiler.visit_not_istartswith_op_binary s^,,,V[[9 ''(>v||(LM -t--fhE"EErc |j}|j}|j|j|_|j||fi|Srrrs rvisit_endswith_op_binaryz$SQLCompiler.visit_endswith_op_binary sF,,~~fll3 (t((@R@@rc |j}|j}|j|j|_|j||fi|Srrrs rvisit_not_endswith_op_binaryz(SQLCompiler.visit_not_endswith_op_binary sF,,~~fll3 ,t,,VXDDDrc |j}|j}t|j|_|j t|j |_|j ||fi|Srrrs rvisit_iendswith_op_binaryz%SQLCompiler.visit_iendswith_op_binary s\,,,V[[9 ~~&r)rrr\r r rr rimplrwrappedrr@rrexistingrrnrmrKrMs rvisit_bindparamzSQLCompiler.visit_bindparam8s$>>..t||+>>** :> @&&)*<*<((Y-?-?"..&  "..0@"#,--5  8A@ 9==!DJJt$4// #JD$++66T>bffBHOOI.,   &*D # !+/(++ {:+((YK7(#d##  %))$>>       3,C rctrr)rr dbapi_typerJs rrzSQLCompiler.render_bind_casts !##rc |tur|}n|j|jx|jdd}|rC|tj tj fvr!tjd|jf|jtjfi|S|j}|jr|j}||||\}} | S|j!||j"S)NrzBound parameter '%s' rendering literal NULL in a SQL expression; comparisons to NULL should not use operators outside of 'is' or 'is not')r)r.rrrr!is_is_notr& warn_limitedr+rr%rrrrrr) rrrrrropleepr rs rrz$SQLCompiler.render_literal_bindparams v -(E&9+=+=+EVVL$/"Y]]I4D4D$EE%%@#(  $t||H$5$5<<<--E   JJD*.)A+ 'I' $ #,,UINNC Crc|9|js-|jtjj S|j |j }|r ||Stjdtj|d|#t$r5}tjdtj|d|d|d}~wwxYw)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. Nz Could not render literal value "z" with datatype z); see parent stack trace for more detail.z:No literal value renderer is available for literal value ") should_evaluate_nonerrNull _instance_cached_literal_processorrrr7rsql_util_repr_single_value)rrr processores rrz SQLCompiler.render_literal_values =!;!;<< 7 7 9: :33DLLA   ''""//678!!&)  && 33E:;<%g##   sB C0C  Cc||jvr|j|S|j}t|tjr|j d|}||j|<|S)Nr)r)r+rrrDrr)rrrs rrzSQLCompiler._truncate_bindparam&s^  '??9- -MM i!:!: ;22; JI&/ "rc||f|jvr|j||fS|j|j}t||jdz kDr]|j j |d}|dt|jdz ddzt|ddz}|dz|j |<n|}||j||f<|S)Nrrrr6) r` apply_mapr_rr]rarmaxhex)r ident_classranonnamecounter truncnames rrrz!SQLCompiler._truncated_identifier3s  $"6"6 6''d(;< <>>$--0 x=4,,q0 0..22;BGS!2!2Q!6:;g,qr"#  5jj|r#jj fd|} |}| }|r"j j ||i_|rGd|z} |r| S|:|jj} | jrj|| | } | Sjtjurjd|iz} njd|iz} |Pjj r:|jj} | jrj|| | } | S)Nc@j|jdS)Nr)rr)rrs rrz.SQLCompiler.bindparam_string..esd88Drz__[POSTCOMPILE_%s]r)addrrrrr?rrrrender_literal_castrrr`rar.r-r) rrrr escaped_fromraccumulate_bind_namesvisited_bindparamrnew_namer@ type_impls ` rrzSQLCompiler.bindparam_stringKss ! , ! % %d +  (  $ $T *&&--d3 2266D $  &*&=&=&C&Ct$'D # &-C )*BBLL 00// 3OCJ ZZ=22 2//64.@C##vtn4C  & 66&>>t||LI))++NIsK rc|j}|jddt|j|jD]\}}|j |fd|i|y)Ncte_opts)copyrvrr_independent_ctes_optsr)rstmtrlocal_kwcteopts rrz&SQLCompiler._dispatch_independent_ctess[779 Z&  " "D$?$? HC #C " "4 B# B B rc " j} | jusJ||d<|j} t| tj rj d| } d} d} |j} |jxs |j}| jvrj| \}}}|| k(sJ|| f}j|}|jr|jrtjd|| f}|rtjnd}|| fx}}j|=|j|<||fzj| <n=|rtjnd}|| f}|jvrj|}nd}|||u} ||jus||urd} n||jur-| |=|j}|| usJ||usJj|=n[t!|t!|k(s)|j" |j"|j%|rd} ntjd| z|s| sy|j&O|j&}|j&j}t|tj rj d|}n|}d}| r|j|<||fzj| <|jvrj(|fi||s]|| vrX|j*rd_j.j1|| }|j*r^|j2}|j5dDcgc]\}}}}}|s|xs|}}}}}}|dd j7fd |Dzz }|j9d ddusJjs|j2j:fd |i|Sj<||j>fi|} |j2j:fd di|}!|d | d|!dz }|j@r$|dj<||j@fi|zz }|| |<|r|r| |jB|jE<| s| rj.j1|| S|rhj.j1||}j.jG| rj.jI| } |jK| z }|Sj.j1|| Sycc}}}}}w)N visiting_cterTFz6CTE is stated as 'nest_here' in more than one locationrz5Multiple, unrelated CTEs found with the same name: %rrrc3lK|]+}jj|j-yw)r8N)rformat_label_namer_)r*identrs rr,z(SQLCompiler.visit_cte..:s:"*4!MM;; % <*4s14subqueryrSrz (rr)&rrDrrrrDrr_get_reference_ctenestingrFrEr7rrr _restateshash _is_clone_ofcompare _cte_alias visit_cte recursiverGr format_aliasr_generate_columns_plus_namesrwrr_generate_prefixes _prefixes _suffixesrsr)_requires_quotesrget_render_as_alias_suffix)"rrJrSashint fromhintsrMrrEr self_ctescte_name is_new_cteembedded_in_current_named_cte_reference_cterS cte_levelrexisting_cte_optscte_level_name existing_cteold_level_namenew_level_nameexisting_cte_reference_cte pre_alias_ctecte_pre_alias_namer col_source proxy_namefallback_label_namervrepeated recur_colsprefixesrs"` rrYzSQLCompiler.visit_ctes((* DII%%%!$~88 h 9 9 :11'8DH (-%//1++1!1!1 T33 3.2.D.D/ +Iq+= ='2N22>BL $,,**1 #,X!6/6C OA 3> %NNM!$!4!4 ,h.G.GH%)%?%?/&" M!%  69D # #N 35CG6D " "> 2DII-}77%#Y*>==*.D'}}11#x@==!$J")EEdK"L &/$',9z9L" F "*4 "Dzz*e4===zz:3;;99%+/5 7t66S]] .4 H;CKK::%)-3Eh>>D==C"9$"9"9S]]#.4#D"& # 5= !!#--/2"?}}11#x@@!}}11#7IJ==11(;#}}228.s}$+C!MM//9 $)#@#@ !&"M$,,"E"E"M"M$'HH#"06#"!" &( !( $+sA3A6r)rzrrrrrrDrrrr[rsr)ra_supports_derived_columns_render_derivedrwrvformat_from_hint_text)rrrSrbrrcrQrrrrr alias_namer@s`` ` rr|zSQLCompiler.visit_aliasys4 "&0((((.3*+ )7'610;,-  &?+B+Be+K4EMM44 # %  EVw"')L:? ?Of%67 V%**h&?&?@!77L "ZZ ==--eZ@ @ 7A !!%//"344EMM44!76<E"')$99 **5*=C..53H3HvII$)77$Ui/00 % 0&J45==33%)/ rc 2d|d<|j|fi|S)NTrQr|)rrQrs rvisit_subqueryzSQLCompiler.visit_subquerys#:t/B//rc 8d|d<d|j|fi|zS)NTrz LATERAL %sr)rlateral_rs rr{zSQLCompiler.visit_laterals)9 .d..x>2>>>rc |j|fddi|d|jj|fi|}|j#|d|jj|fi|zz }|S)NrSTz TABLESAMPLE z REPEATABLE (%s))r| _get_methodrseed)r tablesamplerSrrs rvisit_tablesamplezSQLCompiler.visit_tablesamples D  [ < < < 8K # # % 8 8 D D     ' &3   33D?B? D rc jdjdjfdjD}d|S)Nr rc 3K|]I}|D]B}jtj|djij fiDKyw)rN)rrr _column_typesr)r*chunkelemrrrs rr,z-SQLCompiler._render_values..se  ' DLL26!//*,     'AAr) setdefaultr rw_data)rrrtupless``` r_render_valueszSQLCompiler._render_valuessG ow'<'<=  !   !!rc (j|fi}|jrd}nMt|jtj rj d|j}n |j}|jrd}nd}|r|r!||nd|j|j<|r`dd<|d|djjj|d d jfd |jDd}|S|d|d}|S) NrzLATERAL rz(unnamed VALUES element)Frrr (rc3DK|]}|jfiywrrrs rr,z+SQLCompiler.visit_values..s+"%41A00<<%4r)r_unnamedrrrrDrrrzrsr)rarrrwcolumns)rrrSrrrqrrs` ` r visit_valueszSQLCompiler.visit_valuess D   .2 .   D  h&?&? @--h ED<.add_to_result_maps&wwj%Hrc$||f|z|yrr)rrrrrrs rrvz;SQLCompiler._label_select_column..add_to_result_maps&y7':ErNzX_label_select_column is only relevant within the columns clause of a SELECT or RETURNING)rz*proxy_name is required if 'name' is passedTF)r\rvr)rrr_has_column_expressioncolumn_expressionrrrrHrrrrrFrr TextClauseUnaryExpressionwraps_column_expression NamedColumn_non_anon_label_anon_name_labelrDrfr)rrrrrSrrrsrtr\column_is_repeatedneed_column_expressionsrrcol_exprrv result_exprrender_with_labelrs ` @rrz SQLCompiler._label_select_columnZsf {{'' 5  & & #':--f5HH  !% 7 7  "%6"I '%6" !% %  : $ fhnn -v%+fkkfnn5F ' & <; <&( $$ K&v%%)!FH$9$9:1"---1 D0" FH$7$78$)!FH$<$<=$*$B$B$Lf! vx';';<**2$(!$)! * 211*0*A*A'&+X-F-F--.AB- $,1j] ' !!"7/' " .{--dI6HIIrc>|j||}|r|d|zz }|Sr)get_from_hint_text)rrJrhintrhinttexts rrz!SQLCompiler.format_from_hint_texts***5$7  sX~ %Grcyrr)rbyfromss rget_select_hint_textz SQLCompiler.get_select_hint_textrcyrrrrrs rrzSQLCompiler.get_from_hint_textrrcyrrrs rget_crud_hint_textzSQLCompiler.get_crud_hint_text rrc$dj|Srr)r hint_textss rget_statement_hint_textz#SQLCompiler.get_statement_hint_text sxx ##rrrrrc |j }|r |jn|jd}|j||}|d}|d} |r&|s$|j|j | d} | S|j|| } | S)Nr{rrrexplicit_correlate_fromsimplicit_correlate_froms)rrrJ_get_display_froms difference) r select_stmtrSrrrrrrrrss r_display_froms_for_selectz%SQLCompiler._display_froms_for_selectszz>-5))4::b>#::;M  12^, '!44)8)C)C **, 5E "44)8)55E rtranslate_select_structurec  %|Jdd| d<|j||fi| } | j| d<| j}|j } | r|js| |_|duxs|} |j r?|j |fd|i| } | |ur&| }|}| }|j||fi| } | j}| r |j n|jd}| xs&|jddxs|jddx}}|rd}|sd | vr| d =|j|| ||||}| j}|jddd d }|jr|j|\}}|r ||d zz }nd}|jr|j|| |jr!||j ||jfi| z }||j"|fi| z }| j$Dcgc]#\}}}}}|j'|||||||||| %c}}}}}Dcgc]}||}}|r|t)t+| j$Dcgc] \}}}}}| c}}}}}j$Dcgc] \}}}}}| c}}}}}%|j,D cgc]'\}}}} t/||t1%fd|D| )c} }}}|_|j3||| |||| | }|j4rQ|j4D!"cgc]!\}!}"|!d|j6j8fvr|"#}#}!}"|#r|d |j;|#zz }|j<r2| r| r.| st?|jnd}$|jA|$|z}|jBr$|d |j ||jBfi| zz }|jjEd|Scc}}}}}wcc}wcc}}}}}wcc}}}}}wcc} }}}wcc}"}!w)NzpSQLAlchemy 1.4 requires use of the translate_select_structure hook for structural translations of SELECT objectsFr\rrSr{rrrv)rqr\zSELECT r)rrsrtrrc3BK|]}j||ywrr)r*orFs rr,z+SQLCompiler.visit_select..s$F#QY]]1a%8#srr)#rJ_ambiguous_table_name_mapr rrrrr_setup_select_stackrFrf_hints_setup_select_hintsrrr^r]get_select_precolumnscolumns_plus_namesrrrrrr._compose_select_body_statement_hintsrrrrDrrr_rv)&rrrS insert_intorcrselect_wraps_forrrrrris_embedded_selectnew_select_stmtcompile_state_wraps_forrrrrsrr hint_textbyfromrrsrtrrurv inner_columnsr+rr dialect_nameht per_dialectrrFs& @r visit_selectzSQLCompiler.visit_select;s  '  - '+0&': ::  !'   3 3 )*$-- zz> D..!.D +47F;  * *=d==$*.4O k1*7'#. - B B B!)/! ,55 -5))4::b>  >yy7? >yy5u= 5 "'  #':f'D*+(( vw $[[]!!$)E J     $ 8 8 E Iv C'F  ( (  + +K @  +D++[226< D ***;A&AA.#55'&6 '#))'&)(;'/,C* $6' *}-   4 #3#?+== > &/ $ > $5GG H &/ $ H I:.2-A-A $.B)CsE#u$F#$FF.B $D ((            ' '+6*F*F*F&\2C):):#;;*F  d::;GGG 990H3;C OM***G$ND  C1$11[226< D r y @  $&s$&(O  OO+O(,O1 &O9c |jjDcic];\\}}}|d|jjfvr||d|j |diz=}}}}|j |}||fScc}}}w)NrrT)rb)rrgrrrr)rrrrrrrs rrzSQLCompiler._setup_select_hintss /5mm.A.A.C /D* (3 1 122 8u//T/BCD D.C  --f5 &   sAA8c |d}|d}|dk(r||d<nf|rd|d} t| j} t|j| k7r2tjdd| |dzt|jfz|r%|s#|j |j |d} n|j ||} tt| } | j|} | | ||d }|jj|| S) Nrrrrz}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %drrr)rrr$r) rrurr7rrrror*rrr)rrrrrSrrrrrnumcolsrsnew_correlate_fromsall_correlate_fromsrs rrzSQLCompiler._setup_select_stacks; 12^, Q  &E*  Z(H(889G=334?&&! &*F889     '!44)8)C)C **, 5E"44)8)55E "-"78177H02 * * )$ rc ,|dj|z }|jtzr1tit } |jt z} |r | |_nd} d} |s|j}|r|dz }|jr8|dj|D cgc]} | j|fd|| d|c} z }nJ|dj|D cgc]} | j|fd| d|c} z }n||jz }|jr)|j|jfd| i|} | r|d| zz }| r| J| j|jr||j|fi|z }|j r'|j|j fi|} | r|d | zz }|j"r||j$|fi|z }|j&r||j(|fi|z }|j*||j,|fi|z }|Scc} wcc} w) NrFz FROM T)rSrcrrSrrz WHERE z HAVING )rwrWrgrkrorhrrstriprrrC_where_criteriarr_group_by_clausesrN_having_criteria_order_by_clausesrOrPrQ_for_update_argfor_update_clause) rrrrrrsrrrr warn_lintingfts rrz SQLCompiler._compose_select_bodyHs  -(( <<4 4$R/K<<,6L#. K L;;=D  J D}} "' "'A-,, #'&,(3  % "'    "'"'A -,, #'(3%  "'   D%%' 'D  ! !111&&4?CIA a' * **      # # (D((:6: :D  " "111''+1A q((  # # (D((:6: :D  * * *D**6.sI (0$ {*ldll>O>O.O &F % %d 1b 1(0s=Ar)rrHrwrrs` ` rr]zSQLCompiler._generate_prefixess1 (0    cMF rcv|jsy|r|dkDrtj}t|jj D]g}|j |j \}}}|jxs |j}||k(xs |xr||dzk(} |r| sV|j|||<in |j}|syt|Dcgc]}|jc}} |j| dz} | dj|jD cgc]} | c} z } | dz } |r{|dkDrvt|j D]Z}|j |j \}}}|j|=|j||f=|j |j =\| Scc}wcc} w)z include_following_stack Also render the nesting CTEs on the next stack. Useful for SQL structures like UNION or INSERT that can wrap SELECT statements containing nesting CTEs. rrr, z )rDr&rrkeysrFrRrSrgrZget_cte_preamblerwrrE) rrrIrDrJrirerErSis_rendered_levelrGcte_texttxts rrzSQLCompiler._render_cte_clausesyy ]Q.##%DDIINN,-040F0F**,1- 8X++9)9)9$-$>%+N ]Q=N0N" $5 IIcNS .99DtFKK >  >??E ]Q.DIIK(040F0F**,1- 8XIIcN++Y,AB**3+A+A+CD )=!?s F1 F6 c |ryy)NzWITH RECURSIVEWITHr)rrZs rrzSQLCompiler.get_cte_preambles #rc h|jrtjdd|jrdSdS)zcCalled when building a ``SELECT`` statement, position is just before column list. a DISTINCT ON is currently supported only by the PostgreSQL dialect. Use of DISTINCT ON for other backends is currently silently ignored, however this usage is deprecated, and will raise CompileError in a future release for all backends that do not support this syntax.z1.4versionrr) _distinct_onr&warn_deprecated _distinctrrrs rrz!SQLCompiler.get_select_precolumnss:     3   %..{6B6rc x|j|jttjfi|}|rd|zSy)z5allow dialects to customize how GROUP BY is rendered.z GROUP BY r)rrrsr!comma_op)rrrgroup_bys rrNzSQLCompiler.group_by_clausesG1400  $ $i 0B0B&C GI  (* *rc x|j|jttjfi|}|rd|zSy)z5allow dialects to customize how ORDER BY is rendered.z ORDER BY r)rrrsr!r)rrrrs rrOzSQLCompiler.order_by_clausesG1400  $ $i 0B0B&C GI  (* *rc y)Nz FOR UPDATErrs rrzSQLCompiler.for_update_clausesrc |jdtj|D cgc]"\}}}}} |j|||f|| ||d|$} }}}}} ddj | zScc} }}}}w)NT)cols)rtrrrs RETURNING r)r\r_select_iterablesrrw) rrHreturning_colsrrrrsrtrrurs rreturning_clausezSQLCompiler.returning_clauses222411.A3# " # )D ( (# %8#+%   #  ,dii000- s'A. c d}|j#|d|j|jfi|zz }|j4|j|dz }|d|j|jfi|zz }|S)Nrz LIMIT z LIMIT -1z OFFSET ) _limit_clauser_offset_clause)rrrrs rrYzSQLCompiler.limit_clause6s    + K,$,,v/C/C"Jr"JJ JD  ,##+ % Jf.C.C!Jr!JJ JD rc ||j}|j}nddd}d}|jK|j}|r!|j|r|j }|j |fi|} |d| zz }n|r|dz }|O|r!|j|r|j }|d|j |fi||drdndd |d rd nd z }|S) NF)r with_tiesrz OFFSET %s ROWSz OFFSET 0 ROWSz FETCH FIRST rz PERCENTz ROWS r!z WITH TIESONLY)rW_fetch_clause_optionsr_simple_int_clauserender_literal_executer) rrrXrequire_offset"use_literal_execute_for_simple_intrfetch_clause_optionsr offset_clause offset_strs rrXzSQLCompiler.fetch_clause@s  !//L#)#?#? /45#I   ,"11M2--m< - D D F %m:r:J '*4 4D  & &D  #2--l;+BBD  \0R029= 2E3K@ fL D  rc  R|r|j|j|<|s|r|jj|} |rG| rE|jj | dz|jj |j z} n|jj |j } | s]|r[|j |vrM|jd||j } | |j|jjd| z} |r||vr|j| ||||} | Sy)Nrrr) fullnamersrrrrrrrrar[r) rrrSrrbrc use_schemarrrrr@ anon_names r visit_tablezSQLCompiler.visit_tableis% ',~~K  e $ V#}}>>uE .MM../?@mm))%**56 mm))%**5)0 &>> $ : :!9%**!E!I ? ? 224C!CUi/00 % 0&Jrc |ri|jjtjt |j j t |jj |jrd}n|jrd}nd}|j j|fd|d||z|jj|fd|d|zdz|jj|fd|i|zS)Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN Tr ON r) rtrfrrr)rxr*rruisouterronclause)rrwrSrr join_types r visit_joinzSQLCompiler.visit_joins      $ $!!dii556djj667  99+I \\+I I (DII ( ( !{ >D  ,djj++!{>D   /dmm.."-17  rc"|jjDcic]%\\}}}|d|jjfvr||'}}}}|j|vr+|j ||j||jd}||fScc}}}w)NrT)rrgrrrr)rrH table_textrrr dialect_hintss r_setup_crud_hintszSQLCompiler._setup_crud_hintss04{{/@/@/B /B+ )3 1 122 9 /B  :: &33DJJ djj(A4Jj(( s*B c|jj}|j}|j}|y|jr'|j j |jd}n&|jj |jd}||zr|S|jr3tjd|dd|jjdy)a)given a :class:`.Table`, return a usable sentinel column or columns for this dialect if any. Return None if no sentinel columns could be identified, or raise an error if a column was marked as a sentinel explicitly but isn't compatible with this dialect. NrzColumn z@ can't be explicitly marked as a sentinel column when using the a dialect, as the particular type of default generation on this column is not currently compatible with this dialect's specific INSERT..RETURNING syntax which can receive the server-generated value in a deterministic way. To remove this error, remove insert_sentinel=True from primary key autoincrement columns; these columns are automatically used as sentinels for supported dialects in any case.) r"insertmanyvalues_implicit_sentinel _sentinel_column_characteristicsr is_autoinc_sentinel_col_autoinc_lookuprdefault_characterization _sentinel_col_non_autoinc_lookup is_explicitr7r-r)rr sentinel_optssentinel_characteristics sent_colsbitmasks r_get_sentinel_column_for_tablez*SQLCompiler._get_sentinel_column_for_tables GG #(#I#I ,44   # . .77;;(AA1G;;??(AA1G 7 "  # / /)))A,(><<$$%&@ @  rc # @ABCDKj}|J|jsd} ntj|j} t |} |j rj jsd} d} nEj jr&|r)jr|j |jrd} d} nd} d} | rNttdt||dD]*\} \}}t|||g| r | |gngd| | || ,y|r,t!j"j$j&|}nd}|j(}|r||}d|d}|j+|d}j j,}|rAt j.}t |j0}||z }t3|||z |z}td t5|}td t5|}d}d} | |z| |zrdnd z}|j0}|J|r$|Dcgc]\}}}}|||||f}}}}}d xCDj6sj8r j8AniAt;|d } Afd @|j<rd }!nd }!ddj?@fd|D|!d}"| jAAfd|D}#| jC|#Dcic] }||d | }$}d Bnd }"t;}#i}$|j<rd|dBnd|dBt;}%|j0D]}&|%jE|&d|%r]jF}'|'Jt|'D()chc] \}(})|)|%vr|( }*}(})t3|*CtI|*dzDt |*DCz k(sJjJr9tMjNjP}+tMjR|+ddBB|r[|d |},|d |}-g|d |g|d ||r|}.n t |,}.r,fdtU|.DD/01cgc] \}/}0}1|/|0|1f }}0}/}1j6r|jV}2|2t |,d k(rdx}3}4|,}5n|,d dC}3|,d Dd}4CDfd|,D}5|j<r'd j?Bfdt|,Ddd}6nB|.zdd}6jJr9|2d kDr4|4rJCdz}7|2|.z|7z}8tYfdtU|7|8D}9|6|9z}6|j+d|6}:tYtZj\j_|5};|3|;z|4z};ng}<|$ja};t|,D]\}=}|"j+dtc|=}>|j<r|>j+dtc|=}>||;jE|#Dcic] }|d|=||c}|j+ddj?|<}:t|:|;||,| r|-D?cgc] }?| |? c}?ng|.| ||d | dz } |rZyycc}}}}wcc}wcc})}(wcc}1}0}/wcc}wcc}?ww)NTFzKSequence[Tuple[_DBAPISingleExecuteParams, _MutableCoreSingleExecuteParams]]rrrr__EXECMANY_TOKEN__zList[Sequence[Any]]rc|D]G}j||}|jjd|izjd|diz}I|S)Nr__EXECMANY_INDEX__)rrr-)r formattedr+r?rs rapply_placeholderszISQLCompiler._deliver_insertmanyvalues_batches..apply_placeholderssgC,00c:C ) 1 1))VSM9))!cU*<#=>?!I ! rz, _IMV_VALUES_COUNTERrrc3:K|]\}}}}||ywrr)r*rrL bind_keysrMs rr,z@SQLCompiler._deliver_insertmanyvalues_batches..s)62D.Aq)Y#9i82Drc3ZK|]"\}}}}|D]}j||$ywrr)r*rrOr+r?s rr,z@SQLCompiler._deliver_insertmanyvalues_batches..s<4*<&Aq!Y$C#&&sC0$1*<(+z, _IMV_VALUES_COUNTER), z), r z\d+rc3HK|]}D]\}}}|d|||fyw)rNr)r*ror+len_rgeneric_setinputsizess rr,z@SQLCompiler._deliver_insertmanyvalues_batches..s>/%>E.CNCs 5%)45.C6%>rrrc3(K|] }| ywrr)r*rlexpand_pos_lower_indexexpand_pos_upper_indexs rr,z@SQLCompiler._deliver_insertmanyvalues_batches..s"&!&A01GH!&sc3ZK|]"\}}jdt|$yw)_IMV_VALUES_COUNTERN)rr)r*rrexecutemany_values_w_commas rr,z@SQLCompiler._deliver_insertmanyvalues_batches..$s5 )917>> 5s1v)9rQc3>K|]}j|ywr)r/)r*rrs rr,z@SQLCompiler._deliver_insertmanyvalues_batches..As)&!2A >>?sC!2rEXECMANY_INDEX__rY__)3r;rAr/r>rr6rsupports_default_metavaluesupports_multivalues_insertrr?r=rrrrE functoolspartialrrr7rinsertmanyvalues_max_parametersr)r9minrrQr?rorCrwrrrfr%r1r4rLrMr/rranger;r.rr from_iterablerFrr)Err r!compiled_parametersrT batch_sizer<rimv_sentinel_from_params lenparamsuse_row_at_a_time downgradedrMparamcompiled_paramrstimv_single_values_exprexecutemany_values max_paramstotal_num_of_paramsnum_params_per_batchnum_params_outside_of_batchbatchescompiled_batchesrIrNr9rr+rstall_keysimv_values_counterformatted_values_clausekeys_to_replacebase_parametersall_names_we_will_expandrr%r?rall_expand_positionsescapedrJcompiled_batchrLnew_keyrSrnum_ins_paramsextra_params_leftextra_params_rightbatch_iteratorexpanded_values_stringr}rirrFrGreplaced_values_clausesrfmvrMrMr?rZrVrWsE` ` @@@@@r!_deliver_insertmanyvalues_batchesz-SQLCompiler._deliver_insertmanyvalues_batches!s$$&&$( !$,$7$7((% ! O   t||'N'N!% J99 #$$%%-1N1N !% J % J 5>a $78 6115.-)G1/~>?+6.  ## 77%9C C!$!7!7 %()?%@ " !7 8:%%&8:NO \\AA "%doo"6 #&s'='=#> #&:: ("==+,J,d:.>? !4(;#< HL!Z/Z'AQ !33!--- +="*<&CdBc3t9b)*< " ;<;!7&&%)%<%<"%'":a=)H !''%<"%'"*+DII62D6-,""!'' # '334*<4O$..??CZ]3''? *, &&( #!eO O''.//GH+011G0H-L*14 $..(//Q8/(".. "...&/{%;(%; T77%;%( *--A)B&),-A)BQ)F&,--0FFGG""))D$G$GH-/VVy$d,F.*Aj)E-a ;N$&GAj !-/ Qz *%/"%(Z"$ /%*+=%>/+/*sdC(/(+!$!B!B "Sq]2=??%(:%*N(-a1H2H(I%).q2H2I)J&&!&&N ++ )2%(8   r.*46HHr.*&&>A+= 2112Q6E(,>?%GC!&&!&uc!2&!I.Di-O*%.%6%6(*@&"',OO11.A'# &)*()$+-'&5&:&:&<# )% 0HAu199*CFC//!kk*?QH+2237'..>MNosC51#c 2oN!1&/%6%6(II56&" )"#'-:HH2*2.H"'  MHIo"P:(D+xOIsXHY%Y 1B"Y%Y #A;Y%Y.B5Y%#Y3FY% Y 9Y%Y &Y%?&Y%c |j|fi|}|j}|||d<d}n j }|r-d_js|_j s|_jj tt|dd}d}jr|g}tj|||fd|i|}jrB|@t|}jr)jxj|z c_ n|_ |j} | snjj sXjj"sBjj$s,t'j(djj*z|j,rjj.s,t'j(djj*zj0s |j2r!|j4rt'j(d |j} n |j} j6} jj } d } |j8r!| j:||j8fi|z } | d z } | j=|j>} |j@rjC|| \}} |jDrjG||| | z } | s| s,| d d jI| Dcgc] \}}}}| c}}zz } |jJ}d}d}d}j0xs |j2}|r|jL}||sJ| Dcic] \}}}}|| }}}}g}|D]7}||vrd}n/jO|}|||vrd}n|j |9|@jjPtRjTzrd}n|djVrJdtY|tY|z}j[|||}j\r | d|zz } nd}|j^j`jddfddi|}jbrLjjdr6|stjnd}| djg|d|z } n| d|zz } n| sf| rd| dz } |rtidjjjtmd| ||j4|jndu||r t|nd| _8n}|j,r*| dd jId|jrDz } nGd jItmd| Dcgc] \}}}}| c}}}|r |rjjPtRjtzr|jvsd}jjPtRjxz} d jIdt{| D}!| r$d jIfdt{| D}"n|!}"| d|"d|d|!d z } n d}| d!|d"z } tid|tmd| ||j4|jndu||r t|nd|||# _8n | d!|d"z } |jn'j`|jnfi|}#|#r| d|#zz } |rj\s| d|zz } jbrEjjds/|stjnd}jg|d| z} jj}d| Scc}}wcc}}}wcc}}w)$NrMFTrrrAzWThe '%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.zcRETURNING cannot be determinstically sorted when using an INSERT which includes multi-row values().zINSERT zINTO  (%s)rzTsentinel selection rules should have prevented us from getting here for this dialectrrr{rrrHrz DEFAULT VALUESr8)r<r=r?r@rBz VALUES c3RK|]}ddjd|Dz!yw)rrc3*K|] \}}}}| ywrr)r*rrs rr,z5SQLCompiler.visit_insert...ts L^>1a^sNr)r*crud_param_sets rr,z+SQLCompiler.visit_insert..rs3+Nyy L^ LLN*Ms%'c3,K|] \}}d|ywpNr)r*rrs rr,z+SQLCompiler.visit_insert..s),IDAq!A3,Isc3K|]L\}^}}j|j|jjjd|Nywr)rrrr)r*rrrrs rr,z+SQLCompiler.visit_insert..sX4 1N 9C! !11 # # @ @ N"#A3 1NsAAz SELECT z FROM (VALUES (z)) AS imp_sen(z#, sen_counter) ORDER BY sen_counterz VALUES (r) r6r7r9r;r<r=r?r@rArBrC)?rJr rr rrrrorQr_get_crud_paramsrr4rA single_paramsrsupports_default_valuesr_supports_empty_insertr7rr_has_multi_parametersr`r& _returning_sort_by_parameter_orderrr^r] format_tablerrr9rrrwuse_insertmanyvaluesuse_sentinel_columnsrr;rRr[_insert_sentinelrrr*rrrDcte_follows_insertrr5default_metavalue_tokenr_post_values_clauser;all_multi_paramsr]is_default_metavalue_onlyr^rrv)$r insert_stmtrArMrrrcounted_bindparamcrud_params_structcrud_params_singlerrrr7rrrnamed_sentinel_paramsadd_sentinel_colsrBrr param_names_params_by_col_add_sentinel_col param_namer select_textrrrsembed_sentinel_valuerender_bind_castscolnamescolnames_w_castpost_values_clauses$` r visit_insertzSQLCompiler.visit_insert|s; ::  !# $--  #!-B~ H::~H  DM)))6&%%%2" #&5 #)  ! ??|3 !# !22      0     ??0< #$5 6 ""))5**.??*->D*/==#LL88LL;;LL66""!\\../   . .<<;;&&137<<3D3DE '';+A+A66&&I"4!A!A !3!A!A =="&,,"F"F  +D++[2268 D **;+<+<=    22; KMAz  ( (  + +K <  %< Gdii+=>+=-!T1a+=> D 2FF9= !00JK4J4J  2 G G  ,+++3E"2D.Q;$2D")+%):%(>04-!%!C!C)"J"8I)JJ04-)00<*;)0 GG6HHI-1)$5Q#7#H#HDH"&n!5=N8O!O#44$, 5   --... $     )&$,, 234BFJLKyyT\\<<7?DJJT ++&304,  ++#(? % %D#):LL889;M&#<<$77tC%62C-.&7#*&& 0 0  +=*M*M D)- +/9*++1eQ+) %$% GG6MMN 0II ,0( GG6NNO& $yy),56H,I) H)+/))4 1::L0M 4++3"?"34$$=#>?&&.Z0//D,1(i(A'B!DDD):$)'@'+9*(3D#<<$77tC%62C-.(=&7)=)*&0)$=#>a@@  * * 6!-//"35" "000 D$B$B C** *D 99T\\<<3;C OM''"/,0(   r s?0"^s;]]%;], cy)z3Provide a hook for MySQL to add LIMIT to the UPDATENr)r update_stmts rupdate_limit_clausezSQLCompiler.update_limit_clausercy)z3Provide a hook for MySQL to add LIMIT to the DELETENr)r delete_stmts rdelete_limit_clausezSQLCompiler.delete_limit_clauserrc 6d|d<|j|fddi|S)z|Provide a hook to override the initial table clause in an UPDATE statement. MySQL overrides this. TrSrr)rr from_table extra_fromsrs rupdate_tables_clausez SQLCompiler.update_tables_clauses*8 ,z,,TE$E"EErc td)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 UPDATErrrrr from_hintsrs rupdate_from_clausezSQLCompiler.update_from_clauses" %  rc ||j||fi|}|j}|||d<d}n |j }|r-d|_|js||_|j s||_|j tzr1tit}|j tz}|r ||_ nd}d}|j}t|} | rDtt|j} |D cgc] } | | vs|  } } | j!|} ng} |jh} |jj#| | |dd}|j$r!||j&||j$fi|z }|j(||j| fd|i|}t+j,||||fi|}|j.}|j0r|j3||\}}nd}|j4r|j7||||z }|dz }|dj9d t;d |Dz }|j<s |j>r>|j@r2|d |jC||j<xs |j>| zz }|r,|jD||j| |fd|i|}|r|d |zz }|jFr)|jH|jFfd|i|}|r|d |zz }|jK|}|r|d |zz }|j<s |j>r>|j@s2|d |jC||j<xs |j>| zz }|jLr.|stO|jnd}|jQ||z}|r|J|jSd|jjUd|Scc} w)NrMFTrzUPDATE rz SET rc36K|]\}}}}|dz|zyw)=Nr)r*rrrs rr,z+SQLCompiler.visit_update..`s. &!4 3J &szList[Tuple[Any, str, str, Any]]rr WHERE rUPDATErr{)+rJr rr!rrrWrgrkrorhr _extra_fromsrr*rrrr^r]rrrrrr9rrrwrr&rr*rrrrrrDrrrrv)rrrMrrrrrr is_multitable main_fromsrrender_extra_fromsrrr7r crud_paramsr8extra_from_textrrYrs r visit_updatezSQLCompiler.visit_updatesN: ::  !# $--  #!-B~ H::~H  DM)))6&%%%2" <<4 4$R/K<<,6L#. K L#00 [) ];+<+<=>J&"&a!:*=; ")..{;O!# *001O #2 /)    +D++[2268 D/T..      $    "22 +}h :< )66   (,(>(>Z) %M:!M  ( (  + +K <     %)1;&     " "k&<&<--d33++E{/E/E(04 5d55!!"  (   Oo--  & &111++9DHJA A %// <  C,& &D  # #{'='=00 C$//''A;+A+A$,0 D 993;C OM***G$ND * **   x  0 r S"s * N94N9c td)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 DELETErrs rdelete_extra_from_clausez$SQLCompiler.delete_extra_from_clauses" %  rc .|j|fddd|S)NT)rSrr)rrrrrs rdelete_table_clausezSQLCompiler.delete_table_clauses,,z,,  d .0  rc |j||fi|}|j}|||d<d}n |j }|r-d|_|js||_|j s||_|j tzr1tit}|j tz}|r ||_ nd}d}|j}|jhj|} |jj| | |dd} |j r!| |j"||j fi|z } | dz } |j%||j||} t+j,||||fi||j.r|j1|| \} } nd} |j2r|j5||| | z } |j6s |j8r>|j:r2| d|j=||j6xs |j8| zz } |r,|j>||j|| fd |i|}|r| d|zz } |j@r)|jB|j@fd |i|}|r| d |zz } |jE|}|r| d|zz } |j6s |j8r>|j:s2| d|j=||j6xs |j8| zz } |jFr.|stI|jnd}|jK| | z} |r|J|jMd |jjOd| S#t&$r@|j%||j|} |r|j)|j|} YAwxYw)NrMFTrzDELETE FROM )rrrrrrDELETErr{)(rJr rrrrrWrgrkrorhrrrrrr^r]r TypeErrorrrrrr9rrr&rr*rrrrrrDrrrrv)rrrMrrrrrrrrr7rr8rrrYrs r visit_deletezSQLCompiler.visit_deletes: ::  !# $--  #!-B~ H::~H  DM)))6&%%%2" <<4 4$R/K<<,6L#. K L#00 &,,-33K@ #2 /)    +D++[2268 D  M11!!' 2J dKOBO   (,(>(>Z) %M:!M  ( (  + +K <   # #{'='=,, C$//''A;+A+A$,0 D ;d;;!!  (   Oo--  & &111++9DHJA A %// <  C,& &D  # #{'='=00 C$//''A;+A+A$,0 D 993;C OM***G$ND * **   x  0 r U M11[.. JLL!2!2 LL Ms+MAN  N c >d|jj|zS)Nz SAVEPOINT %srformat_savepointrsavepoint_stmtrs rvisit_savepointzSQLCompiler.visit_savepoint3s > >~ NNNrc >d|jj|zS)NzROLLBACK TO SAVEPOINT %srrs rvisit_rollback_to_savepointz'SQLCompiler.visit_rollback_to_savepoint6s#)DMM,J,J -   rc >d|jj|zS)NzRELEASE SAVEPOINT %srrs rvisit_release_savepointz#SQLCompiler.visit_release_savepoint;s#% (F(F )   r)rr\r rrrrUr$rVrrWrerkzOptional[SQLCompiler]rr)rr7)rr%)rzDict[Any, Any])rzMutableMapping[CTE, str])rzVMutableMapping[str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]]])NT)rrrrrr)NNTNTF)rrrrrrrz Optional[int]rrrSrrr[F)r!r[rTrrr)rzCallable[[Any], str])NFFNr)NTrN)rColumnClause[Any]rvOptional[_ResultMapAppender]rrrwrrz Optional[_AmbiguousTableNameMap]rrrrr)NF)r$z Function[Any]rvrrrrr)FNNr)NFNN)FFFFF)r3rrrDrr)rrrr)FFNNNN)rrrrrrr?r7rzOptional[TypeEngine[Any]]r@zOptional[Set[str]]rAr9rrrr)rJrMrSrrbrrczOptional[_FromHintsType]rMz Optional[CTE]rzOptional[FromLinter]rEzselectable._CTEOptsrrrr7)FFFNFFNN) rrrrrrrrrr)NNNTFFT)FFNNNFN)rrrzTuple[str, _FromHintsType] rHrBrzSequence[ColumnElement[Any]]rrrrrr)NFF)FFFNTNN)rrJrr>)r rr!rWrgz%List[_MutableCoreSingleExecuteParams]rTrHrhr:r<rrrrz Iterator[_InsertManyValuesBatch]rm)rrrr EXTRACT_MAPr)r&rrrrCOMPOUND_KEYWORDSrKrr r!r#r$r&r'r*r+r,r0r1r2r3r4r5r6r8r:r;r< frozensetr=r>rr?rpostfetch_lastrowidr@r%rArBrCrLrNrrpatternrrrrJrfrr3rsro_memoized_propertyrwryr~rmemoized_propertyrmemoized_instancemethodr contextlibcontextmanagerrrirhrrrrrrrrjpreload_modulerrr6rArCrNrTrWrhrnr{rrrrrrrrrrrrrrrrrrrrr rrrr"r'r,r2r.r@r=r:rUrQrrdrlrortrwr|rrrrrrzrrrrrr~rbrcrrrrrrrrrrrrrrrrrrrrrrr rrr.rrrrrr:rrr$_CTEOptsrYr}rr|rr{rrrrrarrrrrrrrr<rrrrrrrrr]rrrrNrOrrrYrXr/r5r9r, CLIENTSIDErRr\SENTINEL_DEFAULTNONErYrZr@rrXr>rFrrrrrrrrrrrrrrrrrr s  K    ; :/.66 F)HdHdHd +*%.0O*/.0O*/$BF>EK ((I--6 %$4',t+5:+T9 "OT!B!!%(' .- &+d*"OT!"d! ).- !ND  !&%=A "9@+/-. 6:295929=A:A@OO.3- `.3+`!#"/b /;?".0EI 9O!9O89O 9O , 9O #C 9O9O 9OvA    4052h   "@L&&K ( T :   7;?,,8, , ,\8 C04?B3 -AC$L6"BB  4$ ;?H*TM1d 6p8    05*GG IIJA E BFA E BFA E BF    AE     $" cJ$ $!% DB#J &6 *$ #&*484815AAA A $ A 2 A 2A/AA AFC.2&*,0(; (;(;E(BV VV V , V $ V*V&VV Vp30 bH0?  "$L9(   !      4EI 8 " %bJH $.-   1t11 - /L M  ,1:'+*KZ !! ! # !2h]~ %3j 7  1151 " 1  1 1@+0 'X!%.` < )"(:t'9'9 , 7 7,>> , = =,>> , 1 1,>> , 5 5,55 , 5 5,55 ($&$D#I#I , 1 1,:: $ << (<|YY-YC Y C Y  Y"&Y?Y *Yx AEpd F  KZ  AFO  rrceZdZdZdZej dfdZdZdZ dZ dZ dd Z d Z d Zd Zd ZdZdZdZdZxZS)StrSQLCompileraA :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:`_expression.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:`_expression.ClauseElement.compile` directly. .. seealso:: :ref:`faq_sql_expression_string` cy)Nzrr~s rrz$StrSQLCompiler._fallback_column_nameUsrzsqlalchemy.engine.urlc T|jdk7rtjj}|jj |jj }|j|d|}t|ts|j|fi|St|1||S)Nr)rk) stringify_dialectr&r engine_urlURLr get_dialectstatement_compilerrrrrr)rrrrurlrcompilerrs rrz,StrSQLCompiler.visit_unsupported_compilationXs  $ $ 1..++CMcggnnW%>%>?KKMOG1142Hh7'x''6266w4WcBBrc ~|j|jfi|d|j|jfi|dS)Nrr)rrxrrks rvisit_getitem_binaryz#StrSQLCompiler.visit_getitem_binaryfs: DLL + + DLL , ,  rc *|j||fi|Srrrks rvisit_json_getitem_op_binaryz+StrSQLCompiler.visit_json_getitem_op_binaryl(t((@R@@rc *|j||fi|Srrrks r!visit_json_path_getitem_op_binaryz0StrSQLCompiler.visit_json_path_getitem_op_binaryor rc @d|jj|dS)Nz)rformat_sequencerCs rr=zStrSQLCompiler.visit_sequencers#$T]]%B%B8%L$MQ O rc tj|Dcgc]}|jd|ddi}}ddj|zScc}w)NTFrr)rrrrw)rrHrrrrvrs rrzStrSQLCompiler.returning_clausews]++N; ;  % %dAtUB ?;  dii000  sA c Pdd<ddjfd|DzS)NTrSrrc3HK|]}|jfdiywrcNrr*rrrrs rr,z4StrSQLCompiler.update_from_clause..s0#   !A  B Br B rrrrs` ``rrz!StrSQLCompiler.update_from_clauses38 #  #    rc Pdd<ddjfd|DzS)NTrSrc3HK|]}|jfdiywrrrs rr,z:StrSQLCompiler.delete_extra_from_clause..s0   !A  B Br B rrrrs` ``rrz'StrSQLCompiler.delete_extra_from_clauses38 dii      rc y)NzSELECT 1 WHERE 1!=1rrs rrz#StrSQLCompiler.visit_empty_set_exprs$rc d|zS)Nz[%s]rrs rrz!StrSQLCompiler.get_from_hint_texts }rc *|j|dfi|S)Nz r~rks rrz+StrSQLCompiler.visit_regexp_match_op_binarys,t,,V\HRHHrc *|j|dfi|S)Nz rrks rrz/StrSQLCompiler.visit_not_regexp_match_op_binarys,t,,V5ELLLrc d|jj|fi|d|jj|fi|dS)Nz(rr)rxrrrks rr z-StrSQLCompiler.visit_regexp_replace_op_binarys> *FKK * *4 62 6 +FLL + +D 7B 7  rc d|jj|fi|d|jj|fi|dS)Nz TRY_CAST(rr)rrr)rrrs rvisit_try_castzStrSQLCompiler.visit_try_casts> *DKK * *4 :6 : .DOO . .t >v >  rr)rrrrrr&rrrr r r=rrrrrrrr rrrs@rrrAs& T01 C2 C AA 1 15 1 " 1  1  1  %IM  rrceZdZdZer d0 d1dZejdZejdZ d2 d3dZ dZ dZ d Z d Zd4d Z d5d Zd ZdZdZ d6dZdZd4dZdZdZdZdZdZdZdZdZd5dZdZ dZ!dZ"dZ#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.Z2d/Z3y)7 DDLCompilerTcyrrrs rrzDDLCompiler.__init__s rcf|jj|jd|jS)NrH)rrrr/s rrzDDLCompiler.sql_compilers/||.. LL$T5N5N/  rc.|jjSr)rrr/s r type_compilerzDDLCompiler.type_compilers||222rNcyrrrs rrzDDLCompiler.construct_paramss rc |j}t|jtjr|j }|j }|j|j}t|dk(r|dd}}n |d|d}}|jd||jd||jd|j|j|jj|j|zS)Nrrrr{rr#r,)contextrtargetr#rJrFrformat_table_seqrrrrrr )rddlrr'rpathrschs r visit_ddlzDDLCompiler.visit_ddls++ cjj&,, /llnG}}H,,SZZ8D4yA~!!Wbs!"XtAws   w .   x -   z8+@+@+L M  223==73JKKrc xd}|jr|dz }||jj|jzS)NzCREATE SCHEMA IF NOT EXISTS ) if_not_existsr format_schemar)rrrrs rvisit_create_schemazDDLCompiler.visit_create_schemas9    $ $Ddmm11&..AAArc d}|jr|dz }||jj|jz }|jr|dz }|S)Nz DROP SCHEMA IF EXISTS  CASCADE) if_existsrr1rcascaderdroprrs rvisit_drop_schemazDDLCompiler.visit_drop_schemasK >> L D  ++DLL99 << J D rc ,|j}|j}d}|jr!|dj|jdzz }|dz }|jr|dz }||j |dzz }|j |}|r||dzz }|dz }d}d}|jD]P} | j} |j| | jxr| } | ||z }d }|d | zz }| jrd }R|j||j } | r ||d z| zz }|d|j#|zz }|S#tj$rE} tjd |jd | jd| jd| d} ~ wwxYw)Nz CREATE rzTABLE r/r Ffirst_pkr Tz (in table 'z ', column 'z'): r) _include_foreign_key_constraintsz )%s )rrr^rwr0rcreate_table_suffixrrr.r7r descriptionrargscreate_table_constraintsinclude_foreign_key_constraintspost_create_table)rrrrrrrArr> create_columnr processedceconsts rvisit_create_tablezDDLCompiler.visit_create_tables== ?? CHHU__-3 3D     $ $D %%e,s22"66u=  '#- -D   #^^M"**F  LL!F,>,>,Ox<) (I%D &ID9,,D%%#H,$-- -3-S-S.   I$u, ,D d44U;;; ## &&((&++rwwqzC s5AD;;FAFFc |j}|jryj||}djfd|jD}|r|d|zz }|S)Nr=rc3@K|]}j|ywr)rr*rrs rr,z2DDLCompiler.visit_create_column..-s 7IDLL $7Is)rsystemget_column_specificationrw constraints)rrr>rrrrJs` rvisit_create_columnzDDLCompiler.visit_create_column&sd ==,,Vh,G 7=7I7I    C%K D rc lg}|jr|j|j|j}||j|}n t }|j |j Dcgc]}||jur||vr|c}djdfd|DDScc}w)Nz, c3$K|]}|| ywrr)r*rs rr,z7DDLCompiler.create_table_constraints..Ls#  } rc3K|]I}|jr6jjr t|ddsj |Kyw) use_alterFN)_should_create_for_compilerrsupports_alterr4rrNs rr,z7DDLCompiler.create_table_constraints..NsI"-J::4@ 33":{EB  Z("-r)r.rforeign_key_constraintsrror_sorted_constraintsrw)rrr@rrQall_fkcs omit_fkcsrvs` rrDz$DDLCompiler.create_table_constraints5s       u00 100 + 7 ++,LMII22 2AE---!92D2  }}  "-    s.B1c xd}|jr|dz }||jj|jzS)Nz DROP TABLE r4)r6rrrr8s rvisit_drop_tablezDDLCompiler.visit_drop_tableZs6 >> L Ddmm00>>>rc Rd|jj|jzS)Nz DROP VIEW rrrrr9rs rvisit_drop_viewzDDLCompiler.visit_drop_view`s  : :4<< HHHrc`|j"tjd|jzy)Nz,Index '%s' is not associated with any table.)rr7rrrros r_verify_index_tablezDDLCompiler._verify_index_tablecs0 ;; "">K  rc |j}j|j}d}|jr|dz }|jt j d|dz }|jr|dz }|j||d|j|j|d d jfd |jDd z }|S) NzCREATE UNIQUE z0CREATE INDEX requires that the index have a namezINDEX r/include_schemar1r-rrc3ZK|]"}jj|dd$yw)FTrr N)rr)r*rrs rr,z1DDLCompiler.visit_create_index..s:.D!!))T*.rQr) rrerrrr7rr0_prepared_index_namerrrw expressions)rrriinclude_table_schemarrorrs` rvisit_create_indexzDDLCompiler.visit_create_indexis   '== << I D :: ""B      $ $D  % %eN % K  ! ! (< "  II"--     rc |j}|jtjdd}|jr|dz }||j |dzS)Nz.DROP INDEX requires that the index have a namez DROP INDEX r4Trh)rrr7rr6rm)rr9rrors rvisit_drop_indexzDDLCompiler.visit_drop_indexs^  :: ""@  >> L Dd//d/KKKrc|j&|jj|j}nd}|r|r|jj|}nd}|jj |}|r|dz|z}|SNr)rrrr format_index)rrorir schema_name index_names rrmz DDLCompiler._prepared_index_namesw ;; "#}}>>u{{K #  .--445EFKK]]//6 $s*Z7Jrc d|jj|jjd|j |jS)N ALTER TABLE z ADD )rrrrrrrrs rvisit_add_constraintz DDLCompiler.visit_add_constraints8 MM & &v~~';'; < LL (  rc d|jj|jd|jj |jj t jS)NzCOMMENT ON TABLE r)rrrrrcommentr%Stringrzs rvisit_set_table_commentz#DDLCompiler.visit_set_table_commentsL MM & &v~~ 6    2 2&&(9   rc Rd|jj|jzS)NzCOMMENT ON TABLE %s IS NULLr`ras rvisit_drop_table_commentz$DDLCompiler.visit_drop_table_comments',t}}/I/I LL0   rc d|jj|jddd|jj |jj t jS)NzCOMMENT ON COLUMN T) use_tabler-r)r format_columnrrrr}r%r~rzs rvisit_set_column_commentz$DDLCompiler.visit_set_column_commentsZ MM ' '$4 (     2 2&&(9    rc Vd|jj|jdzS)NzCOMMENT ON COLUMN %s IS NULLT)r)rrrras rvisit_drop_column_commentz%DDLCompiler.visit_drop_column_comments/- 0K0K LLD1L1   rc @tj|t|rrrzs rvisit_set_constraint_commentz(DDLCompiler.visit_set_constraint_comments--dDLAArc @tj|t|rrras rvisit_drop_constraint_commentz)DDLCompiler.visit_drop_constraint_comments--dDJ??rcg}|j|jd|jz|j|jd|jz|j|jd|jz|j|jd|jz|j |jd|j |jd|j|jd|jz|j|j|jrdnd d j|S) NzINCREMENT BY %dz START WITH %dz MINVALUE %dz MAXVALUE %dz NO MINVALUEz NO MAXVALUEzCACHE %dCYCLEzNO CYCLEr) incrementrr}minvaluemaxvalue nominvalue nomaxvaluecachecyclerw)ridentity_optionsrs rget_identity_optionsz DDLCompiler.get_identity_optionss  % % 1 KK),<,F,FF G  ! ! - KK*:*@*@@ A  $ $ 0 KK (8(A(AA B  $ $ 0 KK (8(A(AA B  & & 2 KK &  & & 2 KK &  ! ! - KK %5%;%;; <  ! ! - KK#3#9#9z Jxx~rc d}|jr|dz }||jj|jz }|r||z }|j |j}|r|d|zz }|S)NzCREATE SEQUENCE r/r)r0rrrr)rrrrroptionss rvisit_create_sequencez!DDLCompiler.visit_create_sequencesn!    $ $D  --fnn==  FND++FNN;  C'M !D rc xd}|jr|dz }||jj|jzS)NzDROP SEQUENCE r4)r6rrrr8s rvisit_drop_sequencezDDLCompiler.visit_drop_sequences6 >> L Ddmm33DLLAAArc d|j}|j|jj|}nd}|"t j d|jzd|jj |jjd|jrdnd||jrdSdS)Nz99 t0088   e4 9    44Z@@ rc d}|j%|jj|}||d|zz }|d|jj |j ddzz }||j |z }|Srrrs rrz)DDLCompiler.visit_column_check_constraintIrrc Bt|dk(ryd}|j%jj|}||d|zz }|dz }|ddj fd|j r |j n |jDzz }|j|z }|S)Nrrrz PRIMARY KEY rrc3hK|])}jj|j+ywrrrrr*rvrs rr,z;DDLCompiler.visit_primary_key_constraint..^s3# ( MM   '(/2) rrrrrw_implicit_generatedcolumns_autoinc_firstrrrs` rvisit_primary_key_constraintz(DDLCompiler.visit_primary_key_constraintUs z?a  ?? &!]]<99  # 1100''(#     44Z@@ rc |jd}|j%|jj|}||d|zz }t|jdj j }|ddjfd|jDd|j||ddjfd |jDd z }||j|z }||j|z }||j|z }|S) Nrrrz FOREIGN KEY(rc3hK|])}j|jj+ywr)rparentrr*rrs rr,z;DDLCompiler.visit_foreign_key_constraint..r'7J!qxx}}-7Jrz ) REFERENCES rc3hK|])}j|jj+ywr)rrrrs rr,z;DDLCompiler.visit_foreign_key_constraint..xrrr) rrrrrrrrwdefine_constraint_remote_tabledefine_constraint_matchdefine_constraint_cascadesr)rrrrr remote_tablers @rvisit_foreign_key_constraintz(DDLCompiler.visit_foreign_key_constraintis== ?? &!]]<99J//03::@@  II7A7J7J   / /L(  II7A7J7J    ,,Z88 // ;; 44Z@@ rc$|j|S)z=Format the remote table clause of a CREATE CONSTRAINT clause.)r)rrrrs rrz*DDLCompiler.define_constraint_remote_tables$$U++rc t|dk(ryd}|j%jj|}||d|zz }|dj|fi|ddj fd|Ddz }|j |z }|S) Nrrrrgrrc3hK|])}jj|j+ywrrrs rr,z6DDLCompiler.visit_unique_constraint..s%F:admm))!&&1:rr)rrrr!define_unique_constraint_distinctrwrrs` rvisit_unique_constraintz#DDLCompiler.visit_unique_constraints z?a  ?? &!]]<99 2D 2 2: D D IIF:F F   44Z@@ rc yrrrs rrz-DDLCompiler.define_unique_constraint_distinctrrcd}|j0|d|jj|jtzz }|j0|d|jj|jt zz }|S)Nrz ON DELETE %sz ON UPDATE %s)ondeletervalidate_sql_phrase FK_ON_DELETEonupdate FK_ON_UPDATErrrs rrz&DDLCompiler.define_constraint_cascadess    * Odmm&G&G##\' D    * Odmm&G&G##\' D rcd}|j|jr|dz }n|dz }|j0|d|jj|jtzz }|S)Nrz DEFERRABLEz NOT DEFERRABLEz INITIALLY %s)rrrr FK_INITIALLYrs rrz+DDLCompiler.define_constraint_deferrabilitysq  ,$$ %))    + Odmm&G&G$$l' D rcFd}|j|d|jzz }|S)Nrz MATCH %s)r rs rrz#DDLCompiler.define_constraint_matchs-    ' K*"2"22 2D rc d|jj|jddz}|jdur|dz }|S|jdur|dz }|S)NzGENERATED ALWAYS AS (%s)FTrlz STOREDz VIRTUAL)rrrJ persisted)r generatedrrs rvisit_computed_columnz!DDLCompiler.visit_computed_columnsr)D,=,=,E,E   U$-F-     $ & I D  E ) J D rc dd|jrdndd}|j|}|r|d|zz }|S)Nz GENERATED ALWAYSz BY DEFAULTz AS IDENTITYr)alwaysr)rrrrrs rvisit_identity_columnz!DDLCompiler.visit_identity_columns@ H\ 9 ++H5  Gg% %D r)...) rr\r r@rrrrrrrrrr)FT)4rrrrrrr&rrr$rr-r2r:rKrRrDr^rbrerprrrmr{rrrrrrrrrrrPrArFrrrrrrrrrrrrrrrrrrr r s F FI,/03   , #C   &*   .      33 6:GK! 2E  3 L&B 2h  7;# J? IBF@ L      B@( B  &6 J;  (0,    rr c(eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZd1dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ 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/Z0d0Z1y)2GenericTypeCompilerc y)NFLOATrrs r visit_FLOATzGenericTypeCompiler.visit_FLOATrc y)NDOUBLErrs r visit_DOUBLEz GenericTypeCompiler.visit_DOUBLErc y)NzDOUBLE PRECISIONrrs rvisit_DOUBLE_PRECISIONz*GenericTypeCompiler.visit_DOUBLE_PRECISIONs!rc y)NREALrrs r visit_REALzGenericTypeCompiler.visit_REALrrc |jy|jdd|jizSd|j|jdzS)NNUMERICzNUMERIC(%(precision)s) precisionz!NUMERIC(%(precision)s, %(scale)s)rscalerrs r visit_NUMERICz!GenericTypeCompiler.visit_NUMERICM ?? " [[ +{EOO.LL L6"__: rc |jy|jdd|jizSd|j|jdzS)NDECIMALzDECIMAL(%(precision)s)rz!DECIMAL(%(precision)s, %(scale)s)rrrs r visit_DECIMALz!GenericTypeCompiler.visit_DECIMALrrc y)NINTEGERrrs r visit_INTEGERz!GenericTypeCompiler.visit_INTEGERrc y)NSMALLINTrrs rvisit_SMALLINTz"GenericTypeCompiler.visit_SMALLINTrc y)NBIGINTrrs r visit_BIGINTz GenericTypeCompiler.visit_BIGINTrrc y)N TIMESTAMPrrs rvisit_TIMESTAMPz#GenericTypeCompiler.visit_TIMESTAMPsrc y)NDATETIMErrs rvisit_DATETIMEz"GenericTypeCompiler.visit_DATETIMEr rc y)NDATErrs r visit_DATEzGenericTypeCompiler.visit_DATErrc y)NTIMErrs r visit_TIMEzGenericTypeCompiler.visit_TIMErrc y)NCLOBrrs r visit_CLOBzGenericTypeCompiler.visit_CLOBrrc y)NNCLOBrrs r visit_NCLOBzGenericTypeCompiler.visit_NCLOBrrNc|}|r |d|zz }n|jr|d|jzz }|jr|d|jzz }|S)N(%d)z COLLATE "%s")lengthr)rrrlength_overriders r_render_string_typez'GenericTypeCompiler._render_string_type sR  F_, ,D \\ FU\\) )D ?? Oeoo5 5D rc &|j|dS)NCHARr%rs r visit_CHARzGenericTypeCompiler.visit_CHAR''v66rc &|j|dS)NNCHARr(rs r visit_NCHARzGenericTypeCompiler.visit_NCHARs''w77rc &|j|dS)NVARCHARr(rs r visit_VARCHARz!GenericTypeCompiler.visit_VARCHARs''y99rc &|j|dS)NNVARCHARr(rs rvisit_NVARCHARz"GenericTypeCompiler.visit_NVARCHARs''z::rc &|j|dS)NTEXTr(rs r visit_TEXTzGenericTypeCompiler.visit_TEXTr*rc y)NUUIDrrs r visit_UUIDzGenericTypeCompiler.visit_UUID"rrc y)NBLOBrrs r visit_BLOBzGenericTypeCompiler.visit_BLOB%rrc Jd|jxrd|jzxsdzS)NBINARYr"rr#rs r visit_BINARYz GenericTypeCompiler.visit_BINARY(s$5<<AFU\\,AGRHHrc Jd|jxrd|jzxsdzS)N VARBINARYr"rr?rs rvisit_VARBINARYz#GenericTypeCompiler.visit_VARBINARY+s$ellDv /DJKKrc y)NBOOLEANrrs r visit_BOOLEANz!GenericTypeCompiler.visit_BOOLEAN.rrc |jr|jjs|j|ddS|j|fi|S)Nr' )r$) native_uuidrsupports_native_uuidr%r9rs r visit_uuidzGenericTypeCompiler.visit_uuid1sE   (I(I++E62+N N"4??5/B/ /rc (|j|fi|Sr)r<rs rvisit_large_binaryz&GenericTypeCompiler.visit_large_binary7tu+++rc (|j|fi|Sr)rFrs r visit_booleanz!GenericTypeCompiler.visit_boolean:!t!!%.2..rc (|j|fi|Sr)rrs r visit_timezGenericTypeCompiler.visit_time=rNrc (|j|fi|Sr)rrs rvisit_datetimez"GenericTypeCompiler.visit_datetime@"t""5/B//rc (|j|fi|Sr)rrs r visit_datezGenericTypeCompiler.visit_dateCrNrc (|j|fi|Sr)rrs rvisit_big_integerz%GenericTypeCompiler.visit_big_integerF t  -"--rc (|j|fi|Sr)r rs rvisit_small_integerz'GenericTypeCompiler.visit_small_integerIrVrc (|j|fi|Sr)rrs r visit_integerz!GenericTypeCompiler.visit_integerLrQrc (|j|fi|Sr)rrs r visit_realzGenericTypeCompiler.visit_realOrNrc (|j|fi|Sr)rrs r visit_floatzGenericTypeCompiler.visit_floatRst,,,rc (|j|fi|Sr)rrs r visit_doublez GenericTypeCompiler.visit_doubleUr[rc (|j|fi|Sr)rrs r visit_numericz!GenericTypeCompiler.visit_numericXrQrc (|j|fi|Srr0rs r visit_stringz GenericTypeCompiler.visit_string[rQrc (|j|fi|Srrirs r visit_unicodez!GenericTypeCompiler.visit_unicode^rQrc (|j|fi|Srr6rs r visit_textzGenericTypeCompiler.visit_textarNrc (|j|fi|Srrnrs rvisit_unicode_textz&GenericTypeCompiler.visit_unicode_textdrNrc (|j|fi|Srrirs r visit_enumzGenericTypeCompiler.visit_enumgrQrc 2tjd|z)NzKCan't generate DDL for %r; did you forget to specify a type on this Column?r}rs rrzGenericTypeCompiler.visit_nulljs" #%* +  rc Z|j|j|jfi|Sr)r type_enginerrs rvisit_type_decoratorz(GenericTypeCompiler.visit_type_decoratorqs't||E--dll;BrBBrc &|jdi|Sr) get_col_specrs rvisit_user_definedz&GenericTypeCompiler.visit_user_definedts!u!!'B''rr)2rrrrrrrrrrr rrrrrrr r%r)r-r0r3r6r9r<r@rCrFrKrMrPrSrUrXrZr]r_rarcrergrjrlrorqrsrrwrzrrrrrs"  78:;7IL0 ,/,0,.0/,-.///,,/ C(rrc*eZdZdZdZdZdZdZy)StrSQLTypeCompilerc r |j}||fi|S#t$r|j|fi|cYSwxYwr)rAttributeError_visit_unknown)rrrrs rrzStrSQLTypeCompiler.processysN 2!&!9!9 &d1b1 1 4&4&&u33 3 4s 66cR|jdr |jSt|)Nr[)rZrr~)rr+s r __getattr__zStrSQLTypeCompiler.__getattr__s% >>( #&& & % %rc |jj|jjjk(r|jjSt|Sr)rrupperreprrs rrz!StrSQLTypeCompiler._visit_unknownsA ?? # #u'?'?'E'E'G G??++ +; rc yrrrs rrzStrSQLTypeCompiler.visit_nullrrc ` |j}|di|S#t$rt|cYSwxYwr)ryr~r)rrrrys rrzz%StrSQLTypeCompiler.visit_user_defineds= & --L %"% % ;  s --N)rrrrrrrrzrrrr|r|xs2&  &rr|ceZdZddZy)_SchemaForObjectCallablecyrr)r_SchemaForObjectCallable__objs rrz!_SchemaForObjectCallable.__call__s3rN)rrrrr rrrrrs.rrceZdZddZy)rcyrr)rrs rrz _BindNameForColProtocol.__call__ssrN)rrrrr rrrrrs:rrceZdZUdZeZeZeZ de d<de d<de d<e jdZ de d < d Zd e d < d+dZdZdZd,dZd,dZdZd,dZd-dZdZd.d/dZd.d0dZdZd1dZ d. d2dZ d. d3dZd.dZej@dd1dZ!d1d Z"d1d!Z#d"Z$d#Z%d4d$Z&d%Z' d.d&Z( d5d'Z)d1d(Z*ejVd)Z,d*Z-y )6rz@Handle quoting and case-folding of identifiers based on options.r initial_quote final_quotezMutableMapping[str, str]_stringsr#rrFr_includes_none_schema_translateNc||_||_|xs |j|_||_|jdz|_||_||_i|_|jjdv|_ y)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. r6)rrN) rrr escape_quoteescape_to_quote omit_schemaquote_case_sensitive_collationsrrYr)rrrrrrrs rrzIdentifierPreparer.__init__st. *&<$*<*<(#0014&/N, $ 7 7< ! rc|jj|j}|jj|jd|vfd}||_|_|S)Nc|j}|jr:|r6| d|vsd|vrtjd|zt d|xsdzdS|jS)NrrzJSquare bracket characters ([]) not supported in schema translate name '%s'z __[SCHEMA_%s]_noneFr)r#_use_schema_mapr7rr0)rr includes_nones r symbol_getterz@IdentifierPreparer._with_schema_translate..symbol_gettersw::D""(8M#t **8:>?##tw7uzz!r)r__new__rerfrr)rrpreprrs @rrz)IdentifierPreparer._with_schema_translatesX~~%%dnn5 T]]+ 44  ""//<, rc|dvr)jstjddd<fd}tjd||S)Nzschema translate map which previously did not have `None` present as a key now has `None` present; compiled statement may lack adequate placeholders. Please use consistent keys in successive schema_translate_map dictionaries.rc|jd}|vr|}n|dvrtjd|}|s-jj}|stj dj |S)Nr6)Nrzschema translate map which previously had `None` present as a key now no longer has it present; don't know how to apply schema for compiled statement. Please use consistent keys in successive schema_translate_map dictionaries.zLDialect has no default schema name; can't use None as dynamic schema target.)rr7r-rdefault_schema_namerr)rrrdrs rrz=IdentifierPreparer._render_schema_translates..replaces771:Dqy#$T7 ?*11=$( ##'<<#C#C '**=$$%56 6rz(__\[SCHEMA_([^\]]+)\]))rr7r-rLr)rr rrrs` @rrz,IdentifierPreparer._render_schema_translatessZ  1977--94AgJ 72vv0'9EErc|j|j|j}|jr|jdd}|S)zEscape an identifier. Subclasses should override this to provide database-dependent escaping behavior. rr)rrrrrrs r_escape_identifierz%IdentifierPreparer._escape_identifier"s> d//1E1EF  MM#t,E rcN|j|j|jS)zCanonicalize an escaped identifier. Subclasses should override this to provide database-dependent unescaping behavior that reverses _escape_identifier. )rrrrs r_unescape_identifierz'IdentifierPreparer._unescape_identifier.s!}}T1143D3DEErcx|7|j|s&tjd|d|jd|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 zUnexpected SQL phrase: z (matching against r)r r7rr)rrrOs rrz&IdentifierPreparer.validate_sql_phrase7s=  syy'9""CKK) rcX|j|j|z|jzS)z~Quote an identifier. Subclasses should override this to provide database-dependent quoting behavior. )rrrrs rquote_identifierz#IdentifierPreparer.quote_identifierIs3   %%e, -  rc|j}||jvxs?|d|jvxs,|jj t | xs||k7S)z5Return True if the given identifier requires quoting.r)r5reserved_wordsillegal_initial_characterslegal_charactersr r)rrlc_values rr`z#IdentifierPreparer._requires_quotesVsf;;= ++ + #Qx4::: #((..s5z:: #E!  rcL|jjt| S)zjReturn True if the given identifier requires quoting, but not taking case convention into account.)rr rrs rr8z1IdentifierPreparer._requires_quotes_illegal_chars`s"((..s5z:::rcV|tjdd|j|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`. zThe 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().0.9r )r&rr)rr#forces rrzIdentifierPreparer.quote_schemaes5.    !  zz&!!rcR|tjddt|dd}|k||jvr|j|S|j |r|j ||j|<n||j|<|j|S|r|j |S|S)aConditionally quote an identifier. 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().rr r)r&rr4rr`r)rrPrs rrzIdentifierPreparer.quotes,    !  w- = %}}U++((/+/+@+@+GDMM%(+0DMM%(}}U++ ((/ /Lrc@|jr|j|S|Sr)rr)rcollation_names rrz#IdentifierPreparer.format_collations  / /::n- -! !rc|j|j}|j|}|js|r||j |dz|z}|Srt)rrrrr)rr>r-rrs rrz"IdentifierPreparer.format_sequencesYzz(--(11(;   ,$$%56GF rc$|j|S)zPrepare a quoted schema name.rr9s rr1z IdentifierPreparer.format_schema6szz$rc~|+t|tjr|j|}|j |S)Prepare a quoted column name.)rrrDr0r)rrr_s rrOz$IdentifierPreparer.format_label_name;s;  J (++% >>(+Dzz$rcn| |j}|+t|tjr|j |}t |ddsF|r3|j |j||dz|j|zS|j|S|r$|j |j||dz|zS|S)rrF)r-rr) rrrrDr0r4rrr)rrrr table_namer-r_s rrz IdentifierPreparer.format_columnIs <;;D  J (++% >>(+Dv|U3%% *&jj& 'zz$'' %% *&  rc|j|}|js(|r&|r$|j||j|dfS|j|dfS)z(Format table name and schema as a tuple.Frj)rrrr)rrr-rs rr)z#IdentifierPreparer.format_table_seqvsj 11%8J3C!!"23!!%E!:  %%e%>@ @rcd|j|j|j|jfD\}}}tjd|||dz}|S)Nc3FK|]}tj|ywr)rLrMrs rr,z4IdentifierPreparer._r_identifiers..s$)  IIaLs!zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)initialfinalr)rrrrLrN)rrr escaped_finalrs r_r_identifiersz!IdentifierPreparer._r_identifierssp) ""  ''(8(89) %  JJ $"EmL M  rc|j}|j|Dcgc] \}}|xs| c}}Dcgc]}|j|c}Scc}}wcc}w)z:Unpack 'schema.table.column'-like strings into components.)rfindallr)r identifiersrarlrs runformat_identifiersz'IdentifierPreparer.unformat_identifierssh   *+;)?@)?Aaf1f)?@ @  % %a (@  @ s AA)rNrTF)rrrr)rrrrr)r#rrrrr)rPrrrrr)T)rz Label[Any]rr7rr)rzOptional[AliasedReturnsRows]rr7rr)TN)FNNFN).rrrrRESERVED_WORDSrLEGAL_CHARACTERSrILLEGAL_INITIAL_CHARACTERSrrr/ attrgetterrrrrrrrrrr`r8rrrrrur[rr&rrrrrrurr1rOrr)rrrrrrrrs|J#N'!;&&2E(2E2Eh2O/O-2#T1 (," H0'FR F$   ; %"N2h" 8<..'4. . JN$1$9F$ $T012,     $-    " +ZA" " rr)r __future__rrwcollections.abcabcrrenumrrarr/rLtimerr<rrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r)_typingr'r(r)r*r+r,r-r.r/r0r1r2type_apir3visitorsr4r5r7r8 util.typingr9r:r; annotationr<r=r>rr?r*r@dmlrArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrS engine.cursorrTengine.interfacesrUrVrWrXrYrZr[r\r]r_FromHintsTyperrNIrLEGAL_CHARACTERS_PLUS_SPACErerrrrrUNICODErrr[r\ror_r=mulrmodnegltlenegtgeeqis_distinct_fromis_not_distinct_from concat_opr{ not_match_oprrrrrtrr rexists distinct_opinvany_opall_opdesc_opasc_opnulls_first_op nulls_last_opbitwise_xor_op bitwise_or_opbitwise_and_opbitwise_not_opbitwise_lshift_opbitwise_rshift_oprsrrrrrrrrrrrcuberollup grouping_setsrrr_CompoundSelectKeywordr UNION_ALLr EXCEPT_ALLr INTERSECT_ALLrrrr r r rrrrr5rErRr`rer.rfrgrhri namedtuplerkr EnsureKWArgrBinaryElementRoleCompilerColumnElementrrrrr rr|rrr)rs0rr! s"#)  ! &2#! %!"# +,"#)*'&'#./&+'"',4<:<=3=C+:lC'(_B2::.5(bjj):BDDA.3Arl;lc!fl;AA3%HrzzMM6?. @fA. BfC. FwG. HfI. JnK. L] e U e c  [.  b  N N !4 N  . h y N NNF NNF h _- )&       ""$( &%%++W%%//%%,,h%%00,%%//%%33_ > !*  Ji $1$:J:zt tnZ2!;!$ G  g.FK FB & l ?#''' w6HI?#DH'H'VF4##F0 C ("@"@2#  C ("@"@# LuT (uT pil [l ^X(Xvj(,j(Z&,&B/x/;h;  w]