
    [h?G                   |   U d Z ddlmZ ddlZddlmZ ddlZddlm	Z	 ddl
Z
ddlZddlZddlZddlmZ ddlZddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddl&m'Z' ddl&m(Z( ddl&m)Z) ddl&m*Z* dd l&m+Z+ dd!l&m,Z, dd"l&m-Z- dd#l&m.Z. dd$l&m/Z/ dd%l&m0Z0 dd&l&m1Z2 dd'l3m4Z4 dd(l3m5Z5 dd)l'm6Z6 dd*l'm7Z7 dd+l'm8Z8 dd,l'm9Z9 dd-l'm:Z: dd.l*m;Z; dd/l0m<Z< dd0l=m>Z> d1d2l&m?Z? d1d&l&m1Z1 d1d3l1m@Z@ d1d4lAmBZB d1d5lAmCZC d1d6lAmDZD d1d7lAmEZE ej$        r>dd8lFmGZG dd9l'mHZH dd:l'mIZI dd;l'mJZJ dd<lKmLZL dd=lMmNZN dd>lOmPZP dd?lOmQZQ dd@lOmRZR ddAlOmSZS ddBlOmTZT ddCl*mUZU ddDl*mVZV ddEl*mWZW ddFl*mXZX ddGl*mYZY ddHl*mZZZ ddIl*m[Z[ ddJl*m\Z\ ddKl*m]Z] ddLl*m^Z^ ddMl+m_Z_ ddNl.m`Z` ddOl.maZa ddPl.mbZb ddQl.mcZc ddRl.mdZd ddSl.meZe ddTl.mfZf ddUl/mgZg ddVl/mhZh ddWl/miZi ddXl/mjZj ddYl/mkZk ddZl/mlZl dd[l/mmZm dd\l/mnZn dd]l/moZo dd^lpmqZq dd_lpmrZr dd`lpmsZs ddalpmtZt ddbl=muZu d1dclvmwZw d1ddlxmyZy d1delxmzZz d1dflxm{Z{ d1dglxm|Z| d1dhlxm}Z} d1dilxm~Z~ d1djlxmZ d1dklxmZ d1dllxmZ edmef         Zh dnZ ej        doej                  Z ej        dpej                  Zdq  eddr          D                                 dsg          Z ej        dtej                  Z ej        dtej                  Z ej        duej                  Z ej        dvej                  Z ej        dwej                  ZdxZedydzd{d|d}d~Zi e,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        di e,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        de,j        diZe+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        de+j        diZded<   ddddddddddddddddǜZe/j        j        de/j        j        de/j        j        de/j        j        de/j        j        de/j        j        diZ G d΄ de          Z G dЄ deC          ZdZded<   dZded<   d1Zded<   dZded<    G dۄ deE          Z G d݄ ded߬          Z G d de          Z G d de          Z G d de          Z G d de@          Z G d de	          Z G d de	          Z ee          \  ZZZZ G d d ej        dddg                    Z G d d          Z G d de1j                  Z G d de-j        e         e*j                  Z G d de-j        e         e*j                  Z G d de          Z G d de          Z G d de          Z G d d e          Z G d de          Z G d deC          Z G d deC          Z G d d          ZdS (	  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)NO_ARG)quoted_name)	TupleType)prefix_anon_map   )exc)FastIntFlag)Literal)Protocol)Self)	TypedDict)_AnnotationDict)_AmbiguousTableNameMap)CompileState)
Executable)CacheKey)ExecutableDDLElement)Insert)Update)
UpdateBase)UpdateDMLState)
ValuesBase)_truncated_label)BinaryExpression)BindParameter)ClauseElement)ColumnClause)ColumnElement)False_)Label)Null)True_)Function)Column)
Constraint)ForeignKeyConstraint)Index)PrimaryKeyConstraint)Table)UniqueConstraint)_ColumnsClauseElement)AliasedReturnsRows)CompoundSelectState)CTE)
FromClause)NamedFromClause)ReturnsRows)Select)SelectState)_BindProcessorType)TypeDecorator)
TypeEngine)UserDefinedType)	Visitable)CursorResultMetaData)_CoreSingleExecuteParams)_DBAPIAnyExecuteParams)_DBAPIMultiExecuteParams)_DBAPISingleExecuteParams)_ExecuteOptions)_GenericSetInputSizesType)_MutableCoreSingleExecuteParams)Dialect)SchemaTranslateMapTyperZ   >^   asdoinisonortoallandanyascendfornewnotoffoldsetbothcaser   descelsefromfullintojoinleftlikenullonlysomethentrueuserwhenarraycheckcrossfalsegrantgroupilikeinnerlimitorderouterrighttableunionusingwherebinarycolumncreateexceptfreezehavingisnulloffsetselectuniqueanalyseanalyzebetweencollatedefaultforeignleadingnaturalnotnullplacingprimarysimilarverbosedistinctoverlapstrailing	initially	intersect	localtime	symmetric
asymmetric
constraint
deferrable
referencescurrent_datecurrent_rolecurrent_timecurrent_usersession_userauthorizationlocaltimestampcurrent_timestampz^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$c                ,    h | ]}t          |          S  )str).0xs     f/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/sql/compiler.py	<setcomp>r      s    ;;;c!ff;;;    
   $z5^(?:RESTRICT|CASCADE|SET NULL|NO ACTION|SET DEFAULT)$z^(?:DEFERRED|IMMEDIATE)$z%(?<![:\w\$\x5c]):([\w\$]+)(?![:\w\$])z\x5c(:[\w\$]*)(?![:\w\$])z%%(%(name)s)s?z%%sz:[_POSITION]z$[_POSITION]z	:%(name)s)pyformatqmarkformatnumericnumeric_dollarnamed AND z OR z + z * z -  % -z < z <= z != 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 zEXISTS 	DISTINCT zNOT zANY zALL z DESCz ASCz NULLS FIRSTz NULLS LASTz ^ z | z & ~z << z >> coalesceCURRENT_DATECURRENT_TIMECURRENT_TIMESTAMPCURRENT_USER	LOCALTIMELOCALTIMESTAMPrandomsysdateSESSION_USERUSERCUBEROLLUPzGROUPING SETSzDict[Type[Function[Any]], str]	FUNCTIONSmonthdayyearsecondhourdoyminutequarterdowweekepochmillisecondsmicrosecondstimezone_hourtimezone_minute)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  UNIONz	UNION ALLEXCEPTz
EXCEPT ALL	INTERSECTzINTERSECT ALLc                  B    e Zd ZU dZded<   	 ded<   	 ded<   	 ded<   d	S )
ResultColumnsEntrya  Tracks 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.

    r   keynamenameTuple[Any, ...]objectsTypeEngine[Any]typeN__name__
__module____qualname____doc____annotations__r   r   r   r  r  k  sY           LLL;III%  r   r  c                      e Zd Zdd
ZdS )_ResultMapAppenderr  r   r  r
  Sequence[Any]type_r  returnNonec                    d S Nr   selfr  r  r
  r  s        r   __call__z_ResultMapAppender.__call__  s	     sr   N)
r  r   r  r   r
  r  r  r  r  r  r  r  r  r  r   r   r   r  r    s(             r   r  z
Literal[0]RM_RENDERED_NAMEz
Literal[1]RM_NAMEz
Literal[2]
RM_OBJECTS   z
Literal[3]RM_TYPEc                  .    e Zd ZU ded<   ded<   ded<   dS )_BaseCompilerStackEntryzSet[FromClause]asfrom_fromscorrelate_fromsr\   r$   Nr  r  r  r  r   r   r   r%  r%    s6         !!!!$$$$r   r%  c                  B    e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
S )_CompilerStackEntryr;   compile_stateboolneed_result_map_for_nestedneed_result_map_for_compoundr\   select_0Select[Any]insert_from_selectNr(  r   r   r   r*  r*    sN         $$$$&&&&######r   r*  F)totalc                      e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
ed<   	 edd            Zedd            ZdS )ExpandedStatea  represents 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   	statementre   
parameters%Mapping[str, _BindProcessorType[Any]]
processorsOptional[Sequence[str]]positiontupzMapping[str, List[str]]parameter_expansionr  r	  c                z      j         t          j        d          t           fd j         D                       S )zrTuple of positional parameters, for statements that were compiled
        using a positional paramstyle.

        Nz.statement does not use a positional paramstylec              3  2   K   | ]}j         |         V  d S r  r6  )r   keyr  s     r   	<genexpr>z6ExpandedState.positional_parameters.<locals>.<genexpr>  s*      FFcT_S)FFFFFFr   )r:  r3   InvalidRequestErrortupler  s   `r   positional_parametersz#ExpandedState.positional_parameters  sN     #)@   FFFFT5EFFFFFFr   c                    | j         S )z.synonym for :attr:`.ExpandedState.parameters`.r>  rC  s    r   additional_parametersz#ExpandedState.additional_parameters  s     r   N)r  r	  )r  re   )r  r  r  r  r  propertyrD  rF  r   r   r   r4  r4    s          " NNN=(((( 6555+(((( 1000 	G 	G 	G X	G    X  r   r4  c                      e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
Zded<   	 d
Zded<   	 dZded<   	 dZded<   	 dZ	ded<   	 d
Z
ded<   	 d
Zded<   dS )_InsertManyValuesa  represents 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

    r,  is_default_exprr   single_values_exprList[crud._CrudParamElementStr]insert_crud_paramsintnum_positional_params_countedFsort_by_parameter_orderincludes_upsert_behaviorsNOptional[Sequence[Column[Any]]]sentinel_columnsr   num_sentinel_columnsr9  sentinel_param_keysimplicit_sentinelembed_values_counter)r  r  r  r  r  rP  rQ  rS  rT  rU  rV  rW  r   r   r   rI  rI    s          
  8777M&&&&
 %*)))) ',++++ 9=<<<< !"!!!! 487777  $####	 "'&&&&	 	r   rI  c                  x    e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<   ded<   ded<   ded<   ded<   ded<   dS )_InsertManyValuesBatchas  represents 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

    r   replaced_statementrf   replaced_parameters#Optional[_GenericSetInputSizesType]processed_setinputsizesz#Sequence[_DBAPISingleExecuteParams]batchzSequence[Tuple[Any, ...]]sentinel_valuesrN  current_batch_sizebatchnumtotal_batchesr,  rows_sortedis_downgradedNr  r   r   r   rY  rY  ^  s         
 
 ////@@@@........MMMr   rY  c                  D    e Zd ZdZdZdZdZdZeez  ez  Zeez  Z	dZ
dZdS )	InsertmanyvaluesSentinelOptszcbitflag enum indicating styles of PK defaults
    which can work as implicit sentinel columns

    r   r2            @   N)r  r  r  r  NOT_SUPPORTEDAUTOINCREMENTIDENTITYSEQUENCEANY_AUTOINCREMENT_SUPPORTED_OR_NOTUSE_INSERT_FROM_SELECTRENDER_SELECT_COL_CASTSr   r   r   rf  rf  w  sX         
 MMHH%08;%(99 r   rf  c                      e Zd ZdZ	 dZ	 dZdS )CompilerStater   r   r2   N)r  r  r  	COMPILINGSTRING_APPLIEDNO_STATEMENTr   r   r   rt  rt    s-        I=N L r   rt  c                  .    e Zd ZdZdZ	 dZ	 dZ	 eez  ZdS )Lintingzrepresent preferences for the 'SQL linting' feature.

    this feature currently includes support for flagging cartesian products
    in SQL statements.

    r   r   r2   N)r  r  r  r  
NO_LINTINGCOLLECT_CARTESIAN_PRODUCTSWARN_LINTINGFROM_LINTINGr   r   r   ry  ry    sG          J!" L2-<L r   ry  c                  "    e Zd ZdZddZddZdS )
FromLinterzKrepresents current state for the "cartesian product" detection
    feature.Nc                   | j         }|sdS t          | j                  }t          |          }||}|                    |           n|                                }t          j        |g          }|rs|rq|                                |                               fd|D             }|	                    fd|D                        |
                    |           |r|q|r||fS dS )NNNc                    h | ]}|v |	S r   r   r   edgenodes     r   r   z"FromLinter.lint.<locals>.<setcomp>  s    @@@$44<<<<<r   c              3  P   K   | ] }||                                         V  !d S r  )indexr  s     r   r@  z"FromLinter.lint.<locals>.<genexpr>  s7      NNDTdjj&6&6"67NNNNNNr   )fromsr   edgesremovepopcollectionsdequepopleftdiscard
extendleftdifference_update)	r  startr  r  the_rest
start_withstack	to_remover  s	           @r   lintzFromLinter.lint  s$   
 	:DJu::JOOJ''''!J!:,// 	/ 	/==??DT""" A@@@%@@@I NNNNINNNNNN##I...  	/ 	/   	Z'':r   SELECTc                                                       \  }}|r`|}|r^d}d                     fd|D                       }|                    || j        |                   }t	          j        |           d S d S d S )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.r   c              3  :   K   | ]}d j         |          d V  dS )"N)r  )r   from_r  s     r   r@  z"FromLinter.warn.<locals>.<genexpr>  sG       & &16,
5),,,& & & & & &r   )	stmt_typer  r  )r  r   r   r  r&   warn)r  r  r  r  r  template	froms_strmessages   `       r   r  zFromLinter.warn  s    #yy{{*  	#E #7  !II & & & &:?& & &  	 #//'#*Z0 *   	'"""""%	# 	## #r   r  )r  )r  r  r  r  r  r  r   r   r   r  r    sG         # # # #J# # # # # #r   r  r  r  c                      e Zd ZU dZdZded<   	 dZded<   	 ded	<   	 d
Zd
ZdZ	ded<   dZ
ded<   dZded<   ej        Zded<   	 ded<   ej        Zded<   dZded<   	 dZded<   	 dZded<   	 ded<   	 dd
 ej                    fd<d$Zd= fd'Zed(             Zd) Zd* Zed>d,            Zd?d1Zd@d2Z	 	 	 dAdBd:Zed;             Z xZ S )CCompileda  Represent 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.
    NOptional[ClauseElement]r5   r   stringrt  stateFzOptional[CursorResultMetaData]_cached_metadataz"Optional[List[ResultColumnsEntry]]_result_columns Optional[SchemaTranslateMapType]schema_translate_mapri   execution_optionsIdentifierPreparerpreparerr9   _annotationszOptional[CompileState]r+  dml_compile_stateOptional[CacheKey]	cache_keyfloat	_gen_timedialectrl   render_schema_translater,  compile_kwargsMapping[str, Any]c                >   || _         | j         j        | _        |r&|| _        | j                            |          | _        |t
          j        | _        || _        |j	        | _
        |j        | _        | j
        r*t          rt          |t                    sJ |j        | _         | j        | j        fi || _        |r)|J | j                            | j        |          | _        t
          j        | _        nt
          j        | _        t-                      | _        dS )a  Construct 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)r  identifier_preparerr  r  _with_schema_translatert  ru  r  r5  supports_executioncan_executer  r   
isinstancer<   _execution_optionsr  processr  _render_schema_translatesrv  rw  r   r  r  r  r5  r  r  r  s         r   __init__zCompiled.__init__K  s    4 8 	(<D% M@@$ DM  &0DJ&DN(;D ) 6D F  =%i<<<<<)2)E&&$,t~HHHHDK& +777"mEEK!5  '5DJJ&3DJ%r   r  r  c                l    |                                   t                                                      S r  )_init_compiler_clssuper__init_subclass__)cls	__class__s    r   r  zCompiled.__init_subclass__  s+       ww((***r   c                    d S r  r   r  s    r   r  zCompiled._init_compiler_cls  s    r   c                p    | j         r|                    | ||          S t          j        | j                  r  )r  _execute_compiledr3   ObjectNotExecutableErrorr5  )r  
connectiondistilled_paramsr  s       r   _execute_on_connectionzCompiled._execute_on_connection  sE      	?//&(9   .t~>>>r   c                H    t          j        | t          |                    |r  r3   UnsupportedCompilationErrorr  r  elementerrkws       r   visit_unsupported_compilationz&Compiled.visit_unsupported_compilation  s    -dDMMBBKr   SQLCompilerc                    t                      )zReturn a Compiled that is capable of processing SQL expressions.

        If this compiler is one, it would likely just return 'self'.

        NotImplementedErrorrC  s    r   sql_compilerzCompiled.sql_compiler  s     "###r   objrc   kwargsr   c                     |j         | fi |S r  _compiler_dispatch)r  r  r  s      r   r  zCompiled.process  s    %s%d55f555r   c                :    | j         t          j        u r| j        S dS )z3Return the string text of the generated SQL or DDL.r  )r  rt  rv  r  rC  s    r   __str__zCompiled.__str__  s!     :555;2r   Tparams"Optional[_CoreSingleExecuteParams]extracted_parameters&Optional[Sequence[BindParameter[Any]]]escape_names)Optional[_MutableCoreSingleExecuteParams]c                    t                      )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.
        r  r  r  r  r  s       r   construct_paramszCompiled.construct_params  s     "###r   c                *    |                                  S )z0Return the bind params for this compiled object.r  rC  s    r   r  zCompiled.params  s     $$&&&r   )
r  rl   r5  r  r  r  r  r,  r  r  )r  r  r  r  )r  rc   r  r   r  r   r  r   NNTr  r  r  r  r  r,  r  r  )!r  r  r  r  r5  r  r  is_sqlis_ddlr  r  r  r&   
EMPTY_DICTr  r  r+  r  r  immutabledictr  r  classmethodr  r  r  rG  r  r  r  r  r  __classcell__r  s   @r   r  r    sJ        
 
 *.I----F4-FF7;;;;;:>O>>>>=AAAAA)-8888
 !   $(OL3333,0M0000 154444	 %)I((((	  BF(-,>D,>,@,@7( 7( 7( 7( 7(r+ + + + + +   [? ? ?L L L $ $ $ X$6 6 6 6    6:GK!	$ $ $ $ $ ' ' X' ' ' ' 'r   r  c                  .    e Zd ZdZdZddZddZddZdS )TypeCompilerz2Produces DDL specification for TypeEngine objects.z	visit_\w+r  rl   c                    || _         d S r  )r  )r  r  s     r   r  zTypeCompiler.__init__  s    r   r  r  r  r   r  r   c                    |j         r*| j        j        |j         v r|j         | j        j                 } |j        | fi |S r  )_variant_mappingr  r  r  r  r  r  s      r   r  zTypeCompiler.process  sM    "	>!U%;;;*4<+<=E'u'33333r   r  r  	Exceptionr   c                .    t          j        | |          |r  )r3   r  r  s       r   r  z*TypeCompiler.visit_unsupported_compilation  s     -dG<<#Er   N)r  rl   )r  r  r  r   r  r   )r  r   r  r  r  r   r  r   )r  r  r  r  ensure_kwargr  r  r  r   r   r   r  r    sa        <<L   4 4 4 4F F F F F Fr   r  c                  T    e Zd ZdZdZdZd
dZed             Zed             Z	d Z
d	S )_CompileLabelz;lightweight label object which acts as an expression.Label.labelr  r  
_alt_namesr   c                8    || _         || _        |f|z   | _        d S r  r  )r  colr  	alt_namess       r   r  z_CompileLabel.__init__  s"    	&9,r   c                    | j         j        S r  r  	proxy_setrC  s    r   r  z_CompileLabel.proxy_set      |%%r   c                    | j         j        S r  r  r  rC  s    r   r  z_CompileLabel.type      |  r   c                    | S r  r   r  r  s     r   
self_groupz_CompileLabel.self_group      r   N)r   )r  r  r  r  __visit_name__	__slots__r  rG  r  r  r  r   r   r   r  r    s         FEN/I- - - -
 & & X& ! ! X!    r   r  c                  X    e Zd ZdZdZdZd Zed             Zed             Z	d Z
d Zd	S )
ilike_case_insensitivea  produce 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_operandr  
comparatorc                ,    || _         |j        | _        d S r  r  )r  r  s     r   r  zilike_case_insensitive.__init__  s    !,r   c                    | j         j        S r  r  rC  s    r   r  z ilike_case_insensitive.proxy_set	  r  r   c                    | j         j        S r  r  rC  s    r   r  zilike_case_insensitive.type  r  r   c                    | S r  r   r  s     r   r  z!ilike_case_insensitive.self_group  r  r   c                P    t          | j                            |                    S r  )r  r  _with_binary_element_type)r  r  s     r   r$  z0ilike_case_insensitive._with_binary_element_type  s'    %L22599
 
 	
r   N)r  r  r  r  r  r  r  rG  r  r  r  r$  r   r   r   r  r    s        	 	 6N'I- - - & & X& ! ! X!  
 
 
 
 
r   r  c                  ,   e Zd ZU dZeZ ej        ddddddddd          Zde	d	<   	 d
e	d<   de	d<   dZ
eZdZde	d<   dZde	d<   dZde	d<   	 de	d<   	 dZde	d<   	 dZde	d<   	 dZde	d<   	 dZde	d<   de	d<   	 de	d <   	 d!e	d"<   	 dZde	d#<   	 dZde	d$<   	 dZde	d%<   	 d&e	d'<   	 d&e	d(<   	 d&e	d)<   	 d*e	d+<   	 dZde	d,<   	 dZde	d-<   	 dZde	d.<   	 dZde	d/<   	 dZde	d0<   	 dZde	d1<   	 dZd2e	d3<   	 dZd4e	d5<   	 dZd6e	d7<   dZ d8e	d9<   dZ!d:e	d;<    e"            Z#d<e	d=<   	  e"            Z$d<e	d><   	 ej%        Z&d?e	d@<   	 dZ'	 dZ(	 dZ)dAe	dB<   	 dZ*d6e	dC<   	 dZ+d6e	dD<   dZ,d6e	dE<   dZ-de	dF<   dGe	dH<   dIe	dJ<   dKe	dL<   de	dM<    e.j/        dN          Z0 e.j/        dO          Z1 e.j/        e1j2         dPe0j2                   Z3e4dQ             Z5e4dR             Z6ddde7dfdsdbZ8e9dtdd            Z:ej;        dude            Z<e9df             Z=e9dg             Z>e9dh             Z?ej@        dvdj            ZAejB        dwdl            ZCeDjE        dm             ZFdn ZGdo ZHej@        dxdq            ZIdr ZJe9dydt            ZK	 	 dzd{dyZL	 	 	 	 	 	 d|d}dZMejB        d             ZNe9d             ZO	 d~ddZP ejQ        d          d             ZRde	d<   ej@        dd            ZSej@         ejQ        d          d                         ZTej@         ejQ        d          d                         ZUddZVd ZWd~dZXd ZY	 d~dZZ	 d~dZ[	 	 	 	 	 ddZ\d Z]d Z^	 	 	 	 dddZ_d Z`d Zad Zbd Zcd Zdd ZeddZf	 ddZgddZhddZiddZjd Zkd Zld Zmd Znd Zod Zpd Zqd Zrd Zsd Ztd Zud Zvd Zwd Zx	 dddÄZydĄ Zzdń Z{ddƄZ|	 ddǄZ}dȄ Z~dɄ Z	 ddʄZd˄ Zd̄ Zd̈́ Zd΄ Zdτ ZdЄ Zdф Zd҄ Z	 ddӄZdԄ Z	 	 	 	 ddՄZdք Zdׄ Zd؄ Zdل Zdڄ Z	 d~dd߄Zd Zd Zej@        d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddZddZddZ	 	 	 	 	 ddZd ZedfdZdd Zd ZddZddZ	 	 	 	 	 	 dddZd Zddddd ej        d          fddZd Zd Z	 	 	 	 	 	 	 	 dd Zd! Zd" Zd~d#Zd$ Zdd%Zd& Zd' Zdd,Z	 dd-Z	 	 	 	 	 	 	 dd.ZĐd/ ZŐd0 ZƐdd4Zǐd5 ZȐd6 Zɐd7e	d8<   ej        s( ej        d9 e"            fd: e"            fg          Z	 d~d;ZdZdae	d<<   	 	 	 	 	 	 	 	 dd=ZϐddAZАdB ZѐdC ZҐdD Z	 	 ddEZԐdF ZՐddGZ֐dH ZאdI ZؐdJ ZِddPZڐdQ Z	 	 	 ddRZ	 	 	 	 	 	 	 	 ddSZݐddTZސdU Z ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        i          Ze                    ej        ej        i          ZddXZdddZ	 ddeZdf Zdg Zdh Zdi Z	 dddlZdm Zdn ZddoZdp Zdq Zdr ZdS (  r  z~Default implementation of :class:`.Compiled`.

    Compiles :class:`_expression.ClauseElement` objects into SQL strings.

    PAZC_)%():.[] zClassVar[Mapping[str, str]]bindname_escape_characterszClassVar[Pattern[str]]_bind_translate_re_bind_translate_charsTFr,  isdeleteisinsertisupdatezOptional[List[Column[Any]]]	postfetchr   zSequence[Column[Any]]insert_prefetchupdate_prefetchN&Optional[Sequence[ColumnElement[Any]]]implicit_returningisplaintextzDict[str, BindParameter[Any]]bindszDict[BindParameter[Any], str]
bind_nameszList[_CompilerStackEntry]r  returning_precedes_values'render_table_with_column_in_update_fromansi_bind_rulesr   bindtemplatecompilation_bindtemplate_numeric_binds_identifier_charzList[ResultColumnsEntry]r  _textual_ordered_columns_ad_hoc_textual_ordered_columns_loose_column_name_matching_numeric_binds_render_postcompilezOptional[ExpandedState]_post_compile_expanded_stateOptional[str]_pre_expanded_stringOptional[List[str]]_pre_expanded_positiontupzOptional[_InsertManyValues]_insertmanyvaluesz!Optional[crud._CrudParamSequence]_insert_crud_paramszFrozenSet[BindParameter[Any]]literal_execute_paramspost_compile_paramszutil.immutabledict[str, str]escaped_bind_nameszbOptional[Tuple[Dict[BindParameter[Any], List[BindParameter[Any]]], Dict[str, BindParameter[Any]]]]_cache_key_bind_matchr:  _values_bindparam_visited_bindparaminlinez"Optional[MutableMapping[CTE, str]]cteszDict[Tuple[int, str], CTE]ctes_by_level_namez/Dict[CTE, Tuple[int, str, selectable._CTEOpts]]level_name_by_ctectes_recursivez"__\[POSTCOMPILE_(\S+?)(~~.+?~~)?\]z%\(([^)]+?)\)s|c                .    |                                   d S r  )_init_bind_translater  s    r   r  zSQLCompiler._init_compiler_clsC  s      """""r   c                    t          j        d                    | j                            }t          j        d| d          | _        | j        | _        d S )Nr  r0  r1  )reescaper   r3  compiler4  r5  )r  regs     r   ra  z SQLCompiler._init_bind_translateG  sK    i >??@@!#JJJJ!7!7$'$B!!!r   r  rl   r5  r  r  r  column_keysr9  for_executemanylintingry  _supporting_againstOptional[SQLCompiler]r  r   c                J   || _         || _        |r-d |d         D             }	d |d         D             }
|
|	f| _        || _        || _        i | _        t          j                    | _        g | _	        g | _
        |j        | _        | j        rD|j                            d          x| _        }|r|j        dk    rdnd| _        t           | _        nt$          |j                 | _        d| _        |j        p|j        | _        t-                      | _        i | _        i | _        t5          j        | ||fi | | j        s| j        s| j        rt>          rtA          |tB                    sJ | j        s| j        rUt>          rtA          |tD                    sJ |j#        rd	| _$        n(| j        r!| j        r| j%        j&        r|j'        rd	| _$        t$          |j                 | _(        |r;| j)        *                    d
 |j)        +                                D                        | j,        tZ          j.        u rn| j        r0| j        r| /                                 n| 0                                 | j1        r2| 2                    dd	          }| 3                    |d	           dS dS dS )a  Construct 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.

        c                    i | ]
}|j         |S r   r?  r   bs     r   
<dictcomp>z(SQLCompiler.__init__.<locals>.<dictcomp>r  s    333AE1333r   r   c                    i | ]}||gS r   r   ro  s     r   rq  z(SQLCompiler.__init__.<locals>.<dictcomp>s  s    111qAs111r   r   r   r   r.  NTc                "    i | ]\  }}|d v	||S )>   r  r  r  
positionalrD  rK  rE  r   r   kvs      r   rq  z(SQLCompiler.__init__.<locals>.<dictcomp>  s@       1	 	 q	 	 	r   Fr  _no_postcompile)_populate_self)4rg  r  rW  rh  ri  r?  r&   column_dictr@  r  r  rt  
paramstyle
startswithrK  rF  _pyformat_templaterE  BIND_TEMPLATESr[  label_lengthmax_identifier_lengthr1   anon_maptruncated_names_truncated_countersr  r  r7  r8  r6  r   r  rA   rC   _inlinerZ  r  insert_executemany_returning_return_defaultsrD  __dict__updateitemsr  rt  rv  _process_numeric_process_positionalrL  r  #_process_parameters_for_postcompile)r  r  r5  r  rg  rh  ri  rj  r  cksmckbmnbr6  s                r   r  zSQLCompiler.__init__M  s6   @ '" 	633il333D11IaL111D*.D&
  / 
 *,, 
! ",? 		O'.'9'D'DY'O'OOD" "-1AAACCs 3 -?D)),:7;M,ND)	  AG$A 	 ()) <>35 $==f==== 	'DM 	'T] 	' 9!)Z88888} ' '  =%i<<<<<$ 	'"&DKK) '' A' &6	' #'DK*7+=> 	M    3 < B B D D    " :555 /& /))++++,,...' !22!&$( 3  

 88t 9      65 r   r  c                ,    | j         dS | j         j        S )a  When 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)rR  rK  rC  s    r   insert_single_values_exprz%SQLCompiler.insert_single_values_expr  s     !)4)<<r   c                    | j         r| j         S | j        *t          | j                  rd | j        j        D             S dS )a  The effective "returning" columns for INSERT, UPDATE or DELETE.

        This is either the so-called "implicit returning" columns which are
        calculated by the compiler on the fly, or those present based on what's
        present in ``self.statement._returning`` (expanded into individual
        columns using the ``._all_selected_columns`` attribute) i.e. those set
        explicitly using the :meth:`.UpdateBase.returning` method.

        .. versionadded:: 2.0

        Nc                0    g | ]}t          |          |S r   r'   r   cs     r   
<listcomp>z3SQLCompiler.effective_returning.<locals>.<listcomp>  s6       $Q''  r   )r=  r5  r)   _all_selected_columnsrC  s    r   effective_returningzSQLCompiler.effective_returning  s\     " 
	**^'F4>,B,B' =    4r   c                    | j         S )zVbackwards compatibility; returns the
        effective_returning collection.

        )r  rC  s    r   	returningzSQLCompiler.returning  s     ''r   c                n    	 | j         d         d         S # t          $ r}t          d          |d}~ww xY w)a  Return 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)r  ies     r   current_executablezSQLCompiler.current_executable  sM    <	M:b>,// 	M 	M 	MCDD"L	Ms    
4/4c                T    t          | j                  t          | j                  z   S r  )listr:  r;  rC  s    r   prefetchzSQLCompiler.prefetch6  s#    D())D1E,F,FFFr   Dict[Any, Any]c                    i S r  r   rC  s    r   _global_attributeszSQLCompiler._global_attributes:  s    	r   MutableMapping[CTE, str]c                d    t          j                    }|| _        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&   OrderedDictr[  r\  r]  r^  )r  r[  s     r   _init_cte_statezSQLCompiler._init_cte_state>  s:     *.)9););	 #% "$#r   c              #  @  K   | j         | j        }}g dc| _         | _        	 | j        r| j        d         }d|d<   nd}| j         | j        fV  |r|                    d           ||c| _         | _        dS # |r|                    d           ||c| _         | _        w xY w)z;special API to support the use case of 'nested result sets'Fr  Tr-  N)r  rI  r  r  )r  result_columnsordered_columnsentrys       r   _nested_resultzSQLCompiler._nested_resultV  s        ! ( 79%3d3	z 
26:233&(===== 8		6777 8D $"7"7"7  8		6777 8D $"7    s   ,A5 5(Bc                     j         rJ  j        t          j        u sJ  j        rJ  j        j        dk    rdn j        j        dk    sJ dg dfd	t          j         j	         j
                   _
         j        r^d
  j                                        D             t           j                  t                    k    sJ fdD              _         n _          j        rcg t          j         j	         j        j                  } fd j        j        D             } j                            ||           _        d S d S )Nr   %sr   r   mre.Match[str]r  r   c                    |                      d          }|r                    |           S                     |                      d                     |                      d          S )Nr   r2   r   )r   append)r  normal_bindplaceholder	positionss     r   find_positionz6SQLCompiler._process_positional.<locals>.find_position{  sd    ''!**K "  ---""   ,,,wwqzz!r   c                    i | ]\  }}||	S r   r   ru  s      r   rq  z3SQLCompiler._process_positional.<locals>.<dictcomp>  s    OOOtq!aOOOr   c                <    g | ]}                     ||          S r   get)r   r  reverse_escapes     r   r  z3SQLCompiler._process_positional.<locals>.<listcomp>  s6          37""4..     r   c           
     ~    g | ]9}|d          |d         t          j        j        |d                   |d         f:S )r   r   r2   r"  )rc  sub_positional_pattern)r   rw  r  r  s     r   r  z3SQLCompiler._process_positional.<locals>.<listcomp>  sZ     " " "  aDaDF43]AaDIIaD	" " "r   rK  rM  )r  r  r  r   )r:  r  rt  rv  rK  r  r|  rc  r  r  r  rV  r  lenrR  rK  rM  _replace)r  rK  rM  r  r  r  r  s   `  @@@@r   r  zSQLCompiler._process_positionaln  s   ####z]99999&&&&<"h..KK<*g5555K		" 	" 	" 	" 	" 	" 	" f$mT[
 
 " 	)OOt/F/L/L/N/NOOONt.//3~3F3FFFFF       ;D     D  )D! 	I!#(&9" "
" " " " " /B" " " &*%;%D%D#5#5 &E & &D"""%	 	r   c                ~   	  j         sJ  j        t          j        u sJ d}i 	 j        rW j        Pt          j         fd j        	                                D              j        	                                          }n j        	                                }|D ]A}|	v r j
        |         }| j        v s	| j        v rd 	|<   , j         | }|dz  }|	|<   B| _        t          	           _         j        rDt%          	          } fd	                                D             	t%          	          |k    sJ  j                            	fd j                   _         j        rH j        j        	z  }d  j        j        D             } j                            ||           _        d S d S )Nr   c              3  .   K   | ]}|j         v|V  d S r  )rX  )r   r  r  s     r   r@  z/SQLCompiler._process_numeric.<locals>.<genexpr>  s=        4#999 9999 r   c                N    i | ]!\  }}j                             ||          |"S r   )rV  r  )r   r  posr  s      r   rq  z0SQLCompiler._process_numeric.<locals>.<dictcomp>  sB       D# '++D$77  r   c                :    |                      d                   S Nr   r   r  	param_poss    r   <lambda>z.SQLCompiler._process_numeric.<locals>.<lambda>  s    i

+ r   c                >    g | ]}|d          |d         d|d         fS )r   r   r  r"  r   )r   rw  s     r   r  z0SQLCompiler._process_numeric.<locals>.<listcomp>  s=     " " " 1qtT1Q4(" " "r   r  )rK  r  rt  rv  rR  rX  	itertoolschainr@  valuesr?  rU  rT  rF  next_numeric_posr  r:  rV  r  r  _pyformat_patternr  r  rK  rM  r  )
r  numr   	bind_namebindph
len_beforerK  rM  r  s
   `        @r   r  zSQLCompiler._process_numeric  sZ   """"z]99999$&	! 	-d&<&H O    $ 6 6 8 8  
 &&(( EE O**,,E 	* 	*II%%:i(D0004666 (,	)$$;BSBBq')	)$$ #	??" 	0YJ   !*!2!2  I y>>Z//// ,00++++T[
 
 ! 	 &9 " "/B" " "
 &*%;%D%D#5#5	 &E & &D"""	 	r   VMutableMapping[str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]]]c                >     d  fd j         D             D             S )Nc                    i | ]
\  }}|||S r  r   )r   r?  values      r   rq  z0SQLCompiler._bind_processors.<locals>.<dictcomp>  s2     
 
 
U   # " !  r   c           	   3     K   | ]t}j         |         |j        j        s|j                            j                  n7t          fd t          t          |j                  j        D                       fV  udS )c              3  L   K   | ]}|                     j                  V  d S r  )_cached_bind_processorr  )r   	elem_typer  s     r   r@  z9SQLCompiler._bind_processors.<locals>.<genexpr>.<genexpr>  sG       # # ) &<<T\JJ# # # # # #r   N)	r@  r  _is_tuple_typer  r  rB  r   r0   types)r   	bindparamr  s     r   r@  z/SQLCompiler._bind_processors.<locals>.<genexpr>  s          OI.  )~<	==dlKKK" # # # #-1 )9>. .#	# # #       r   )r@  rC  s   `r   _bind_processorszSQLCompiler._bind_processors  sK    
 
    "&  
 
 
 	
r   c                2    t          | j                  dk    S r  )r  r  rC  s    r   is_subqueryzSQLCompiler.is_subquery  s    4:""r   r7   c                    | S r  r   rC  s    r   r  zSQLCompiler.sql_compiler  s    r   r  r  r  r4  c                \    |                      ||d          }|                     |          S )aR  Return 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

        Trx  )r  r  )r  r  r  r6  s       r   construct_expanded_statez$SQLCompiler.construct_expanded_state  sD     **%  + 
 


 77
 
 	
r   r  r  _group_numberOptional[int]_checkry  rk   c                   | j         r:|s8| j        J |st          | j        j                  S t	          j        d          |ot          | j                  }|rU| j        t	          j	        d          | j        d         }| j
        }	|	J |	\  }
fdt          ||          D             }nd}|ri }| j                                        D ]\  }}|r| j                            ||          n|}|j        |v r||j                 ||<   >||v r||         ||<   N|rG|j        r@|r t	          j        d|j        |fz  d          t	          j        d	|j        z  d          |r|                    ||          }n|}|j        r|j        ||<   |j        ||<   |S i }| j                                        D ]\  }}|r| j                            ||          n|}|rG|j        r@|r t	          j        d|j        |fz  d          t	          j        d	|j        z  d          |r|                    ||          }n|}|j        r|j        ||<   |j        ||<   |S )
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_paramsr   c                2    i | ]\  }}|         D ]}||S r   r   )r   rp  	extractedr  r  s       r   rq  z0SQLCompiler.construct_params.<locals>.<dictcomp>X  sJ     " " " Ay G" "  i" " " "r   z@A value is required for bind parameter %r, in parameter group %dcd3x)codez)A value is required for bind parameter %r)rL  rM  dictr6  r3   rA  r,  rV  r  CompileErrorrW  zipr@  r  r  r?  requiredcallableeffective_valuer  )r  r  r  r  r  r  ry  has_escaped_namesorig_extracted
ckbm_tupler*  resolved_extractedpdr  r  escaped_namevalue_paramr  s                    @r   r  zSQLCompiler.construct_params-  s    # 
	O 
	4@@@ D=HIII-4   )JT$2I-J-J 	& ~%&J  
 "&!23J))) GD!" " " "$'8L$M$M" " " "& K	B#'?#8#8#:#: %= %=	4 )D+//d;;;  =F**'-im'<B|$$V^^'-d|B|$$ =	 2 =$ !54(}m<= "(	    "5G'm,!'    * 0&8&<&<%y' ' '0 ) =+6+F<((+6+<<((IB#'?#8#8#:#: 9 9	4 )D+//d;;;   i0 $ !54(}m<= "(	    "5G'm,!'    & ,"4"8"8I"N"NKK"+K% 9'2'BB|$$'2'8B|$$Ir   c                $   | j         j        j        j        fdi }| j        }| j        D ]U}||v r|j        j        r/fdt          t          |j                  j
        D             ||<   B |j                  ||<   V|S )Nc                x    |                                                              }||vr|v r|S d S r  )_unwrapped_dialect_implget_dbapi_type)typdbtypedbapir  exclude_typesinclude_typess     r   lookup_typez<SQLCompiler._get_set_input_sizes_lookup.<locals>.lookup_type  sV    0099HHOOF ""*fM.I.I"*f.E.Etr   c                &    g | ]} |          S r   r   )r   r  r	  s     r   r  z;SQLCompiler._get_set_input_sizes_lookup.<locals>.<listcomp>  s3     ) ) )  K$$) ) )r   )r  include_set_input_sizesexclude_set_input_sizesr  rT  r@  r  r  r   r0   r  )	r  
inputsizesrT  r  r  r  r  r  r	  s	       @@@@@r   _get_set_input_sizes_lookupz'SQLCompiler._get_set_input_sizes_lookup  s    ,77
	 
	 
	 
	 
	 
	 
	 
	 
!%!< 
	D 
	DI222~, D) ) ) )#Iy~>>D) ) )
9%%
 )4IN(C(C
9%%r   c                .    |                      d          S )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)r  r  rC  s    r   r  zSQLCompiler.params  s     $$E$222r   r6  rz  c                0    i } j         }| j        } j        rg } j        }| j        }ndx}} j        }t          d|          t          d|          i }i i }	d}
 j        r||} j        rg }
n j        	                                } j
        }|D ]|r|                              n} j                 }| j        v r2|vr-                     ||                    |                    |<   e| j        v r|v r|	|         }d}n;|                              }                     |||          }|\  }}||	|<   ||<   |j        s|                    |           |j        j        r5|J |                    fdt-          |d          D                        n"|                    fd|D                        |
 |
                    d |D                        n!||                    d	 |D                        d
 |D             |<   ||                               fd}t3          j         j        ||          }|
X|J  fdt-          |
 j                  D              j                            fd|          }|                    |
           t=          |||||          }|rE| _         | _        |j         _         j        rtA          |j        pd          nd _        | _!        |S )a  handle 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.

        Nr7  z/Mapping[str, Sequence[_BindProcessorType[Any]]]render_literal_valuec              3     K   | ]M\  }}t          |d           D ]7\  }}v r.         |d z
           d|d|         |d z
           fV  8NdS )r   Nr*  	enumerate)r   ituple_elementjr*  r  tuple_processorss        r   r@  zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>N  s       	. 	.
 !1=(1-(C(C	. 	. !%1#'777 0 6q1u = I /3ddAAAqq 9 0 6q1u = !J I I I I	. 	.r   r   c              3  :   K   | ]\  }}v 	|         fV  d S r  r   )r   r?  r*  r  single_processorss      r   r@  zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>Y  sJ       . . &Q#'888 !"3D"9:8888. .r   c              3      K   | ]	\  }}|V  
d S r  r   r   r  r*  s      r   r@  zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>_  s7       3 3%,T1D3 3 3 3 3 3r   c              3      K   | ]	\  }}|V  
d S r  r   r  s      r   r@  zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>f  s&      .M.Mat.M.M.M.M.M.Mr   c                    g | ]\  }}|S r   r   )r   
expand_keyr*  s      r   r  zCSQLCompiler._process_parameters_for_postcompile.<locals>.<listcomp>g  s)     1 1 1'4z1
1 1 1r   c                L   |                      d          }|         }|                      d          rn|                      d                              d          }|d         |d         cd                    fd|                    d          D                       }|S )Nr   r2   ~~r"  r   c              3  (   K   | ]}|V  d S r  r   )r   expbe_leftbe_rights     r   r@  z]SQLCompiler._process_parameters_for_postcompile.<locals>.process_expanding.<locals>.<genexpr>v  sD       ! ! !(hh7! ! ! ! ! !r   )r   splitr   )r  r?  exprtokr%  r&  replacement_expressionss       @@r   process_expandingzJSQLCompiler._process_parameters_for_postcompile.<locals>.process_expandingm  s    ''!**C*3/D wwqzz ggajj&&t,,$'FCF!yy ! ! ! ! !#zz$//! ! !   Kr   c                .    i | ]\  }}|j          | S r   rF  )r   r  r?  r  s      r   rq  zCSQLCompiler._process_parameters_for_postcompile.<locals>.<dictcomp>  s=       C ;BSBB  r   c                :    |                      d                   S r  r  r  s    r   r  zASQLCompiler._process_parameters_for_postcompile.<locals>.<lambda>  s    )AGGAJJ/ r   r   )"rO  r  rt  rQ  r:  r  r   rK  r@  r  rV  r  r?  rT  render_literal_bindparamr  rU  $_literal_execute_expanding_parameterliteral_executer  r  r  r  extendr  rc  r  _post_compile_patternr  r  r4  r5  r  rM  )r  r6  rz  expanded_parameterspre_expanded_stringnew_positiontuppre_expanded_positiontupr8  new_processorsto_update_setsnumeric_positiontupnamesebnr  	parameter	to_updater  leep_resreplacement_exprr+  r5  expanded_stater  r  r*  r  r  s   `                     @@@@@r   r  z/SQLCompiler._process_parameters_for_postcompile  s   $ ! #7&"&+? 	> O'+'E$'/+/+;( :>=O6*
 3Z
 
  =z
 
 >@24)+ 48? 	-7C#;E" )&(#O**,,E% I	- I	-D25?3774...4L
4(ID777'>>>55%1;1M1M 6   ,L9 D444#::: .| <I!FF (^^D11F#HH$i   H 5=1Y 03<N<0<L+L9 0 %%i000 ~4 %111&-- 	. 	. 	. 	. 	.
 5>fa4H4H	. 	. 	. 	 	 	 	 '-- . . . . .*3. . .   
 +6+22 3 3093 3 3     )4 (...M.M9.M.M.MMMM1 18A1 1 1'- !,&&t,,,	 	 	 	 	 F&(9;N
 
	 *"...    )')>! !  I .22//// I ""#6777&
 
  	? )<D%-ED*(2DK ?^/52666 
 1?D-r   zsqlalchemy.engine.cursorc                b    t           j        j        }|j                            | j                  S )z(utility method used for unit tests only.)r&   	preloadedengine_cursorrd   _create_description_match_mapr  )r  cursors     r   _create_result_mapzSQLCompiler._create_result_map  s/     -*HH 
 
 	
r   _BindNameForColProtocol_get_bind_name_for_colCallable[[Any], str]c                    | j         }|S r  )rI  )r  getters     r   _within_exec_param_key_getterz)SQLCompiler._within_exec_param_key_getter  s    ,r   zsqlalchemy.engine.resultc                  	
 t           j        j        }| j        | j        J | j        j        }t          rt          |t                    sJ |j	        }fd|j
        D             	d |j        <j                            | j        d           
           | j        v rfd}|nd 
|                    d |j
        D                       	
fd}|S )Nc                R    g | ]#}t          j        d  |          d          |f$S )r  N)operatormethodcaller)r   r  param_key_getters     r   r  zKSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.<listcomp>  sI     
 
 
 "5*:*:3*?*?FFL
 
 
r   c                <    |                     |           }||S | S r  r  )	lastrowidr6  param_valueautoinc_keys      r   _autoinc_getterzPSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>._autoinc_getter  s,    ",..i"H"HK".
  +*  )(r   c                    g | ]	}|j         
S r   rn  r   r  s     r   r  zKSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.<listcomp>      %K%K%K#cg%K%K%Kr   c                                    fdD                       S   fdD                       S )a  given 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.

            Nc              3  4   K   | ]\  }} |          V  d S r  r   )r   rL  r  r6  s      r   r@  zWSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>  s1      LL[VSffZ00LLLLLLr   c              3  \   K   | ]&\  }}|u r           nn
 |          V  'd S r  r   )r   rL  r  autoinc_colautoinc_getterrT  r6  s      r   r@  zWSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>  su         $ +--  .9 +N9jAAA!* $VJ//     r   r   )rT  r6  r^  r_  getterslastrowid_processorrow_fns   ``r   r  zDSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get  s     #.//	::	 vLLLLGLLLLLLv        (/     r   )r&   rC  engine_resultrM  r+  r5  r   r  r?   r   primary_key_autoincrement_columnr  _cached_result_processorr  r?  result_tuple)r  resultr5  r   rW  r  r^  r_  rV  r`  ra  rR  rb  s         @@@@@@@r   +_inserted_primary_key_from_lastrowid_getterz7SQLCompiler._inserted_primary_key_from_lastrowid_getter  s`    -=!---&0	 	1i00000
 
 
 
(
 
 

 1""-"2"K"Kd# # +*;77K dj((
) 
) 
) 
) 
) "1 #'$$%K%K9J%K%K%KLL	 	 	 	 	 	 	 	 	4 
r   c                  	 t           j        rddlm} nt          j        j        }| j        J | j        j        }t          rt          |t                    sJ | j        |j        }| j        }|J d t          |          D             t          dfd|j        D                       |                    d |j        D                       		fd}|S )Nr2   )rh  c                    i | ]\  }}||	S r   r   )r   idxr  s      r   rq  zKSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.<dictcomp>	  s    ===HCsC===r   z'List[Tuple[Callable[[Any], Any], bool]]c                    g | ]C}|v rt          j        |                   d fn t          j        d |          d          dfDS )Tr  NF)rP  
itemgetterrQ  )r   r  rR  rets     r   r  zKSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.<listcomp>!	  s|         czz (S22D99 !-!#3#3C#8#8$  		  r   c                    g | ]	}|j         
S r   rn  rY  s     r   r  zKSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.<listcomp>0	  rZ  r   c                8       fdD                       S )Nc              3  N   K   | ]\  }}|r |          n
 |          V   d S r  r   )r   rL  use_rowr6  rows      r   r@  zWSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get.<locals>.<genexpr>3	  sV        #FG  '>sFF:,>,>     r   r   )rt  r6  r`  rb  s   ``r   r  zDSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get2	  sD    6     '.     r   )typingr   enginerh  r&   rC  rc  r+  r5  r  r?   rM  r   r=  r  r   rd  rg  )
r  rh  r5  r   r  r  r`  rR  ro  rb  s
         @@@@r   +_inserted_primary_key_from_returning_getterz7SQLCompiler._inserted_primary_key_from_returning_getter
	  s7     	2'''''''^1F!---&0	 	1i00000=+	$$$==	)(<(<===5     !,  
 
" $$%K%K9J%K%K%KLL	 	 	 	 	 	 
r   c                    dS )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.

        r  r   rC  s    r   default_fromzSQLCompiler.default_from:	  s	     rr   c                H    |j         j        | fi |}|j        D ]}|| j        vr| j        |         }|                    |j        |j                 dd          }| j        |         }|x| j        |<   | j        |<   || j        |<   | j                            |d           || j        v r| xj        |hz  c_        || j	        v r| xj	        |hz  c_	        | j
        }|r@|\  }	}
|j        D ]3}|j        |
v r(|
|j                 }|	|                             |           4|S )a  SQL 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_keyr  N)r  r  	translater?  _with_valuer?  r@  r  rU  rT  rW  _cloned_setr  )r  override_bindsr  sqltextrv  bpnew_bpr  r  r  r  cbs               r   visit_override_bindsz SQLCompiler.visit_override_bindsD	  sk   " <.(;DGGBGG  ) "	0 "	0A
""AB ^^(0! $  F ?2&D/55DJqMDJt,&*DOF#OD)))T---((VH4((T000++x7++3J 0'
d. 0 0Bv~~!"&\R///r   c                4    d |j         j        | fi |z   dz   S Nr,  r-  r  r  )r  groupingasfromr  s       r   visit_groupingzSQLCompiler.visit_grouping	  +    8X%8HHHHH3NNr   c                4    d |j         j        | fi |z   dz   S r  r  )r  r  r  s      r   visit_select_statement_groupingz+SQLCompiler.visit_select_statement_grouping	  r  r   c                   | j         r| j        j        r	 t          d| j         d         d                   }n'# t          $ r}t          j        d          |d }~ww xY w|j        \  }}}|r|}	n|}	|j        j	        }
|
8|
j
        |	v r/|
                    |	|
j
                           r|j        j	        |d<    | j        |j        fd|i|S )N'Union[SelectState, CompoundSelectState]r  r+  ECan't resolve label reference for ORDER BY / GROUP BY / DISTINCT etc.render_label_as_labelwithin_columns_clause)r  r  supports_simple_order_by_labelr   KeyErrorr3   r  _label_resolve_dictr  _order_by_label_elementr  shares_lineager  )r  r  r  r  r+  ke	with_cols
only_froms	only_colsresolve_dictorder_by_elems              r   visit_label_referencez!SQLCompiler.visit_label_reference	  s9    : %	$,E %		 $=JrN?3! !    &/   1	$ ))( $OCM )!&,66!00 !34  7 O; ./ t|O
 
"7
 
 
 	
s   !7 
AAAc                    | j         s|                     |j                  S 	 t          d| j         d         d                   }n># t          $ r1}t          j        |j        dt          j	        |           Y d }~nd }~ww xY w|j
        \  }}}	 |r||j                 }	n||j                 }	|	|d<    | j        |	fd|i|S # t          $ r2}
t          j        |j        dt          j	        |
           Y d }
~
d S d }
~
ww xY w)Nr  r  r+  r  )extraexc_clsr  r  r  )r  r  _text_clauser   r  r   _no_text_coercionr  r3   r  r  )r  r  r  r  r+  r  r  r  r  r  r  s              r   visit_textual_label_referencez)SQLCompiler.visit_textual_label_reference	  s    z 	6<< 4555	 9
2/ MM  		 		 		'/ (        		 ,9+L(	:y	$ 1 10 /2F*+4< +@DJ    		 		 		'/ (         		s/   !A 
B 'A;;B C 
C='C88C=c                   |o| }||u }	|	s|rBt          |j        t          j                  r|                     d|j                  }
n|j        }
|rq|% ||
|j        ||
f|j        z   |z   |j                    |j        j        | fddd|t          t          j                 z   | j                            ||
          z   S |	r| j                            ||
          S  |j        j        | fddi|S )NcolidentT)r  within_label_clauser  F)r  r  r   rD   _truncated_identifierr	  r  r  r  	OPERATORSr!   as_r  format_label)r  r  add_to_result_mapr  r  r  result_map_targetsr  render_label_with_asrender_label_only	labelnames              r   visit_labelzSQLCompiler.visit_label	  sg    "=*=&= 	 2U: 	' 4 	'%*h&?@@ ' 66z5:NN		!J	 	 ,!!JI&)99<NNJ	   10*.(,  	  IM*+ -,,UI>>?	  	=--eY???35=3 ,157  r   c                *    t          j        d          )Nz:Cannot compile Column object until its 'name' is assigned.r3   r  r  r   s     r   _fallback_column_namez!SQLCompiler._fallback_column_name
  s    H
 
 	
r   c                ,    |j         } | j        |fi |S r  )	_resolvedr  )r  r  r  sql_elements       r   visit_lambda_elementz SQLCompiler.visit_lambda_element
  s$    't|K..2...r   r   ColumnClause[Any]r  Optional[_ResultMapAppender]include_tabler  r	  ambiguous_table_name_map Optional[_AmbiguousTableNameMap]c                0   |j         x}}||                     |          }|j        }	|	s0t          |t          j                  r|                     d|          }|2|||j        f|z   }
|j        r|
|j        fz  }
 ||||
|j	                   |	r| 
                    |          }n| j                            |          }|j        }|	|r|j        s|S | j                            |          }|r| j                            |          dz   }nd}t"          rt          |t$                    sJ |j         }|s|r||v r||         }t          |t          j                  r|                     d|          }|| j                            |          z   dz   |z   S )Nr  r/  r  alias)r  r  
is_literalr  r   rD   r  r?  	_tq_labelr  escape_literal_columnr  quoter   named_with_columnschema_for_objectquote_schemar   r[   )r  r   r  r  r  r  r  r  	orig_namer  targetsr   effective_schemaschema_prefix	tablenames                  r   visit_columnzSQLCompiler.visit_column 
  s    ";&y<--f55D&
 	@jx/HII 	@--j$??D(tVZ03EEG /F,..dIwDDD 	- --d33DD=&&t,,D==U5L=K#}>>uEE #M../?@@3F  !# :!%99999
I %@,@ !9994Y?	)X%>?? K 66w	JJ	 4=#6#6y#A#AACG$NNr   c                @    | j                             |j                  S r  )r  format_collation	collationr  r  r  s      r   visit_collationzSQLCompiler.visit_collation[
  s    }--g.?@@@r   c                    |j         S r  r  )r  
fromclauser  s      r   visit_fromclausezSQLCompiler.visit_fromclause^
  s
    r   c                    |j         S r  r  )r  r  r  s      r   visit_indexzSQLCompiler.visit_indexa
  s
    zr   c                Z    ||d<   | j         |d<    | j        j        j        |j        fi |S )Ntype_expressionr  )r  r  type_compiler_instancer  r  )r  
typeclauser  s      r   visit_typeclausezSQLCompiler.visit_typeclaused
  sH     *$(M !:t|2:O
 
!
 
 	
r   c                J    | j         j        r|                    dd          }|S Nr+  %%r  _double_percentsreplacer  texts     r   post_process_textzSQLCompiler.post_process_textk
  '    =) 	+<<T**Dr   c                J    | j         j        r|                    dd          }|S r  r  r  s     r   r  z!SQLCompiler.escape_literal_columnp
  r  r   c           	          fd} j         sd _        |r |d d ft          j                   t                              d t                              |                     j                                      S )Nc                    |                      d          }|j        v r j        j        |         fi S  j        |fi S r  )r   _bindparamsr  bindparam_string)r  r  r  r  
textclauses     r   do_bindparamz2SQLCompiler.visit_textclause.<locals>.do_bindparamv
  s]    771::Dz---#t|J$:4$@GGBGGG,t,T88R888r   Tc                ,    |                      d          S r  r  )r  s    r   r  z.SQLCompiler.visit_textclause.<locals>.<lambda>
  s    aggajj r   )	r  r>  r%   NULLTYPEBIND_PARAMS_ESCr  BIND_PARAMSr  r  )r  r  r  r  r  s   `` ` r   visit_textclausezSQLCompiler.visit_textclauseu
  s    	9 	9 	9 	9 	9 	9 	9 z 	$#D 	L dD:-9JKKK ""  OOd44Z_EE 
 
 	
r   c                   | j          }|r| j        n| j         d         }t                      t                      |d}| j                             |           |j        r|                     ||           |p1|dk    o|                    dd          p|                    dd          }|r[|j        x| _        | _	        |j         ot          |j                  | _        |j        D ]}	|                     |	d| j                     | j        |j        fi |}
| j        r1|st#          | j                   nd }|                     |	          |
z   }
| j                             d           |
S )
Nr  r'  r&  r$   r   r.  Fr-  T)r  r  nesting_level)r  _default_stack_entryr   r  _independent_ctes_dispatch_independent_ctesr  rt  rI  rG  r,  column_argsrJ  r  _add_to_result_mapr  r[  r  _render_cte_clauser  )r  tafcompound_indexr  r  toplevelr  	new_entrypopulate_result_mapr  r  r  s               r   visit_textual_selectz SQLCompiler.visit_textual_select
  s    z>-5I))4:b>  #uuEE*
 *
	
 	
)$$$  	5++C444  >!# EII<eDD>
 yy5u== 	  	D!D$A 47>/A 0dG GD, _  *.&*&=      t|CK..2..9 	O3;EC
OOOM***GG$ND
rr   r(  rL   r  c                    dS NNULLr   r  r(  r  s      r   
visit_nullzSQLCompiler.visit_null
      vr   rM   c                "    | j         j        rdS dS )Nr   1r  supports_native_booleanr  s      r   
visit_truezSQLCompiler.visit_true
  s    </ 	63r   rJ   c                "    | j         j        rdS dS )Nr   0r  r  s      r   visit_falsezSQLCompiler.visit_false
  s    </ 	73r   c                ^     |                     d  fd|D             D                       S )Nc              3     K   | ]}||V  	d S r  r   r   ss     r   r@  z7SQLCompiler._generate_delimited_list.<locals>.<genexpr>
  s<       
 


 
 
 
 
 
r   c              3  4   K   | ]} |j         fi V  d S r  r  r   r  r  r  s     r   r@  z7SQLCompiler._generate_delimited_list.<locals>.<genexpr>
  s9      II1*a*466266IIIIIIr   r   )r  r   	separatorr  s   `  `r   _generate_delimited_listz$SQLCompiler._generate_delimited_list
  sM    ~~ 
 
IIIIIIII
 
 
 
 
 	
r   c                Z    t           j                            t          j        t           j        j        t           j        j        |          \  }}|dk    r |d         j         fi S t          t          j                 }|
                    d  fd|D             D                       S )Nr   r   c              3     K   | ]}||V  	d S r  r   r  s     r   r@  z;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>
  s<       " """ " " " " "r   c              3  4   K   | ]} |j         fi V  d S r  r  r  s     r   r@  z;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>
  s9      LLq.!.t::r::LLLLLLr   )r   BooleanClauseList_process_clauses_for_booleanr!   and_rM   
_singletonrJ   r  r  r   )r  clausesr  lccr  s   ` `  r   _generate_delimited_and_listz(SQLCompiler._generate_delimited_and_list
  s    1NNNN%O&	
 
W !88071:0<<<<<!).1I>> " "LLLLLGLLL" " "   r   c                $    d | j         |fi |z  S N(%s))visit_clauselist)r  
clauselistr  s      r   visit_tuplezSQLCompiler.visit_tuple
  s#    --j??B????r   c                f    |j         }|d}nt          |j                  } | j        |j        |fi |S Nr2  )rP  r  r  r"  )r  r)  r  seps       r   r(  zSQLCompiler.visit_clauselist
  sC    !;CCJ/0C,t,Z-?KKKKKr   c                    |j         }|                     |dd           }|r
 |||fi |S 	 t          |         }d|d<    | j        |j        |fi |S # t
          $ r}t          j        | |          |d }~ww xY w)Nexpression_clauselistT_in_operator_expression)rP  _get_operator_dispatchr  r  r"  r  r3   r  )r  r)  r  	operator_dispopstringr  s          r   visit_expression_clauselistz'SQLCompiler.visit_expression_clauselist
  s    '	**.
 
  	54
I44444	 +H -1B()040"H 02  	  	L 	L 	L1$	BBK	Ls   A 
A7A22A7c                   d}|j         | |j         j        | fi |dz   z  }|j        D ].\  }}|d |j        | fi |z   dz    |j        | fi |z   dz   z  }/|j        |d |j        j        | fi |z   dz   z  }|dz  }|S )NzCASE r2  zWHEN z THEN zELSE END)r  r  whenselse_)r  clauser  r   condrh  s         r   
visit_casezSQLCompiler.visit_case  s    <#00@@@@3FFA"L 	 	LD&)$)$99&99: ,&+D;;F;;< 	AA <#9&,9$II&IIICOA 	
U
r   c                (     |j         j        | fi |S r  )typed_expressionr  )r  type_coercer  s      r   visit_type_coercezSQLCompiler.visit_type_coerce  s     >{+>tJJrJJJr   c                     |j         j        | fi |}t          j        d|          }d |j        j        | fi |d|r|                    d          n|d|r|                    d          ndS )Nz(.*)( COLLATE .*)zCAST(r   r   r-  r2   r  )r  r  rc  matchr:  r   )r  r   r  type_clauserB  s        r   
visit_castzSQLCompiler.visit_cast  s    8do8HHHH,k::*DK*4::6::::#4EKKNNN44#+EKKNNN+
 	
r   c           
     d   |d         t           j        u rdn|d         t           j        u rdnj|d         dk     r6 | j        t          j        t          |d                             fi |dn( | j        t          j        |d                   fi |dd|d         t           j        u rdn|d         t           j        u rdnj|d         dk     r6 | j        t          j        t          |d                             fi |dn( | j        t          j        |d                   fi |dS )	Nr   zUNBOUNDED PRECEDINGzCURRENT ROWz
 PRECEDINGz
 FOLLOWINGr   r   zUNBOUNDED FOLLOWING)r   RANGE_UNBOUNDEDRANGE_CURRENTr  literalabs)r  range_r  s      r   _format_frame_clausez SQLCompiler._format_frame_clause'  s    !9 888 &% ayH$::: "M "!9q==	 )DL ( 0VAY @ @ DF     (4<(8(C(CJJrJJJJM ( !9 888 &% ayH$::: "M "!9q==	 )DL ( 0VAY @ @ DF     (4<(8(C(CJJrJJJJM+'
 '	
r   c                d     |j         j         fi }|j        d  j        |j        fi z  }n>|j        d  j        |j        fi z  }n |j        d  j        |j        fi z  }nd }|dd                     fdd|j        fd|j        ffD             |r|gng z             d	S )
NzRANGE BETWEEN %szROWS BETWEEN %szGROUPS BETWEEN %sz OVER (r2  c           	     ^    g | ])\  }}|t          |          |d |j        fi *S )Nz BY )r  r  )r   wordr:  r  r  s      r   r  z*SQLCompiler.visit_over.<locals>.<listcomp>e  sc        %f )c&kk) tt6V6tFFvFFFH *))r   	PARTITIONORDERr-  )	r  r  rJ  rK  rowsgroupsr   partition_byorder_by)r  overr  r  rJ  s   ` `  r   
visit_overzSQLCompiler.visit_overQ  sZ   .t|.t>>v>>;"'*C$*C+ +%+ + FF Y"&)B)B	* *#* * FF [$(+D4+D, ,%, , FF F DDHH     %d&78 $-0)    &-F882	/   
 	
r   c                V     |j         j        | fi |d |j        j        | fi |dS )Nz WITHIN GROUP (ORDER BY r-  )r  r  rT  )r  withingroupr  s      r   visit_withingroupzSQLCompiler.visit_withingroupr  sN    2K24BB6BBBB3K 3DCCFCCCC
 	
r   c                V     |j         j        | fi |d |j        j        | fi |dS )Nz FILTER (WHERE r-  )funcr  	criterion)r  
funcfilterr  s      r   visit_funcfilterzSQLCompiler.visit_funcfilterx  sM    .JO.t>>v>>>>3J 3DCCFCCCC
 	
r   c                    | j                             |j        |j                  }d|d |j        j        | fi |dS )NzEXTRACT(r   r-  )extract_mapr  fieldr(  r  )r  extractr  ra  s       r   visit_extractzSQLCompiler.visit_extract~  sQ     $$W]GMBBEE+GL+D;;F;;;;
 	
r   c                T     | j         |j        fi |} | j        |fi |}d|d|S )Nr,  z).)visit_functionfnr  )r  r  r  compiled_fncompiled_cols        r   visit_scalar_function_columnz(SQLCompiler.visit_scalar_function_column  sK    )d)'*;;;;(t(77B77'KK66r   r[  Function[Any]c                    |# ||j         |j         |j         f|j                   t           d|j                                         z  d           }|r
 ||fi |}nt                              |                                j        d           r|j        rdz  n\|j          j	        
                              st          t          j                  r j	                                      ndz   d                     fd|j        D             gz             d  j        |fi |iz  }|j        r|dz  }|S )Nzvisit_%s_funcz%(expr)sr/  c                    g | ]R}j                             |          st          t          j                  rj                             |          n|SS r   )r  _requires_quotes_illegal_charsr  r   r/   r  )r   r)  r  r  s     r   r  z.SQLCompiler.visit_function.<locals>.<listcomp>  so        	  =GGLL!%dH,@AA!++C000 !  r   r(  z WITH ORDINALITY)r  r  getattrlowerr   r  _deannotater  	_has_argsr  rm  r  r   r/   r  r   packagenamesfunction_argspec_with_ordinality)r  r[  r  r  r3  r  r  s   `     @r   re  zSQLCompiler.visit_function  s    (diTYL$)LLLt_ty/@/@@$GG  	@4''''DD==!1!1!3!3!=tDDD )> 'J&Dy }CCDII!$(<==DM''--- 	  j(88      $0   &	  ..t>>v>>?@D   	'&&Dr   c                6    |                      |j                  S r  )visit_sequencesequence)r  
next_valuer  s      r   visit_next_value_funcz!SQLCompiler.visit_next_value_func  s    "":#6777r   c                :    t          d| j        j        z            )Nz2Dialect '%s' does not support sequence increments.r  r  r  r  rw  r  s      r   rv  zSQLCompiler.visit_sequence  s$    !@l 
 
 	
r   c                (     |j         j        | fi |S r  )clause_exprr  )r  r[  r  s      r   rs  zSQLCompiler.function_argspec  s     2t24BB6BBBr   c           
     H     j          } |j        | fi }|r j        s| _        |j        }|r j        n j         d         }|p| o|                    dd          }	|dk    r||d<    j                             |d         |d         |||	d           |j        r                     |            j	        |j
                 }
d	|
z   d	z                        fd
t          |j                  D                       }dd<   |  j        |fi t          ddiz  }|  j        |fi z  }|j        r|  j        |fi z  } j        r2|st)           j                   nd }                     |d          |z   } j                             d           |S )Nr  r.  Fr   r/  r'  r&  )r'  r&  r$   r+  r.  r2  c              3  @   K   | ]\  }} |j         f|d V  dS ))r  r  Nr  )r   r  r  r  r  r  s      r   r@  z4SQLCompiler.visit_compound_select.<locals>.<genexpr>  sf         Aq %$!' =C      r   r  r  Tr  include_following_stackr   )r  _compile_state_factoryr+  r5  r  r  r  r  r  compound_keywordskeywordr   r  selectsgroup_by_clauser  order_by_clause_has_row_limiting_clause_row_limit_clauser[  r  r  r  )r  csr  r  r  r   r+  compound_stmtr  need_result_mapr  r  r  s   ` ` `        r   visit_compound_selectz!SQLCompiler.visit_compound_select  se    z>11"dEEfEE 	/D. 	/!.D%/-5I))4:b>" 
 A		8%@@ 	 Q "E*
#():#; %n 5 !.0? 	
 	
 	
 * 	C++M6BBB(4g#))      &bj11	  
 
 #($$RII4+H+Hv+H+H+HIII$$R226222& 	9*D*288888D9 	3;EC
OOOM''"/,0 (   	  	
rr   c                H    |j          | j        |fi |S  | j        |fi |S r  )_fetch_clausefetch_clauselimit_clause)r  r  r  s      r   r  zSQLCompiler._row_limit_clause  sA    '$4$R226222$4$R226222r   c                P    d|j         d||rd|z   nd}t          | |d           S )Nvisit_r*  r  )r  rn  )r  r2  
qualifier1
qualifier2attrnames        r   r1  z"SQLCompiler._get_operator_dispatch  sE     J *2C*2

 tXt,,,r   c                   |||fz  }||d<   ||d<   |j         rg|j        rt          j        d          |                     |j         dd          }|r |||j         fi |S  | j        |t          |j                  fi |S |j        rL|                     |j        dd          }|r |||j        fi |S  | j        |t          |j                 fi |S t          j        d          )Nr  r  zFUnary expression does not support operator and modifier simultaneouslyunaryrP  modifierz,Unary expression has no operator or modifier)rP  r  r3   r  r1   _generate_generic_unary_operatorr   _generate_generic_unary_modifier)r  r  r  r  r  r3  s         r   visit_unaryzSQLCompiler.visit_unary  sk    (5(*&7B"#'9B#$> 	~ &2   .. D  tE5>88R888<t<9U^4 8:   ^ 	.. D  tE5>88R888<t<9U^4 8:   ">  r   c                \   | j         j        rw | j        |j        fi |dz    | j        t	          j        |j        |j        j        j        t          j
        u r|j        j        nt          j
                              fi |z   S  | j        |j        fi |dz    | j        |j        fi |z   S )N / )r  div_is_floordivr  r   r   Castr   r  _type_affinityr%   Numericr  r   rP  r  s       r   visit_truediv_binaryz SQLCompiler.visit_truediv_binary9  s    <' 	V[//B// $,M  &|0?'/ 0  0 #L-- "*!1!3!3    	( V[//B//$,v|22r223r   c                   | j         j        rG|j        j        j        t
          j        u r* | j        |j        fi |dz    | j        |j        fi |z   S d | j        |j        fi |dz    | j        |j        fi |z   z  S )Nr  z	FLOOR(%s))	r  r  r   r  r  r%   Integerr  r   r  s       r   visit_floordiv_binaryz!SQLCompiler.visit_floordiv_binaryT  s    L(	!0H4DDD V[//B//$,v|22r223 V[//B//$,v|22r223 r   c                z    |j         s| j        j        r | j        |j        fi |S d | j        |j        fi |z  S )Nz%s = 1_is_implicitly_booleanr  r  r  r  r  r  rP  r  s       r   visit_is_true_unary_operatorz(SQLCompiler.visit_is_true_unary_operatore  s[    *	B|3	B  4<662666ldl7?AAbAAAAr   c                    |j         s| j        j        rd | j        |j        fi |z  S d | j        |j        fi |z  S )NNOT %sz%s = 0r  r  s       r   visit_is_false_unary_operatorz)SQLCompiler.visit_is_false_unary_operatorn  s`    *	B|3	B ldl7?AAbAAAAldl7?AAbAAAAr   c                J    d|                      |t          j                  z  S )Nr  )override_operator)visit_binaryr!   match_opr  s       r   visit_not_match_op_binaryz%SQLCompiler.visit_not_match_op_binaryw  s.    $++i&8 , 
 
 
 	
r   c                <    d | j         |t          |         fi |z  S r&  )_generate_generic_binaryr  r  s       r   visit_not_in_op_binaryz"SQLCompiler.visit_not_in_op_binary|  s:     55Ih'
 
+-
 
 
 	
r   c                @   |t           j        u r7t          |          dk    r"dd                    d |D                       z  S dS |t           j        u r7t          |          dk    r"dd                    d |D                       z  S dS |                     |          S )	Nr   z(%s)) OR (1 = 1r   c              3     K   | ]}d V  dS r  Nr   r   r  s     r   r@  z6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>  "      ::f::::::r   zNULL) OR (1 = 1z(%s)) AND (1 != 1c              3     K   | ]}d V  dS r  r   r  s     r   r@  z6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>  r  r   zNULL) AND (1 != 1)r!   	not_in_opr  r   in_opvisit_empty_set_expr)r  r  	expand_opr  s       r   visit_empty_set_op_exprz#SQLCompiler.visit_empty_set_op_expr  s    	+++5zzA~~(II::E:::::  )()/))5zzA~~*II::E:::::  +*,,U333r   c                :    t          d| j        j        z            )Nz3Dialect '%s' does not support empty set expression.r{  r  element_typesr  s      r   r  z SQLCompiler.visit_empty_set_expr  s$    !Al 
 
 	
r   c                   	
 j                              j                  }|sb|j        r8 j        j        rdnd                     j         j        j                  z   }n                     j         gj                  }nf|j        sI|j        rt          |d         t          j                  ryt          |d         t          t          f          sW|j        rt          d           j        j        rdndd                     fdt#          |          D                       z   }n|r j        }|                    |          }|r|                    d          s
J d            |                    d                              d	          }|d
         |d         c	
d                    	
 fd|D                       }n"d                     fd|D                       }d|fS )NVALUES r  r   z?bind_expression() on TupleType not supported with literal_bindsr   c           	   3     K   | ]C\  }}d d                     fdt          |j        j                  D                       z  V  DdS )r'  r   c              3  J   K   | ]\  }}                     ||          V  d S r  r  )r   r  
param_typer  s      r   r@  z[SQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>.<genexpr>  sK        -E: 11%DD     r   N)r   r  r  r  )r   r  r  r=  r  s      r   r@  zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>  s         %A} II    14)9>+?2 2         r   r2   )unexpected format for expanding parameterr"  r   r"  c              3  Z   K   | ]%}                     |j                  V  &d S r  r  r  )r   r  r%  r&  r=  r  s     r   r@  zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>  s]       3 3 	  11%HHH 	3 3 3 3 3 3r   c              3  N   K   | ]}                     |j                  V   d S r  r  )r   r  r=  r  s     r   r@  zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>  sI       3 3 --eY^DD3 3 3 3 3 3r   r   )r  r  r  r  tuple_in_valuesr  r  r  _isnullr  collections_abcr   r   bytes_has_bind_expressionr  r   r  r3  searchr   r'  )r  r=  r  bind_expression_templatetyp_dialect_implreplacement_expressionpost_compile_patternr  r)  r%  r&  s   ``       @@r   2_literal_execute_expanding_parameter_literal_bindsz>SQLCompiler._literal_execute_expanding_parameter_literal_binds  s    %>AA$,OO A	
  . 
!%!=EII200N()*= *&& *.)E)E^$i&9* *&& , 0	$0	6!9o&>??0	 vay3,770	
  4 )$   "\9A		r		      )2&(9(9    &"" ( '+'A$(//0HII ?QWW  ? ?>? ? ? ggajj&&t,,$'FCF!)- 3 3 3 3 3 3 3 "(3 3 3 * *&& *. 3 3 3 3 3!'3 3 3 * *&
 )))r   c                   	 j         r                     |          S  j        }j                            |          	 j        r j        n j         j        j        r	j	        r	 	fdnfd|sRg 	j
        r'                     j        j        j                  }n                     j        gj                  }n	j
        sI	j        rt          |d         t           j                  rt          |d         t$          t&          f          sa	j        rJ fdt+          |d          D             |j        rdndd                    fd	t+          |          D                       z   }n=fd
t+          |d          D             d                    fdD                       }|fS )Nc                F                         j        d| iz            S Nr  )render_bind_castr  )r  bind_templater=  r  r  s    r   _render_bindtemplatezNSQLCompiler._literal_execute_expanding_parameter.<locals>._render_bindtemplate  s/    ,,N$!VTN2  r   c                    d| iz  S r  r   )r  r  s    r   r  zNSQLCompiler._literal_execute_expanding_parameter.<locals>._render_bindtemplate  s    $~55r   r   c                Z    g | ]'\  }}t          |d           D ]\  }}d|d||f(S )r   r*  r  )r   r  r  r  r  r  s        r   r  zDSQLCompiler._literal_execute_expanding_parameter.<locals>.<listcomp>  sh       $A} )- ; ;  Au  $ttQQQ*E2   r   r   r  r  r   c              3     K   | ];\  d d                     fdt                    D                       z  V  <dS )r'  r   c              3  r   K   | ]1\  }} t                    z  |z            d                    V  2dS )r   N)r  )r   r  r  r  r  r>  r  s      r   r@  zMSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>.<genexpr>!  si         %Au -,%a#m*<*<&<q&@A!D      r   N)r   r  )r   r  r  r  r>  s    @@r   r@  zCSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>  s         %A} II        )2-(@(@	         r   c                (    g | ]\  }}d ||fS )r*  r   )r   r  r  r  s      r   r  zDSQLCompiler._literal_execute_expanding_parameter.<locals>.<listcomp>+  s=       Au !DD!!$e,  r   c              3  4   K   | ]\  }} |          V  d S r  r   )r   r?  r  r  s      r   r@  zCSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>/  sD       / /.8c5$$S))/ / / / / /r   )r1  r  r  r  r  rK  rE  rD  _bind_typing_render_castsr  r  r  r  r  r  r  r  r   r   r  	_is_arrayr  r  r   )
r  r  r=  r  r  r  r  r  r>  r  s
   ```   @@@@r   r0  z0SQLCompiler._literal_execute_expanding_parameter  s   $ 	JJ6   ,$>AA'JJ 	. 9MM -M L2	6 1	6
        6 6 6 6 6  ,	I. )-)E)EN()*=* *&& *.)E)E^$i&9* *&& , !	$!	6!9o&>??!	 vay3,77!	
 (1111   (1&!(<(<  I %4<		"		      )2&(9(9    &""    )&! 4 4  I &*YY / / / /<E/ / / & &" 000r   c           	     F   |rt          j        |j                  r|l|d         }|j                            t          j        t          |j        j	        |gz             t          |j
        j	        |gz                                  n[|j                            t          j        t          |j        j	                  t          |j
        j	                                       | j        rCt          |j        t          j                  r$t          |j
        t          j                  rd|d<   |p|j        }|                     |dd           }	|	r
 |	||fi |S 	 t           |         }
 | j        ||
f||d|S # t$          $ r}t'          j        | |          |d }~ww xY w)Nenclosing_lateralTr1  r   )from_linterlateral_from_linter)r!   is_comparisonrP  r  r  r  productr*   r   r+   r   rC  r  r   rF   r1  r  r  r  r3   r  )r  r   r  eager_groupingr  r  r  r  r2  r3  r4  r  s               r   r  zSQLCompiler.visit_binary5  s      	926?CC 	".$&':$;!#)00%!"K59J8KK  ""L6:K9LL 	 	 	 	 	 !((%!&+";<<!&,"<==     	)6;(>??	) 6<)?@@	)
 %)B !%8	**9hEE 	4	00R000$Y/ 5t4 !,(;	 
     P P P5dIFFCOPs   E; ;
F FF c                (     | j         |j        fi |S r  )r  sql_functionr  s       r   &visit_function_as_comparison_op_binaryz2SQLCompiler.visit_function_as_comparison_op_binarym  s    t|G077B777r   c                    | j         j        r* | j        |j        fi |dz    | j        |j        fi |z   S  | j        |j        fi |dz    | j        |j        fi |z   S )Nz %% r   )r  r  r  r   r   r  s       r   visit_mod_binaryzSQLCompiler.visit_mod_binaryp  s    =) 	V[//B//$,v|22r223 V[//B//$,v|22r223r   c                p    |j         |d<    | j        |d|                     |j                  z   dz   fi |S )Nr  r2  )r  r  r  r4  r  s       r   visit_custom_op_binaryz"SQLCompiler.visit_custom_op_binary~  sW    '6,t,$,,X->???#E
 
 
 
 	
r   c                V     | j         ||                     |j                  dz   fi |S r,  )r  r  r4  r  s       r   visit_custom_op_unary_operatorz*SQLCompiler.visit_custom_op_unary_operator  sA    4t4T//0ABBSH
 
LN
 
 	
r   c                V     | j         |d|                     |j                  z   fi |S r,  )r  r  r4  r  s       r   visit_custom_op_unary_modifierz*SQLCompiler.visit_custom_op_unary_modifier  sA    4t4S455h6GHHH
 
LN
 
 	
r   r   BinaryExpression[Any]r4  r  c                    |                     dd          }d|d<   |j        |d<    |j        j        | fd|i||z    |j        j        | fd|i|z   }|r|rd|z  }|S )Nr0  FT
_binary_opr  r'  )r  rP  r   r  r   )r  r   r4  r  r  r0  r  s          r   r  z$SQLCompiler._generate_generic_binary  s     #%&&)BE"J"J(,$%!?<*FK* %379   .fl- %379 	 	 # 	!~ 	!D=Dr   c                .    | |j         j        | fi |z   S r  r  r  r  r4  r  s       r   r  z,SQLCompiler._generate_generic_unary_operator  s%    :%-:4FF2FFFFr   c                .     |j         j        | fi ||z   S r  r  r  s       r   r  z,SQLCompiler._generate_generic_unary_modifier  s$    /u}/;;;;hFFr   c                B    t          j        dt          j                  S )Nz'%')r  )r   literal_columnr%   
STRINGTYPErC  s    r   _like_percent_literalz!SQLCompiler._like_percent_literal  s    &uH4GHHHHr   c                0    d |j         j        | fi | dS )Nzlower(r-  r  r  s      r   $visit_ilike_case_insensitive_operandz0SQLCompiler.visit_ilike_case_insensitive_operand  s+    I::4FF2FFIIIIr   c                    |                                 }| j        }|                    |j                                      |          |_         | j        ||fi |S r  _cloner  concatr   visit_like_op_binaryr  r   rP  r  percents        r   visit_contains_op_binaryz$SQLCompiler.visit_contains_op_binary  sW    ,~~fl33::7CC(t(@@R@@@r   c                    |                                 }| j        }|                    |j                                      |          |_         | j        ||fi |S r  r	  r  r
  r   visit_not_like_op_binaryr  s        r   visit_not_contains_op_binaryz(SQLCompiler.visit_not_contains_op_binary  sW    ,~~fl33::7CC,t,VXDDDDDr   c                   |                                 }| j        }t          |j                  |_        |                    t          |j                                                |          |_         | j        ||fi |S r  r	  r  r  r   r
  r   visit_ilike_op_binaryr  s        r   visit_icontains_op_binaryz%SQLCompiler.visit_icontains_op_binary  sw    ,,V[99~~"6<00
 

&// 	 *t)&(AAbAAAr   c                   |                                 }| j        }t          |j                  |_        |                    t          |j                                                |          |_         | j        ||fi |S r  r	  r  r  r   r
  r   visit_not_ilike_op_binaryr  s        r   visit_not_icontains_op_binaryz)SQLCompiler.visit_not_icontains_op_binary  sw    ,,V[99~~"6<00
 

&// 	 .t-fhEE"EEEr   c                    |                                 }| j        }|                    |j                  |_         | j        ||fi |S r  )r	  r  _rconcatr   r  r  s        r   visit_startswith_op_binaryz&SQLCompiler.visit_startswith_op_binary  sK    ,''55(t(@@R@@@r   c                    |                                 }| j        }|                    |j                  |_         | j        ||fi |S r  )r	  r  r  r   r  r  s        r   visit_not_startswith_op_binaryz*SQLCompiler.visit_not_startswith_op_binary  sK    ,''55,t,VXDDDDDr   c                    |                                 }| j        }t          |j                  |_        |                    t          |j                            |_         | j        ||fi |S r  )r	  r  r  r   r  r   r  r  s        r   visit_istartswith_op_binaryz'SQLCompiler.visit_istartswith_op_binary  se    ,,V[99''(>v|(L(LMM)t)&(AAbAAAr   c                    |                                 }| j        }t          |j                  |_        |                    t          |j                            |_         | j        ||fi |S r  )r	  r  r  r   r  r   r  r  s        r   visit_not_istartswith_op_binaryz+SQLCompiler.visit_not_istartswith_op_binary  se    ,,V[99''(>v|(L(LMM-t-fhEE"EEEr   c                    |                                 }| j        }|                    |j                  |_         | j        ||fi |S r  r  r  s        r   visit_endswith_op_binaryz$SQLCompiler.visit_endswith_op_binary  sI    ,~~fl33(t(@@R@@@r   c                    |                                 }| j        }|                    |j                  |_         | j        ||fi |S r  r  r  s        r   visit_not_endswith_op_binaryz(SQLCompiler.visit_not_endswith_op_binary  sI    ,~~fl33,t,VXDDDDDr   c                    |                                 }| j        }t          |j                  |_        |                    t          |j                            |_         | j        ||fi |S r  r  r  s        r   visit_iendswith_op_binaryz%SQLCompiler.visit_iendswith_op_binary  sc    ,,V[99~~&<V\&J&JKK)t)&(AAbAAAr   c                    |                                 }| j        }t          |j                  |_        |                    t          |j                            |_         | j        ||fi |S r  r  r  s        r   visit_not_iendswith_op_binaryz)SQLCompiler.visit_not_iendswith_op_binary  sc    ,,V[99~~&<V\&J&JKK-t-fhEE"EEEr   c                    |j                             dd           } |j        j        | fi |d |j        j        | fi ||#d|                     |t          j                  z   ndz   S )Nrd  z LIKE  ESCAPE r  	modifiersr  r   r  r   r  r%   r  r  r   rP  r  rd  s        r   r  z SQLCompiler.visit_like_op_binary  s    !%%h55 +FK*46626666+FL+D77B777

 ! 2268;NOOOO
 	
r   c                    |j                             dd           } |j        j        | fi |d |j        j        | fi ||#d|                     |t          j                  z   ndz   S )Nrd  z
 NOT LIKE r-  r  r.  r0  s        r   r  z$SQLCompiler.visit_not_like_op_binary  s    !%%h55*FK*46626666+FL+D77B777

 ! 2268;NOOOO
 	
r   c                    |t           j        u rF|                                }t          |j                  |_        t          |j                  |_         | j        ||fi |S r  )r!   ilike_opr	  r  r   r   r  r  s       r   r  z!SQLCompiler.visit_ilike_op_binary  s^    y)))]]__F0==FK1&,??FL )t(@@R@@@r   c                    |t           j        u rF|                                }t          |j                  |_        t          |j                  |_         | j        ||fi |S r  )r!   not_ilike_opr	  r  r   r   r  r  s       r   r  z%SQLCompiler.visit_not_ilike_op_binary(  s^    y---]]__F0==FK1&,??FL -t,VXDDDDDr   c                ^    |j                             dd          } | j        ||rdndfi |S )Nr   Fz BETWEEN SYMMETRIC z	 BETWEEN r/  r  r  r  r   rP  r  r   s        r   visit_between_op_binaryz#SQLCompiler.visit_between_op_binary1  sN    $((e<<	,t,YG))K
 
KM
 
 	
r   c                ^    |j                             dd          } | j        ||rdndfi |S )Nr   Fz NOT BETWEEN SYMMETRIC z NOT BETWEEN r7  r8  s        r   visit_not_between_op_binaryz'SQLCompiler.visit_not_between_op_binary7  sQ    $((e<<	,t,)2G%%
 
 
 
 	
r   rP  c                D    t          j        d| j        j        z            Nz/%s dialect does not support regular expressionsr3   r  r  r  r  s       r   visit_regexp_match_op_binaryz(SQLCompiler.visit_regexp_match_op_binary?  )     =l 
 
 	
r   c                D    t          j        d| j        j        z            r=  r>  r  s       r    visit_not_regexp_match_op_binaryz,SQLCompiler.visit_not_regexp_match_op_binaryG  r@  r   c                D    t          j        d| j        j        z            )Nz;%s dialect does not support regular expression replacementsr>  r  s       r   visit_regexp_replace_op_binaryz*SQLCompiler.visit_regexp_replace_op_binaryO  s)     Il 
 
 	
r   c           	        |s|j                             | j                  }|j        r|                    |          }	 | j        |	fd||o|j         ||d|}
|j        r~t          j        d|
          }|s
J d            d|	                    d          d|	                    d          d	|	                    d
          d}
|r | j
        |fd|
d|}d|z  S |
S |s|p|j        p|o| j        }|p|j        }nd}|r | j
        |fddi|}|j        rd|z  }|S |                     |          }|| j        v r| j        |         }||ur|j        s|j        rU|j                            |j                  s6|j                            |j                  st'          j        d|z            |j        |j        k    rt'          j        d|d          |j        s|j        rG|j        r|j        rt'          j        d          t'          j        d|j         d|j         d          |x| j        |j        <   | j        |<   | j        }|r@|\  }}|j        D ]3}|j        |v r(||j                 }||                             |           4|j        rd| _        |r.|rd| _        |r| xj        |hz  c_        n| xj        |hz  c_         | j        |f||j        |j         d|}|j        rd|z  }|S )NT)skip_bind_expressionr  literal_bindsr1  render_postcompilez&^(.*)\(__\[POSTCOMPILE_(\S+?)\]\)(.*)$r  z(__[POSTCOMPILE_r2   r"  r   z~~REPL~~r"  z~~]))r  r  r'  Fr  zIBind parameter '%s' conflicts with unique bind parameter of the same namez"Can't reuse bound parameter name 'z' in both 'expanding' (e.g. within an IN expression) and non-expanding contexts.  If this parameter is to receive a list/array value, set 'expanding=True' on it for expressions that aren't IN, otherwise use a different parameter name.a)  Encountered unsupported case when compiling an INSERT or UPDATE statement.  If this is a multi-table UPDATE statement, please provide string-named arguments to the values() method with distinct names; support for multi-table UPDATE statements that target multiple tables for UPDATE is very limitedzbindparam() name 'z' 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_z').)post_compile	expandingbindparam_type)r  dialect_implr  r  bind_expressionr  rJ  rc  rB  r   r/  r1  rC  _truncate_bindparamr?  r   r  intersectionr~  r3   r  _is_crudr?  rW  r  
isoutparamhas_out_parametersrL  rT  rU  r  )r  r  r  rG  rF  r1  rH  r  implrM  wrappedr  ro  rI  r  existingr  r  r  r  r  s                        r   visit_bindparamzSQLCompiler.visit_bindparamW  s    $ $	>..t|<<D( ""&"6"6y"A"A&$,#)-*?"/"K	8K4K$3'9    & , A7 A IIIIIII











G % ,;d;%265<  %	   &|+ 	! D,D)Bd.B 
 +Ai.ALL L 	/$/ 159? C " #slJ''	224:z$'Hy((_/(1(8/$.;;!+ /
 %0==!- / *ACGH   '9+>>>** :>@   & )*< ( Y-?  ".&
 
 
 ".5 5 5 #,-5 5 5	 	 	 8A@
9=!DJt$4 /
 	/#JD$+ / /6T>>bfBHOOI... 	+&*D# 	8! 0+/( 8++	{:+++((YK7((#d#
%)$>	
 

 
 
  	3,C
r   c                    t                      r  r  )r  r  
dbapi_typer  s       r   r  zSQLCompiler.render_bind_cast  s    !###r   c                   |t           ur|}nz|j        l|j        e|                    dd           }|r5|t          j        t          j        fvrt          j        d|j	        f            | j
        t          j        fi |S |j        }|j        r| j        } ||||          \  }}	|	S |                     ||j                  S )Nr  zBound parameter '%s' rendering literal NULL in a SQL expression; comparisons to NULL should not use operators outside of 'is' or 'is not')r  )r.   r  r  r  r!   is_is_notr&   warn_limitedr?  r  r%   r  r  rJ  r  r  r  )
r  r  r  r  r  r  opleepr>  r@  s
             r   r/  z$SQLCompiler.render_literal_bindparam  s      v--(EE&9+=+EVVL$// "Y]I4D$EEE%@ #(	   $t|H$5<<<<<-E 		DJD*.$)A+ + +'I'
 $#,,UINCCCr   r  r  sqltypes.TypeEngine[Any]c                   |8|j         s1|                     t          j                                                  S |                    | j                  }|rL	  ||          S # t          $ r3}t          j	        dt          j        |           d| d          |d}~ww xY wt          j	        dt          j        |           d|           )a  Render 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_noner  r   rL   	_instance_cached_literal_processorr  r  r3   r  sql_util_repr_single_value)r  r  r  	processores        r   r  z SQLCompiler.render_literal_value   s    =!;= << 7 7 9 9:::33DLAA	 		 y'''   &# 3E::# # # # #   ")/66) )!&) )  s   
A# #
B -.BB c                    || j         v r| j         |         S |j        }t          |t          j                  r|                     d|          }|| j         |<   |S )Nr  )r@  r?  r  r   rD   r  )r  r  r  s      r   rN  zSQLCompiler._truncate_bindparamG  sb    ''?9--M	i!:;; 	K22;	JJI &/	"r   ident_classr  rD   c                   ||f| j         v r| j         ||f         S |                    | j                  }t          |          | j        dz
  k    rd| j                            |d          }|dt          | j        dz
  d                   dz   t          |          dd          z   }|dz   | j        |<   n|}|| j         ||f<   |S )N   r   r   r*  r2   )	r  	apply_mapr  r  r  r  r  maxhex)r  ri  r  anonnamecounter	truncnames         r   r  z!SQLCompiler._truncated_identifierT  s     $"666'd(;<<>>$-00x==4,q000.22;BBGS!2Q!6:::;g,,qrr"# 
 5<aKD$[11 I4=k401r   c                    || j         z  S r  r  r  r  s     r   
_anonymizezSQLCompiler._anonymizei  s    dm##r   rI  rJ  escaped_fromrK  Optional[TypeEngine[Any]]accumulate_bind_namesOptional[Set[str]]visited_bindparamc                    ||                     |           ||                    |           |s< j                            |          r" j                             fd|          }	|}|	}|r! j                            ||i           _        |rEd|z  }
|r|
S |8|                     j                  }|j	        r 
                    |||
          }
|
S  j        t          j        u r j        d|iz  }
n j        d|iz  }
|D j        j        r8|                     j                  }|j
        r 
                    |||
          }
|
S )Nc                D    j         |                     d                   S )Nr   )r5  r   )r  r  s    r   r  z.SQLCompiler.bindparam_string.<locals>.<lambda>  s    d8D r   z__[POSTCOMPILE_%s]r  )addr  r4  r  r  rV  r   r  r  render_literal_castr  r  rt  ru  rE  rD  r  )r  r  rI  rJ  rv  rK  rx  rz  r  new_namero  	type_impls   `           r   r  zSQLCompiler.bindparam_stringl  s    !,!%%d+++($$T*** 
	 &--d33 	   266DDDD   $ 	&*&=&C&Ct$' 'D#  	5&-C  
 )*BBL 	 0 P//	3OOCJZ=222/64.@CC#vtn4C &6 ' '>>t|LLI) L++NIsKK
r   c                    |                                 }|                    dd            t          |j        |j                  D ]\  }} |j        | fd|i| d S )Ncte_opts)copyr  r  r  _independent_ctes_optsr  )r  stmtr  local_kwcteopts         r   r  z&SQLCompiler._dispatch_independent_ctes  s~    7799Z&&&"D$?
 
 	C 	CHC #C"4BB#BBBBB	C 	Cr   r  rY   r  ashint	fromhintsOptional[_FromHintsType]visiting_cteOptional[CTE]r  Optional[FromLinter]r  selectable._CTEOptsc                                                      }	|	 j        u sJ ||d<   |j        }
t          |
t          j                  r                     d|
          }
d}d}|                                }|j        p|j        }| j	        v r j	        |         \  }}}||
k    sJ ||
f} j
        |         }|j        r]|j        rt          j        d          ||
f}|rt           j                  nd}||
fx}} j
        |= | j
        |<   ||fz    j	        |<   n5|rt           j                  nd}||
f}| j
        v r j
        |         }nd }|||u }||j        u s||u rd}n||j        u r,|	|= |                                }||u sJ ||u sJ  j	        |= n]t!          |          t!          |          k    s#|j        |j        |                    |          rd}nt          j        d|
z            |s|sd S |j        D|j        }|j        j        }t          |t          j                  r                     d|          }n|}d }|rE| j
        |<   ||fz    j	        |<   | j        vr  j        |fi | |s||	vr|j        rd _         j                            ||
          }|j        rM|j        }d |                    d          D             }|d	d
                     fd|D                       z  z  }|                    dd          du sJ  j        s |j        j         fd|i|S   j        ||j        fi |} |j        j         fddi|}|d|d|dz  }|j         r|d  j        ||j         fi |z   z  }||	|<   |r|r|
|j!        |"                                <   |s|r j                            ||
          S |ri j                            ||          } j        #                    |
          r j        $                    |
          }
| %                    |
          z  }|S  j                            ||
          S d S )Nr  r  TFz6CTE is stated as 'nest_here' in more than one locationr   z5Multiple, unrelated CTEs found with the same name: %rc                &    g | ]\  }}}}}|
|p|S r   r   )r   r*  
proxy_namefallback_label_namer  repeateds         r   r  z)SQLCompiler.visit_cte.<locals>.<listcomp>J  sF     " " "&/$'"
 ,9z" " "r   r'  r   c              3  Z   K   | ]%}j                             |j                   V  &dS )rs  N)r  format_label_namer  )r   identr  s     r   r@  z(SQLCompiler.visit_cte.<locals>.<genexpr>[  sW       " " !& !M;; % <  " " " " " "r   subqueryr  r   z
(r-  r2  )&r  r[  r  r  r   rD   r  _get_reference_ctenestingr]  r\  r3   r  r  r  	_restateshash_is_clone_ofcompare
_cte_alias	visit_cte	recursiver^  r  format_aliasr  _generate_columns_plus_namesr   r  r  _generate_prefixes	_prefixes	_suffixesr  r*   _requires_quotesr  get_render_as_alias_suffix)r  r  r  r  r  r  r  r  r  	self_ctescte_name
is_new_cteembedded_in_current_named_cte_reference_cter  	cte_levelr*  existing_cte_optscte_level_nameexisting_cteold_level_namenew_level_nameexisting_cte_reference_ctepre_alias_ctecte_pre_alias_namer  
col_source
recur_colsprefixesr   s   `                             r   r  zSQLCompiler.visit_cte  s?    ((**	DI%%%%!$~8h 9:: 	E11'8DDH
(-%//11+1!1 T333.2.D/+Iq+ ===='2N2>BL
  $, *1  
 #,X!6/6=C
OOOA	3<h2GG+N;:F'79GK :&~6
 ,39DJI'2N!888#6~F##,8L,H) l,,,|0C0C"

.. l+-9-L-L-N-N*1^CCCC1\AAAA*+EFF
 #YY$|"4"444  ,8+8D  KK55  E "'JJ
 *,.67  
  	j 	4>%NM!$!4,h.GHH %)%?%?/& &"  M!% D	&69D#N35CG 6D">2 DI--}77777% ;&#Y*>*>= /*.D'}11#x@@= !$J
" " )EEdKK" " "J  F		 " " " " *4	" " "   D zz*e44====z ? :3;9 %+/5    7t6S]   .4   H ;CK: %)-3 E Dhhh>>D= C"9$"9S]# #.4# #  D "&	# 	A >5=!#--//2 A"? A}11#x@@@! A}11#7IJJ=11(;; =#}228<<H77AAA}11#x@@@tr   c                `    |j         rd |d<   |j        r | j        |fi |S  | j        |fi |S )Nr  )joins_implicitly_is_lateralvisit_lateralvisit_aliasr  s      r   visit_table_valued_aliasz$SQLCompiler.visit_table_valued_alias  sX    # 	% $B} 	3%4%g44444#4#G22r222r   c                     | j         |fi |S r  )r  r  s      r   visit_table_valued_columnz%SQLCompiler.visit_table_valued_column  s     t //B///r   c
           
     T   
 |r!d
vrj         sJ 
d<   |	rd
vr	d
v r|	
d<   |1|j        u r( j        j         f|||||d
}|r
|s|rd|d}|S x}
d<   |s|rBt          j        t
          j                  r                     dj                  }nj        }|r j        	                    |          S |r|	r||	j
                                        <    j        j         fd|d	
}|rd|d}|                      j        	                    |                    z   }j        r5j        r.|d
d                    
 fdj        D                       z  z  }|r"|v r                     ||         |          }|S  j        j         fd|i
S )Nr  r  )r  r  iscrudr  lateralenclosing_aliasr,  r-  r  r  T)r  r  r'  r   c              3     K   | ]N}j                             |j                  j        r d  j        j        j        |j        fi z  ndV  OdS ) %sr  N)r  r  r  _render_derived_w_typesr  r  r  r  )r   r  r  r  r  s     r   r@  z*SQLCompiler.visit_alias.<locals>.<genexpr>  s           !M//999 $)#@	!("M$,"E"M$'H#" #"06#" #"!" !"
 &(!(	     r   r  )r  r  r  r  r  r   rD   r  r  r  r  r*   r  _supports_derived_columns_render_derivedr   r  format_from_hint_text)r  r  r  r  r  r  r  r  r  r  r  r   
alias_namero  s   ``        `   r   r  zSQLCompiler.visit_alias  s     	<"&00 ((((.3*+
 <)77'6110;,-&?+Be+K+K4EM4	# %	 	 	 	E  *V *w *"'%%)L:??Of%67 	(V 	(%*h&?@@ (!77LL

"Z
 -	=--eZ@@@ +	 B7A!%//"3"344EM4!7 6< E  * *"'%%)$99**5*==  C . 53H vII       $)7     $  Ui//00	% 0&  J 45=3 %)/  r   c                (    d|d<    | j         |fi |S )NTr  r  )r  r  r  s      r   visit_subqueryzSQLCompiler.visit_subquery  s&    :t//B///r   c                .    d|d<   d | j         |fi |z  S )NTr  z
LATERAL %sr  )r  lateral_r  s      r   r  zSQLCompiler.visit_lateral  s,    9.d.x>>2>>>>r   c                     | j         |fddi|d |                                j        | fi |}|j        |d |j        j        | fi |z  z  }|S )Nr  Tz TABLESAMPLE z REPEATABLE (%s))r  _get_methodr  seed)r  tablesampler  r  r  s        r   visit_tablesamplezSQLCompiler.visit_tablesample  s    D[<<<<<<<8K##%%8DDDDD

 '&3 3D??B?? D r   c                                          dj                   d                     fdj        D                       }d| S )NrG  r   c           	   3     K   | ]=}|D ]8} j         t          j        |d j        i                                fi V  9>dS )r  N)r  r   r   _column_typesr  )r   chunkelemr  r  r  s      r   r@  z-SQLCompiler._render_values.<locals>.<genexpr>  s       	
 	
 	
 	
  DL26!/ *,,  	 	
 	
 	
 	
 	
 	
 	
r   r  )
setdefaultrG  r   _data)r  r  r  tupless   ``` r   _render_valueszSQLCompiler._render_values  ss    
ow'<=== 	
 	
 	
 	
 	
 	
 !	
 	
 	
 	
 	
 "!!!r   c           
           j         |fi }|j        rd }nBt          |j        t          j                  r                     d|j                  }n|j        }|j        rd}nd}|r|r ||nd|j        |	                                <   |rddd<   |d|d 
                     j                            |                    d	d
                     fd|j        D                       d}n|d|d}|S )Nr  zLATERAL r  z(unnamed VALUES element)Fr  r,  r-   (r   c              3  4   K   | ]} |j         fi V  d S r  r  r  s     r   r@  z+SQLCompiler.visit_values.<locals>.<genexpr>=  sL       " " ! 1A0<<<<" " " " " "r   )r  _unnamedr  r  r   rD   r  r  r  r*   r  r  r  r   columns)r  r  r  r  r  rw  r  r  s   `   `   r   visit_valueszSQLCompiler.visit_values!  sg   D..2.. 	 DDh&?@@ 	 --hEEDD<D 	 GGG 	,  ,DD2L !'"3"3"5"56  ,&+?#GGAA33DM4G4G4M4MNNNN		 " " " " "%,_" " "    
 !(+r   c                &    d | j         |fi | dS r  )r  r  s      r   visit_scalar_valueszSQLCompiler.visit_scalar_valuesG  s)    8&4&w55"558888r   c                    d|z   S )Nr   r   )r  alias_name_texts     r   r  z&SQLCompiler.get_render_as_alias_suffixJ  s    ''r   r  r
  r  r  c                    |sJ ||dk    rd| _         d| _        |j        rt          j        d          | j                            t          ||||                     d S )N*FTzxMost backends don't support SELECTing from a tuple() object.  If this is an ORM query, consider using the Bundle object.)rI  rH  r  r3   r  r  r  r  r  s        r   r  zSQLCompiler._add_to_result_mapM  s     ?gnn$)D!#'D  	"4  
 	##wgu==	
 	
 	
 	
 	
r   c                .     | j         d||d|i n|fi |S )aL  Render 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

        NF_label_select_column)r  r  r   r  column_clause_argsr  s         r   _label_returning_columnz#SQLCompiler._label_returning_columnf  sC     )t($,BB2D
 
 
 
 	
r   c                   j                             | j                  }|j        r|s|r|                              }n}|r| j        }|
r|fd}n|ur|fd}nd}|	s
J d            t          t          j                  r'|urt          |j
        j        f          }n|}n|r&|
J d            t          |||j        f          }n|urd}nt          t          j                  r|oj         oj        du}ngt          t          j                  rd}nJt          t          j                  r
j        p|}n&t          t          j                  s
j        d}nd}|rQ|s|
rJ j        }t          |t          j                  st          j        |          n|}t          |||f          }n|}|                    |	||	            |j        | fi |S )
z.produce labeled columns present in a select().c                &     | || f|           d S r  r   )r  r  r
  r  r  s       r   r  z;SQLCompiler._label_select_column.<locals>.add_to_result_map  s"    &&wwj%HHHHHr   c                ,     | |f|z   |           d S r  r   )r  r  r
  r  r  r   s       r   r  z;SQLCompiler._label_select_column.<locals>.add_to_result_map  s2    &&y7':E    r   NzX_label_select_column is only relevant within the columns clause of a SELECT or RETURNING)r  z*proxy_name is required if 'name' is passedTF)r  r  r  )r  rL  r  _has_column_expressioncolumn_expressionr  r  r   rK   r  r  r  r  rH   r  r   
TextClauseUnaryExpressionwraps_column_expressionNamedColumn_non_anon_label_anon_name_labelrD   r  r  )r  r   r   r  r  r  r  r  r  r  column_is_repeatedneed_column_expressionsr  rS  col_exprr  result_exprrender_with_labelr  s     `               @r   r  z SQLCompiler._label_select_column{  s1     {''55& 	#	':	 --f55HHH 	%
 !% 7
 " %6"I I I I I I
 ''%6"      !% % 	
 	
:	
 	
 	
 fhn-- \	'v%%+fkfn5F   ' T	' &&; '&& ( $  KK& v%% %)!!FH$9:: *  1"--1D0 "!
 FH$788 *$)!!FH$<== *$*$B$Lf!!
 vx';<<	* *2$(!!$)!  '* B
  2111*0*A' &+X-F -H-.ABBB - $ ,1j]   '!!"7/' 	" 	
 	
 	

 .{-dII6HIIIr   c                F    |                      ||          }|r|d|z   z  }|S r,  )get_from_hint_text)r  r  r   hintr  hinttexts         r   r  z!SQLCompiler.format_from_hint_text  s2    **5$77 	&sX~%Gr   c                    d S r  r   )r  byfromss     r   get_select_hint_textz SQLCompiler.get_select_hint_text%      tr   r   rZ   r  c                    d S r  r   r  r   r  s      r   r  zSQLCompiler.get_from_hint_text(  s	     tr   c                    d S r  r   r
  s      r   get_crud_hint_textzSQLCompiler.get_crud_hint_text-  r  r   c                ,    d                     |          S r,  r  )r  
hint_textss     r   get_statement_hint_textz#SQLCompiler.get_statement_hint_text0  s    xx
###r   r*  r  r'  r&  c                   | j          }|r| j        n| j         d         }|                    ||           }|d         }|d         }	|r-|s+|                    |                    |	          d          }
n|                    ||	          }
|
S )Nr  r'  r&  r   explicit_correlate_fromsimplicit_correlate_froms)r  r  r  _get_display_froms
difference)r  select_stmtr  r  r  r   r  r+  r'  r&  r  s              r   _display_froms_for_selectz%SQLCompiler._display_froms_for_select:  s     z>-5I))4:b>#::;MM 12^, 	' 	!44)8)C)C * * *,	 5  EE "44)8)5 5  E r   translate_select_structurec	           
         |
J d            d|	d<    j          fi |	}
|
j        |	d<   |
j         j         }|r j        s|
 _        |d up|} j        r0  j        fdi|	}|ur|
}}| j          fi |	}
|
j        |r j        n j        d         }|p+|                    dd          p|                    dd          x|rdsd	|	v r|	d	=                      |
|||          }|		                                
                    ddd
           d}j        r#                               \  }}|r||dz   z  }nd }j        r                     |	           j        r|  j        j        fi |	z  }|  j        fi |	z  }d  fd|
j        D             D             }rU|St'          t)          d |
j        D             d |j        D                                 fd j        D              _                             ||
|||||	          }j        r0 fdj        D             }|r|d                     |          z   z  } j        r5|r|r1|st5           j                  nd }                     |          |z   }j        r|d  j        j        fi |	z   z  } j                            d           |S )NzpSQLAlchemy 1.4 requires use of the translate_select_structure hook for structural translations of SELECT objectsFr  r  r  r  r.  r-  r  )r  r  zSELECT r2  c                    g | ]}||S r  r   r  s     r   r  z,SQLCompiler.visit_select.<locals>.<listcomp>  s)     
 
 
* }- , }}r   c                Z    g | ]'\  }}}}}                     
|	|||| 
  
        (S ))r  r  r  r  r  r  )r   r  r  r  r   r  r  r  r  r  r  r  s         r   r  z,SQLCompiler.visit_select.<locals>.<listcomp>  sm       '# ))'&)(;'/,C *    r   c                    g | ]
\  }}}}}|S r   r   r   r?  r  r  r  r  s         r   r  z,SQLCompiler.visit_select.<locals>.<listcomp>  9     	 	 	&/ $ 	 	 	r   c                    g | ]
\  }}}}}|S r   r   r  s         r   r  z,SQLCompiler.visit_select.<locals>.<listcomp>  r  r   c           
     p    g | ]2\  }}}}t          ||t          fd |D                       |          3S )c              3  D   K   | ]}                     ||          V  d S r  r  )r   or|  s     r   r@  z6SQLCompiler.visit_select.<locals>.<listcomp>.<genexpr>  s1      $F$FQY]]1a%8%8$F$F$F$F$F$Fr   )r  rB  )r   r?  r  r  r  r|  s        r   r  z,SQLCompiler.visit_select.<locals>.<listcomp>  sc     $ $ $ *CsE #u$F$F$F$F#$F$F$FFF $ $ $r   c                :    g | ]\  }}|d j         j        fv |S r  r  r  )r   dialect_namehtr  s      r   r  z,SQLCompiler.visit_select.<locals>.<listcomp>  s<       &\2C):#;;; ;;;r   r  )r  _ambiguous_table_name_mapr5  r  r+  r  r  r  _setup_select_stackr  r  _hints_setup_select_hintsr  r  r  r  get_select_precolumnscolumns_plus_namesr  r  r  _compose_select_body_statement_hintsr  r[  r  r  r  r  )r  r  r  insert_intor  r  select_wraps_forr  r  r  r+  r   is_embedded_selectnew_select_stmtcompile_state_wraps_forr  r  r  	hint_textbyfrominner_columnsper_dialectr  r  r  r  r|  s   ```                    @@@@r   visit_selectzSQLCompiler.visit_select^  s	     ''- ('' +0&'::
 
!'
 
 3 	)* $-z> 	/D. 	/!.D+47F;
 * 	6=d= $*.4 O k11*7'#. - B B! !)/! ! ,5-5I))4:b>  >yy7??>yy5u==	
5  	("'
 # 	,':f'D'D*+((vw
 
 $[[]]!!$)EJJ	
 	
 	
  	 $ 8 8 E EIv (	C'F( 	A++K@@@  	+D+[2 6<  D 	**;AA&AAA
 
        & #5'  
 
 
4  "	#3#? 	 	 +=	 	 		 	 5G	 	 	  I2$ $ $ $ .2-A	$ $ $D  ((	
 	
 ' 	H   *5*F  K
  Hd::;GGGG 9 	O0 	OH 	O3;EC
OOOM***GG$ND  	C1$1[2 6<   D 	
rr   r   r0  Tuple[str, _FromHintsType]c                      fd|j                                         D             }                     |          }||fS )Nc           	     v    i | ]5\  \  }}}|d j         j        fv ||d|                    d          iz  6S )r  r  T)r  r  r  r  )r   r  r  r  r  s       r   rq  z3SQLCompiler._setup_select_hints.<locals>.<dictcomp>.  sh     
 
 
 + (3 1222 8u//T/BBCD 322r   )r*  r  r  )r  r   r6  r5  s   `   r   r+  zSQLCompiler._setup_select_hints+  s[    
 
 
 
 /5m.A.A.C.C
 
 
 --f55	&  r   c           	     .   |d         }|d         }|dk    r||d<   nf|rd|d         }	t          |	j                  }
t          |j                  |
k    r0t          j        dd|
|dz   t          |j                  fz            |r-|s+|                    |                    |          d          }n|                    ||          }t          t          |           }|	                    |          }||||d	}| j
                            |           |S )
Nr'  r&  r   r/  z}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %dr   r   r  )r&  r'  r$   r+  )r  r  r-  r3   r  r  r  r   r+   r   r  r  )r  r   r+  r  r  r  r  r'  r&  r/  numcolsr  new_correlate_fromsall_correlate_fromsr  s                  r   r)  zSQLCompiler._setup_select_stack7  su      12^,Q &E* 	Z(H(899G=344??&!
 &*F899			    	' 	!44)8)C)C * * *,	 5  EE "44)8)5 5  E
 "-"788177HH 02 *	*
 *
	 	
)$$$r   c	                j    |d                     |          z  } j        t          z  r5t          i t	                                 j        t
          z  }	|r _        nd d}	|s|                                }|r[|dz  }|j        r(|d                      fd|D                       z  }n>|d                      fd|D                       z  }n| 	                                z  }|j
        r  j        |j
        fdi}
|
r|d|
z   z  }|	rJ                                  |j        r|  j        |fi z  }|j        r  j        |j        fi }
|
r|d|
z   z  }|j        r|  j        |fi z  }|j        r|  j        |fi z  }|j        |  j        |fi z  }|S )	Nr   Fz 
FROM c           	     4    g | ]} |j         fd dS )T)r  r  r  r  )r   fr6  r  r  r  s     r   r  z4SQLCompiler._compose_select_body.<locals>.<listcomp>  sZ     	 	 	  -, #'&,(3	 
 % 	 	 	r   c                2    g | ]} |j         fd dS )Tr  r  r  )r   rD  r  r  r  s     r   r  z4SQLCompiler._compose_select_body.<locals>.<listcomp>  sW         -, #'(3  %	   r   r  z 
WHERE z	 
HAVING )r   ri  r{  r  r   r|  r  rstripr*  ry  _where_criteriar$  r  _group_by_clausesr  _having_criteria_order_by_clausesr  r  r  _for_update_argfor_update_clause)r  r  r   r+  r7  r  r6  r   r  warn_lintingtr  s   `     ` `  @r   r.  z SQLCompiler._compose_select_bodyk  s    			-(((<44 	!$R//K<,6L /#. K L  	!;;==D 	(JD} 			 	 	 	 	 	 	 "'	 	 	   		      "'  
 
 
 D%%'''D! 	(11& 4?CI A  (a' 	***# 	;(D(::6:::D" 	)11' +1 A  )q((# 	;(D(::6:::D* 	=*D*6<<V<<<D!-*D*6<<V<<<Dr   c                \     d                      fd|D                       }|r|dz  }|S )Nr2  c              3  b   K   | ])\  }}|d v s|j         j        k     |j        fi V  *dS ))Nr  Nr=  )r   prefixr&  r  r  s      r   r@  z1SQLCompiler._generate_prefixes.<locals>.<genexpr>  sb       
 
${**ldl>O.O.O &F%d11b11.O.O.O.O
 
r   r  )r  r  r  r  r:  s   `  ` r   r  zSQLCompiler._generate_prefixes  sZ     
 
 
 
 
(0
 
 
 
 

  	cMFr   c                0   | j         sdS |r|dk    rt          j                    }t          | j                                                   D ]Y}| j        |                                         \  }}}|j        p|j        }||k    p
|o||dz   k    }	|r|	sI| j         |         ||<   Zn| j         }|sdS t          d |D                       }
| 	                    |
          dz   }|d
                    d |                                D                       z  }|dz  }|ry|dk    rst          |                                          D ]Q}| j        |                                         \  }}}| j         |= | j        ||f= | j        |                                = R|S )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.
        r  r   c                    g | ]	}|j         
S r   )r  )r   r  s     r   r  z2SQLCompiler._render_cte_clause.<locals>.<listcomp>  s    <<<cm<<<r   r2  , 
c                    g | ]}|S r   r   )r   txts     r   r  z2SQLCompiler._render_cte_clause.<locals>.<listcomp>  s     > > > > > >r   z
 )r[  r&   r  r  keysr]  r  r  rw   get_cte_preambler   r  r\  )r  r  r  r[  r  r  r  r  r  is_rendered_levelr^  cte_texts               r   r  zSQLCompiler._render_cte_clause  s    y 	2  	]Q..#%%DDINN,,-- + +040F**,,1-	8X +9)9$-$> %+N	]Q=N0N "   $5  IcNS		+ 9D 	2<<t<<<==((883>FKK > > > > >???E 	E]Q..DIIKK(( E E040F**,,1-	8X IcN+Y,AB*3+A+A+C+CDDr   c                    |rdS dS )NzWITH RECURSIVEWITHr   )r  r  s     r   rY  zSQLCompiler.get_cte_preamble	  s     	##6r   c                R    |j         rt          j        dd           |j        rdndS )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.z1.4versionr   r  )_distinct_onr&   warn_deprecated	_distinctr  r   r  s      r   r,  z!SQLCompiler.get_select_precolumns  sG    
  	 3
     %.6{{B6r   c                f     | j         |j        t          t          j                 fi |}|rd|z   S dS )z5allow dialects to customize how GROUP BY is rendered.z
 GROUP BY r  )r  rI  r  r!   comma_op)r  r   r  group_bys       r   r  zSQLCompiler.group_by_clause  sO     140$i	0B&C
 
GI
 
  	(**2r   c                f     | j         |j        t          t          j                 fi |}|rd|z   S dS )z5allow dialects to customize how ORDER BY is rendered.z
 ORDER BY r  )r  rK  r  r!   rf  )r  r   r  rT  s       r   r  zSQLCompiler.order_by_clause*  sO     140$i	0B&C
 
GI
 
  	(**2r   c                    dS )Nz FOR UPDATEr   rd  s      r   rM  zSQLCompiler.for_update_clause6  s    }r   r  rA   returning_colsSequence[_ColumnsClauseElement]r  c                     fd                     dt          j        |                    D             }dd                    |          z   S )Nc           
     F    g | ]\  }}}}} j         	|f||||d S ))r  r  r  r  )r  )
r   r  r  r  r   r  r  r  r  r  s
         r   r  z0SQLCompiler.returning_clause.<locals>.<listcomp>A  st     
 
 
# )D(#	 %8#+%	 	 	 	
 
 
r   T)cols
RETURNING r   )r  r   _select_iterablesr   r  r  rj  r  r  r  s   `` `` r   returning_clausezSQLCompiler.returning_clause9  s}    
 
 
 
 
 
 
" 2241.AA 3  #
 
 
, dii0000r   c                    d}|j         |d | j        |j         fi |z   z  }|j        %|j         |dz  }|d | j        |j        fi |z   z  }|S )Nr  z
 LIMIT z

 LIMIT -1z OFFSET )_limit_clauser  _offset_clause)r  r   r  r  s       r   r  zSQLCompiler.limit_clauseY  s}    +K,$,v/C"J"Jr"J"JJJD ,#+%Jf.C!J!Jr!J!JJJDr   c                   ||j         }|j        }nddd}d}|j        I|j        }|r)|                    |          r|                                } | j        |fi |}	|d|	z  z  }n|r|dz  }|X|r)|                    |          r|                                }|d | j        |fi ||d         rdndd	|d
         rdndz  }|S )NF)r  	with_tiesr  z
 OFFSET %s ROWSz
 OFFSET 0 ROWSz
 FETCH FIRST r  z PERCENTz ROWS rw  z	WITH TIESONLY)r  _fetch_clause_optionsru  _simple_int_clauserender_literal_executer  )
r  r   r  require_offset"use_literal_execute_for_simple_intr  fetch_clause_optionsr  offset_clause
offset_strs
             r   r  zSQLCompiler.fetch_clausec  sI    !/L#)#?  /45#I#I  ,"1M2G--m<<G !. D D F F%m::r::J'*44DD 	'&&D#2E--l;;E  ,BBDDD\00R00029=E

2EE3K@LfL D
 r   c
                H   |r|j         |j        |<   |s|r| j                            |          }|r@|r>| j                            |          dz   | j                            |j                  z   }n| j                            |j                  }|		|	j        |ur_|s]|r[|j        |v rR|                     d||j                           }|| 	                    | j        
                    d |                    z   }|r"||v r|                     ||||         |          }|S dS )Nr/  r  r  )fullnamer  r  r  r  r  r  r  r  r  r  r  )r  r   r  r  r  r  
use_schemar  r  r  r  r  ro  	anon_names                 r   visit_tablezSQLCompiler.visit_table  sx     	6',~Ke$ #	V #	#}>>uEE . M../?@@m))%*556  m))%*55 (/*2%??, @ 1 @ 
&>>> $ : :!9%*!E! !I  ? ?224CC! ! C  Ui//00	% 0&  J2r   c                z   |r[|j                             t          j        t	          |j        j                  t	          |j        j                                       |j        rd}n|j	        rd}nd} |j        j
        | fd|d||z    |j        j
        | fd|d|z   dz    |j        j
        | fd|i|z   S )Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN TrF   ON r  )r  r  r  r  r*   r   r+   r   r   isouterr  onclause)r  r   r  r  r  	join_types         r   
visit_joinzSQLCompiler.visit_join  s-    	$$!di566dj677    9 	!+II\ 	!+II I(DI(!{ >D   ,dj+!{ >D 	  /dm. "-17 	
r   c                      fd|j                                         D             }|j        |v r(                     ||j        ||j                 d          }||fS )Nc                B    i | ]\  \  }}}|d j         j        fv ||S r$  r%  )r   r   r  r5  r  s       r   rq  z1SQLCompiler._setup_crud_hints.<locals>.<dictcomp>  sC     
 
 
+ )3 1222 9222r   T)r*  r  r   r  )r  r  
table_textdialect_hintss   `   r   _setup_crud_hintszSQLCompiler._setup_crud_hints  s|    
 
 
 
/3{/@/@/B/B
 
 

 :&&33DJdj(A4 J j((r   rT   rR  c                D   | j         j        }|j        }|j        }|dS |j        r!| j                            |j        d          }n | j                            |j        d          }||z  r|S |j	        r+t          j        d|d          d| j         j         d          dS )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.

        Nr   zColumn 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_lookupr  default_characterization _sentinel_col_non_autoinc_lookupis_explicitr3   rA  r  )r  r   sentinel_optssentinel_characteristics	sent_colsbitmasks         r   _get_sentinel_column_for_tablez*SQLCompiler._get_sentinel_column_for_table  s     G#(#I ,4	4#. 	7;;(A1 GG ;??(A1 G 7" 	#/ 	 )
@)A, 
@ 
@<$
@ 
@ 
@   tr   rg   compiled_parameters%List[_MutableCoreSingleExecuteParams]generic_setinputsizesr\  
batch_sizerN  rP  r  r   Iterator[_InsertManyValuesBatch]c              #     123456789:K    j         }|J |j        sd 1nt          j        |j         1t	                    }	|j        r j        j        sd}
d}n, j        j        r|r j	        r|j
        |j        rd}
d}nd}
d}|
r`t          t          dt          |                    d          D ]1\  }\  9}t          |99g1r 1|          gng d||	||
  
        V  2d S |r!t!          j         j        j        |          :nd :|j        }:r :|          }d| d}|                    |d          } j        j        }|rCt	           j                  }t	          |j                  }||z
  }t3          |||z
  |z            }t          d	t5                              }t          d	t5          |                    }d }d}|	|z  |	|z  rdnd
z   }|j        }|J :r:fd|D             }d
x67 j        s j        r j        4ni 4t;          d
                   }4 fd3|j        rd}nd}dd                    3fd|D                        | d}|                     4fd|D                       }fd|!                    |          D             }d5nd}t;                      }i }|j        rd| d5nd| d5t;                      2|j        D ]}2"                    |d                    2r_ j#        }|J 2fdt          |          D             } t3          |           6tI          |           dz   7t	          |           76z
  k    sJ  j%        r2tM          j'         j(                  }!tM          j)        |! dd5          5|r|d
|         }"|d
|         }#g |d
|<   g |d
|<   |r|}$nt	          |"          }$r%d fdtU          |$          D             D             } j        r8|j+        }%|%t	          |"d
                   k    rdx}&}'|"}(n/|"d
         d 6         }&|"d
         7d          }'67fd|"D             }(|j        r7d                    5fdt          |"          D                       d d         })n5|$z  d d         }) j%        rE|%d
k    r?|'rJ 6dz   }*|%|$z  |*z   }+tY           fdtU          |*|+          D                       },|)|,z  })|                    d|)          }-tY          tZ          j.        /                    |(                    }.|&|.z   |'z   }.ng }/|0                                }.t          |"          D ]\  89|                    d tc          8                    }0|j        r#|0                    d!tc          8                    }0|/2                    |0           |."                    89fd"|D                        |                    dd                    |/                    }-t          |-|.||"1r1fd#|#D             ng |$|||d
  
        V  |dz  }|d S d S )$NTFzKSequence[Tuple[_DBAPISingleExecuteParams, _MutableCoreSingleExecuteParams]]r   r  r,  r-  __EXECMANY_TOKEN__zList[Sequence[Any]]r   c                8    g | ]\  }}}}|| |          |fS r   r   )r   r  r?  r(  strsts        r   r  zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<listcomp>  sB     " " "&CdB c33t99b)" " "r   c                    | D ]E}                     ||          }|                    j        d|iz  j        d| diz            }F|S )Nr  __EXECMANY_INDEX__)r  r  rD  )rX  	formattedr?  rV  r  s      r   apply_placeholderszISQLCompiler._deliver_insertmanyvalues_batches.<locals>.apply_placeholders  sq      C,00c::C ) 1 1)VSM9)!c#=#=#=>?! !II
 ! r   z, _IMV_VALUES_COUNTERr  r   c              3  :   K   | ]\  }}}} ||          V  d S r  r   )r   r*  r  	bind_keysr  s       r   r@  z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>  sL       6 6.Aq)Y #"9i886 6 6 6 6 6r   c              3  X   K   | ]$\  }}}}|D ]}                     ||          V  %d S r  r  )r   r*  r  r?  rV  s       r   r@  z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>  sf       4 4&Aq!Y$4 4  #&&sC004 4 4 4 4 4 4r   c                .    i | ]}|d          |         S )r   r   )r   r?  r6  s     r   rq  zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<dictcomp>  s4        Z]3'  r   z, _IMV_VALUES_COUNTER), z), r"  c                "    h | ]\  }}|v 	|S r   r   )r   rl  r  all_names_we_will_expands      r   r   z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<setcomp>  s3     ( ( (!T777 777r   z\d+r  c                     g | ]\  }}}|||fS r   r   )r   new_keylen_r  s       r   r  zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<listcomp>.  s5     + + +*s dC(+ + +r   c              3  >   K   | ]}D ]\  }}}| d | ||fV  dS )r*  Nr   )r   r  r?  r  r  r  s        r   r@  z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>0  si       / /!.C/ / +Cs  ))%))45/ / / / / / /r   r   c              3  ,   K   | ]}|         V  d S r  r   )r   rp  expand_pos_lower_indexexpand_pos_upper_indexs     r   r@  z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>E  sC       & & 01GGH& & & & & &r   c              3  d   K   | ]*\  }}                     d t          |                    V  +dS )_IMV_VALUES_COUNTERN)r  r   )r   r  r*  executemany_values_w_commas      r   r@  z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>L  sX           !%1 7>> 5s1vv            r   c              3  .   K   | ]}j          | V  d S r  r-  r   r  r  s     r   r@  z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>i  sE       & &  >CCC& & & & & &r   EXECMANY_INDEX__r  c                ,    i | ]}| d  |         S )__r   )r   r?  r  params     r   rq  zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<dictcomp>  s)    NNNsC1c
NNNr   c                &    g | ]} |          S r   r   )r   r  _sentinel_from_paramss     r   r  zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<listcomp>  s%    HHH2**2..HHHr   )3rR  rU  rP  rn  r  rJ  r  supports_default_metavaluesupports_multivalues_insertr  rS  rQ  r  r   r  rY  	functoolspartialr  r  rK  r  insertmanyvalues_max_parametersr@  rM  minr  rt  rV  r   rW  r   rO  r  r  r:  rm  rK  rc  rd  rF  r  rangerO  rB  r  r  from_iterabler  r   r  );r  r5  r6  r  r  r  rP  r  imv	lenparamsuse_row_at_a_time
downgradedra  compiled_paramimv_single_values_exprexecutemany_values
max_paramstotal_num_of_paramsnum_params_per_batchnum_params_outside_of_batchbatchescompiled_batchesr]  rb  rM  all_keysimv_values_counterformatted_values_clausekeys_to_replacebase_parametersr  r:  all_expand_positionsescapedr^  compiled_batchr`  num_ins_paramsextra_params_leftextra_params_rightbatch_iteratorexpanded_values_stringr  ry   r  rZ  r[  replaced_values_clausesfmvr  r  r  rV  r  r  r  r  r  r  s;   ` ` `                                            @@@@@@@@@@r   !_deliver_insertmanyvalues_batchesz-SQLCompiler._deliver_insertmanyvalues_batchesI  s
      $& 	$(!!$,$7(%! 
OO	 	t|'N 	 !%JJ9 	#	$	 %-1N-
 !%JJ %J 	5>a
$788  6 6  115. -)G 1 ..~>>??+       F 	#7%9  CC
 C!$!7 	A%(S)?%@%@":!7:::%%&8:NOO	 \A
 	"%do"6"6#&s'=#>#> #&:: ( "==+, J ,d:.>.>??!4(;#<#<
 
 HL!Z/Z'.AAQ
 !3!--- 	" " " "*<" " " ;<;!7 M	& (%)%<""%'":a=))H! ! ! ! ! ! ' (%<""%'"''DII 6 6 6 62D6 6 6 - - '' "'' '' ''#
 '33 4 4 4 4*<4 4 4  O
   #..??  O *,&&&(#!eeO O' MH.HHH +* .M1G-L-L-L*14$. 9 9(//Q8888 ( "."...( ( ( (%.{%;%;( ( ($
 *--A)B)B&),-A)B)BQ)F&,---0FFG G G G " )D$GHH-/V$$$d,F. .*  D	AjL)E-a
l;N$&GAjL!-/Qz\* 0%/""%(ZZ"$ + +/ / / /%*+=%>%>/ / /+ + +'  X!$!B "Sq]]22=??%(:%*NN(-a1H2H1H(I%).q2H2I2I)J&& & & & &!&& & &N
 +          )2%(8(8	        rc.** 46HHrc.* & P>A+=+=  21112Q6E(,>?%GC !& & & & &!&uc!2!2& & & ! !I .Di-O*%.%6%6(*@& &" ',O11.AA' '#
 &)*() $# +-'&5&:&:&<&<# )% 0 0 
 
HAu199*CFF C / I!kk*?QHH+223777'..NNNNNoNNN    &/%6%6(II566& &"
 )"#' -HHHHHHHH"'      MHI  D	 D	 D	 D	 D	r   c                x     |j         | fi |}|j        }|||d<   d}n j         }|r#d _         j        s| _         j        s| _         j                            t                      t                      |d           d}d } j        r|g }t          j
         |||fd|i|} j        r7|5t          |          } j        r j         xj        |z  c_        n| _        |j        }	|	sE j        j        s9 j        j        s- j        j        s!t'          j        d j        j        z            |j        r^ j        j        s!t'          j        d j        j        z             j        s|j        r|j        rt'          j        d	          |j        }	n|j        }	 j        }
 j        j        }d
}|j        r|  j        ||j        fi |z  }|dz  }|
                    |j                  }|j         r !                    ||          \  }}|j"        r #                    ||           ||z  }|	s|s%|dd$                    d |	D                       z  z  }|j%        }d }d }d} j        p|j        }|r|j&        }||sJ d |	D             }g }|D ]B}||vrd } n9 '                    |          }|||         vrd } n|                    |           C|3 j        j(        tR          j*        z  rd}n|d         j+        r
J d            tY          |          tY          |          z   } -                    |||          } j.        r|d|z   z  }nd }|j/        w  j0         j        d         d         fddi|} j1        rE j        j2        r9|st           j                  nd }|d 3                    |d          |z  }n|d|z  z  }n|	s]|r[|dz  }|rRti          d j        j5        tm          d|	          ||j        |j7        d u||rt          |          nd|	  	         _8        nn|j        r,|dd$                    d |j9        D                       z  }n;d$                    d tm          d|	          D                       }|r|r j        j(        tR          j:        z  r|j;        sd} j        j(        tR          j<        z  }d$                    d t{          |	          D                       }|r/d$                     fdt{          |	          D                       }n|}|d | d!| d"| d#z  }nd}|d$| d%z  }ti          d|tm          d|	          ||j        |j7        d u||rt          |          nd|||&           _8        n	|d$| d%z  }|j7          j0        |j7        fi |}|r|d|z   z  }|r j.        s|d|z   z  } j1        r> j        j2        s2|st           j                  nd } 3                    |d          |z   } j        >                    d           |S )'Nr  FTr  r   rz  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.zcRETURNING cannot be determinstically sorted when using an INSERT which includes multi-row values().zINSERT zINTO  (%s)r   c                    g | ]	\  }}}}|
S r   r   )r   r*  r(  s      r   r  z,SQLCompiler.visit_insert.<locals>.<listcomp>  s     >>>-!T1a>>>r   c                    i | ]
\  }}}}||S r   r   )r   r  r*  param_namess       r   rq  z,SQLCompiler.visit_insert.<locals>.<dictcomp>3  s2     " " ".Q; " " "r   zTsentinel selection rules should have prevented us from getting here for this dialectr  r2  r  r1  r0  r  r  z DEFAULT VALUESrL  )rP  rQ  rS  rT  rV  z VALUES c              3  Z   K   | ]&}d d                     d |D                       z  V  'dS )r'  r   c              3  $   K   | ]\  }}}}|V  d S r  r   r   r*  r  s      r   r@  z5SQLCompiler.visit_insert.<locals>.<genexpr>.<genexpr>  s*       L L>1a L L L L L Lr   Nr  )r   crud_param_sets     r   r@  z+SQLCompiler.visit_insert.<locals>.<genexpr>  s\         ' yy L L^ L L LLLN     r   c                    g | ]	\  }}}}|
S r   r   r  s      r   r  z,SQLCompiler.visit_insert.<locals>.<listcomp>  s0       &1eQ   r   c              3  &   K   | ]\  }}d | V  dS pNr   )r   r  r*  s      r   r@  z+SQLCompiler.visit_insert.<locals>.<genexpr>  s=       ) )$(AqA) ) ) ) ) )r   c              3     K   | ]E\  }^}}                     |j        |j                            j                  d |           V  FdS r  )r  r  r  r  )r   r  r  r*  r  s       r   r@  z+SQLCompiler.visit_insert.<locals>.<genexpr>  st       4 4 !-9C! !11 # # @ @ N N 'A 4 4 4 4 4 4r   z SELECT z FROM (VALUES (z)) AS imp_sen(z#, sen_counter) ORDER BY sen_counterz	 VALUES (r-  )rJ  rK  rM  rO  rP  rQ  rS  rT  rU  rV  rW  )?r  r5  r  r7  r  r+  r  r   rt  r   _get_crud_paramsr  rK  rX  single_paramsr  supports_default_valuesr  supports_empty_insertr3   r  r  _has_multi_parametersr  r=  
_returning_sort_by_parameter_orderr  r  r  format_tabler   r*  r  r  r  r   use_insertmanyvaluesuse_sentinel_columnsrM  r  rf  ro  _insert_sentinelr  rr  rA  r   r  r[  cte_follows_insertr  rI  default_metavalue_tokenr   _post_values_clauserR  all_multi_paramsrq  is_default_metavalue_onlyrr  r  r  ) r  insert_stmtrz  r  r  r+  r   counted_bindparamcrud_params_structcrud_params_singler  r  r  r  r*  r  named_sentinel_paramsadd_sentinel_colsrV  rj  _params_by_col_add_sentinel_col
param_namerr  select_textr  r  embed_sentinel_valuerender_bind_castscolnamescolnames_w_castpost_values_clauses    `                               r   visit_insertzSQLCompiler.visit_insert  s	    ;:
 
!#
 
 $-#!-B~HH:~H 	3 DM) 7)6&% 3%2"
#&55 #) 	
 	
 	
  ! ? 	#|3
 !#!2	
 

 0
 
 
 ? 	?0< #$5 6 6" ?)5**.??***->D*/= #
	L8
	 L;
	 L6	
	 "!\./   . 	B<; &137<3DE   '+6+A6 &I   "4!A!3!A="&,"F  	+D+[2 68  D 	**;+<==
 	L 22;
KKMAz( 	=++K<<<
 	%< 	Gdii>>+=>>>   D  2F9= !0JK4J H	$ 2 G ,++++" "2D" " " )+%): 
= 
=%(>>04-!%!C!C)" "J "8I)JJJ04-)00<<<<(0 G6HI -1)) $5Q#7#H  D   "&n!5!5=N8O8O!O#44$,  5     - /...  $)&$,
234 BFJL K y 
,T\< 
,7? IDJT++&304 ,     K  ++# z	A(? z	A%%D# ):L89;M  &#< $7tC%62CJ-...&7#* * *&& 0 d	AD		   +=*M      DD )-		 *.9*+ +  ) )% $ QA%6E G6MN6E 0I6E ,0( G6NO &
  $yy ) ),56H,I,I) ) )    H ) 3 +/)) 4 4 4 4 1::L0M0M4 4 4 + + +3/? / /$=/ /&./ / /DD ,1(D(ADDDDD):$)'@'+9*( ( 3D#< $7tC%62CJ-...(=&7)=)* * *&&0 @$=@@@@*6!-/" "35" " " 1000 	+D$B 	+C***D9 	T\< 	3;EC
OOOM''"/,0 (   	  	
rr   c                    dS )z3Provide a hook for MySQL to add LIMIT to the UPDATENr   )r  update_stmts     r   update_limit_clausezSQLCompiler.update_limit_clause      tr   c                    dS )z3Provide a hook for MySQL to add LIMIT to the DELETENr   )r  delete_stmts     r   delete_limit_clausezSQLCompiler.delete_limit_clause  r  r   c                ,    d|d<    |j         | fddi|S )z|Provide a hook to override the initial table clause
        in an UPDATE statement.

        MySQL overrides this.

        Tr  r  r  )r  r  
from_tableextra_fromsr  s        r   update_tables_clausez SQLCompiler.update_tables_clause  s-     8,z,TEE$E"EEEr   c                     t          d          )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 UPDATEr  r  r  r"  r#  
from_hintsr  s         r   update_from_clausezSQLCompiler.update_from_clause(  s     "%
 
 	
r   r  r@   c                    |j         || fi |}t          rt          |t                    sJ |j        }|||d<   d}n| j         }|r#d| _        | j        s|| _        | j        s|| _        | j	        t          z  r5t          i t                                }| j	        t          z  }|r|| _        nd }d}|j        }t!          |          }	|	rEt          t#          |j                            fd|D             }
                    |          }n
g }
|j        h}| j                            |||d           d}|j        r| | j        ||j        fi |z  } | j        ||j        |
fd|i|}t1          j        | |||fi |}|j        }|j        r|                     ||          \  }}nd }|j        r|                     ||           ||z  }|dz  }|d	                    d
 tA          d|          D                       z  }| j!        s|j"        r1| j#        r*|d| $                    || j!        p|j"        |          z   z  }|r" | j%        ||j        |
|fd|i|}|r|d|z   z  }|j&        r | j'        |j&        fd|i|}|r|d|z   z  }| (                    |          }|r|d|z   z  }| j!        s|j"        r1| j#        s*|d| $                    || j!        p|j"        |          z   z  }| j)        r1|stU          | j                  nd }| +                    |          |z   }|r|J |,                    d           | j        -                    d           |S )Nr  FTc                    g | ]}|v|	S r   r   )r   rD  
main_fromss     r   r  z,SQLCompiler.visit_update.<locals>.<listcomp>_  s*     " " "!:*=*=*=*=*=r   r  zUPDATE r  z SET r   c              3  0   K   | ]\  }}}}|d z   |z   V  dS )=Nr   )r   r*  r(  r  s       r   r@  z+SQLCompiler.visit_update.<locals>.<genexpr>  sG       
 
!4 3J
 
 
 
 
 
r   zList[Tuple[Any, str, str, Any]]r2  r   WHERE r  UPDATEr  r  ).r  r   r  rB   r5  r  r8  r  r+  ri  r{  r  r   r|  r  _extra_fromsr,  r+   r   r   r  r  r  r$  r   r  r  r*  r  r  r  r   r   r=  r  rA  rr  r(  rH  r$  r  r[  r  r  r  r  )r  r  r  r  r+  r   r  rN  r#  is_multitablerender_extra_fromsr'  r  r  r  crud_paramsr  extra_from_textrO  r  r  r+  s                        @r   visit_updatezSQLCompiler.visit_update6  s     ;:
 
!#
 
  	=m^<<<<<#-#!-B~HH:~H 	3 DM) 7)6&% 3%2"<44 	!$R//K<,6L /#. K L#0[)) 		2];+<==>>J" " " "&" " " )..{;;OO!#*01O
#2 /) 	
 	
 	
   	+D+[2 68  D /T.
 
 $	

 
 

 "2+}h
 
:<
 
 )6 	!(,(>(>Z) )%M:: !M( 	=++K<<<
		 
 
%)1;& &
 
 
 
 
 	
 " 	k&< 	- d33+E{/E(0 4      
	.5d5!"	 
 (  O  .o--& 	&11+ 9DHJ A  &	A%//<< 	'C,&&D #	'2'=	0	 C$//'A;+A$, 0    D 9 	O3;EC
OOOM***GG$ND 	1***x000
rr   c                     t          d          )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 DELETEr  r  r  r"  r#  r'  r  s         r   delete_extra_from_clausez$SQLCompiler.delete_extra_from_clause  s     "%
 
 	
r   c                $     |j         | fddd|S )NT)r  r  r  )r  r  r"  r#  r  s        r   delete_table_clausezSQLCompiler.delete_table_clause  s3    ,z,
d
 
.0
 
 	
r   c                ,    |j         || fi |}|j        }|||d<   d}n| j         }|r#d| _        | j        s|| _        | j        s|| _        | j        t          z  r5t          i t                                }| j        t          z  }|r|| _        nd }d}|j        }|j        h                    |          }	| j                            |	|	|d           d}
|j        r|
 | j        ||j        fi |z  }
|
dz  }
	 |                     ||j        ||          }nJ# t&          $ r= |                     ||j        |          }|r|                     |j        |          }Y nw xY wt+          j        | |||fi | |j        r|                     ||          \  }}nd }|j        r|                     ||           |
|z  }
| j        s|j        r1| j        r*|
d|                     || j        p|j        |	          z   z  }
|r" | j        ||j        ||fd
|i|}|r|
d|z   z  }
|j         r | j!        |j         fd
|i|}|r|
d|z   z  }
| "                    |          }|r|
d|z   z  }
| j        s|j        r1| j        s*|
d|                     || j        p|j        |	          z   z  }
| j#        r1|stI          | j                  nd }| %                    |          |
z   }
|r|J |&                    d           | j        '                    d           |
S )Nr  FTr  zDELETE FROM )r  r2  r  r  r.  r  DELETEr0  r  )(r  r5  r  r6  r  r+  ri  r{  r  r   r|  r  r1  r   r   r  r  r  r;  	TypeErrorr  r   r  r*  r  r  r  r=  r  rA  rr  r9  rH  r$  r   r[  r  r  r  r  )r  r  r  r  r+  r   r  rN  r#  r'  r  r  r*  r  r5  rO  r  r  s                     r   visit_deletezSQLCompiler.visit_delete  s   ::
 
!#
 
 $-#!-B~HH:~H 	3 DM) 7)6&% 3%2"<44 	!$R//K<,6L /#. K L#0&,-33K@@
#2 /) 	
 	
 	
   	+D+[2 68  D 		M11!'	 2  JJ  	M 	M 	M 11[. J  MLL!2LLL	M 	dKOOBOOO 	!(,(>(>Z) )%M:: !M( 	=++K<<<
 #	'2'=	,	 C$//'A;+A$, 0    D  
	.;d;!	 
 (  O  .o--& 	&11+ 9DHJ A  &	A%//<< 	'C,&&D #	'2'=	0	 C$//'A;+A$, 0    D 9 	O3;EC
OOOM***GG$ND 	1***x000
rs   <D AE"!E"c                <    d| j                             |          z  S )NzSAVEPOINT %sr  format_savepointr  savepoint_stmtr  s      r   visit_savepointzSQLCompiler.visit_savepointb  s     > >~ N NNNr   c                <    d| j                             |          z  S )NzROLLBACK TO SAVEPOINT %srB  rD  s      r   visit_rollback_to_savepointz'SQLCompiler.visit_rollback_to_savepointe  s&    )DM,J,J-
 -
 
 	
r   c                <    d| j                             |          z  S )NzRELEASE SAVEPOINT %srB  rD  s      r   visit_release_savepointz#SQLCompiler.visit_release_savepointj  s&    %(F(F)
 )
 
 	
r   )r  rl   r5  r  r  r  rg  r9  rh  r,  ri  ry  rj  rk  r  r   )r  rN  )r  r<  )r  r  )r  r  )r  r  )r  r7   )NT)r  r  r  r,  r  r4  )NNTNTF)r  r  r  r  r  r,  r  r  r  r,  ry  r,  r  rk   F)r6  rk   rz  r,  r  r4  )r  rJ  r  )NFFNr   )NTr   N)r   r  r  r  r  r,  r  r	  r  r  r  r   r  r   r  )NF)r(  rL   r  r   r  r   )r(  rM   r  r   r  r   )r(  rJ   r  r   r  r   )r[  rj  r  r  r  r   r  r   )r[  rj  r  r   r  r   )FNNr   )NFNN)
r   r  r4  r   r  r,  r  r   r  r   )r   r  rP  r   r  r   r  r   )FFFFF)r  r   r  r_  r  r   )ri  r   r  rD   r  r   )r  r   r  r   )FFNNNN)r  r   rI  r,  rJ  r,  rv  rN  rK  rw  rx  ry  rz  rP  r  r   r  r   )r  rY   r  r,  r  r,  r  r  r  r  r  r  r  r  r  r   r  rN  )FFFNFFNN)
r  r   r  r   r
  r	  r  r  r  r  )NNNTFFT)r   rZ   r  rN  r  rN  )FFNNNFN)r   r0  r  r:  )r   r0  r  r   r  r   
r  rA   rj  rk  r  r,  r  r   r  r   )NFF)FFFNTNNN)r   rT   r  rR  )r5  r   r6  rg   r  r  r  r\  r  rN  rP  r,  r  r  r  r  r  )r  r@   r  r  r  r   r  r   )r  r  r  r  EXTRACT_MAPr`  r&   r  r3  r  r  COMPOUND_KEYWORDSr  r6  r7  r8  r:  r;  r=  r>  rA  rB  rC  rG  rH  rI  rJ  rK  rL  rM  rO  rQ  rR  rS  	frozensetrT  rU  r  rV  rR  postfetch_lastrowidrW  r:  rX  rY  rZ  rc  re  r3  r  patternr  r  r  ra  rz  r  rG  r  ro_memoized_propertyr  r  r  r  memoized_propertyr  memoized_instancemethodr  
contextlibcontextmanagerr  r  r  r  r  r  r  r  r  r  r  preload_modulerG  rM  ri  rw  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r$  r*  r(  r5  r<  r@  rD  rK  rV  rY  r^  rc  ri  re  ry  rv  rs  r  r  r1  r  r  r  r  r  r  r  r  r  r  r0  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r#  r%  r'  r)  r+  r  r  r  r  r9  r;  r?  rB  rD  rV  r  r.   r/  r  rN  r  ru  r  r  r$   _CTEOptsr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ru  r   r  r  r  r9  r+  r)  r.  r  r  rY  r,  r  r  rM  rr  r  r  r  r  r  r-   
CLIENTSIDErf  rp  SENTINEL_DEFAULTNONErm  rn  r  r   rl  r  r  r  r  r  r   r$  r(  r6  r9  r;  r@  rF  rH  rJ  r   r   r   r  r    sW          K 		 		
 	
     : /...6666F)HHH
 +***% .0O//// .0O////$ BFEEEE K((((I----6 %$$$4 ',++++ 5:+9999
 "O!!!! B!!!! ('''
 .---
 &+**** "O!!!! "!!!! ).---- !N     !&%%%% =A @@@@ +/....
 6:9999599999=AAAAA<EIKKGGGG
 :CDDDD
 8<FFFF
   % 	      (,K++++ .21111.22222F,,,, 3222 GFFF&BJ'LMM"
#455$"*$FF'<'DFF  # # [# C C [C )-/3 %%59P P P P Pd = = = X=$ 
   0 ( ( X(  M  M X MD G G XG 
    
!   "!.   .9 9 9vG G GR 

 
 
 
8# # #    X
 6:!
 
 
 
 
2 6:GK!'+ %~ ~ ~ ~ ~@ 
!$ $ "!$L 
3 
3 X
3  %C C C C CJ T344
 
 54
 4333	    
T344P P 54 Pd 
T344, , 54 ,\   > > >@O O O OO O O .3-
 -
 -
 -
` .3+ + + +` !#"/ / / /b
 
 

/ / / ;?".0EI9O 9O 9O 9O 9OvA A A    
 
 
  
  

 
 
 
4 052 2 2 2h         
 
 
  "@ @ @L L L  &  &K K K
 
 
(
 (
 (
T
 
 
B
 
 

 
 

 
 
7 7 7 ;?, , , , ,\8 8 8
 
 
C C C C 04? ? ? ?B3 3 3- - - AC$ $ $ $L  6  "B B BB B B
 
 


 
 
4 4 4$
 
 
 ;?H* H* H* H*TM1 M1 M1d  6 6 6 6p8 8 8  
 
 

 
 


 
 
  %	    2G G GG G G 
I I IJ J JA A AE E EB B BF F FA A AE E EB B BF F FA A AE E EB B BF F F

 

 

	
 	
 	
A A AE E E
 
 

 
 

 
 
 

 
 
 

 
 
 
 $" c c c cJ$ $ $ $!%	D D D DB% % % %N     *$ $ $ $ #&*484815A A A A AFC C C .2&*,0(;
(;E(B(BV V V V Vp3 3 30 0 0 b b b bH0 0 0? ? ?   " " "$ $ $ $L9 9 9( ( (
 
 
 
4 EI
 
 
 
8  "  %bJ bJ bJ bJH       
  $ $ $ .--- 
1t1-		/LM 
  

 ,1   : '+**** K K K KZ
! 
! 
! 
!2 2 2h] ] ]~    %3 3 3 3j  7 7 7 7 	 	 	
 
 
  1 1 1 1@   +0' ' ' 'X !%3 3 3 3j
 
 
 
<
) 
) 
)" (:t'9,7,>,=,>,1,>,5,5,5,5	
( ($& $D#I#I,1,:	
$ $ < < < <|Y Y Y Yx
 AEp p p pd    F F F
 
 
" '+R R R R Rh
 
 
 
 
 

A A A AFO O O
 
 


 
 
 
 
r   r  c                       e Zd ZdZd Z ej        d           fd            Zd Zd Z	d Z
d ZddZd Zd Zd Zd Zd Zd Zd Zd Z xZS )StrSQLCompilera  A :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`

    c                    dS )Nz<name unknown>r   r  s     r   r  z$StrSQLCompiler._fallback_column_name  s    r   zsqlalchemy.engine.urlc                h   |j         dk    rt          j        j        } |j                            |j                                                               }|                    |d |           }t          |t                    s |j
        |fi |S t                                          ||          S )Nr   )rj  )stringify_dialectr&   rC  
engine_urlURLr   get_dialectstatement_compilerr  r^  r  r  r  )r  r  r  r  urlr  compilerr  s          r   r  z,StrSQLCompiler.visit_unsupported_compilation  s    $	11.+CMcgnnW%>??KKMMOOG114 2  H h77 7'x'662666ww44WcBBBr   c                V     | j         |j        fi |d | j         |j        fi |dS )Nr0  r1  )r  r   r   r  s       r   visit_getitem_binaryz#StrSQLCompiler.visit_getitem_binary  sJ    DL++++++DL,,,,,,
 	
r   c                      | j         ||fi |S r  ri  r  s       r   visit_json_getitem_op_binaryz+StrSQLCompiler.visit_json_getitem_op_binary      (t(@@R@@@r   c                      | j         ||fi |S r  rk  r  s       r   !visit_json_path_getitem_op_binaryz0StrSQLCompiler.visit_json_path_getitem_op_binary  rm  r   c                >    d| j                             |           dS )Nz<next sequence value: >)r  format_sequencer|  s      r   rv  zStrSQLCompiler.visit_sequence  s%    OT]%B%B8%L%LOOO	
r   r  rA   rj  rk  r  r,  r  r   r  r   c               t      fdt          j        |          D             }dd                    |          z   S )Nc           	     B    g | ]}                     d |ddi           S )NTFr  r   r  r  s     r   r  z3StrSQLCompiler.returning_clause.<locals>.<listcomp>  s?     
 
 
 %%dAtUB??
 
 
r   ro  r   )r   rp  r   rq  s   `     r   rr  zStrSQLCompiler.returning_clause  sO    
 
 
 
+N;;
 
 
 dii0000r   c                ^     dd<   dd                      fd|D                       z   S )NTr  r=  r   c              3  8   K   | ]} |j         fd iV  dS r  Nr  r   rO  r'  r  r  s     r   r@  z4StrSQLCompiler.update_from_clause.<locals>.<genexpr>  sQ       #
 #
 !A BBBrBB#
 #
 #
 #
 #
 #
r   r  r&  s   `   ``r   r(  z!StrSQLCompiler.update_from_clause  s]     8 #
 #
 #
 #
 #
 #
 #
 #
 #
 
 
 
 	
r   c                ^     dd<   dd                      fd|D                       z   S )NTr  r   c              3  8   K   | ]} |j         fd iV  dS rx  r  ry  s     r   r@  z:StrSQLCompiler.delete_extra_from_clause.<locals>.<genexpr>  sQ        
  
 !A BBBrBB 
  
  
  
  
  
r   r  r8  s   `   ``r   r9  z'StrSQLCompiler.delete_extra_from_clause  s]     8dii  
  
  
  
  
  
  
  
  
 
 
 
 	
r   c                    dS )NzSELECT 1 WHERE 1!=1r   r  s      r   r  z#StrSQLCompiler.visit_empty_set_expr  s    $$r   c                    d|z  S )Nz[%s]r   r
  s      r   r  z!StrSQLCompiler.get_from_hint_text  s    }r   c                      | j         |dfi |S )Nz
 <regexp> r  r  s       r   r?  z+StrSQLCompiler.visit_regexp_match_op_binary  s    ,t,V\HHRHHHr   c                      | j         |dfi |S )Nz <not regexp> r  r  s       r   rB  z/StrSQLCompiler.visit_not_regexp_match_op_binary  s     ,t,V5ELLLLLr   c                X    d |j         j        | fi |d |j        j        | fi |dS )Nz<regexp replace>(r   r-  )r   r  r   r  s       r   rD  z-StrSQLCompiler.visit_regexp_replace_op_binary  sN     *FK*46626666+FL+D77B7777
 	
r   c                X    d |j         j        | fi |d |j        j        | fi |dS )Nz	TRY_CAST(r   r-  )r:  r  r  )r  r   r  s      r   visit_try_castzStrSQLCompiler.visit_try_cast  sN     *DK*4::6::::.DO.t>>v>>>>
 	
r   rM  )r  r  r  r  r  r&   rX  r  ri  rl  ro  rv  rr  r(  r9  r  r  r?  rB  rD  r  r  r  s   @r   r^  r^  p  sE        &      T011C C C C 21C
 
 
A A AA A A
 
 

1 1 1 1
 
 

 
 
% % %  I I IM M M
 
 

 
 
 
 
 
 
r   r^  c                     e Zd ZdZer	 	 	 dWdXdZej        dYd            Zej	        d             Z
	 	 	 dZd[dZd Zd Zd Zd Zd\dZ	 d]d Zd! Zd" Zd^d&Z	 d_d'Zd( Z	 d\d`d+Zd, Zd- Zd. Zd/ Zd0 Zd1 Zd2 Zd3 Zd]d4Z d5 Z!d6 Z"d7 Z#d8 Z$d9 Z%dad=Z&dbd@Z'dA Z(dB Z)dC Z*dcdHZ+dI Z,dJ Z-dddLZ.dddMZ/dedOZ0dedPZ1dedQZ2dfdSZ3dT Z4dU Z5dV Z6dS )gDDLCompilerT.r  rl   r5  r>   r  r  r  r,  r  r  c                    d S r  r   r  s         r   r  zDDLCompiler.__init__  s	     3r   r  r  c                P    | j                             | j         d | j                  S )Nr  )r  re  r  rC  s    r   r  zDDLCompiler.sql_compiler  s-    |..L$T5N / 
 
 	
r   c                    | j         j        S r  )r  r  rC  s    r   type_compilerzDDLCompiler.type_compiler  s    |22r   Nr  r  r  r  r  r  c                    d S r  r   r  s       r   r  zDDLCompiler.construct_params  s	     tr   c                   |j         }t          |j        t          j                  r|                                }| j        }|                    |j                  }t          |          dk    r|d         d}}n|d         |d         }}|	                    d|           |	                    d|           |	                    d|
                    |j                             | j                            |j        |z            S )Nr   r   r  r  r   r#   r  )contextr  targetr#   rT   r  r  format_table_seqr  r  r  r  r  r5  )r  ddlr  r  r  pathr   schs           r   	visit_ddlzDDLCompiler.visit_ddl  s    +cj&,// 	NllnnG}H,,SZ88D4yyA~~!!Wbs!"XtAwsw...x---z8+@+@+L+LMMM 223=73JKKKr   c                b    d}|j         r|dz  }|| j                            |j                  z   S )NzCREATE SCHEMA IF NOT EXISTS )if_not_existsr  format_schemar  )r  r   r  r  s       r   visit_create_schemazDDLCompiler.visit_create_schema  s:     	%$$Ddm11&.AAAAr   c                ~    d}|j         r|dz  }|| j                            |j                  z  }|j        r|dz  }|S )NzDROP SCHEMA 
IF EXISTS  CASCADE)	if_existsr  r  r  cascader  dropr  r  s       r   visit_drop_schemazDDLCompiler.visit_drop_schema  sP    > 	!L D++DL999< 	JDr   c                   |j         }| j        }d}|j        r |d                    |j                  dz   z  }|dz  }|j        r|dz  }||                    |          dz   z  }|                     |          }|r||dz   z  }|dz  }d}d}|j        D ]}	|	j         }
	 |                     |	|
j	        o|           }|||z  }d	}|d
|z   z  }|
j	        rd}D# t          j        $ r8}t          j        d|j        d|
j        d|j        d                   |d }~ww xY w|                     ||j                  }|r||d
z   |z   z  }|d|                     |          z  z  }|S )Nz
CREATE r2  zTABLE r  r,  
Ffirst_pkrU  	Tz(in table 'z', column 'z'): r   ) _include_foreign_key_constraintsz
)%s

)r  r  r  r   r  r  create_table_suffixr  r  rd  r3   r  descriptionr  argscreate_table_constraintsinclude_foreign_key_constraintspost_create_table)r  r   r  r   r  r  r  r  r  create_columnr   	processedceconsts                 r   visit_create_tablezDDLCompiler.visit_create_table!  s   =? 	4CHHU_--33D 	%$$D%%e,,s22"66u== 	.'#--D	 #^ 	 	M"*F LL!F,>,Ox< )  	 (I%D &ID9,,D% $#H#   &&(((&+++rwqzzC   ---3-S . 
 
  	-I$u,,Dd44U;;;;s   9CD&3DDFc                     |j         }|j        rd S                      ||          }d                     fd|j        D                       }|r|d|z   z  }|S )Nr  r2  c              3  B   K   | ]}                     |          V  d S r  )r  r   r   r  s     r   r@  z2DDLCompiler.visit_create_column.<locals>.<genexpr>\  s@       
 
)3DLL$$
 
 
 
 
 
r   )r  systemget_column_specificationr   constraints)r  r   r  r  r   r  r  s   `      r   visit_create_columnzDDLCompiler.visit_create_columnU  s    = 	4,,Vh,GG 
 
 
 
7=7I
 
 
 
 
  	 C%KDr   c                L    g }j         r|                    j                    j        }||                    |          nt	                      |                    fdj        D                        d                    d  fd|D             D                       S )Nc                .    g | ]}|j         u|v|S r   )rd  )r   r  	omit_fkcsr   s     r   r  z8DDLCompiler.create_table_constraints.<locals>.<listcomp>t  s;       E---!92D2D 2D2D2Dr   z, 
	c              3     K   | ]}||V  	d S r  r   )r   r  s     r   r@  z7DDLCompiler.create_table_constraints.<locals>.<genexpr>{  s4       
 
 }  }}}
 
r   c              3     K   | ]K}|                               j        j        rt          |d d          4                    |          V  LdS )	use_alterFN)_should_create_for_compilerr  supports_alterrn  r  r  s     r   r@  z7DDLCompiler.create_table_constraints.<locals>.<genexpr>}  s|        ::4@@
 3 #:{EBBZ((     r   )rd  r  foreign_key_constraintsr  r   r2  _sorted_constraintsr   )r  r   r  r  r  all_fkcsr  s   ``    @r   r  z$DDLCompiler.create_table_constraintsd  s    
  	2u01110+7 ++,LMMIII    2  	
 	
 	
 }} 
 
   "-  
 
 
 
 
 	
r   c                b    d}|j         r|dz  }|| j                            |j                  z   S )Nz
DROP TABLE r  )r  r  r  r  r  s       r   visit_drop_tablezDDLCompiler.visit_drop_table  s8    > 	!L Ddm00>>>>r   c                F    d| j                             |j                  z   S )Nz
DROP VIEW r  r  r  r  r  r  s      r   visit_drop_viewzDDLCompiler.visit_drop_view  s     : :4< H HHHr   r  rR   r  c                L    |j         t          j        d|j        z            d S )Nz,Index '%s' is not associated with any table.)r   r3   r  r  )r  r  s     r   _verify_index_tablezDDLCompiler._verify_index_table  s1    ;">K   r   c           	         |j         }                     |            j        }d}|j        r|dz  }|j        t          j        d          |dz  }|j        r|dz  }|                     ||          d|	                    |j
        |          d	d
                     fd|j        D                       dz  }|S )NzCREATE UNIQUE z0CREATE INDEX requires that the index have a namezINDEX r  include_schemar  r  r  r   c              3  R   K   | ]!}j                             |d d          V  "dS )FTr  rG  N)r  r  )r   r(  r  s     r   r@  z1DDLCompiler.visit_create_index.<locals>.<genexpr>  sX          !))T *       r   r-  )r  r  r  r   r  r3   r  r  _prepared_index_namer  r   r   expressions)r  r   r  include_table_schemar  r  r  r  s   `       r   visit_create_indexzDDLCompiler.visit_create_index  s&      '''=< 	ID:"B   	 	%$$D%%eN%KKKK!!(< "     II     "-	      
 	
 r   c                    |j         }|j        t          j        d          d}|j        r|dz  }||                     |d          z   S )Nz.DROP INDEX requires that the index have a namez
DROP INDEX r  Tr  )r  r  r3   r  r  r  )r  r  r  r  r  s        r   visit_drop_indexzDDLCompiler.visit_drop_index  sb    :"@   > 	!L Dd//d/KKKKr   r  r   c                    |j          | j                            |j                   }nd }|r|r| j                            |          }nd }| j                            |          }|r|dz   |z   }|S Nr/  )r   r  r  r  format_index)r  r  r  r  schema_name
index_names         r   r  z DDLCompiler._prepared_index_name  s     ;"#}>>u{KK# 	. 	-445EFFKKK]//66
 	8$s*Z7Jr   c                    d| j                             |j        j                  d|                     |j                  S )NALTER TABLE z ADD )r  r  r  r   r  r  r   r  s      r   visit_add_constraintz DDLCompiler.visit_add_constraint  s@     M&&v~';<<<<LL(((
 	
r   c                    d| j                             |j                  d| j                            |j        j        t          j                              S )NzCOMMENT ON TABLE r   )r  r  r  r  r  commentr%   Stringr  s      r   visit_set_table_commentz#DDLCompiler.visit_set_table_comment  sV     M&&v~666622&(9(9  
 	
r   c                F    d| j                             |j                  z  S )NzCOMMENT ON TABLE %s IS NULLr  r  s      r   visit_drop_table_commentz$DDLCompiler.visit_drop_table_comment  s(    ,t}/I/IL0
 0
 
 	
r   c                    d| j                             |j        dd          d| j                            |j        j        t          j                              S )NzCOMMENT ON COLUMN T)	use_tabler  r   )r  format_columnr  r  r  r  r%   r  r  s      r   visit_set_column_commentz$DDLCompiler.visit_set_column_comment  sj     M''$4 (     22&(9(9  	
 	
r   c                J    d| j                             |j        d          z  S )NzCOMMENT ON COLUMN %s IS NULLT)r  )r  r  r  r  s      r   visit_drop_column_commentz%DDLCompiler.visit_drop_column_comment  s0    -0K0KLD 1L 1
 1
 
 	
r   c                F    t          j        | t          |                    r  r  r  s      r   visit_set_constraint_commentz(DDLCompiler.visit_set_constraint_comment  s    -dDLLAAAr   c                F    t          j        | t          |                    r  r  r  s      r   visit_drop_constraint_commentz)DDLCompiler.visit_drop_constraint_comment  s    -dDJJ???r   c                R   g }|j         |                    d|j         z             |j        |                    d|j        z             |j        |                    d|j        z             |j        |                    d|j        z             |j        |                    d           |j        |                    d           |j        |                    d|j        z             |j        |                    |j        rdnd	           d
	                    |          S )NzINCREMENT BY %dzSTART WITH %dzMINVALUE %dzMAXVALUE %dzNO MINVALUEzNO MAXVALUEzCACHE %dCYCLEzNO CYCLEr2  )
	incrementr  r  minvaluemaxvalue
nominvalue
nomaxvaluecachecycler   )r  identity_optionsr  s      r   get_identity_optionsz DDLCompiler.get_identity_options  s*   %1KK),<,FFGGG!-KK*:*@@AAA$0KK(8(AABBB$0KK(8(AABBB&2KK&&&&2KK&&&!-KK
%5%;;<<<!-KK#3#9IzJJJxx~~r   c                    d}|j         r|dz  }|| j                            |j                  z  }|r||z  }|                     |j                  }|r|d|z   z  }|S )NzCREATE SEQUENCE r  r2  )r  r  rr  r  r  )r  r   rR  r  r  optionss         r   visit_create_sequencez!DDLCompiler.visit_create_sequence  sz    ! 	%$$D--fn=== 	FND++FN;; 	"C'M!Dr   c                b    d}|j         r|dz  }|| j                            |j                  z   S )NzDROP SEQUENCE r  )r  r  rr  r  r  s       r   visit_drop_sequencezDDLCompiler.visit_drop_sequence   s8    > 	!L Ddm33DLAAAAr   c                   |j         }|j        | j                            |          }nd }|t	          j        d|j         z            d| j                            |j         j                  d|j        rdnd||j	        rdndS )Nz<Can't emit DROP CONSTRAINT for constraint %r; it has no namer  z DROP CONSTRAINT r  r  r  )
r  r  r  format_constraintr3   r  r  r   r  r  )r  r  r  r   formatted_names        r   visit_drop_constraintz!DDLCompiler.visit_drop_constraint&  s    \
?&!]<<ZHHNN!N!"!#'<0   " M&&t|'9:::: N2LL2N,.JJB.	
 	
r   c                   | j                             |          dz   | j        j                            |j        |          z   }|                     |          }||d|z   z  }|j         |d|                     |j                  z   z  }|j        ,| j        j	        r |d|                     |j                  z   z  }|j
        s|j        r| j        j	        s|dz  }|S )Nr2  )r  z	 DEFAULT z	 NOT NULL)r  r  r  r  r  r  get_column_default_stringcomputedidentitysupports_identity_columnsnullable)r  r   r  colspecr   s        r   r  z$DDLCompiler.get_column_specification9  s   M''//l199V :   	 0088{W,,G?&sT\\&/::::G O'6 ( sT\\&/::::G 	#	#'+|'M	# {"Gr   c                    dS Nr  r   r  r   s     r   r  zDDLCompiler.create_table_suffixT      rr   c                    dS r  r   r  s     r   r  zDDLCompiler.post_create_tableW  r  r   r   Column[Any]rN  c                    t          |j        t          j                  r|                     |j        j                  S d S r  )r  server_defaultr#   DefaultClauserender_default_stringargr  s     r   r  z%DDLCompiler.get_column_default_stringZ  s9    f+V-ABB 	--f.C.GHHH4r   r   Union[Visitable, str]c                    t          |t                    r%| j                            |t          j                  S | j                            |d          S )NT)rG  )r  r   r  r  r%   r  r  )r  r   s     r   r  z!DDLCompiler.render_default_string`  sV    gs## 	J$99,   $,,WD,IIIr   c                d    |j         r|                     |          S |                     |          S r  )is_column_levelvisit_column_check_constraintvisit_check_constraintr  r   r  s      r   &visit_table_or_column_check_constraintz2DDLCompiler.visit_table_or_column_check_constrainth  s5    % 	;55jAAA..z:::r   c                    d}|j         $| j                            |          }||d|z  z  }|d| j                            |j        dd          z  z  }||                     |          z  }|S Nr  CONSTRAINT %s z
CHECK (%s)FTr  r  r  r  r  r  r  define_constraint_deferrabilityr  r   r  r  r  s        r   r  z"DDLCompiler.visit_check_constraintn      ?&!]<<ZHHN)(>99t088e4  9  
  
 
 	
 	44Z@@@r   c                    d}|j         $| j                            |          }||d|z  z  }|d| j                            |j        dd          z  z  }||                     |          z  }|S r   r"  r$  s        r   r  z)DDLCompiler.visit_column_check_constraintz  r%  r   r   rS   r  r   c                :    t          |          dk    rdS d}|j        $ j                            |          }||d|z  z  }|dz  }|dd                     fd|j        r|j        n|j        D                       z  z  }|                     |          z  }|S )Nr   r  r!  zPRIMARY KEY r'  r   c              3  V   K   | ]#}j                             |j                  V  $d S r  r  r  r  ru  s     r   r@  z;DDLCompiler.visit_primary_key_constraint.<locals>.<genexpr>  sI       #
 #
 M''#
 #
 #
 #
 #
 #
r   )	r  r  r  r  r   _implicit_generatedcolumns_autoinc_firstr  r#  r$  s   `    r   visit_primary_key_constraintz(DDLCompiler.visit_primary_key_constraint  s     z??a2?&!]<<ZHHN)(>99 #
 #
 #
 #
 1(
00'#
 #
 #
 
 
 
 	
 	44Z@@@r   c           
         | j         d}|j        $| j                             |          }||d|z  z  }t          |j                  d         j        j        }|dd                    fd|j        D                       d|                     ||          dd                    fd	|j        D                       d
z  }|| 	                    |          z  }|| 
                    |          z  }||                     |          z  }|S )Nr  r!  r   zFOREIGN KEY(r   c              3  V   K   | ]#}                     |j        j                  V  $d S r  )r  parentr  r   rD  r  s     r   r@  z;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>  D        23qx}--     r   z) REFERENCES r  c              3  V   K   | ]#}                     |j        j                  V  $d S r  )r  r   r  r0  s     r   r@  z;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>  r1  r   r-  )r  r  r  r  r   r   r   r   define_constraint_remote_tabledefine_constraint_matchdefine_constraint_cascadesr#  )r  r   r  r  r  remote_tabler  s         @r   visit_foreign_key_constraintz(DDLCompiler.visit_foreign_key_constraint  sm   =?&!]<<ZHHN)(>99J/003:@II    7A7J       //L(    II    7A7J      

 
	
 	,,Z888//
;;;44Z@@@r   c                ,    |                     |          S )z=Format the remote table clause of a CREATE CONSTRAINT clause.)r  )r  r   r   r  s       r   r3  z*DDLCompiler.define_constraint_remote_table  s     $$U+++r   rU   c                *    t          |          dk    rdS d}|j        $ j                            |          }||d|z  z  }|d  j        |fi |dd                     fd|D                       dz  }|                     |          z  }|S )	Nr   r  r!  r  r,  r   c              3  V   K   | ]#}j                             |j                  V  $d S r  r)  ru  s     r   r@  z6DDLCompiler.visit_unique_constraint.<locals>.<genexpr>  s5      FFadm))!&11FFFFFFr   r-  )r  r  r  r  !define_unique_constraint_distinctr   r#  r$  s   `    r   visit_unique_constraintz#DDLCompiler.visit_unique_constraint  s     z??a2?&!]<<ZHHN)(>992D2:DDDDDDIIFFFF:FFFFFFF
 	
 	44Z@@@r   c                    dS r  r   r  s      r   r;  z-DDLCompiler.define_unique_constraint_distinct  s	     rr   rQ   c                    d}|j         ||                     |          z  }|j        ||                     |          z  }|S r  )ondelete"define_constraint_ondelete_cascadeonupdate"define_constraint_onupdate_cascader  r   r  s      r   r5  z&DDLCompiler.define_constraint_cascades  sP     *D;;JGGGD*D;;JGGGDr   c                R    d| j                             |j        t                    z  S )Nz ON DELETE %s)r  validate_sql_phraser?  FK_ON_DELETEr  r   s     r   r@  z.DDLCompiler.define_constraint_ondelete_cascade  -     !B!B"
 "
 
 	
r   c                R    d| j                             |j        t                    z  S )Nz ON UPDATE %s)r  rE  rA  FK_ON_UPDATErG  s     r   rB  z.DDLCompiler.define_constraint_onupdate_cascade  rH  r   rP   c                    d}|j         |j         r|dz  }n|dz  }|j        +|d| j                            |j        t                    z  z  }|S )Nr  z DEFERRABLEz NOT DEFERRABLEz INITIALLY %s)r   r   r  rE  FK_INITIALLYrC  s      r   r#  z+DDLCompiler.define_constraint_deferrability  so     ,$ *%))+Odm&G&G$l' '  D r   c                2    d}|j         |d|j         z  z  }|S )Nr  z	 MATCH %s)rB  rC  s      r   r4  z#DDLCompiler.define_constraint_match  s'    'K*"222Dr   c                    d| j                             |j        dd          z  }|j        du r|dz  }n|j        du r|dz  }|S )NzGENERATED ALWAYS AS (%s)FTr  z STOREDz VIRTUAL)r  r  r  	persisted)r  	generatedr  r  s       r   visit_computed_columnz!DDLCompiler.visit_computed_column  sj    )D,=,E,EU$ -F -
 -
 
 $&&IDD E))JDr   c                b    d|j         rdndd}|                     |          }|r|d|z  z  }|S )Nz
GENERATED ALWAYSz
BY DEFAULTz AS IDENTITYr  )alwaysr  )r  r  r  r  r  s        r   visit_identity_columnz!DDLCompiler.visit_identity_column  sP      9HH\99
 ++H55 	&Gg%%Dr   )...)
r  rl   r5  r>   r  r  r  r,  r  r  r  r  r  rK  r  )r  rR   r  r  )FT)r  rR   r  r,  r  r   )r   r  r  rN  )r   r  r  r   )r   rS   r  r   r  r   )r   rU   r  r   r  r   )r   rQ   r  r   )r   rP   r  r   )7r  r  r  r  r   r  r&   rS  r  rT  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r,  r7  r3  r<  r;  r5  r@  rB  r#  r4  rQ  rU  r   r   r   r  r    s       F 	 FI,/03	 	 	 	 	 

 
 
 

 
3 3 3
 6:GK!	    L L L&B B B  2 2 2h     7;#
 #
 #
 #
J? ? ?I I I    BF   @L L L 49    $
 
 

 
 

 
 


 
 

 
 

B B B@ @ @  (   B B B
 
 
&  6       J J J J; ; ;
 
 

 
 
   ,  0, , ,
   "   
	 	 	 	
 
 
 

 
 
 
           r   r  c                     e Zd ZdXdZdYd	ZdZdZd[dZd\dZd]dZd^dZ	d_dZ
d`dZdadZdbdZdcdZdddZded!Zdfd#Zdgd)Zdhd+Zdid-Zdjd/Zdkd1Zdfd2Zdld4Zdmd6Zdnd8Zdod:Zdpd<Zdld=Zdmd>Zdpd?Zddd@Z dbdAZ!dcdBZ"d`dCZ#d_dDZ$d^dEZ%d[dFZ&dXdGZ'dYdHZ(d\dIZ)djdJZ*dqdLZ+dfdMZ,drdOZ-dsdQZ.dR Z/dtdTZ0dudVZ1dWS )vGenericTypeCompilerr  sqltypes.Float[Any]r  r   r  r   c                    dS )NFLOATr   r  s      r   visit_FLOATzGenericTypeCompiler.visit_FLOAT      wr   sqltypes.Double[Any]c                    dS )NDOUBLEr   r  s      r   visit_DOUBLEz GenericTypeCompiler.visit_DOUBLE      xr   sqltypes.DOUBLE_PRECISION[Any]c                    dS )NzDOUBLE PRECISIONr   r  s      r   visit_DOUBLE_PRECISIONz*GenericTypeCompiler.visit_DOUBLE_PRECISION  s
     "!r   sqltypes.REAL[Any]c                    dS )NREALr   r  s      r   
visit_REALzGenericTypeCompiler.visit_REAL  r	  r   sqltypes.Numeric[Any]c                ^    |j         dS |j        dd|j         iz  S d|j         |j        dz  S )NNUMERICzNUMERIC(%(precision)s)	precisionz!NUMERIC(%(precision)s, %(scale)s)rl  scalerm  r  s      r   visit_NUMERICz!GenericTypeCompiler.visit_NUMERIC  J    ?"9[ +{EO.LLL6"_: :  r   sqltypes.DECIMAL[Any]c                ^    |j         dS |j        dd|j         iz  S d|j         |j        dz  S )NDECIMALzDECIMAL(%(precision)s)rl  z!DECIMAL(%(precision)s, %(scale)s)rm  rm  r  s      r   visit_DECIMALz!GenericTypeCompiler.visit_DECIMAL)  rp  r   sqltypes.Integerc                    dS )NINTEGERr   r  s      r   visit_INTEGERz!GenericTypeCompiler.visit_INTEGER4      yr   sqltypes.SmallIntegerc                    dS )NSMALLINTr   r  s      r   visit_SMALLINTz"GenericTypeCompiler.visit_SMALLINT7      zr   sqltypes.BigIntegerc                    dS )NBIGINTr   r  s      r   visit_BIGINTz GenericTypeCompiler.visit_BIGINT:  ra  r   sqltypes.TIMESTAMPc                    dS )N	TIMESTAMPr   r  s      r   visit_TIMESTAMPz#GenericTypeCompiler.visit_TIMESTAMP=  s    {r   sqltypes.DateTimec                    dS )NDATETIMEr   r  s      r   visit_DATETIMEz"GenericTypeCompiler.visit_DATETIME@  r~  r   sqltypes.Datec                    dS )NDATEr   r  s      r   
visit_DATEzGenericTypeCompiler.visit_DATEC  r	  r   sqltypes.Timec                    dS )NTIMEr   r  s      r   
visit_TIMEzGenericTypeCompiler.visit_TIMEF  r	  r   sqltypes.CLOBc                    dS )NCLOBr   r  s      r   
visit_CLOBzGenericTypeCompiler.visit_CLOBI  r	  r   sqltypes.Textc                    dS )NNCLOBr   r  s      r   visit_NCLOBzGenericTypeCompiler.visit_NCLOBL  r\  r   r  lengthr  r  rN  c                6    |}|r	|d| dz  }|r	|d| dz  }|S )Nr,  r-  z
 COLLATE "r  r   )r  r  r  r  r  s        r   _render_string_typez'GenericTypeCompiler._render_string_typeO  sF      	"MMMM!D 	.-----Dr   sqltypes.CHARc                D    |                      d|j        |j                  S )NCHARr  r  r  r  s      r   
visit_CHARzGenericTypeCompiler.visit_CHARY      ''eoNNNr   sqltypes.NCHARc                D    |                      d|j        |j                  S )NNCHARr  r  s      r   visit_NCHARzGenericTypeCompiler.visit_NCHAR\  s    ''uOOOr   sqltypes.Stringc                D    |                      d|j        |j                  S )NVARCHARr  r  s      r   visit_VARCHARz!GenericTypeCompiler.visit_VARCHAR_  s%    ''u|U_
 
 	
r   sqltypes.NVARCHARc                D    |                      d|j        |j                  S )NNVARCHARr  r  s      r   visit_NVARCHARz"GenericTypeCompiler.visit_NVARCHARd  s%    ''eo
 
 	
r   c                D    |                      d|j        |j                  S )NTEXTr  r  s      r   
visit_TEXTzGenericTypeCompiler.visit_TEXTi  r  r   sqltypes.Uuid[Any]c                    dS )NUUIDr   r  s      r   
visit_UUIDzGenericTypeCompiler.visit_UUIDl  r	  r   sqltypes.LargeBinaryc                    dS )NBLOBr   r  s      r   
visit_BLOBzGenericTypeCompiler.visit_BLOBo  r	  r   sqltypes.BINARYc                .    d|j         r
d|j         z  pdz   S )NBINARY(%d)r  r  r  s      r   visit_BINARYz GenericTypeCompiler.visit_BINARYr  s     5<AFU\,AGRHHr   sqltypes.VARBINARYc                .    d|j         r
d|j         z  pdz   S )N	VARBINARYr  r  r  r  s      r   visit_VARBINARYz#GenericTypeCompiler.visit_VARBINARYu  s     elDv/DJKKr   sqltypes.Booleanc                    dS )NBOOLEANr   r  s      r   visit_BOOLEANz!GenericTypeCompiler.visit_BOOLEANx  ry  r   c                t    |j         r| j        j        s|                     ddd           S  | j        |fi |S )Nr      )r  r  )native_uuidr  supports_native_uuidr  r  r  s      r   
visit_uuidzGenericTypeCompiler.visit_uuid{  sN      	0(I 	0++F2+NNN"4?5//B///r   c                     | j         |fi |S r  )r  r  s      r   visit_large_binaryz&GenericTypeCompiler.visit_large_binary       tu+++++r   c                     | j         |fi |S r  )r  r  s      r   visit_booleanz!GenericTypeCompiler.visit_boolean      !t!%..2...r   c                     | j         |fi |S r  )r  r  s      r   
visit_timezGenericTypeCompiler.visit_time      tu+++++r   c                     | j         |fi |S r  )r  r  s      r   visit_datetimez"GenericTypeCompiler.visit_datetime  s    "t"5//B///r   c                     | j         |fi |S r  )r  r  s      r   
visit_datezGenericTypeCompiler.visit_date  r  r   c                     | j         |fi |S r  )r  r  s      r   visit_big_integerz%GenericTypeCompiler.visit_big_integer       t --"---r   c                     | j         |fi |S r  )r}  r  s      r   visit_small_integerz'GenericTypeCompiler.visit_small_integer  s     #t"5//B///r   c                     | j         |fi |S r  )rx  r  s      r   visit_integerz!GenericTypeCompiler.visit_integer  r  r   c                     | j         |fi |S r  )rh  r  s      r   
visit_realzGenericTypeCompiler.visit_real  r  r   c                     | j         |fi |S r  )r[  r  s      r   visit_floatzGenericTypeCompiler.visit_float  s    t,,,,,r   c                     | j         |fi |S r  )r`  r  s      r   visit_doublez GenericTypeCompiler.visit_double  r  r   c                     | j         |fi |S r  )ro  r  s      r   visit_numericz!GenericTypeCompiler.visit_numeric  r  r   c                     | j         |fi |S r  r  r  s      r   visit_stringz GenericTypeCompiler.visit_string  r  r   sqltypes.Unicodec                     | j         |fi |S r  r  r  s      r   visit_unicodez!GenericTypeCompiler.visit_unicode  r  r   c                     | j         |fi |S r  r  r  s      r   
visit_textzGenericTypeCompiler.visit_text  r  r   sqltypes.UnicodeTextc                     | j         |fi |S r  r  r  s      r   visit_unicode_textz&GenericTypeCompiler.visit_unicode_text  r  r   sqltypes.Enumc                     | j         |fi |S r  r  r  s      r   
visit_enumzGenericTypeCompiler.visit_enum  r  r   c                0    t          j        d|z            )NzKCan't generate DDL for %r; did you forget to specify a type on this Column?r  r  s      r   r  zGenericTypeCompiler.visit_null  s$    #%*+
 
 	
r   TypeDecorator[Any]c                N     | j         |                    | j                  fi |S r  )r  type_enginer  r  s      r   visit_type_decoratorz(GenericTypeCompiler.visit_type_decorator  s.     t|E--dl;;BBrBBBr   UserDefinedType[Any]c                     |j         di |S rL  )get_col_specr  s      r   visit_user_definedz&GenericTypeCompiler.visit_user_defined  s     "u!''B'''r   N)r  rX  r  r   r  r   )r  r]  r  r   r  r   )r  rb  r  r   r  r   )r  re  r  r   r  r   )r  ri  r  r   r  r   )r  rq  r  r   r  r   )r  ru  r  r   r  r   )r  rz  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r   r  r  r  rN  r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )r  r  r  r   r  r   )2r  r  r  r[  r`  rd  rh  ro  rt  rx  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r   r   r   rW  rW    s             " " " "
   	 	 	 		 	 	 	                              O O O OP P P P
 
 
 


 
 
 

O O O O      I I I IL L L L   0 0 0 0, , , ,
/ / / /, , , ,0 0 0 0, , , ,. . . .0 0 0 0
/ / / /, , , ,- - - -. . . ./ / / // / / // / / /, , , ,, , , ,
/ / / /
 
 
C C C C
( ( ( ( ( (r   rW  c                  ,    e Zd Zd Zd Zd Zd Zd ZdS )StrSQLTypeCompilerc                `    	 |j         } || fi |S # t          $ r  | j        |fi |cY S w xY wr  )r  AttributeError_visit_unknown)r  r  r  r  s       r   r  zStrSQLTypeCompiler.process  si    	2!&!9 &%d11b111  	4 	4 	4&4&u3333333	4s    --c                X    |                     d          r| j        S t          |          )Nr  )r}  r	  r	  )r  r?  s     r   __getattr__zStrSQLTypeCompiler.__getattr__  s-    >>(## 	&&& %%%r   c                    |j         j        |j         j                                        k    r|j         j        S t          |          S r  )r  r  upperreprr  s      r   r	  z!StrSQLTypeCompiler._visit_unknown  s:    ?#u'?'E'E'G'GGG?++;;r   c                    dS r  r   r  s      r   r  zStrSQLTypeCompiler.visit_null  r	  r   c                `    	 |j         } |di |S # t          $ r t          |          cY S w xY wrL  )r 	  r	  r	  )r  r  r  r 	  s       r   r	  z%StrSQLTypeCompiler.visit_user_defined  sV    	& -L  <%%"%%%  	 	 	;;	s    --N)r  r  r  r  r	  r	  r  r	  r   r   r   r	  r	    s_        2 2 2& & &    & & & & &r   r	  c                      e Zd ZddZdS )_SchemaForObjectCallable_SchemaForObjectCallable__objr   r  r   c                    d S r  r   )r  r	  s     r   r  z!_SchemaForObjectCallable.__call__        r   N)r	  r   r  r   r  r   r   r   r	  r	    s        ......r   r	  c                      e Zd ZddZdS )rH  r  r  r  r   c                    d S r  r   )r  r  s     r   r  z _BindNameForColProtocol.__call__  r	  r   N)r  r  r  r   r  r   r   r   rH  rH    s        ::::::r   rH  c                     e Zd ZU dZeZeZeZ	de
d<   de
d<   de
d<    ej        d          Zde
d	<   	 d
Zde
d<   	 	 	 	 	 dTdUdZd ZdVdZdWdZdWdZd  ZdWd!ZdXd"Zd# ZdYdZd&ZdYd[d(Zd) Z	 d\d]d-Z	 dYd^d1Z	 dYd_d4ZdYd5Z ej         d6          	 d\d`d:            Z!	 d\dad;Z"	 d\dad<Z#dbd?Z$dcdBZ%	 	 dddedEZ&dF Z'	 dYdGZ(	 	 	 	 	 dfdgdNZ)d\dOZ*ej+        dP             Z,dhdSZ-dS )ir  z@Handle quoting and case-folding of identifiers based on options.r   initial_quotefinal_quotezMutableMapping[str, str]_stringsr#   r	  r  Fr,  _includes_none_schema_translater  NTr  rl   rN  escape_quotequote_case_sensitive_collationsomit_schemac                    || _         || _        |p| j        | _        || _        | j        dz  | _        || _        || _        i | _        | j         j        dv | _	        dS )as  Construct 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.
        r2   )r   r   N)
r  r	  r	  r	  escape_to_quoter	  r	  r	  r|  r  )r  r  r	  r	  r	  r	  r	  s          r   r  zIdentifierPreparer.__init__  so    . *&<$*<(#014&/N, $ 7 <
 !
r   c                    | j                             | j                   }|j                            | j                   d |v fd}||_        |_        |S )Nc                    | j         }| j        r;|r7|d|v sd|v rt          j        d|z            t	          d|pdz  d          S | j         S )Nr0  r1  zJSquare bracket characters ([]) not supported in schema translate name '%s'z__[SCHEMA_%s]_noneFr  )r#   _use_schema_mapr3   r  r/   )r  r  includes_nones     r   symbol_getterz@IdentifierPreparer._with_schema_translate.<locals>.symbol_getter;  s    :D" 
"(8M(8#t*8:>?   ##tw7u    z!r   )r  __new__r  r  r  r	  )r  r  prepr%	  r$	  s       @r   r  z)IdentifierPreparer._with_schema_translate5  sm    ~%%dn55T]+++ 44	" 	" 	" 	" 	" "//<,r   r5  r  rm   r  c                     |d v r& j         st          j        d          d          d<    fd}t          j        d||          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.r!	  c                    |                      d          }|v r	|         }n|dv rt          j        d          |}|s"j        j        }|st          j        d                              |          S )Nr2   )Nr!	  zschema 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.)r   r3   rA  r  default_schema_namer  r  )r  r  r  dr  s      r   r  z=IdentifierPreparer._render_schema_translates.<locals>.replace]  s    771::Dqyy#$T7  ?**1=   $( # #'<#C ' *=   $$%5666r   z(__\[SCHEMA_([^\]]+)\]))r	  r3   rA  rc  r  )r  r5  r  r  r+	  s   `   @r   r  z,IdentifierPreparer._render_schema_translatesM  s}     !1997 -9   4AgJ	7 	7 	7 	7 	7 	72 v0'9EEEr   r  c                    |                     | j        | j                  }| j        r|                     dd          }|S )zEscape an identifier.

        Subclasses should override this to provide database-dependent
        escaping behavior.
        r+  r  )r  r	  r	  r  r  r  s     r   _escape_identifierz%IdentifierPreparer._escape_identifierx  s@     d/1EFF  	-MM#t,,Er   c                B    |                     | j        | j                  S )zCanonicalize an escaped identifier.

        Subclasses should override this to provide database-dependent
        unescaping behavior that reverses _escape_identifier.
        )r  r	  r	  r-	  s     r   _unescape_identifierz'IdentifierPreparer._unescape_identifier  s     }}T143DEEEr   c                t    |5|                     |          s t          j        d|d|j        d          |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: z (matching against r-  )rB  r3   r  rR  )r  r  rf  s      r   rE  z&IdentifierPreparer.validate_sql_phrase  sN     syy'9'9""77CKKK)   r   c                L    | j         |                     |          z   | j        z   S )z~Quote an identifier.

        Subclasses should override this to provide database-dependent
        quoting behavior.
        )r	  r.	  r	  r-	  s     r   quote_identifierz#IdentifierPreparer.quote_identifier  s0     %%e,,-	
r   c                    |                                 }|| j        v p<|d         | j        v p-| j                            t          |                     p||k    S )z5Return True if the given identifier requires quoting.r   )ro  reserved_wordsillegal_initial_characterslegal_charactersrB  r   )r  r  lc_values      r   r  z#IdentifierPreparer._requires_quotes  sd    ;;==++ #Qx4::#(..s5zz:::# E!		
r   c                R    | j                             t          |                     S )zjReturn True if the given identifier requires quoting, but
        not taking case convention into account.)r7	  rB  r   r-	  s     r   rm  z1IdentifierPreparer._requires_quotes_illegal_chars  s$     (..s5zz::::r   forcer   c                \    |t          j        dd           |                     |          S )a  Conditionally 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_  )r&   rb  r  )r  r#   r:	  s      r   r  zIdentifierPreparer.quote_schema  sD    .   !     zz&!!!r   r  c                J   |t          j        dd           t          |dd          }|`|| j        v r| j        |         S |                     |          r|                     |          | j        |<   n
|| j        |<   | j        |         S |r|                     |          S |S )a  Conditionally 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().r<	  r_  r  )r&   rb  rn  r	  r  r3	  )r  r  r:	  s      r   r  zIdentifierPreparer.quote  s    ,   !     w--=%%}U++((// 1+/+@+@+G+GDM%((+0DM%(}U++ 	((///Lr   c                >    | j         r|                     |          S |S r  )r	  r  )r  collation_names     r   r  z#IdentifierPreparer.format_collation  s%    / 	"::n---!!r   rw  schema.Sequencer  c                    |                      |j                  }|                     |          }| j        s|r||                     |          dz   |z   }|S r  )r  r  r  r	  r  )r  rw  r  r  r  s        r   rr  z"IdentifierPreparer.format_sequence  sm     zz(-((11(;;  	D	D !,$$%566<tCDr   r  
Label[Any]r  c                :    |                      |p|j                  S r  r  r  )r  r  r  s      r   r  zIdentifierPreparer.format_label+  s     zz$,%*---r   r  Optional[AliasedReturnsRows]c                l    ||J |                      |j                  S |                      |          S r  rD	  )r  r  r  s      r   r  zIdentifierPreparer.format_alias0  s;     <$$$::ej)))::d###r   c                l    |p|j         }|                     |          r|                     |          }|S r  )r  r  r3	  )r  	savepointr  r  s       r   rC  z#IdentifierPreparer.format_savepoint9  s>     '	  '' 	1))%00Er   zsqlalchemy.sql.namingr   Union[Constraint, Index]_alembic_quotec                   t           j        j        }|j        t          u r |                    ||j                  }|d S n|j        }|J |j        dk    r|                     ||          S | 	                    ||          S )Nr  )rJ	  )
r&   rC  
sql_namingr  r,   _constraint_name_for_tabler   r  truncate_and_render_index_name#truncate_and_render_constraint_name)r  r   rJ	  namingr  s        r   r  z$IdentifierPreparer.format_constraintB  s     *?j((44J, D |t  ?D$//66^ 7    ;;^ <   r   c                `    | j         j        p| j         j        }|                     |||          S r  )r  max_index_name_lengthr   _truncate_and_render_maxlen_namer  r  rJ	  max_s       r   rN	  z1IdentifierPreparer.truncate_and_render_index_name\  s?     L. 2|1 	 44$
 
 	
r   c                `    | j         j        p| j         j        }|                     |||          S r  )r  max_constraint_name_lengthr  rS	  rT	  s       r   rO	  z6IdentifierPreparer.truncate_and_render_constraint_namej  s?     L3 2|1 	 44$
 
 	
r   rU	  rN  c                   t          |t          j                  rAt          |          |k    r-|d|dz
           dz   t	          j        |          dd          z   }n| j                            |           |s|S |                     |          S )Nr   rh  r*  )	r  r   rD   r  r&   md5_hexr  validate_identifierr  )r  r  rU	  rJ	  s       r   rS	  z3IdentifierPreparer._truncate_and_render_maxlen_namex  s     dH566 	34yy4AqL)C/$,t2D2DRSS2IIL,,T222 	$K::d###r   r  rR   c                8    |                      |          }|J |S r  )r  )r  r  r  s      r   r  zIdentifierPreparer.format_index  s&    %%e,,r   r   rZ   c                    |%t           rt          |t                    sJ |j        }|                     |          }|                     |          }| j        s|r|r|                     |          dz   |z   }|S )z'Prepare a quoted table and schema name.Nr/  )r   r  r[   r  r  r  r	  r  )r  r   r  r  rh  r  s         r   r  zIdentifierPreparer.format_table  s     < :!%99999:DD!!11%88 	HJ 	H3C 	H&&'7883>GFr   c                ,    |                      |          S )zPrepare a quoted schema name.r"	  rt  s     r   r  z IdentifierPreparer.format_schema  s     zz$r   c                    |/t          |t          j                  r|                    |          }|                     |          S )Prepare a quoted column name.)r  r   rD   rl  r  )r  r  r  s      r   r  z$IdentifierPreparer.format_label_name  sF     J(+%
 %
 >>(++Dzz$r   r   ColumnElement[Any]r  
table_namer  Optional[Mapping[str, Any]]c                   ||j         }|J |/t          |t          j                  r|                    |          }t          |dd          sM|r6|                     |j        ||          dz   |                     |          z   S |                     |          S |r#|                     |j        ||          dz   |z   S |S )r`	  Nr  F)r  r  r/  )	r  r  r   rD   rl  rn  r  r   r  )r  r   r  r  rb	  r  r  s          r   r  z IdentifierPreparer.format_column  s    <;D###J(+%
 %
 >>(++Dv|U33 	 	(%%* &    jj&&	' zz$'''
  	%%* &    	 r   c                    |                      |          }| j        s0|r.|r,|                     |          |                     |d          fS |                     |d          fS )z(Format table name and schema as a tuple.Fr  )r  r	  r  r  )r  r   r  r  s       r   r  z#IdentifierPreparer.format_table_seq  s      11%88 	AJ 	A3C 	A!!"233!!%E!:: 
 %%e%>>@@r   c                    d | j         | j        |                     | j                  fD             \  }}}t          j        d|||dz            }|S )Nc              3  >   K   | ]}t          j        |          V  d S r  )rc  rd  r  s     r   r@  z4IdentifierPreparer._r_identifiers.<locals>.<genexpr>  s>       )
 )
 IaLL)
 )
 )
 )
 )
 )
r   zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)initialfinalr  )r	  r	  r.	  rc  re  )r  rh	  ri	  escaped_finalrs        r   _r_identifiersz!IdentifierPreparer._r_identifiers  s    )
 )
 " ''(899)
 )
 )
% J$ "EmLLM
 
 r   identifiersSequence[str]c                h      j         } fdd |                    |          D             D             S )z:Unpack 'schema.table.column'-like strings into components.c                :    g | ]}                     |          S r   )r0	  r  s     r   r  z;IdentifierPreparer.unformat_identifiers.<locals>.<listcomp>  s7     
 
 
 %%a((
 
 
r   c                    g | ]	\  }}|p|
S r   r   )r   arp  s      r   r  z;IdentifierPreparer.unformat_identifiers.<locals>.<listcomp>	  s     @@@Aaf1@@@r   )rl	  findall)r  rm	  rk	  s   `  r   unformat_identifiersz'IdentifierPreparer.unformat_identifiers  sR     
 
 
 
@@;)?)?@@@
 
 
 	
r   )r  Nr  TF)r  rl   r	  r   r	  rN  r	  r   r	  r,  r	  r,  )r5  r   r  rm   r  r   )r  r   r  r   )r  r   r  r,  r  )r#   r   r:	  r   r  r   )r  r   r:	  r   r  r   )T)rw  r@	  r  r,  r  r   )r  rB	  r  rN  r  r   )r  rE	  r  rN  r  r   )r   rI	  rJ	  r,  r  rN  )r  r   rJ	  r,  r  r   )r  r   rU	  rN  rJ	  r,  r  r   )r  rR   r  r   )TN)r   rZ   r  r,  r  rN  r  r   )FNNFN)r   ra	  r  r,  r  rN  rb	  rN  r  r,  r  rc	  r  r   )rm	  r   r  rn	  ).r  r  r  r  RESERVED_WORDSr5	  LEGAL_CHARACTERSr7	  ILLEGAL_INITIAL_CHARACTERSr6	  r  rP  
attrgetterr  r	  r  r  r  r.	  r0	  rE  r3	  r  rm  r  r  r  rr  r  r  rC  r&   rX  r  rN	  rO	  rS	  r  r  r  r  r  r  rT  rl	  rt	  r   r   r   r  r    s\        JJ#N'!;&&&&2E(2Eh2O2OOOOO -2#1111
 !%)04!"
 "
 "
 "
 "
H  0)F )F )F )FV
 
 
 
F F F F  $
 
 
 

 
 
 
; ; ;
%" %" %" %" %"N2 2 2 2 2h" " " =A      8<. . . . . JN$ $ $ $ $    T011KO    214 15
 
 
 
 
 15
 
 
 
 
$ $ $ $     "	    (             "  "$( 04, , , , ,\A A A A" 
  "
 
 
 
 
 
r   r  )r  
__future__r   r  collections.abcabcr  rV  enumr   r  r  rP  rc  timer   ru  r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r    r!   r"   r#   r$   r%   r&   rd  _typingr(   r)   r*   r+   r,   r-   r.   r/   r0   visitorsr1   r3   r4   util.typingr5   r6   r7   r8   
annotationr9   r:   r;   r<   r  r=   r  r>   dmlr?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   type_apir_   r`   ra   rb   rc   engine.cursorrd   engine.interfacesre   rf   rg   rh   ri   rj   rk   rl   rm   r   _FromHintsTyperu	  re  Irv	  LEGAL_CHARACTERS_PLUS_SPACEr  r   rw	  rF  rJ  rL  UNICODEr  r  r~  r  r   or_r}  mulr  modnegltlenegtgeeqis_distinct_fromis_not_distinct_from	concat_opr  not_match_opr  r  rf  r  r  rZ  r[  r   existsdistinct_opinvany_opall_opdesc_opasc_opnulls_first_opnulls_last_opbitwise_xor_opbitwise_or_opbitwise_and_opbitwise_not_opbitwise_lshift_opbitwise_rshift_opr  r   r   r   r   r   r   r   r   r   r   r   cuberollupgrouping_setsr   r  rN  _CompoundSelectKeywordr  	UNION_ALLr  
EXCEPT_ALLr  INTERSECT_ALLrO  r  r  r  r   r!  r#  r%  r*  r4  rI  rY  rf  rt  ry  rB  rz  r{  r|  r}  
namedtupler  r  EnsureKWArgr  BinaryElementRoleCompilerColumnElementr  r  r  r^  r  rW  r	  r	  rH  r  r   r   r   <module>r	     s-    " # " " " " "     ) ) ) ) ) )                    				                                                                    ! ! ! ! ! !                                                                                                                                     & & & & & &                         2 2 2 2 2 2       ! ! ! ! ! !       % % % % % %                   ! ! ! ! ! ! " " " " " "       # # # # # #	 5;++++++,,,,,,""""""      ######))))))######************''''''''''''&&&&&&''''''      ######"""""",,,,,,,,,,,,((((((111111......//////&&&&&&++++++''''''""""""'''''',,,,,,''''''$$$$$$))))))######444444<<<<<<::::::<<<<<<======333333======CCCCCC++++++:::::: lC'(_ _ _B 2:.55 (bj):BDAA ;;eeArll;;;AA3%HH rz<bd  rz<bd  rz5rt<<bjA2:NN"*92:FF$ "$ .NG. M6. M5	.
 M5. M5. M5. M3. L%. L&. L&. L%. L&. L%.  4.  "$<!." #.$ 	%. .& M'.( OV).* +., -.. OX/.0 M61.2 M63.4 j5.6 {7.: i;.< ;=.> M6?.@ fA.B fC.F wG.H fI.J nK. .L ]eUec[. .	b 
NN!4N.hyNNFNFh_-	    & ""$( & %+W%/%,h%0,%/%3_        >         !             
            i   $ $ $ $ $1 $ $ $ $: : : : :J : : :zt t t t t
 t t tn    Z   2! ! ! ! !; ! ! !$    G        g   . FKUF F B
&l
?# ?# ?# ?# ?#''w6HII ?# ?# ?#DI' I' I' I' I' I' I' I'XF F F F F4# F F F0    	C ("@  2#
 #
 #
 #
 #
	C ("@#
 #
 #
LSU
 SU
 SU
 SU
 SU
( SU
 SU
 SU
ljl
 l
 l
 l
 l
[ l
 l
 l
^m m m m m( m m m`z( z( z( z( z(, z( z( z(z& & & & &, & & &B/ / / / /x / / /; ; ; ; ;h ; ; ;U
 U
 U
 U
 U
 U
 U
 U
 U
 U
r   