U a'_@sdZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddl mZddlmZddlmZedddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpg^ZedqejZedrejZdsdtedduDdvgZedwejZedwejZedxejZ edyej!Z"edzej!Z#d{d|d}d~ddZ$ededdZ%dddddZ&e j'de j(de j)de j*de j+de j,de j-de j.de j/de j0de j1de j2de j3de j4de j5de j6de j7de j8de j9de j:de j;de jde j?de j@de jAde jBde jCde jDde jEde jFde jGde jHde jIde jJde jKdi%ZLe jMde jNde jOde jPde jQde jRde jSde jTde jUde jVde jWde jXde jYde jZdiZ[ddddddddddddddddʜZ\ej]j^dej]j_dej]j`dej]jadej]jbdej]jcdiZddZedZfdZgdZheiddddddgZjejkddddڍZlejkddddڍZmejkddddڍZnejkddemenBdڍZoGdddeidddgZpGdddeqZrGdddesejteqZuGddde jvZwGddderZxGdddexZyGddderZzGdddeuZ{Gddde{Z|GdddeqZ}dS)a]Base SQL and DDL compiler implementations. Classes provided include: :class:`.compiler.SQLCompiler` - renders SQL strings :class:`.compiler.DDLCompiler` - renders DDL (data definition language) strings :class:`.compiler.GenericTypeCompiler` - renders type specification strings. To generate user-defined SQL strings, see :doc:`/ext/compiler`. N)base) coercions)crud)elements) functions) operators)schema) selectable)sqltypes)NO_ARG)prefix_anon_map) quoted_name)exc)utilallZanalyseZanalyzeandanyarrayasZascZ asymmetric authorizationZbetweenbinaryZbothZcasecastcheckcollatecolumn constraintcreateZcross current_dateZ current_role current_timecurrent_timestamp current_userdefault deferrabledescZdistinctZdoelseendexceptfalseforZforeignfreezefromfullZgrantgroupZhavingZilikein initiallyinnerZ intersectZintoisZisnulljoinleadingleftZlikelimit localtimelocaltimestampZnaturalnewnotZnotnullnulloffoffsetoldononlyororderouteroverlapsZplacingZprimaryZ referencesrightselect session_usersetZsimilarZsome symmetrictableZthentoZtrailingtrueunionuniqueuserZusingverbosewhenwherez ^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$cCsh|] }t|qS)str).0xrSrSXC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\sql\compiler.py srX $z5^(?:RESTRICT|CASCADE|SET NULL|NO ACTION|SET DEFAULT)$z^(?:DEFERRED|IMMEDIATE)$z%(? z >= z = z IS DISTINCT FROM z IS NOT DISTINCT FROM z || z MATCH z NOT MATCH z IN z NOT IN , z FROM  AS z IS z IS NOT z COLLATE zEXISTS DISTINCT zNOT zANY zALL z DESCz ASCz NULLS FIRSTz NULLS LASTcoalesceZ CURRENT_DATEZ CURRENT_TIMEZCURRENT_TIMESTAMPZ CURRENT_USERZ LOCALTIMEZLOCALTIMESTAMPrandomsysdateZ SESSION_USERUSERZCUBEZROLLUPz GROUPING SETSmonthdayyearsecondhourdoyminutequarterdowweekepoch milliseconds microseconds timezone_hourtimezone_minute)rqrrrsrtrurvrwrxryrzr{r|r}r~rUNIONz UNION ALLEXCEPTz EXCEPT ALL INTERSECTz INTERSECT ALL ExpandedState statementZadditional_parameters processors positiontupparameter_expansion NO_LINTINGzDisable all linting.) canonicalCOLLECT_CARTESIAN_PRODUCTSzOCollect data on FROMs and cartesian products and gather into 'self.from_linter' WARN_LINTINGz,Emit warnings for linters that find problems FROM_LINTINGzQWarn for cartesian products; combines COLLECT_CARTESIAN_PRODUCTS and WARN_LINTINGc@seZdZdddZddZdS) FromLinterNcs|j}|sdSt|j}t|}|dk r8|}||n|}t|g}|r|r||fdd|D}| fdd|D| |qL|r||fSdSdS)N)NNcsh|]}|kr|qSrSrSrUZedgenoderSrWrXFsz"FromLinter.lint..c3s|]}|| VqdSN)indexrrrSrW Jsz"FromLinter.lint..) fromsrHedgesremovepop collectionsdequepopleftdiscard extendleftdifference_update)selfstartrrthe_rest start_withstackZ to_removerSrrWlint.s&     zFromLinter.lintcsV\}}|rR|}|rRd}dfdd|D}|j|j|d}t|dS)NzSELECT statement has a cartesian product between FROM element(s) {froms} and FROM element "{start}". Apply join condition(s) between each element to resolve.rjc3s |]}djj|dVqdS)z"{elem}")elemN)r]r)rUfrom_rrSrWrasz"FromLinter.warn..)rr)rr3r]rrwarn)rrrrtemplateZ froms_strmessagerSrrWrSs zFromLinter.warn)N)__name__ __module__ __qualname__rrrSrSrSrWr-s %rrrc@seZdZdZdZdZdZejZ ejZ dZ dZ dZ ddefddZddZdd Zed d Zd d ZddZdddZeddZdS)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. NFcCs||_|jj|_|r(||_|j||_|dk r|||_|j|_|j|_|jrT|j |_ |j |jf||_ |r||j |j ||_ t|_dS)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 .. versionadded:: 1.1 .. seealso:: :ref:`schema_translating` :param compile_kwargs: additional kwargs that will be passed to the initial call to :meth:`.Compiled.process`. N)dialectidentifier_preparerpreparerschema_translate_map_with_schema_translaterZsupports_execution can_execute _annotations_execution_optionsexecution_optionsprocessstring_render_schema_translatesr perf_counter _gen_time)rrrrZrender_schema_translatecompile_kwargsrSrSrW__init__s( zCompiled.__init__cCs&|jr|||||St|jdSr)rZ_execute_compiledrZObjectNotExecutableErrorr)r connectionZ multiparamsparamsrrSrSrW_execute_on_connectionszCompiled._execute_on_connectioncCstjt|t||ddSNZreplace_context)rraise_rUnsupportedCompilationErrortype)relementerrrSrSrWvisit_unsupported_compilationsz&Compiled.visit_unsupported_compilationcCs tdS)zReturn a Compiled that is capable of processing SQL expressions. If this compiler is one, it would likely just return 'self'. NNotImplementedErrorrrSrSrW sql_compilerszCompiled.sql_compilercKs|j|f|Sr_compiler_dispatch)robjkwargsrSrSrWrszCompiled.processcCs |jpdS)z3Return the string text of the generated SQL or DDL.)rrrSrSrW__str__szCompiled.__str__cCs tdS)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. Nrrrextracted_parametersrSrSrWconstruct_paramsszCompiled.construct_paramscCs|S)z0Return the bind params for this compiled object.rrrSrSrWrszCompiled.params)NN)rrr__doc__Z_cached_metadata_result_columnsrr EMPTY_DICTrr compile_state cache_keyr immutabledictrrrpropertyrrrrrrSrSrSrWrls,  3   rc@s,eZdZdZdZddZddZddZd S) TypeCompilerz2Produces DDL specification for TypeEngine objects.z visit_\w+cCs ||_dSr)r)rrrSrSrWrszTypeCompiler.__init__cKs|j|f|Srrrtype_kwrSrSrWrszTypeCompiler.processcKstjt|||ddSr)rrrr)rrrrrSrSrWr s z*TypeCompiler.visit_unsupported_compilationN)rrrrZ ensure_kwargrrrrSrSrSrWrs rc@sBeZdZdZdZdZdddZeddZed d Z d d Z d S) _CompileLabelz;lightweight label object which acts as an expression.Label.label)rnamerScCs||_||_|f||_dSr)rr _alt_names)rcolr alt_namesrSrSrWrsz_CompileLabel.__init__cCs|jjSr)r proxy_setrrSrSrWr sz_CompileLabel.proxy_setcCs|jjSr)rrrrSrSrWr$sz_CompileLabel.typecKs|SrrS)rrrSrSrW self_group(sz_CompileLabel.self_groupN)rS) rrrr__visit_name__ __slots__rrrrrrSrSrSrWrs   rc@sDeZdZdZeZeZdZZ Z dZ dZ dZ dZdZdZdZdZdZdZdZeZeZejZdZdZZdZdZ dZ!ddde"fddZ#e$dd Z%e$d d Z&ej'd d Z(ej)ddZ*e+j,ddZ-ddZ.ej'ddZ/ddZ0e$ddZ1d*ddZ2ej)d+ddZ3e$ddZ4d,d d!Z5e6d"d#d$Z7ej'e6d%d&d'Z8ej'e6d%d(d)Z9d*d+Z:d-d,d-Z;d.d/Z<d.d0d1Z=d/d2d3Z>d0d4d5Z?d6d7Z@d8d9ZAd1d:d;ZBdd?ZDd@dAZEdBdCZFdDdEZGdFdGZHd2dHdIZId3dJdKZJdLdMZKdNdOZLdPdQZMdRdSZNdTdUZOdVdWZPdXdYZQdZd[ZRd\d]ZSd^d_ZTd`daZUdbdcZVdddeZWdfdgZXdhdiZYdjdkZZd4dldmZ[dndoZ\dpdqZ]drdsZ^d5dtduZ_dvdwZ`dxdyZad6dzd{Zbd|d}Zcd~dZdddZeddZfddZgddZhddZiddZjd7ddZkddZlddZmddZnddZoddZpd8ddZqddZrddZsej'ddZtddZuddZvddZwddZxddZyddZzddZ{ddZ|ddZ}ddZ~ddZddZddZddZddZd9ddZefddZddÄZddńZddDŽZddɄZd:dd˄Zd;dd̈́ZddτZddфZdddۄZdd݄Zdd߄Zd?ddZd@ddZddZddZddZddZddZedefdefgZdAddZdZdBddZddZddZddZddZddZddZddZddZddZddZdd Zd d Zd d ZdCddZdDddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)ZdS(E SQLCompilerz~Default implementation of :class:`.Compiled`. Compiles :class:`_expression.ClauseElement` objects into SQL strings. FNTrSc Ksr||_||_|r@dd|dD|_}|dd|dD||_||_i|_t|_ g|_ g|_ |j |_ |j rg|_ |jdk|_t|j|_t|jd|_d|_|jp|j|_t|_i|_tj|||f||js|js|jrB|j r|j |_!|js |jrB|j"rd|_#n(|jrB|jr<|j$j%rB|j&rBd|_#|j rZ|jrZ|'|j(rn|j)dddS) 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. cSsi|] }|j|qSrSkeyrUbrSrSrW sz(SQLCompiler.__init__..rcSsi|] }||gqSrSrSrrSrSrWrsr^NT)_populate_self)* column_keysr_cache_key_bind_matchupdatefor_executemanylintingbindsrZ column_dict bind_namesrr positionalr paramstyle_numeric_bindsBIND_TEMPLATES bindtemplateBIND_TRANSLATEget_bind_translatectes label_lengthmax_identifier_lengthr anon_maptruncated_namesrrisinsertisupdateisdelete _returning returningZ_inlineinlinerZinsert_executemany_returningZ_return_defaults_apply_numbered_params_render_postcompile#_process_parameters_for_postcompile) rrrrrrrrckbmrSrSrWrsV     zSQLCompiler.__init__c CsJz|jddWStk rD}ztjtd|dW5d}~XYnXdS)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 entryrN)r IndexErrorrr)rZierSrSrWcurrent_executableszSQLCompiler.current_executablecCst|j|jSr)listinsert_prefetchupdate_prefetchrrSrSrWprefetch;szSQLCompiler.prefetchcCsiSrrSrrSrSrW_global_attributes?szSQLCompiler._global_attributescCs&t|_i|_d|_|jr"i|_dS)zInitialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise. FN)r OrderedDictr ctes_by_namectes_recursivercte_positionalrrSrSrW_init_cte_stateCs  zSQLCompiler._init_cte_statec csp|j|j}}gd|_|_z0|jr8|jd}d|d<nd}|j|jfVW5|r\|d|||_|_XdS)z;special API to support the use case of 'nested result sets'Fneed_result_map_for_nestedrTN)r_ordered_columnsrr)rZresult_columnsZordered_columnsentryrSrSrW_nested_resultQs   zSQLCompiler._nested_resultcs(tdtdfdd|j|_dS)Nrz \[_POSITION\]csttSr)rTrnextmZposcountrSrWlz4SQLCompiler._apply_numbered_params..) itertoolscountresubrrrSr%rWr is   z"SQLCompiler._apply_numbered_paramscs"tddfddjDDS)Ncss"|]\}}|dk r||fVqdSrrSrUrvaluerSrSrWrqs z/SQLCompiler._bind_processors..c3sH|]@}j||jjs$|jjntfdd|jjDfVqdS)c3s|]}|jVqdSr)_cached_bind_processorr)rUZ elem_typerrSrWrxsz9SQLCompiler._bind_processors...N)rr_is_tuple_typer.rtupletypes)rU bindparamrrSrWrss  )dictrrrSrrW_bind_processorsos  zSQLCompiler._bind_processorscCst|jdkSNr)lenrrrSrSrW is_subqueryszSQLCompiler.is_subquerycCs|SrrSrrSrSrWrszSQLCompiler.sql_compilerc s t|j}|rtz|jd}Wn6tk rR}ztjtd|dW5d}~XYnX|jfddt ||D}nd}|rZi} |j D]\} } |r|j | | n| } | j |kr|| j | | <q| |kr|| | | <q|r| jr|rtjd| j |fdd ntjd | j dd q|r2| | | } n| } | jrJ| j| | <q| j| | <q| Si} |j D]\} } |r|j | | n| } |r| jr|rtjd| j |fdd ntjd | j dd |r| | | } n| } | jr| j| | <n | j| | <qh| SdS) z5return a dictionary of bind parameter keys and valuesrzcThis compiled object has no original cache key; can't pass extracted_parameters to construct_paramsrNcs$i|]\}}|D] }||qqSrSrS)rUrZ extractedbindrrSrWrs  z0SQLCompiler.construct_params..z@A value is required for bind parameter %r, in parameter group %dZcd3x)codez)A value is required for bind parameter %r)boolescaped_bind_namesr TypeErrorrrr CompileErrorrzipritemsrrrequiredZInvalidRequestErrorcallableeffective_valuer-)rrZ _group_number_checkrZhas_escaped_namesZorig_extractedrZresolved_extractedpdr2rZ escaped_nameZ value_paramrSr9rWrs      zSQLCompiler.construct_paramscst|dsdS|j|jjdkr<dkr<fddnfddi}|j}|jD]@}||krlq^|jjrfdd|jjD||<q^|j||<q^|S)Nrcs|}|Sr) dialect_implget_dbapi_type)typdbtype)dbapirrSrW _lookup_typesz=SQLCompiler._get_set_input_sizes_lookup.._lookup_typecsf|}|}|dk r^dks>|kr^t|kr^dksZ|ksZt|kr^|SdSdSr)Z_unwrapped_dialect_implrFrGr)rHrFrI)rJr exclude_types include_typesrSrWrKs$     csg|] }|qSrSrS)rUrH)rKrSrW 6sz;SQLCompiler._get_set_input_sizes_lookup..)hasattrrrJliteral_execute_paramsrrr/r1)rrMrLZ inputsizesrPr2rS)rKrJrrLrMrW_get_set_input_sizes_lookups$     z'SQLCompiler._get_set_input_sizes_lookupcCs |jddS)zoReturn the bind param dictionary embedded into this compiled object, for those values that are present.F)rDrrrSrSrWr>szSQLCompiler.paramscsF|dkr|}i}|jr g}nd}|ji}|jrB|jrBtdii}|jrV|jn|jD]$|j}||j krkr| }|j ||d<q`||j krvkr|} n0| } |j } | || \} } | |<| <|js|| |jjr,|fddt| dDn|fdd| D|jrb|dd| Dd d | D|<q`|jr`|q`fd d } td | |j}t|||||}|rB|j|_|j|j|j|_t|_ |jD]Z}|j |}|j |t|j|j|D](\}}|||j|<}||j|<qq|S)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. Nz\'post-compile' bind parameters are not supported with the 'numeric' paramstyle at this time.render_literal_valuec3s`|]X\}}t|dD]D\}}kr|ddk rd||f|dfVqqdS)rN%s_%s_%s enumeraterUi tuple_elementjr-rrrSrWrs  zBSQLCompiler._process_parameters_for_postcompile..rc3s&|]\}}kr|fVqdSrrSr,r[rSrWrscss|]\}}|VqdSrrS)rUrr-rSrSrWrscSsg|] \}}|qSrSrS)rUZ expand_keyr-rSrSrWrNszCSQLCompiler._process_parameters_for_postcompile..cs|dSr5r.r#)replacement_expressionsrSrWprocess_expandingszJSQLCompiler._process_parameters_for_postcompile..process_expandingz\[POSTCOMPILE_(\S+)\]) rrr4rrrrvaluesrrPrrender_literal_bindparampost_compile_params$_literal_execute_expanding_parameterliteral_executerrr/rVextendappendr*r+rrrr frozensetrr?r-Z _with_value)r parametersrZexpanded_parametersrZnew_processorsZto_update_sets parameterr- to_updater_leepreplacement_exprr^rZexpanded_staterr8Z expanded_key new_paramrS)rrr]rWrDs                  z/SQLCompiler._process_parameters_for_postcompilezsqlalchemy.engine.cursorcCstjj}|j|jS)z(utility method used for unit tests only.)r preloadedZ engine_cursorZCursorResultMetaDataZ_create_description_match_mapr)rcursorrSrSrW_create_result_mapszSQLCompiler._create_result_mapzsqlalchemy.engine.resultcs~tjj}|jd|jj}fdd|jD|jdk rNj |j dnd| dd|jDfdd}|S)Nrcs"g|]}td|d|fqS)rN)operator methodcallerrUr) key_getterrSrWrNszKSQLCompiler._inserted_primary_key_from_lastrowid_getter..cSsg|] }|jqSrSrrrrSrSrWrNscsLdk rdkr.fddDSfddDSdS)Nc3s|]\}}|VqdSrrSrUgetterr)rgrSrWrszWSQLCompiler._inserted_primary_key_from_lastrowid_getter..get..c3s&|]\}}|krn|VqdSrrSrt) autoinc_col lastrowidrgrSrWrsrSrwrg)rvgettersprocrow_fnrxrWrszDSQLCompiler._inserted_primary_key_from_lastrowid_getter..get) rrm engine_result_key_getters_for_crud_columnrrJ primary_keyZ_autoincrement_columnrZ_cached_result_processorr result_tuplerresultrJrrS)rvryrsrzr{rW+_inserted_primary_key_from_lastrowid_getters    z7SQLCompiler._inserted_primary_key_from_lastrowid_gettercsltjj}|jd|jj}ddt|jDfdd|jD| dd|jDfdd}|S) NrcSsi|]\}}||qSrSrS)rUidxrrSrSrWrszKSQLCompiler._inserted_primary_key_from_returning_getter..cs<g|]4}|kr"t|dfntd|ddfqS)TrNF)rp itemgetterrqrr)rsretrSrWrNszKSQLCompiler._inserted_primary_key_from_returning_getter..cSsg|] }|jqSrSrrrrSrSrWrN scsfddDS)Nc3s&|]\}}|r|n|VqdSrrS)rUruZuse_rowrgrowrSrWrszWSQLCompiler._inserted_primary_key_from_returning_getter..get..rS)rrg)ryr{rrWrszDSQLCompiler._inserted_primary_key_from_returning_getter..get) rrmr|r}rrJrVr r~rrrS)ryrsrr{rW+_inserted_primary_key_from_returning_getters  z7SQLCompiler._inserted_primary_key_from_returning_gettercCsdS)zCalled when a SELECT statement has no froms, and no FROM clause is to be appended. Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output. rrSrrSrSrW default_fromszSQLCompiler.default_fromcKsd|jj|f|dSNrerfrr)rgroupingasfromrrSrSrWvisit_groupingszSQLCompiler.visit_groupingcKsd|jj|f|dSrr)rrrrSrSrWvisit_select_statement_grouping"sz+SQLCompiler.visit_select_statement_groupingc Ks|jrl|jjrl|jdd}|j\}}}|r2|}n|}|jj} | dk rl| j|krl| || jrl|jj|d<|j|jfd|i|S)Nrrrender_label_as_labelwithin_columns_clause) rrZsupports_simple_order_by_label_label_resolve_dictrZ_order_by_label_elementrZshares_lineager) rrrrr with_cols only_froms only_colsZ resolve_dictZ order_by_elemrSrSrWvisit_label_reference%s< z!SQLCompiler.visit_label_referencec Ks|js||jS|jdd}|j\}}}z|r>||j}n ||j}Wn8tk r} ztj|jdtj | dW5d} ~ XYn X||d<|j|fd|i|SdS)NrrzECan't resolve label reference for ORDER BY / GROUP BY / DISTINCT etc.)extraZexc_clsrrr) rrZ _text_clauserrKeyErrorrZ_no_text_coercionrr>) rrrrrrrrrrrSrSrWvisit_textual_label_referenceKs.    z)SQLCompiler.visit_textual_label_referencec Ks|o| }||k} | s|r>t|jtjr8|d|j} n|j} |r|dk rj|| |j|| f|j||j|jj|fddd|t t j |j || S| r|j || S|jj|fddi|SdS)NcolidentT)rwithin_label_clauserF) isinstancerr_truncated_label_truncated_identifierrrrr OPERATORSras_r format_label) rradd_to_result_maprrrresult_map_targetsrZrender_label_with_asZrender_label_onlyZ labelnamerSrSrW visit_labelisJ  zSQLCompiler.visit_labelcCstddS)Nz:Cannot compile Column object until its 'name' is assigned.rr>rrrSrSrW_fallback_column_namesz!SQLCompiler._fallback_column_namecKs|j}|j|f|Sr)Z _resolvedr)rrrZ sql_elementrSrSrWvisit_lambda_elementsz SQLCompiler.visit_lambda_elementcKs|j}}|dkr||}|j}|s>t|tjr>|d|}|dk rx|||jf|} |jrh| |jf7} |||| |j |r| |}n |j |}|j } | dks|r| js|S|j | } | r|j | d} nd} | j} t| tjr|d| } | |j | d|SdS)Nr.ralias)rr is_literalrrrrr _tq_labelrescape_literal_columnrquoterJZnamed_with_columnschema_for_object quote_schema)rrr include_tablerrr orig_namertargetsrJeffective_schemaZ schema_prefixZ tablenamerSrSrW visit_columns4         zSQLCompiler.visit_columncKs|j|jSr)rformat_collation collationrrrrSrSrWvisit_collationszSQLCompiler.visit_collationcKs|jSrr)rZ fromclauserrSrSrWvisit_fromclauseszSQLCompiler.visit_fromclausecKs|jSrr)rrrrSrSrW visit_indexszSQLCompiler.visit_indexcKs&||d<|j|d<|jjj|jf|S)Ntype_expressionr)rr type_compilerrr)r typeclauserrSrSrWvisit_typeclauses zSQLCompiler.visit_typeclausecCs|jjr|dd}|SNrd%%r_double_percentsreplacertextrSrSrWpost_process_texts zSQLCompiler.post_process_textcCs|jjr|dd}|SrrrrSrSrWrs z!SQLCompiler.escape_literal_columnc sRfdd}jsd_|r2|ddftjtddt|jS)Ncs:|d}|jkr(jj|fSj|fSdSr5)r.Z _bindparamsrbindparam_string)r$rrr textclauserSrW do_bindparams  z2SQLCompiler.visit_textclause..do_bindparamTcSs |dSr5r\r#rSrSrWr&r'z.SQLCompiler.visit_textclause..) r isplaintextr NULLTYPEBIND_PARAMS_ESCr+ BIND_PARAMSrr)rrrrrrSrrWvisit_textclauses zSQLCompiler.visit_textclausec Ks|j }|r|jn|jd}|p>|dkr4|ddp>|dd}|r|j|_|_|j obt|j|_|jD]}|j |d|j dql|j |j f|S)Nrrneed_result_map_for_compoundFrTrr) r_default_stack_entryrrr_textual_ordered_columnsr;Z column_args_loose_column_name_matchingr_add_to_result_mapr) rZtafcompound_indexrrtoplevelr populate_result_mapcrSrSrWvisit_textual_selects,     z SQLCompiler.visit_textual_selectcKsdSNNULLrSrexprrrSrSrW visit_null'szSQLCompiler.visit_nullcKs|jjr dSdSdS)NrL1rsupports_native_booleanrrSrSrW visit_true*szSQLCompiler.visit_truecKs|jjr dSdSdS)Nr)0rrrSrSrW visit_false0szSQLCompiler.visit_falsec s$|ddfdd|DDS)Ncss|]}|r|VqdSrrSrUsrSrSrWr7sz7SQLCompiler._generate_delimited_list..c3s|]}|jfVqdSrrrUrrrrSrWr9sr3)rr separatorrrSrrW_generate_delimited_list6s z$SQLCompiler._generate_delimited_listc sltjtjtjjtjj|\}}|dkr:|djfSt tj}| ddfdd|DDSdS)Nrrcss|]}|r|VqdSrrSrrSrSrWrIsz;SQLCompiler._generate_delimited_and_list..c3s|]}|jfVqdSrrrrrSrWrKs) rZBooleanClauseListZ_process_clauses_for_booleanrand_ZTrue_Z _singletonZFalse_rrr3)rclausesrZlccrrSrrW_generate_delimited_and_list=s  z(SQLCompiler._generate_delimited_and_listcKsd|j|f|SN(%s))visit_clauselist)r clauselistrrSrSrW visit_tupleOszSQLCompiler.visit_tuplecKs0|j}|dkrd}n t|j}|j|j|f|SN )rprrr)rrrseprSrSrWrRs  zSQLCompiler.visit_clauselistcKsd}|jdk r&||jj|f|d7}|jD]4\}}|d|j|f|d|j|f|d7}q,|jdk r|d|jj|f|d7}|d7}|S)NzCASE rzWHEN z THEN zELSE ZEND)r-rZwhensZelse_)rclauserrVZcondrrSrSrW visit_case[s*    zSQLCompiler.visit_casecKs|jj|f|Sr)Ztyped_expressionr)rZ type_coercerrSrSrWvisit_type_coercenszSQLCompiler.visit_type_coercecKs$d|jj|f||jj|f|fS)NzCAST(%s AS %s))rrr)rrrrSrSrW visit_castqszSQLCompiler.visit_castc Ksd|dtjkrdn\|dtjkr&dnJ|ddkrTd|jtt|df|fnd|jt|df|f|dtjkrdn\|dtjkrdnJ|ddkrd|jtt|df|fnd|jt|df|ffS) Nz %s AND %srzUNBOUNDED PRECEDINGz CURRENT ROWz %s PRECEDINGz %s FOLLOWINGrzUNBOUNDED FOLLOWING)rZRANGE_UNBOUNDEDZ RANGE_CURRENTrliteralabs)rrange_rrSrSrW_format_frame_clausews0      z SQLCompiler._format_frame_clausec s|jrdj|jf}n |jr8dj|jf}nd}d|jjfdfddd|jfd|jffD|r||gngfS) NzRANGE BETWEEN %szROWS BETWEEN %sz %s OVER (%s)rcs6g|].\}}|dk rt|rd||jffqS)Nz%s BY %s)r6r)rUwordrrrrSrWrNs z*SQLCompiler.visit_over..Z PARTITIONORDER)rrrowsrrr3Z partition_byorder_by)rZoverrrrSrrW visit_overs2  zSQLCompiler.visit_overcKs$d|jj|f||jj|f|fS)Nz%s WITHIN GROUP (ORDER BY %s))rrr)rZ withingrouprrSrSrWvisit_withingroupszSQLCompiler.visit_withingroupcKs$d|jj|f||jj|f|fS)Nz%s FILTER (WHERE %s))funcrZ criterion)rZ funcfilterrrSrSrWvisit_funcfilterszSQLCompiler.visit_funcfiltercKs*|j|j|j}d||jj|f|fS)NzEXTRACT(%s FROM %s)) extract_maprfieldrr)rextractrr rSrSrW visit_extracts zSQLCompiler.visit_extractcKs*|j|jf|}|j|f|}d||fS)Nz(%s).%s)visit_functionfnr)rrrZ compiled_fnZ compiled_colrSrSrWvisit_scalar_function_columnsz(SQLCompiler.visit_scalar_function_columnc s|dk r||j|jd|jtd|jd}|rD||f|}nt|jdrj|jrd7n6|jj st t j rj nddfdd|jDgdj|f|i}|jr|d7}|S) NrSz visit_%s_funcz%(expr)srcs4g|],}j|s ttjr,j|n|qSrS)r_requires_quotes_illegal_charsrrrr)rUtokrrrSrWrNs   z.SQLCompiler.visit_function..rz WITH ORDINALITY)rrgetattrlower FUNCTIONSrZ _deannotate __class__Z _has_argsrrrrrrr3Z packagenamesfunction_argspecZ_with_ordinality)rr rrdisprrSrrWrs:       zSQLCompiler.visit_functioncKs ||jSr)visit_sequencesequence)rZ next_valuerrSrSrWvisit_next_value_funcsz!SQLCompiler.visit_next_value_funccKstd|jjdS)Nz2Dialect '%s' does not support sequence increments.rrr)rrrrSrSrWrs zSQLCompiler.visit_sequencecKs|jj|f|Sr)Z clause_exprr)rr rrSrSrWrszSQLCompiler.function_argspecc  s8j }|j|f}|r(js(|_|r2jnjd}|pP| oP|dd}|dkrb||d<j|d|d|||dj|j} d | d fd d t |j D} dd <| j |ft fd i7} | j |f7} |jr| j|f7} jr(|r(| } jd| S)NrrFrselect_0correlate_froms asfrom_froms)r r!r rrrc3s*|]"\}}|jf|dVqdS))rrNr)rUrXrrrrrSrWrsz4SQLCompiler.visit_compound_select..rr)r_compile_state_factoryrrrrecompound_keywordskeywordr3rVselectsgroup_by_clauser3order_by_clause_has_row_limiting_clause_row_limit_clauser_render_cte_clauser) rcsrrrrrr Zneed_result_mapr%rrSr"rWvisit_compound_selectsD        z!SQLCompiler.visit_compound_selectcKs*|jdk r|j|f|S|j|f|SdSr) _fetch_clause fetch_clause limit_clause)rr,rrSrSrWr*)s zSQLCompiler._row_limit_clausecCs(d|j||rd|ndf}t||dS)Nz visit_%s_%s%s_r)rr)r operator_Z qualifier1Z qualifier2attrnamerSrSrW_get_operator_dispatch/s z"SQLCompiler._get_operator_dispatchcKs|dk r"||f7}||d<||d<|jrt|jr8td||jdd}|r\|||jf|S|j|t|jf|SnL|jr||jdd}|r|||jf|S|j|t|jf|Sn tddS)NrrzFUnary expression does not support operator and modifier simultaneouslyunaryrpmodifierz,Unary expression has no operator or modifier)rpr6rr>r4 _generate_generic_unary_operatorr _generate_generic_unary_modifier)rr5rrrrrSrSrW visit_unary7sN zSQLCompiler.visit_unarycKs6|js|jjr|j|jf|Sd|j|jf|SdS)Nz%s = 1Z_is_implicitly_booleanrrrrrrrprrSrSrWvisit_is_true_unary_operator^s z(SQLCompiler.visit_is_true_unary_operatorcKs:|js|jjr"d|j|jf|Sd|j|jf|SdS)NNOT %sz%s = 0r:r;rSrSrWvisit_is_false_unary_operatorgs z)SQLCompiler.visit_is_false_unary_operatorcKsd|j|tjdS)Nr=)override_operator) visit_binaryrmatch_oprrrprrSrSrWvisit_not_match_op_binarypsz%SQLCompiler.visit_not_match_op_binarycKsd|j|t|f|Sr)_generate_generic_binaryrrBrSrSrWvisit_not_in_op_binaryus z"SQLCompiler.visit_not_in_op_binarycCsv|tjkr4t|dkr.dddd|DSdSn>|tjkrht|dkrbdddd|DSd Sn ||SdS) Nrz(%s)) OR (1 = 1rjcss|] }dVqdSrNrSrUrrSrSrWrsz6SQLCompiler.visit_empty_set_op_expr..zNULL) OR (1 = 1z(%s)) AND (1 != 1css|] }dVqdSrFrSrGrSrSrWrszNULL) AND (1 != 1)r not_in_opr6r3in_opvisit_empty_set_expr)rr expand_oprSrSrWvisit_empty_set_op_expr}s    z#SQLCompiler.visit_empty_set_op_exprcCstd|jjdS)Nz3Dialect '%s' does not support empty set expression.r)rZ element_typesrSrSrWrJs z SQLCompiler.visit_empty_set_exprcs|sDjjr0jjrdndjjj}qjgj}ntt|dtt frjjsbt jjrndndd fddt |D}n&jjrt d fdd|D}d|fS) NVALUES rrrjc3s8|]0\}}ddfddt|jjDVqdS)rrjc3s|]\}}||VqdSrrR)rUr-Z param_typerrSrWrsz[SQLCompiler._literal_execute_expanding_parameter_literal_binds...N)r3r?rr1)rUrXrYrhrrSrWrs zQSQLCompiler._literal_execute_expanding_parameter_literal_binds..c3s|]}|jVqdSr)rSr)rUr-rNrSrWrsrS) rr/rtuple_in_valuesrLr1rKrr0rAssertionErrorr3rV)rrhr_replacement_expressionrSrNrW2_literal_execute_expanding_parameter_literal_bindss0   z>SQLCompiler._literal_execute_expanding_parameter_literal_bindscs|jr||S|sJg|jjr6|jj|j}qԈ|jg|j}nt|dtt frfddt |dDj j rdndd fdd t |D}n0fd dt |dDd fd d D}|fS) Nrcs6g|].\}}t|dD]\}}d||f|fqqS)rrTrUrWrrSrWrNs zDSQLCompiler._literal_execute_expanding_parameter..rrMrrjc3s8|]0\ddfddtDVqdS)rrjc3s4|],\}}jdt|diVqdS)rrN)rr6)rUrZr-)rXrrirYrSrWrszMSQLCompiler._literal_execute_expanding_parameter...N)r3rV)rU)rri)rXrYrWrs  zCSQLCompiler._literal_execute_expanding_parameter..cs g|]\}}d|f|fqS)z%s_%srS)rUrXr-rrSrWrNsc3s |]\}}jd|iVqdS)rN)rr,rrSrWrs)rcrRrr/rLr1rKrr0rrVrrOr3)rrrhr_rQrS)rrrirWrbs@   z0SQLCompiler._literal_execute_expanding_parameterc Ks |rft|jrf|dk rJ|d}|jt|jj|g|j j|gn|jt|jj|j j|j rt |jt j rt |j t j rd|d<|p|j}||dd} | r| ||f|Sz t|} Wn:tk r} ztjt||| dW5d} ~ XYnX|j|| f||d|SdS)Nenclosing_lateralTrcrr) from_linterlateral_from_linter)rZ is_comparisonrprrr(productr5 _from_objectsrEansi_bind_rulesrrZ BindParameterr4rrrrrrrD) rrr?eager_groupingrTrUrrSr2ropstringrrSrSrWr@sT        zSQLCompiler.visit_binarycKs|j|jf|Sr)rZ sql_functionr;rSrSrW&visit_function_as_comparison_op_binary&sz2SQLCompiler.visit_function_as_comparison_op_binarycKsT|jjr,|j|jf|d|j|jf|S|j|jf|d|j|jf|SdS)Nz %% rh)rrrr5rErBrSrSrWvisit_mod_binary)szSQLCompiler.visit_mod_binarycKs*|j|d<|j|d||jdf|S)NrYr)rYrDrrZr;rSrSrWvisit_custom_op_binary7s z"SQLCompiler.visit_custom_op_binarycKs|j|||jdf|Sr)r7rrZr;rSrSrWvisit_custom_op_unary_operator?s z*SQLCompiler.visit_custom_op_unary_operatorcKs|j|d||jf|Sr)r8rrZr;rSrSrWvisit_custom_op_unary_modifierDs z*SQLCompiler.visit_custom_op_unary_modifiercKsf|dd}d|d<|j|d<|jj|fd|i|||jj|fd|i|}|rb|rbd|}|S)N _in_binaryFT _binary_oprYr)rrpr5rrE)rrrZrYrr`rrSrSrWrDIs0   z$SQLCompiler._generate_generic_binarycKs||jj|f|Srrrr5rZrrSrSrWr7_sz,SQLCompiler._generate_generic_unary_operatorcKs|jj|f||SrrrbrSrSrWr8bsz,SQLCompiler._generate_generic_unary_modifiercCstjdtjdS)Nz'%')r)rZliteral_columnr STRINGTYPErrSrSrW_like_percent_literalesz!SQLCompiler._like_percent_literalcKs2|}|j}||j||_|j||f|Sr_clonerd__add__rEvisit_like_op_binaryrrrprpercentrSrSrWvisit_contains_op_binaryisz$SQLCompiler.visit_contains_op_binarycKs2|}|j}||j||_|j||f|SrrfrdrgrEvisit_not_like_op_binaryrirSrSrWvisit_not_contains_op_binaryosz(SQLCompiler.visit_not_contains_op_binarycKs,|}|j}||j|_|j||f|Sr)rfrd__radd__rErhrirSrSrWvisit_startswith_op_binaryusz&SQLCompiler.visit_startswith_op_binarycKs,|}|j}||j|_|j||f|Sr)rfrdrorErmrirSrSrWvisit_not_startswith_op_binary{sz*SQLCompiler.visit_not_startswith_op_binarycKs,|}|j}||j|_|j||f|SrrerirSrSrWvisit_endswith_op_binarysz$SQLCompiler.visit_endswith_op_binarycKs,|}|j}||j|_|j||f|SrrlrirSrSrWvisit_not_endswith_op_binarysz(SQLCompiler.visit_not_endswith_op_binarycKsL|jdd}d|jj|f||jj|f|f|rFd||tjndS)Nescapez %s LIKE %s ESCAPE r modifiersrr5rrErSr rcrrrprrtrSrSrWrhsz SQLCompiler.visit_like_op_binarycKsL|jdd}d|jj|f||jj|f|f|rFd||tjndS)Nrtz%s NOT LIKE %srurrvrxrSrSrWrmsz$SQLCompiler.visit_not_like_op_binarycKsL|jdd}d|jj|f||jj|f|f|rFd||tjndS)Nrtzlower(%s) LIKE lower(%s)rurrvrxrSrSrWvisit_ilike_op_binarysz!SQLCompiler.visit_ilike_op_binarycKsL|jdd}d|jj|f||jj|f|f|rFd||tjndS)Nrtzlower(%s) NOT LIKE lower(%s)rurrvrxrSrSrWvisit_not_ilike_op_binarysz%SQLCompiler.visit_not_ilike_op_binarycKs&|jdd}|j||rdndf|S)NrIFz BETWEEN SYMMETRIC z BETWEEN rwrrDrrrprrIrSrSrWvisit_between_op_binarys z#SQLCompiler.visit_between_op_binarycKs&|jdd}|j||rdndf|S)NrIFz NOT BETWEEN SYMMETRIC z NOT BETWEEN r{r|rSrSrWvisit_not_between_op_binarys z'SQLCompiler.visit_not_between_op_binarycKstd|jjdSNz/%s dialect does not support regular expressionsrr>rrrBrSrSrWvisit_regexp_match_op_binarys z(SQLCompiler.visit_regexp_match_op_binarycKstd|jjdSrrrBrSrSrW visit_not_regexp_match_op_binarys z,SQLCompiler.visit_not_regexp_match_op_binarycKstd|jjdS)Nz;%s dialect does not support regular expression replacementsrrBrSrSrWvisit_regexp_replace_op_binarys z*SQLCompiler.visit_regexp_replace_op_binarycKs|s>|j|j}|jr>||} |j| fd|||d|S|sb|pT|jpT|oT|j}|p^|j} nd} |s|r|j |fddi|} |jrd| } | S| |} | |j kr|j | } | |k r| j s|j r| j |j std| n$| js|jrtd|j|jf||j |j<|j | <|j}|rb|jD]*}|j|kr6||j}|||q6|jrpd|_| r|rd|_|r|j|hO_n|j|hO_|j| f| |jd|} |jrd| } | S) NT)skip_bind_expressionr literal_bindsrcFrrzIBind parameter '%s' conflicts with unique bind parameter of the same namezbindparam() name '%s' is reserved for automatic usage in the VALUES or SET clause of this insert/update statement. Please use a name other than column name when using bindparam() with insert() or update() (for example, 'b_%s').) post_compile expanding)rrFrZ_has_bind_expressionbind_expressionrrcrXrr`_truncate_bindparamrrNr intersectionrr>Z_is_crudrrZ _cloned_setreZ isoutparamhas_out_parametersrrPrar)rr2rrrrcZrender_postcompilerimplrrrrexistingrZbpcbrSrSrWvisit_bindparams               zSQLCompiler.visit_bindparamc Ks|tk r|}nZ|jdkrb|jdkrb|dd}|rR|tjtjfkrRtd|j f|j t j f|S|j }|jr|j}|||\}}|S|||jSdS)NrazBound parameter '%s' rendering literal NULL in a SQL expression; comparisons to NULL should not use operators outside of 'is' or 'is not')r r-rBrris_is_notrZ warn_limitedrrr rrCrrRrSr) rr2rSrr-oprjrirkrSrSrWr`C s  z$SQLCompiler.render_literal_bindparamcCs(||j}|r||Std|dS)aRender the value of a bind parameter as a quoted literal. This is used for statement sections that do not accept bind parameters on the target driver/database. This should be implemented by subclasses using the quoting services of the DBAPI. z(Don't know how to literal-quote value %rN)Z_cached_literal_processorrr)rr-r processorrSrSrWrS\ s z SQLCompiler.render_literal_valuecCs@||jkr|j|S|j}t|tjr2|d|}||j|<|S)Nr2)rrrrrr)rr2Z bind_namerSrSrWro s     zSQLCompiler._truncate_bindparamcCs||f|jkr|j||fS||j}t||jdkr|j|d}|dt|jdddt|dd}|d|j|<n|}||j||f<|S)Nrrr1r)r apply_maprr6rrmaxhex)rZ ident_classrZanonnamecounterZ truncnamerSrSrWr| s z!SQLCompiler._truncated_identifiercCs ||jSrrrrrSrSrW _anonymize szSQLCompiler._anonymizec Ks|jr(|dk r||qX|j|n0|sX|sX|j}||rX|dd|}|}|}|rr|jshi|_||j|<|r~d|S|jd|iSdS)NcSst|dS)Nr)_BIND_TRANSLATE_CHARSr.r#rSrSrWr& r'z.SQLCompiler.bindparam_string..z[POSTCOMPILE_%s]r)rrerrsearchr+r<r) rrpositional_namesrrZ escaped_fromrZtr_regnew_namerSrSrWr s(    zSQLCompiler.bindparam_stringc s||d<t|jtjr.d|j}n|j}d} d} |jkrj|} || k} || jksj|| krpd} n"| |jkrj| =nt d||s| r|j dk r|j } |j j} t| tjrԈd| } n|} d} | r|j|<d|j j krdjkrjd|j j di_| jkr2j| f|| s|jkr|jrRd_j||}|jrt|j tjr|j }n,t|j tjr|j jd}ndstdd d |dD}|d d fd d|D7}jrg|d<j|<|dddkstjs0|j j fd|i|Sj!||j"f|}|j j fddi|}|d||f7}|j#r|dj!||j#f|7}|j|<|r|r||j$|<| s| rƈj||S| rj|| }j%|rj&|}|'|7}|Sj||SdS)N visiting_cterTFz5Multiple, unrelated CTEs found with the same name: %rZ autocommitrz%cte should only be against SelectBasecSs"g|]\}}}}}|s|p|qSrSrS)rUr1 proxy_namefallback_label_namerrepeatedrSrSrWrN sz)SQLCompiler.visit_cte..rrjc3s |]}jj|jdVqdS)rN)rformat_label_namer)rUidentrrSrWr s z(SQLCompiler.visit_cte..rsubqueryrz AS %s (%s)r)(rrrrrrrZ _restatesrrr>Z _cte_aliasrrrrM visit_cte recursiverr format_aliasr ZSelectCompoundSelectr&rPZ_generate_columns_plus_namesr3rrrrr_generate_prefixes _prefixes _suffixesr_requires_quotesrget_render_as_alias_suffix)rcterashint fromhintsrrTrZcte_nameZ is_new_cteZembedded_in_current_named_cteZ existing_cteZ pre_alias_cteZcte_pre_alias_namerZ col_sourceZ recur_colsprefixesr1rSrrWr s                zSQLCompiler.visit_ctecKs&|jr|j|f|S|j|f|SdSr) _is_lateral visit_lateral visit_aliasrrSrSrWvisit_table_valued_aliasQ sz$SQLCompiler.visit_table_valued_aliascKs|j|f|Sr)rrrSrSrWvisit_table_valued_columnW sz%SQLCompiler.visit_table_valued_columnc  s|r:dkrjstd<| r:dkr:dkr:| d<|dk r|jkrjjf|||||d} |r|sz|rd| f} | S}d<|s|rtjtjrdj} nj} |r҈j | S|r| r| | j <jjfd|d} |rd| f} |  j | } j r^jr^| dd fd d jD7} |r|kr| ||} | Sjjfd |iSdS) NrSrU)rriscrudrlateralenclosing_aliasrrrT)rrrjc3sB|]:}dj|jjr2djjj|jfndfVqdS)z%s%s %srN)rrrZ_render_derived_w_typesrrrrrrrrrrSrWr s  z*SQLCompiler.visit_alias..r)rrPrrrrrrrrrrrZ_supports_derived_columnsZ_render_derivedr3rformat_from_hint_text)rrrrrrrrrrTrr1Z alias_namerrSrrWrZ s        zSQLCompiler.visit_aliascKsd|d<|j|f|S)NTrr)rrrrSrSrWvisit_subquery szSQLCompiler.visit_subquerycKsd|d<d|j|f|S)NTrz LATERAL %sr)rZlateral_rrSrSrWr szSQLCompiler.visit_lateralcKsRd|j|fddi||j|f|f}|jdk rN|d|jj|f|7}|S)Nz%s TABLESAMPLE %srTz REPEATABLE (%s))rZ _get_methodrseed)rZ tablesamplerrrrSrSrWvisit_tablesample s zSQLCompiler.visit_tablesamplec sdjddfddjD}tjtjrNdj}nj}j r`d}nd}|r|r|dk rx|nd |j <|rd || j |dfd djDf}n d ||f}|S) Nrz VALUES %srjc3s8|]0}|D]&}jtj|djifVq qdS)r1N)rrTupleZ _column_typesr)rUchunkrrrrrSrWr sz+SQLCompiler.visit_values..r_zLATERAL rz(unnamed VALUES element)z %s(%s)%s (%s)c3s$|]}|jfddiVqdS)rFNrrrrSrWr sz%s(%s)) setdefaultrr3_datarrrrrrrrrrcolumns)rrrrTrvrrrSrrW visit_values s2  zSQLCompiler.visit_valuescCsd|S)NrkrS)rZalias_name_textrSrSrWr sz&SQLCompiler.get_render_as_alias_suffixcCsD|dks|dkrd|_d|_|jr,td|j||||fdS)N*FTzxMost backends don't support SELECTing from a tuple() object. If this is an ORM query, consider using the Bundle object.)rrr/rr>rre)rkeynamerobjectsrrSrSrWr szSQLCompiler._add_to_result_mapcCs|d|dd|dkrin|S)aLRender a column with necessary labels inside of a RETURNING clause. This method is provided for individual dialects in place of calling the _label_select_column method directly, so that the two use cases of RETURNING vs. SELECT can be disambiguated going forward. .. versionadded:: 1.4.21 NTF_label_select_column)rstmtrcolumn_clause_argsrSrSrW_label_returning_column s z#SQLCompiler._label_returning_columnc sj|j} | jr(| s|r(| } n} |rh|j}| rL|fdd}ql| k rl|fdd}nd}| sxtdttj r| k rt | j j fd}n| }n|r|dk stdt | ||j fd}n| k rd}n~ttjr |oj ojdk }nTttjr d }n@ttjr<jp8|}n$ttjs\jdkr\d}nd }|r|s|| rvtj}t|tjst|n|}t | ||fd}n| }|j| |d |j|f|S) z.produce labeled columns present in a select().cs||d|dS)NrSrSrrrr)rrSrWrG sz;SQLCompiler._label_select_column..add_to_result_mapcs||f||dSrrSrrrrSrWrO s NzX_label_select_column is only relevant within the columns clause of a SELECT or RETURNING)rz*proxy_name is required if 'name' is passedTFr)rrFrZ_has_column_expressionZcolumn_expressionrrPrrZLabelrrrrZ ColumnClauserrJZ TextClauseZUnaryExpressionZwraps_column_expressionZ NamedColumnZ_non_anon_labelZ_anon_name_labelrrr)rrFrrrrrrrrcolumn_is_repeatedneed_column_expressionsrZcol_exprrZ result_exprZrender_with_labelrSrrWr" s     z SQLCompiler._label_select_columncCs |||}|r|d|7}|Sr)get_from_hint_text)rsqltextrJhintrhinttextrSrSrWr s  z!SQLCompiler.format_from_hint_textcCsdSrrS)rZbyfromsrSrSrWget_select_hint_text sz SQLCompiler.get_select_hint_textcCsdSrrSrrJrrSrSrWr szSQLCompiler.get_from_hint_textcCsdSrrSrrSrSrWget_crud_hint_text szSQLCompiler.get_crud_hint_textcCs d|Srr)rZ hint_textsrSrSrWget_statement_hint_text sz#SQLCompiler.get_statement_hint_textr r!c Ksh|j }|r|jn|jd}|||}|d}|d} |rV|sV|j|| dd} n|j|| d} | S)Nrr r!rSZexplicit_correlate_fromsZimplicit_correlate_froms)rrr#_get_display_froms difference) r select_stmtrrrrr rr r!rrSrSrW_display_froms_for_select s" z%SQLCompiler._display_froms_for_selectc s|dkstdjf|} | jj } | r>js>| _jrjfdi|} | k r| } }| jf|} | j| rjnjd} | p| ddp| dd|rdsd|kr|d=| | ||}|  dddd }j r, \}}|r0||d 7}nd}j rTj D]}|jf|q>jrr|jjf|7}|jf|7}d d fd d | jDD}r|dk rttdd | jDdd | jDfdd jD_|| |||| |}jrDfdd jD}|rD|d |7}jr^| r^|}jr|d jjf|7}jd|S)NzpSQLAlchemy 1.4 requires use of the translate_select_structure hook for structural translations of SELECT objectsrrrFrr)rrzSELECT rcSsg|]}|dk r|qSrrSrrSrSrWrNc sz,SQLCompiler.visit_select..cs4g|],\}}}}}j|||||d qS))rrrrrr)rUrrrrr)rrrrrrrSrWrNe s$ cSsg|]\}}}}}|qSrSrSrUrrrrrrSrSrWrN scSsg|]\}}}}}|qSrSrSrrSrSrWrN scs2g|]*\}}}}||tfdd|D|fqS)c3s|]}||VqdSr)r)rUo translaterSrWr sz6SQLCompiler.visit_select...)r0)rUrrrrrrSrWrN s cs$g|]\}}|djjfkr|qSrrr)rU dialect_namehtrrSrWrN s)rPr#rrrtranslate_select_structurerr_setup_select_stackcopyr_hints_setup_select_hints_independent_ctesrrrget_select_precolumnscolumns_plus_namesr3r?r_compose_select_bodyZ_statement_hintsrrr+rr)rrrrrZselect_wraps_forrrTrrrZnew_select_stmtZcompile_state_wraps_forr rr hint_textbyfromr inner_columnsZ per_dialectrS)rrrrrrrrW visit_select s             zSQLCompiler.visit_selectcs.tfdd|jD}|}||fS)Nc s>g|]6\\}}}|djjfkr||d|jddifqS)rrT)rrrr)rUrrrrrSrWrN s z3SQLCompiler._setup_select_hints..)r3rr@r)rrFrrrSrrWr s  zSQLCompiler._setup_select_hintscCs|d}|d}|dkr"||d<nD|rf|d} t| j} t|j| krftdd| |dt|jf|r|s|j||dd} n|j||d} ttj | } | |} | | ||d }|j || S) Nr r!rrz}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %drrSr)r!r r r) r6Z_all_selected_columnsrrr>rrrHr rWrMrre)rrFrr rrrr r!rZnumcolsrZnew_correlate_fromsZall_correlate_fromsZ new_entryrSrSrWr sJ     zSQLCompiler._setup_select_stackc sx|d|7}jt@r:titjt@} |rB_ndd} |r|d7}|jrx|dfdd|D7}q|dfdd|D7}n |7}|j rԈj |j fdi} | r|d| 7}| r |j r|j |f7}|jr"j |jf} | r"|d | 7}|jr<|j|f7}|jrV|j|f7}|jdk rt|j|f7}|S) NrjFz FROM cs&g|]}|jfddqS)T)rrrTrrUfrrTrrrSrWrN sz4SQLCompiler._compose_select_body..cs$g|]}|jfddqS)TrrTrr)rTrrrSrWrN* srTz WHERE z HAVING )r3rrrrHrrTrr_where_criteriarr_group_by_clausesr'Z_having_criteria_order_by_clausesr(r)r*Z_for_update_argfor_update_clause) rrrFrrrrrrZ warn_lintingtrSrrWr sf         z SQLCompiler._compose_select_bodyc s*dfdd|D}|r&|d7}|S)Nrc3s4|],\}}|dks|jjkr|jfVqdSrr)rUprefixrrrSrWrW s z1SQLCompiler._generate_prefixes..r)rrrrrrSrrWrV s zSQLCompiler._generate_prefixescsbjr(tfddjDgj_jd}|dddjD7}|d7}|S)Ncsg|]}j|qSrS)r)rUrrrSrWrNc sz2SQLCompiler._render_cte_clause..r, cSsg|]}|qSrSrS)rUtxtrSrSrWrNg sz )rsumrrget_cte_preamblerr3r_)rZcte_textrSrrWr+` szSQLCompiler._render_cte_clausecCs|rdSdSdS)NzWITH RECURSIVEZWITHrS)rrrSrSrWrk szSQLCompiler.get_cte_preamblecKs"|jrtjddd|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.4versionrlr)Z _distinct_onrwarn_deprecatedZ _distinctrrFrrSrSrWrq s z!SQLCompiler.get_select_precolumnscKs,|j|jttjf|}|r$d|SdSdS)z5allow dialects to customize how GROUP BY is rendered.z GROUP BY rN)rrrrcomma_op)rrFrZgroup_byrSrSrWr' szSQLCompiler.group_by_clausecKs,|j|jttjf|}|r$d|SdSdS)z5allow dialects to customize how ORDER BY is rendered.z ORDER BY rN)rrrrr )rrFrrrSrSrWr( szSQLCompiler.order_by_clausecKsdS)Nz FOR UPDATErSr rSrSrWr szSQLCompiler.for_update_clausecCstddS)Nz@RETURNING is not supported by this dialect's statement compiler.r)rrreturning_colsrSrSrWreturning_clause szSQLCompiler.returning_clausecKs^d}|jdk r&|d|j|jf|7}|jdk rZ|jdkrB|d7}|d|j|jf|7}|S)Nrz LIMIT z LIMIT -1z OFFSET )Z _limit_clauser_offset_clauserrFrrrSrSrWr0 s   zSQLCompiler.limit_clausecKsnd}|jdk r&|d|j|jf|7}|jdk rj|d|j|jf||jdrPdnd|jdr`dndf7}|S) Nrz OFFSET %s ROWSz FETCH FIRST %s%s ROWS %srjz PERCENTZ with_tiesz WITH TIESZONLY)rrr.Z_fetch_clause_optionsrrSrSrWr/ s   zSQLCompiler.fetch_clausec Ks|r|j|j|<|s|r~|j|} |rL| rL|j| d|j|j} n|j|j} |rz||krz|| ||||} | SdSdS)Nrr)fullnamerrrrrrr) rrJrrrr use_schemarTrrrrSrSrW visit_table s*      zSQLCompiler.visit_tablecKs|r|j|j|jf|jr$d}n|jr0d}nd}|jj|fd|d|||jj|fd|d|d|jj|fd|i|S)Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN Trz ON rT)raddr5rEr-ZisouterrZonclause)rr3rrTrZ join_typerSrSrW visit_join sJ zSQLCompiler.visit_joincsFtfdd|jD}|j|kr>||j||jd}||fS)Ncs,g|]$\\}}}|djjfkr||fqSrr)rUrJrrrrSrWrN s z1SQLCompiler._setup_crud_hints..T)r3rr@rJr)rr table_text dialect_hintsrSrrW_setup_crud_hints s  zSQLCompiler._setup_crud_hintscKs|j||f|}|j}|j }|r4d|_|js4||_|jtt|dtj|||f|}|s|j j s|j j s|j j st d|j j|jr|j jst d|j j|d}n|}|j}|j j }d} |jr| |j||jf|7} | d7} ||j} |jr||| \} } |jr8|jD]} | j|f|q"| | 7} |sL|sh| dd d d |D7} |jsx|jr|||jp|j} |jr| d | 7} nd} |j dk r|j!|j"f|}|j#r|r|j j$r| d |%|f7} n | d|7} nt|s|r| d7} n^|jr<| dd dd|D7} n8d dd |D}| d|7} |rt|j&dkrt||_'|j&dk r|j!|j&f|}|r| d |7} | r|js| d | 7} |j#r|r|j j$s|%| } |j(d| S)NTr r!r zWThe '%s' dialect with current database version settings does not support empty inserts.zcThe '%s' dialect with current database version settings does not support in-place multirow inserts.rzINSERT zINTO  (%s)rjcSsg|]\}}}|qSrSrSrUrrr-rSrSrWrNLsz,SQLCompiler.visit_insert..rz %s%srz DEFAULT VALUESz VALUES %scss&|]}dddd|DVqdS)rrjcss|]\}}}|VqdSrrSrrSrSrWrfsz5SQLCompiler.visit_insert...Nr)rUZcrud_param_setrSrSrWrdsz+SQLCompiler.visit_insert..cSsg|]\}}}|qSrSrSrrSrSrWrNlsz VALUES (%s)r))r#rrrrrerHr_get_crud_paramsrsupports_default_valuesZsupports_default_metavalueZsupports_empty_insertrr>rZ_has_multi_parametersZsupports_multivalues_insertrrr format_tablerJrrrrr3r r rreturning_precedes_valuesrFrZ_insert_from_selectrZcte_follows_insertr+Z_post_values_clauseinsert_single_values_exprr)rZ insert_stmtrrr crud_paramsZcrud_params_singlerrrrr1rrZ select_textr Zpost_values_clauserSrSrW visit_inserts                 zSQLCompiler.visit_insertcCsdS)z3Provide a hook for MySQL to add LIMIT to the UPDATENrS)r update_stmtrSrSrWupdate_limit_clauseszSQLCompiler.update_limit_clausecKsd|d<|j|fddi|S)z|Provide a hook to override the initial table clause in an UPDATE statement. MySQL overrides this. Trrr)rr# from_table extra_fromsrrSrSrWupdate_tables_clausesz SQLCompiler.update_tables_clausecKs tddS)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 UPDATENrrr#r%r& from_hintsrrSrSrWupdate_from_clauses zSQLCompiler.update_from_clausec sL|j||f|}|j}|j }|r4d|_|js4||_|j}t|}|rttt |j fdd|D} |}n g}|j h}|j |||dd} |j r| |j||j f|7} |j||j |f|} tj|||f|} |jr||| \} } nd} |jr|jD]} | j|f|q| | 7} | d7} | ddd | D7} |jsR|jrx|jrx| d |||jpp|j7} |r|j||j || f|}|r| d |7} |jr|j|jf|}|r| d |7} ||}|r| d |7} |js|jr"|js"| d |||jp|j7} |jr<|r<| | } |j!d | S) NTcsg|]}|kr|qSrSrSrZ main_fromsrSrWrNsz,SQLCompiler.visit_update..rzUPDATE z SET rjcss |]\}}}|d|VqdS)=NrSrrSrSrWrsz+SQLCompiler.visit_update..r WHERE r)"r#rrrr _extra_fromsr;rHr rWrJrMrerrr'rrrrrrr3r r rrr*rrr$rr+r)rr#rrrr&Z is_multitableZrender_extra_fromsr rrr!rrextra_from_textrr0rSr+rW visit_updates            zSQLCompiler.visit_updatecKs tddS)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 DELETENrr(rSrSrWdelete_extra_from_clauses z$SQLCompiler.delete_extra_from_clausecCs|j|dddS)NT)rrr)r delete_stmtr%r&rSrSrWdelete_table_clause szSQLCompiler.delete_table_clausec Ks|j||f|}|j}|j }|r4d|_|js4||_|j}|jh|}|j|||dd}|j r|||j ||j f|7}|d7}| ||j|}|j r| ||\} }nd} |jr|jD]} | j|f|q||7}|jr|jr|d|||j7}|r(|j||j|| f|} | r(|d| 7}|jrR|j|jf|} | rR|d| 7}|jrx|jsx|d|||j7}|jr|r||}|jd|S)NTrzDELETE FROM rr-r)r#rrr rr.rJrMrerrr3rrrrr rrr1rrrr+r) rr2rrrr&r rrrrr/rrSrSrW visit_delete#s      zSQLCompiler.visit_deletecCsd|j|S)Nz SAVEPOINT %srformat_savepointrZsavepoint_stmtrSrSrWvisit_savepointwszSQLCompiler.visit_savepointcCsd|j|S)NzROLLBACK TO SAVEPOINT %sr6r8rSrSrWvisit_rollback_to_savepointzsz'SQLCompiler.visit_rollback_to_savepointcCsd|j|S)NzRELEASE SAVEPOINT %sr6r8rSrSrWvisit_release_savepointsz#SQLCompiler.visit_release_savepoint)NNTN)NN)NF)F)F)F)NFFNrS)NTrS)N)NF)N)FN)NrS)NFNN)F)FFFFF)NFFN)FFNNN)FFFNFFNN)F)FN)N)NNNTFF)F)FNNNFN)FFFNTN)FN)rrrr EXTRACT_MAPr COMPOUND_KEYWORDSr$r rrrr rZ'render_table_with_column_in_update_fromrXrrrrrr rfrPrarrr<rrrZpostfetch_lastrowidrr rrrrrmemoized_propertyrZmemoized_instancemethodr contextlibcontextmanagerr!r r4r7rrrQrrpreload_modulerorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrr-r*r4r9r<r>rCrErLrJrRrbr@r[r\r]r^r_rDr7r8rdrkrnrprqrrrsrhrmryrzr}r~rrrrr r`rSrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr+rrr'r(rrr0r/rrrr"r$r'r*r0r1r3r5r9r:r;rSrSrSrWr,s   o %       r B     $   ' ! 1 /  $  & 5  '  *4 6        i   '  c /  $   A4T      !     j   T  rcseZdZdZddZedfddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZddZddZZS)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` cCsdS)NzrSrrSrSrWrsz$StrSQLCompiler._fallback_column_namezsqlalchemy.engine.urlc sX|jdkrFtjj}|j|j}||d}t|t sF| |St t | ||S)Nr#) Zstringify_dialectrrmZ engine_urlURLr get_dialectstatement_compilerrrBrsuperr)rrrrurlrcompilerrrSrWrs     z,StrSQLCompiler.visit_unsupported_compilationcKs$d|j|jf||j|jf|fS)Nz%s[%s])rr5rErBrSrSrWvisit_getitem_binarysz#StrSQLCompiler.visit_getitem_binarycKs|j||f|SrrJrBrSrSrWvisit_json_getitem_op_binarysz+StrSQLCompiler.visit_json_getitem_op_binarycKs|j||f|SrrKrBrSrSrW!visit_json_path_getitem_op_binarysz0StrSQLCompiler.visit_json_path_getitem_op_binarycKsd|j|S)Nz)rformat_sequence)rseqrrSrSrWrszStrSQLCompiler.visit_sequencecs&fddt|D}dd|S)Nc sg|]}d|ddiqS)NTFrrrrSrWrNsz3StrSQLCompiler.returning_clause..z RETURNING rj)rZ_select_iterablesr3)rrr rrSrrWrs zStrSQLCompiler.returning_clausec s(dd<ddfdd|DS)NTrr4rjc3s$|]}|jfdiVqdSrNrrUrr)rrrSrWrsz4StrSQLCompiler.update_from_clause..rr(rSrRrWr*sz!StrSQLCompiler.update_from_clausec s(dd<ddfdd|DS)NTrrjc3s$|]}|jfdiVqdSrPrrQrRrSrWrsz:StrSQLCompiler.delete_extra_from_clause..rr(rSrRrWr1sz'StrSQLCompiler.delete_extra_from_clausecCsdS)NzSELECT 1 WHERE 1!=1rS)rrrSrSrWrJsz#StrSQLCompiler.visit_empty_set_exprcCsd|S)Nz[%s]rSrrSrSrWrsz!StrSQLCompiler.get_from_hint_textcKs|j|df|S)Nz rDrBrSrSrWrsz+StrSQLCompiler.visit_regexp_match_op_binarycKs|j|df|S)Nz rSrBrSrSrWrsz/StrSQLCompiler.visit_not_regexp_match_op_binarycKs:|jd}d|jj|f||jj|f||j|f|fS)N replacementz(%s, %s, %s))rwr5rrE)rrrprrTrSrSrWrs   z-StrSQLCompiler.visit_regexp_replace_op_binary)rrrrrrrArrJrLrMrrr*r1rJrrrr __classcell__rSrSrIrWrBs    rBc@sdeZdZejddZejddZdTddZdd Zd d Z d d Z ddZ dUddZ dVddZ ddZddZddZdWddZddZdXd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-ZdYd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dS)Z DDLCompilercCs|jj|jd|jdS)Nr)rrErrrSrSrWrs zDDLCompiler.sql_compilercCs|jjSr)rrrrSrSrWrszDDLCompiler.type_compilerNcCsdSrrSrrSrSrWrszDDLCompiler.construct_paramscKs|j}t|jtjr|}|j}||j}t|dkrJ|dd}}n|d|d}}| d|| d|| d| |j|j |j |S)NrrrrrJr r)contextrtargetr ZTablerrformat_table_seqr6rrrrr)rZddlrrXrpathrJZschrSrSrW visit_ddls    zDDLCompiler.visit_ddlcKs|j|j}d|S)NzCREATE SCHEMA )r format_schemar)rrrr rSrSrWvisit_create_schema szDDLCompiler.visit_create_schemacKs(|j|j}d|}|jr$|d7}|S)Nz DROP SCHEMA  CASCADE)rr]rcascade)rdroprr rrSrSrWvisit_drop_schema s zDDLCompiler.visit_drop_schemac Ksd|j}|j}d}|jr*|d|jd7}|d7}|jr@|d7}|||d7}||}|rl||d7}|d7}d}d}|jD]} | j} zD|j| | j o| d} | dk r||7}d }|d | 7}| j rd }Wqt j k r$} z2t j t t d |j| j| jd f| dW5d} ~ XYqXq|j||jd} | rN||d | 7}|d||7}|S)Nz CREATE rzTABLE IF NOT EXISTS re Ffirst_pkr Tz (in table '%s', column '%s'): %sr)r) _include_foreign_key_constraintsz )%s )rrrr3 if_not_existsrcreate_table_suffixrrr~rr>rru descriptionrargscreate_table_constraintsZinclude_foreign_key_constraintspost_create_table)rrrrJrrrjrrfZ create_columnr processedZceconstrSrSrWvisit_create_tablesZ     zDDLCompiler.visit_create_tableFc sL|j}|jrdSj||d}dfdd|jD}|rH|d|7}|S)Nrerc3s|]}|VqdSr)rrUrrrSrWrRsz2DDLCompiler.visit_create_column..)rsystemget_column_specificationr3 constraints)rrrfrrrrqrSrrWvisit_create_columnKs zDDLCompiler.visit_create_columnc stg}jr|jj}|dk r0||nt|fddjDdddfdd|DDS)Ncs"g|]}|jk r|kr|qSrS)r~r) omit_fkcsrJrSrWrNks z8DDLCompiler.create_table_constraints..z, css|]}|dk r|VqdSrrS)rUprSrSrWrrs z7DDLCompiler.create_table_constraints..c3s@|]8}|jdks|rjjr.t|dds|VqdS)NZ use_alterF)Z _create_rulerZsupports_alterrrrsrrSrWrts    )r~reZforeign_key_constraintsrrHrdZ_sorted_constraintsr3)rrJrhrrvZall_fkcsrS)rxrrJrWrnZs"     z$DDLCompiler.create_table_constraintscKs$d}|jr|d7}||j|jS)Nz DROP TABLE IF EXISTS ) if_existsrrr)rrarrrSrSrWvisit_drop_tableszDDLCompiler.visit_drop_tablecKsd|j|jS)Nz DROP VIEW rrrrrarrSrSrWvisit_drop_viewszDDLCompiler.visit_drop_viewcCs|jdkrtd|jdS)Nz,Index '%s' is not associated with any table.)rJrr>rrrrSrSrW_verify_index_tables zDDLCompiler._verify_index_tableTc s|j}|j}d}|jr(|d7}|jdkr.) rrrrNrrr>ri_prepared_index_namerrJr3Z expressions)rrrZinclude_table_schemarrrrrSrrWvisit_create_indexs0    zDDLCompiler.visit_create_indexcKs>|j}|jdkrtdd}|jr,|d7}||j|ddS)Nz.DROP INDEX requires that the index have a namez DROP INDEX rzTr)rrrr>r{r)rrarrrrSrSrWvisit_drop_indexs zDDLCompiler.visit_drop_indexcCsX|jdk r|j|j}nd}|r4|r4|j|}nd}|j|}|rT|d|}|SNr)rJrrr format_index)rrrrZ schema_nameZ index_namerSrSrWrs   z DDLCompiler._prepared_index_namecKs d|j|jj||jfS)NzALTER TABLE %s ADD %s)rrrrJrrrrrSrSrWvisit_add_constraints z DDLCompiler.visit_add_constraintcKs(d|j|j|j|jjtfS)NzCOMMENT ON TABLE %s IS %s)rrrrrScommentr StringrrSrSrWvisit_set_table_comments z#DDLCompiler.visit_set_table_commentcKsd|j|jS)NzCOMMENT ON TABLE %s IS NULLr}r~rSrSrWvisit_drop_table_commentsz$DDLCompiler.visit_drop_table_commentcKs.d|jj|jddd|j|jjtfS)NzCOMMENT ON COLUMN %s IS %sT) use_tabler)r format_columnrrrSrr rrrSrSrWvisit_set_column_commentsz$DDLCompiler.visit_set_column_commentcKsd|jj|jddS)NzCOMMENT ON COLUMN %s IS NULLT)r)rrrr~rSrSrWvisit_drop_column_commentsz%DDLCompiler.visit_drop_column_commentcCsg}|jdk r|d|j|jdk r8|d|j|jdk rR|d|j|jdk rl|d|j|jdk r|d|jdk r|d|jdk r|d|j|jdk r||jrdnd |j dk r||j rd nd d |S) NzINCREMENT BY %dz START WITH %dz MINVALUE %dz MAXVALUE %dz NO MINVALUEz NO MAXVALUEzCACHE %drzNO ORDERZCYCLEzNO CYCLEr) incrementrerZminvalueZmaxvalueZ nominvalueZ nomaxvaluecacherBcycler3)rZidentity_optionsrrSrSrWget_identity_optionss(           z DDLCompiler.get_identity_optionscKsVd|j|j}|r||7}|jjdkr6|jj|j_||j}|rR|d|7}|S)NzCREATE SEQUENCE %sr)rrNrrrZdefault_sequence_baser)rrrrroptionsrSrSrWvisit_create_sequences    z!DDLCompiler.visit_create_sequencecKsd|j|jS)NzDROP SEQUENCE %s)rrNrr~rSrSrWvisit_drop_sequenceszDDLCompiler.visit_drop_sequencecKs^|j}|jdk r|j|}nd}|dkr:td|jd|j|jj||jrVdpXdfS)NzrrJr`)rrarrformatted_namerSrSrWvisit_drop_constraints  z!DDLCompiler.visit_drop_constraintcKs|j|d|jjj|j|d}||}|dk rB|d|7}|jdk r`|d||j7}|jdk r|jj r|d||j7}|j s|jr|jj s|d7}|S)Nr)rz DEFAULT z NOT NULL) rrrrrrget_column_default_stringZcomputedidentityZsupports_identity_columnsZnullable)rrrZcolspecr#rSrSrWru)s4    z$DDLCompiler.get_column_specificationcCsdSNrrSrrJrSrSrWrjDszDDLCompiler.create_table_suffixcCsdSrrSrrSrSrWroGszDDLCompiler.post_create_tablecCsPt|jtjrHt|jjtjr2|j|jjt j S|jj |jjddSndSdS)NT)r) rZserver_defaultr Z DefaultClauseargr string_typesrrSr rcrrrSrSrWrJsz%DDLCompiler.get_column_default_stringcKs|jr||S||SdSr)Zis_column_levelvisit_column_check_constraintvisit_check_constraint)rrrrSrSrW&visit_table_or_column_check_constraintWs z2DDLCompiler.visit_table_or_column_check_constraintcKs\d}|jdk r.|j|}|dk r.|d|7}|d|jj|jddd7}|||7}|SNrCONSTRAINT %s z CHECK (%s)FTrrrrrrrdefine_constraint_deferrabilityrrrrrrSrSrWr]s     z"DDLCompiler.visit_check_constraintcKs\d}|jdk r.|j|}|dk r.|d|7}|d|jj|jddd7}|||7}|SrrrrSrSrWris     z)DDLCompiler.visit_column_check_constraintc st|dkrdSd}|jdk r>j|}|dk r>|d|7}|d7}|ddfdd|jrd|jn|jD7}||7}|S) Nrrrz PRIMARY KEY rrjc3s|]}j|jVqdSrrrrrrrSrWr~sz;DDLCompiler.visit_primary_key_constraint..) r6rrrr3Z_implicit_generatedZcolumns_autoinc_firstrrrrSrrWvisit_primary_key_constraintus     z(DDLCompiler.visit_primary_key_constraintc s|jd}|jdk r4|j|}|dk r4|d|7}t|jdjj}|ddfdd|jD|||dfdd|jDf7}|| |7}|| |7}|| |7}|S) Nrrrz"FOREIGN KEY(%s) REFERENCES %s (%s)rjc3s|]}|jjVqdSr)rparentrrrrSrWrsz;DDLCompiler.visit_foreign_key_constraint..c3s|]}|jjVqdSr)rrrrrrSrWrs) rrrrrrrJr3define_constraint_remote_tabledefine_constraint_matchdefine_constraint_cascadesr)rrrrrZ remote_tablerSrrWvisit_foreign_key_constraints0    z(DDLCompiler.visit_foreign_key_constraintcCs ||S)z=Format the remote table clause of a CREATE CONSTRAINT clause.)r)rrrJrrSrSrWrsz*DDLCompiler.define_constraint_remote_tablec spt|dkrdSd}|jdk r>j|}|dk r>|d|7}|ddfdd|D7}||7}|S)Nrrrz UNIQUE (%s)rjc3s|]}j|jVqdSrrrrrSrWrsz6DDLCompiler.visit_unique_constraint..)r6rrrr3rrrSrrWvisit_unique_constraints    z#DDLCompiler.visit_unique_constraintcCsLd}|jdk r&|d|j|jt7}|jdk rH|d|j|jt7}|S)Nrz ON DELETE %sz ON UPDATE %s)Zondeletervalidate_sql_phrase FK_ON_DELETEZonupdate FK_ON_UPDATErrrrSrSrWrs    z&DDLCompiler.define_constraint_cascadescCsLd}|jdk r&|jr|d7}n|d7}|jdk rH|d|j|jt7}|S)Nrz DEFERRABLEz NOT DEFERRABLEz INITIALLY %s)r$r0rr FK_INITIALLYrrSrSrWrs    z+DDLCompiler.define_constraint_deferrabilitycCs d}|jdk r|d|j7}|S)Nrz MATCH %s)matchrrSrSrWrs z#DDLCompiler.define_constraint_matchcKsBd|jj|jddd}|jdkr,|d7}n|jdkr>|d7}|S)NzGENERATED ALWAYS AS (%s)FTrz STOREDz VIRTUAL)rrrZ persisted)r generatedrrrSrSrWvisit_computed_columns   z!DDLCompiler.visit_computed_columncKs2d|jr dndf}||}|r.|d|7}|S)NzGENERATED %s AS IDENTITYZALWAYSz BY DEFAULTr)alwaysr)rrrrrrSrSrWvisit_identity_columns   z!DDLCompiler.visit_identity_column)NN)F)N)FT)F)N)-rrrrr>rrrr\r^rbrrrwrnr|rrrrrrrrrrrrrrrurjrorrrrrrrrrrrrrrSrSrSrWrVsZ   7  )          rVc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUS)VGenericTypeCompilercKsdS)NFLOATrSrrSrSrW visit_FLOATszGenericTypeCompiler.visit_FLOATcKsdS)NZREALrSrrSrSrW visit_REALszGenericTypeCompiler.visit_REALcKs<|jdkrdS|jdkr&dd|jiSd|j|jdSdS)NZNUMERICzNUMERIC(%(precision)s) precisionz!NUMERIC(%(precision)s, %(scale)s)rZscalerrrSrSrW visit_NUMERICs  z!GenericTypeCompiler.visit_NUMERICcKs<|jdkrdS|jdkr&dd|jiSd|j|jdSdS)NZDECIMALzDECIMAL(%(precision)s)rz!DECIMAL(%(precision)s, %(scale)s)rrrrSrSrW visit_DECIMALs  z!GenericTypeCompiler.visit_DECIMALcKsdS)NZINTEGERrSrrSrSrW visit_INTEGERsz!GenericTypeCompiler.visit_INTEGERcKsdS)NZSMALLINTrSrrSrSrWvisit_SMALLINTsz"GenericTypeCompiler.visit_SMALLINTcKsdS)NZBIGINTrSrrSrSrW visit_BIGINT sz GenericTypeCompiler.visit_BIGINTcKsdS)N TIMESTAMPrSrrSrSrWvisit_TIMESTAMP sz#GenericTypeCompiler.visit_TIMESTAMPcKsdS)NZDATETIMErSrrSrSrWvisit_DATETIMEsz"GenericTypeCompiler.visit_DATETIMEcKsdS)NZDATErSrrSrSrW visit_DATEszGenericTypeCompiler.visit_DATEcKsdS)NZTIMErSrrSrSrW visit_TIMEszGenericTypeCompiler.visit_TIMEcKsdS)NZCLOBrSrrSrSrW visit_CLOBszGenericTypeCompiler.visit_CLOBcKsdS)NZNCLOBrSrrSrSrW visit_NCLOBszGenericTypeCompiler.visit_NCLOBcCs0|}|jr|d|j7}|jr,|d|j7}|S)N(%d)z COLLATE "%s")lengthr)rrrrrSrSrW_render_string_types z'GenericTypeCompiler._render_string_typecKs ||dS)NCHARrrrSrSrW visit_CHAR(szGenericTypeCompiler.visit_CHARcKs ||dS)NZNCHARrrrSrSrW visit_NCHAR+szGenericTypeCompiler.visit_NCHARcKs ||dS)NZVARCHARrrrSrSrW visit_VARCHAR.sz!GenericTypeCompiler.visit_VARCHARcKs ||dS)NZNVARCHARrrrSrSrWvisit_NVARCHAR1sz"GenericTypeCompiler.visit_NVARCHARcKs ||dS)NZTEXTrrrSrSrW visit_TEXT4szGenericTypeCompiler.visit_TEXTcKsdS)NZBLOBrSrrSrSrW visit_BLOB7szGenericTypeCompiler.visit_BLOBcKsd|jrd|jpdS)NBINARYrrrrrSrSrW visit_BINARY:sz GenericTypeCompiler.visit_BINARYcKsd|jrd|jpdS)NZ VARBINARYrrrrrSrSrWvisit_VARBINARY=sz#GenericTypeCompiler.visit_VARBINARYcKsdS)NBOOLEANrSrrSrSrW visit_BOOLEAN@sz!GenericTypeCompiler.visit_BOOLEANcKs|j|f|Sr)rrrSrSrWvisit_large_binaryCsz&GenericTypeCompiler.visit_large_binarycKs|j|f|Sr)rrrSrSrW visit_booleanFsz!GenericTypeCompiler.visit_booleancKs|j|f|Sr)rrrSrSrW visit_timeIszGenericTypeCompiler.visit_timecKs|j|f|Sr)rrrSrSrWvisit_datetimeLsz"GenericTypeCompiler.visit_datetimecKs|j|f|Sr)rrrSrSrW visit_dateOszGenericTypeCompiler.visit_datecKs|j|f|Sr)rrrSrSrWvisit_big_integerRsz%GenericTypeCompiler.visit_big_integercKs|j|f|Sr)rrrSrSrWvisit_small_integerUsz'GenericTypeCompiler.visit_small_integercKs|j|f|Sr)rrrSrSrW visit_integerXsz!GenericTypeCompiler.visit_integercKs|j|f|Sr)rrrSrSrW visit_real[szGenericTypeCompiler.visit_realcKs|j|f|Sr)rrrSrSrW visit_float^szGenericTypeCompiler.visit_floatcKs|j|f|Sr)rrrSrSrW visit_numericasz!GenericTypeCompiler.visit_numericcKs|j|f|SrrrrSrSrW visit_stringdsz GenericTypeCompiler.visit_stringcKs|j|f|SrrrrSrSrW visit_unicodegsz!GenericTypeCompiler.visit_unicodecKs|j|f|SrrrrSrSrW visit_textjszGenericTypeCompiler.visit_textcKs|j|f|SrrrrSrSrWvisit_unicode_textmsz&GenericTypeCompiler.visit_unicode_textcKs|j|f|SrrrrSrSrW visit_enumpszGenericTypeCompiler.visit_enumcKstd|dS)NzKCan't generate DDL for %r; did you forget to specify a type on this Column?rrrSrSrWrss zGenericTypeCompiler.visit_nullcKs|j||jf|Sr)rZ type_enginerrrSrSrWvisit_type_decoratorzsz(GenericTypeCompiler.visit_type_decoratorcKs |jf|Sr) get_col_specrrSrSrWvisit_user_defined}sz&GenericTypeCompiler.visit_user_definedN)-rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrSrSrSrWrsT   rc@s4eZdZddZddZddZddZd d Zd S) StrSQLTypeCompilercKs>z |j}Wn"tk r,|j|f|YSX||f|SdSr)rAttributeError_visit_unknown)rrrrrSrSrWrs  zStrSQLTypeCompiler.processcCs|dr|jSt|dS)NZvisit_) startswithrr)rrrSrSrW __getattr__s zStrSQLTypeCompiler.__getattr__cKs(|jj|jjkr|jjSt|SdSr)rrupperreprrrSrSrWrsz!StrSQLTypeCompiler._visit_unknowncKsdSrrSrrSrSrWrszStrSQLTypeCompiler.visit_nullcKs6z |j}Wntk r&t|YSX|f|SdSr)rrr)rrrrrSrSrWrs  z%StrSQLTypeCompiler.visit_user_definedN)rrrrrrrrrSrSrSrWrs rc@s2eZdZdZeZeZeZ e dZ d@ddZ d d Zd d Zd dZddZddZddZddZddZdAddZdBddZddZdCdd ZdDd!d"ZdEd#d$ZdFd%d&Zed'dGd(d)ZdHd*d+Z dId,d-Z!d.d/Z"d0d1Z#dJd2d3Z$d4d5Z%dKd6d7Z&dLd8d9Z'dMd:d;Z(ej)dd?Z+dS)NIdentifierPreparerz@Handle quoting and case-folding of identifiers based on options.r "NTFcCsN||_||_|p|j|_||_|jd|_||_||_i|_|jjdk|_ dS)asConstruct a new ``IdentifierPreparer`` object. initial_quote Character that begins a delimited identifier. final_quote Character that ends a delimited identifier. Defaults to `initial_quote`. omit_schema Prevent prepending schema name. Useful for databases that do not support schemae. r)r]r\N) r initial_quote final_quote escape_quoteescape_to_quote omit_schemaquote_case_sensitive_collations_stringsrr)rrrrrrrrSrSrWrs  zIdentifierPreparer.__init__cs2|j|j}|j|jfdd}||_|S)NcsX|j}|krN|jrN|dk r:d|ks,d|kr:td|td|pDdddS|jSdS)N[]zJSquare bracket characters ([]) not supported in schema translate name '%s'z [SCHEMA_%s]_noneFr)r Z_use_schema_maprr>r)rrrWrSrW symbol_getters z@IdentifierPreparer._with_schema_translate..symbol_getter)r__new____dict__rr)rrprepr rSrWrWrs  z)IdentifierPreparer._with_schema_translatecs4|dkrdd<fdd}td||S)Nr cs6|d}|}|s,jj}|s,td|S)NrzLDialect has no default schema name; can't use None as dynamic schema target.)r.rZdefault_schema_namerr>r)r$rrdrrSrWrs z=IdentifierPreparer._render_schema_translates..replacez(\[SCHEMA_([^\]]+)\]))r*r+)rrrrrSrrWrs   z,IdentifierPreparer._render_schema_translatescCs&||j|j}|jr"|dd}|S)zEscape an identifier. Subclasses should override this to provide database-dependent escaping behavior. rdr)rrrrrr-rSrSrW_escape_identifiers z%IdentifierPreparer._escape_identifiercCs||j|jS)zCanonicalize an escaped identifier. Subclasses should override this to provide database-dependent unescaping behavior that reverses _escape_identifier. )rrrrrSrSrW_unescape_identifiersz'IdentifierPreparer._unescape_identifiercCs*|dk r&||s&td||jf|S)zkeyword sequence filter. a filter for elements that are intended to represent keyword sequences, such as "INITIALLY", "INITIALLY DEFERRED", etc. no special characters should be present. .. versionadded:: 1.3 Nz/Unexpected SQL phrase: %r (matching against %r))rrr>pattern)rrregrSrSrWrs z&IdentifierPreparer.validate_sql_phrasecCs|j|||jS)z~Quote an identifier. Subclasses should override this to provide database-dependent quoting behavior. )rrrrrSrSrWquote_identifier+s z#IdentifierPreparer.quote_identifiercCs<|}||jkp:|d|jkp:|jt| p:||kS)z5Return True if the given identifier requires quoting.r)rreserved_wordsillegal_initial_characterslegal_charactersrr text_type)rr-Zlc_valuerSrSrWr8s  z#IdentifierPreparer._requires_quotescCs|jt| S)zjReturn True if the given identifier requires quoting, but not taking case convention into account.)rrrrrrSrSrWrBsz1IdentifierPreparer._requires_quotes_illegal_charscCs |dk rtjddd||S)aConditionally quote a schema name. The name is quoted if it is a reserved word, contains quote-necessary characters, or is an instance of :class:`.quoted_name` which includes ``quote`` set to ``True``. Subclasses can override this to provide database-dependent quoting behavior for schema names. :param schema: string schema name :param force: unused .. deprecated:: 0.9 The :paramref:`.IdentifierPreparer.quote_schema.force` parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the :meth:`.IdentifierPreparer.quote` method; please refer to :class:`.quoted_name`. NzThe IdentifierPreparer.quote_schema.force parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().0.9r)rr r)rr forcerSrSrWrGs  zIdentifierPreparer.quote_schemacCs|dk rtjdddt|dd}|dkrp||jkr>|j|S||rZ|||j|<n ||j|<|j|Sn|r~||S|SdS)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().rrr)rr rrrr)rrrrSrSrWrns        zIdentifierPreparer.quotecCs|jr||S|SdSr)rr)rZcollation_namerSrSrWrs z#IdentifierPreparer.format_collationcCs>||j}||}|js:|r:|dk r:||d|}|Sr)rrrrr)rrrrrrSrSrWrNs  z"IdentifierPreparer.format_sequencecCs||p |jSrrr)rrrrSrSrWrszIdentifierPreparer.format_labelcCs||p |jSrr)rrrrSrSrWrszIdentifierPreparer.format_aliascCs"|p|j}||r||}|Sr)rrr)rZ savepointrrrSrSrWr7s   z#IdentifierPreparer.format_savepointzsqlalchemy.sql.namingcCs`tjj}|jtjkr0|||j}|dkr6dSn|j}|jdkrN|j ||dS|j ||dSdS)Nr)_alembic_quote) rrmZ sql_namingrrZ _NONE_NAMEZ_constraint_name_for_tablerJrtruncate_and_render_index_name#truncate_and_render_constraint_name)rrrZnamingrrSrSrWrs$  z$IdentifierPreparer.format_constraintcCs|jjp|jj}||||Sr)rZmax_index_name_lengthr _truncate_and_render_maxlen_namerrrmax_rSrSrWr sz1IdentifierPreparer.truncate_and_render_index_namecCs|jjp|jj}||||Sr)rZmax_constraint_name_lengthrr"r#rSrSrWr!sz6IdentifierPreparer.truncate_and_render_constraint_namecCsbt|tjr@t||krL|d|ddt|dd}n |j||sT|S||SdS)Nrr1) rrrr6rZmd5_hexrZvalidate_identifierr)rrr$rrSrSrWr"s  ( z3IdentifierPreparer._truncate_and_render_maxlen_namecCs ||Sr)rrrSrSrWrszIdentifierPreparer.format_indexcCsF|dkr|j}||}||}|jsB|rB|rB||d|}|S)z'Prepare a quoted table and schema name.Nr)rrrrr)rrJrrrrrSrSrWrs  zIdentifierPreparer.format_tablecCs ||S)zPrepare a quoted schema name.r rrSrSrWr]sz IdentifierPreparer.format_schemacCs(|dk rt|tjr||}||S)Prepare a quoted column name.N)rrrrr)rrrrSrSrWrs   z$IdentifierPreparer.format_label_namecCs|dkr|j}|dk r,t|tjr,||}t|ddsh|r\|j|j||dd||S||Sn"|r|j|j||dd|S|SdS)r'NrF)rrr) rrrrrrrrJr)rrrrZ table_namerrrSrSrWr#s@     z IdentifierPreparer.format_columncCsD||}|js0|r0|r0|||j|ddfS|j|ddfSdS)z(Format table name and schema as a tuple.FrN)rrrr)rrJrrrSrSrWrZPs   z#IdentifierPreparer.format_table_seqcCs@dd|j|j||jfD\}}}td|||d}|S)NcSsg|]}t|qSrS)r*rtrrSrSrWrNcsz5IdentifierPreparer._r_identifiers..zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)initialfinalescaped)rrrr*compile)rr(r)Z escaped_finalrrSrSrW_r_identifiersas   z!IdentifierPreparer._r_identifierscs(j}fdddd||DDS)z:Unpack 'schema.table.column'-like strings into components.csg|]}|qSrS)r)rUrXrrSrWrNwsz;IdentifierPreparer.unformat_identifiers..cSsg|]\}}|p|qSrSrS)rUarrSrSrWrNys)r-findall)rZ identifiersr,rSrrWunformat_identifiersss z'IdentifierPreparer.unformat_identifiers)rNrTF)N)N)T)N)N)N)T)T)T)TN)N)FNNFN)T),rrrrRESERVED_WORDSrLEGAL_CHARACTERSrILLEGAL_INITIAL_CHARACTERSrrp attrgetterrrrrrrrrrrrrrrNrrr7rrArr r!r"rrr]rrrZr>r-r0rSrSrSrWrs\  $     ' 4         -  r)~rrr?r(rpr*rrrrrrrr r r r r rrrrHr1r+Ir2ZLEGAL_CHARACTERS_PLUS_SPACErangerMr3rrrUNICODErrrrrror_rmulr+divmodtruedivnegltlenegtgeeqZis_distinct_fromZis_not_distinct_fromZ concat_oprAZ not_match_oprIrHr rrrrrexistsZ distinct_opinvZany_opZall_opZdesc_opZasc_opZnulls_first_opZ nulls_last_oprrmrr r!r"r7r8rnrorGrOZcubeZrollupZ grouping_setsrr<rrZ UNION_ALLrZ EXCEPT_ALLrZ INTERSECT_ALLr=ZRM_RENDERED_NAMEZRM_NAMEZ RM_OBJECTSZRM_TYPE namedtuplersymbolrrrrrobjectrwith_metaclassZEnsureKWArgTyperZ ColumnElementrrrBrVrrrrSrSrSrWs              c ,  ?sc!