
    ,h-G                      % S r SSKJr  SSKrSSKJr  SSKrSSKJ	r	  SSK
r
SSKrSSKrSSKrSSKJr  SSKrSSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSKJ"r"  SSKJ#r#  SSKJ$r$  SSKJ%r%  SSK&J'r'  SSK&J(r(  SSK&J)r)  SSK&J*r*  SS K&J+r+  SS!K&J,r,  SS"K&J-r-  SS#K&J.r.  SS$K&J/r/  SS%K&J0r0  SS&K&J1r2  SS'K3J4r4  SS(K3J5r5  SS)K'J6r6  SS*K'J7r7  SS+K'J8r8  SS,K'J9r9  SS-K'J:r:  SS.K*J;r;  SS/K0J<r<  SS0K=J>r>  S1S2K&J?r?  S1S&K&J1r1  S1S3K1J@r@  S1S4KAJBrB  S1S5KAJCrC  S1S6KAJDrD  S1S7KAJErE  \RH                  (       Ga>  SS8KFJGrG  SS9K'JHrH  SS:K'JIrI  SS;K'JJrJ  SS<KKJLrL  SS=KMJNrN  SS>KOJPrP  SS?KOJQrQ  SS@KOJRrR  SSAKOJSrS  SSBKOJTrT  SSCK*JUrU  SSDK*JVrV  SSEK*JWrW  SSFK*JXrX  SSGK*JYrY  SSHK*JZrZ  SSIK*J[r[  SSJK*J\r\  SSKK*J]r]  SSLK*J^r^  SSMK+J_r_  SSNK.J`r`  SSOK.Jara  SSPK.Jbrb  SSQK.Jcrc  SSRK.Jdrd  SSSK.Jere  SSTK.Jfrf  SSUK/Jgrg  SSVK/Jhrh  SSWK/Jiri  SSXK/Jjrj  SSYK/Jkrk  SSZK/Jlrl  SS[K/Jmrm  SS\K/Jnrn  SS]K/Joro  SS^KpJqrq  SS_KpJrrr  SS`KpJsrs  SSaKpJtrt  SSbK=Juru  S1ScKvJwrw  S1SdKxJyry  S1SeKxJzrz  S1SfKxJ{r{  S1SgKxJ|r|  S1ShKxJ}r}  S1SiKxJ~r~  S1SjKxJr  S1SkKxJr  S1SlKxJr  \Sm\4   r1 Snkr\GR
                  " So\GR                  5      r\GR
                  " Sp\GR                  5      r\" SSq5       V s1 s H  n \" U 5      iM     sn GR                  Sr/5      r\GR
                  " Ss\GR                  5      r\GR
                  " Ss\GR                  5      r\GR
                  " St\GR                  5      r\GR
                  " Su\GR                  5      r\GR
                  " Sv\GR                  5      rSwr\SxSySzS{S|S}.r0 \,GR(                  S~_\,GR*                  S_\,GR,                  S_\,GR.                  S_\,GR0                  S_\,GR2                  S_\,GR4                  S_\,GR6                  S_\,GR8                  S_\,GR:                  S_\,GR<                  S_\,GR>                  S_\,GR@                  S_\,GRB                  S_\,GRD                  S_\,GRF                  S_\,GRH                  S_0 \,GRJ                  S_\,GRL                  S_\,GRN                  S_\,GRP                  S_\,GRR                  S_\,GRT                  S_\,GRV                  S_\,GRX                  S_\,GRZ                  S_\,GR\                  S_\,GR^                  S_\,GR`                  S_\,GRb                  S_\,GRd                  S_\,GRf                  S_\,GRh                  S_\,GRj                  S_E\,GRl                  S\,GRn                  S\,GRp                  S\,GRr                  S\,GRt                  S\,GRv                  S\,GRx                  S0Er\+GR|                  S\+GR~                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S\+GR                  S0rS\S'   SSSSSSSSSSSSSSSS.r\/GR                  GR                  S\/GR                  GR                  S\/GR                  GR                  S\/GR                  GR                  S\/GR                  GR                  S\/GR                  GR                  S0r " S S\5      r " S S\C5      rSrS\S'   SrS\S'   S1rS\S'   SrS\S'    " S S\E5      r " S S\SS9r " S S\5      r " S S\5      r " S S\5      r " S S\@5      r " S S\	5      r " S S\	5      r\" \5      u  rrrr " S S\GR                  " SSS/5      5      r " S S5      r " S S\1GR                  5      r " S S\-GR                  \   \*GR                  5      r " S S\-GR                  \   \*GR                  5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " GS  GS\5      r " GS GS\C5      r " GS GS\C5      r " GS GS5      rgs  sn f (  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)SchemaTranslateMapTyperY   >^   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_ $]+$
   $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                  H    \ rS rSr% SrS\S'    S\S'    S\S'    S\S	'   S
rg)ResultColumnsEntryik  zTracks 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.

strkeynamenameTuple[Any, ...]objectsTypeEngine[Any]type N__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r      O/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/sql/compiler.pyr   r   k  s1     L;
I% r  r   c                  2    \ rS rSr          SS jrSrg)_ResultMapAppenderi  c                    g Nr  selfr   r   r  type_s        r  __call___ResultMapAppender.__call__  s     r  r  N)
r   r   r   r   r  zSequence[Any]r  r  returnNoner  r  r	  r
  r  r  r  r  r  r  r    s7      	
  
r  r  z
Literal[0]RM_RENDERED_NAMEz
Literal[1]RM_NAMEz
Literal[2]
RM_OBJECTS   z
Literal[3]RM_TYPEc                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	_BaseCompilerStackEntryi  zSet[FromClause]asfrom_fromscorrelate_fromsr[   r$   r  Nr  r  r	  r
  r  r  r  r  r  r"  r"    s    !!$$r  r"  c                  H    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S	\S
'   Srg)_CompilerStackEntryi  r:   compile_stateboolneed_result_map_for_nestedneed_result_map_for_compoundr[   select_0Select[Any]insert_from_selectr  Nr%  r  r  r  r'  r'    s      $$"&&##r  r'  F)totalc                  ~    \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'    S\S'    \SS j5       r\SS j5       rSr	g)ExpandedStatei  a  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   	statementrd   
parameters%Mapping[str, _BindProcessorType[Any]]
processorsOptional[Sequence[str]]positiontupzMapping[str, List[str]]parameter_expansionc                   ^  T R                   c  [        R                  " S5      e[        U 4S jT R                    5       5      $ )zbTuple of positional parameters, for statements that were compiled
using a positional paramstyle.

z.statement does not use a positional paramstylec              3  B   >#    U  H  nTR                   U   v   M     g 7fr  r3  ).0keyr  s     r  	<genexpr>6ExpandedState.positional_parameters.<locals>.<genexpr>  s     F5EcT__S)5Es   )r7  r2   InvalidRequestErrortupler  s   `r  positional_parameters#ExpandedState.positional_parameters  s@     #))@  FT5E5EFFFr  c                    U R                   $ )z.synonym for :attr:`.ExpandedState.parameters`.r;  rB  s    r  additional_parameters#ExpandedState.additional_parameters  s     r  r  N)r  r  )r  rd   )
r  r  r	  r
  r  r  propertyrC  rF  r  r  r  r  r1  r1    si    " N=(( 65+(( 10 	G 	G  r  r1  c                      \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'    SrS\S'    SrS\S'    SrS\S'    Sr	S	\S'    Sr
S\S'    SrS\S'    SrS\S'   Srg)_InsertManyValuesi  a  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_columnsr6  sentinel_param_keysimplicit_sentinelembed_values_counterr  )r  r  r	  r
  r  r  rQ  rR  rT  rU  rV  rW  rX  r  r  r  r  rJ  rJ    s     
  87M#&&
 %*T) ',t+ 9=5< !"#! 4807  $t#	 "'$&	r  rJ  c                  ~    \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   Srg)_InsertManyValuesBatchi^  aW  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_statementre   replaced_parameters#Optional[_GenericSetInputSizesType]processed_setinputsizesz#Sequence[_DBAPISingleExecuteParams]batchzSequence[Tuple[Any, ...]]sentinel_valuesrO  current_batch_sizebatchnumtotal_batchesr)  rows_sortedis_downgradedr  Nr  r  r  r  rZ  rZ  ^  sD    
 //@@....Mr  rZ  c                  J    \ rS rSrSrSrSrSrSr\\-  \-  r	\\	-  r
SrSrS	rg
)InsertmanyvaluesSentinelOptsiw  z[bitflag enum indicating styles of PK defaults
which can work as implicit sentinel columns

r   r1            @   r  N)r  r  r	  r
  r  NOT_SUPPORTEDAUTOINCREMENTIDENTITYSEQUENCEANY_AUTOINCREMENT_SUPPORTED_OR_NOTUSE_INSERT_FROM_SELECTRENDER_SELECT_COL_CASTSr  r  r  r  rg  rg  w  sE    
 MMHH%08;%(99 r  rg  c                  $    \ rS rSrSr Sr SrSrg)CompilerStatei  r   r   r1   r  N)r  r  r	  r
  	COMPILINGSTRING_APPLIEDNO_STATEMENTr  r  r  r  ru  ru    s     I=N Lr  ru  c                  4    \ rS rSrSrSr Sr Sr \\-  rSr	g)Lintingi  zrepresent preferences for the 'SQL linting' feature.

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

r   r   r1   r  N)
r  r  r	  r
  r  
NO_LINTINGCOLLECT_CARTESIAN_PRODUCTSWARN_LINTINGFROM_LINTINGr  r  r  r  rz  rz    s5     J!" L2-<Lr  rz  c                  ,    \ rS rSrSrSS jrSS jrSrg)	
FromLinteri  zGrepresents current state for the "cartesian product" detection
feature.Nc                  ^	 U R                   nU(       d  g[        U R                  5      n[        U5      nUb  UnUR                  U5        OUR	                  5       n[
        R                  " U/5      nU(       a~  U(       aw  UR                  5       m	UR                  T	5        U Vs1 s H  nT	U;   d  M  UiM     nnUR                  U	4S jU 5       5        UR                  U5        U(       a	  U(       a  Mw  U(       a  XE4$ gs  snf )NNNc              3  T   >#    U  H  oUR                  T5      (       +    v   M     g 7fr  )index)r<  edgenodes     r  r>  "FromLinter.lint.<locals>.<genexpr>  s      NIDdjj&6"67I   %()fromsr~   edgesremovepopcollectionsdequepopleftdiscard
extendleftdifference_update)
r  startr  r  the_rest
start_withstackr  	to_remover  s
            @r  lintFromLinter.lint  s    

DJJu:JOOJ'!J!!:,/==?DT" +0@%$44<%I@ NINN##I.   '' As   '
D5Dc                   ^  T R                  5       u  p#U(       a\  UnU(       aR  SnSR                  U 4S jU 5       5      nUR                  UUT R                  U   S9n[        R
                  " U5        g g g )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  J   >#    U  H  nS TR                   U    S 3v   M     g7f)"N)r  )r<  from_r  s     r  r>  "FromLinter.warn.<locals>.<genexpr>  s'      &:?a

5)*!,%    #)	stmt_typer  r  )r  r   r   r  r&   warn)r  r  r  r  r  template	froms_strmessages   `       r  r  FromLinter.warn  s    #yy{ E7  !II &:?& 	 #//'#**Z0 *  		'"!  r  r  r  )SELECT)r  r  r	  r
  r  r  r  r  r  r  r  r  r    s    #J#r  r  r  r  c                    ^  \ rS rSr% SrSrS\S'    SrS\S'    S	\S
'    SrSr	Sr
S\S'   SrS\S'   SrS\S'   \R                  rS\S'    S\S'   \R                  rS\S'   SrS\S'    SrS\S'    SrS\S'    S\S'    SS\R(                  " 5       4         S*S jjrS+U 4S  jjr\S! 5       rS" rS# r\S,S$ j5       rS-S% jrS.S& jr   S/       S0S' jjr\S( 5       r S)r!U =r"$ )1Compiledi  a  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]r2   r   stringru  stateFzOptional[CursorResultMetaData]_cached_metadataz"Optional[List[ResultColumnsEntry]]_result_columns Optional[SchemaTranslateMapType]schema_translate_maprh   execution_optionsIdentifierPreparerpreparerr8   _annotationszOptional[CompileState]r(  dml_compile_stateOptional[CacheKey]	cache_keyfloat	_gen_timec                   Xl         U R                   R                  U l        U(       a&  X0l        U R                  R	                  U5      U l        Ub  [
        R                  U l        X l        UR                  U l
        UR                  U l        U R                  (       a3  [        (       a  [        U[        5      (       d   eUR                  U l        U R"                  " U R                  40 UD6U l        U(       a0  Uc   eU R                  R'                  U R$                  U5      U l        [
        R(                  U l        O[
        R*                  U l        [-        5       U l        g)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)dialectidentifier_preparerr  r  _with_schema_translateru  rv  r  r2  supports_executioncan_executer  r   
isinstancer;   _execution_optionsr  processr  _render_schema_translatesrw  rx  r   r  r  r  r2  r  render_schema_translatecompile_kwargss         r  __init__Compiled.__init__K  s   4 88(<% MM@@$DM  &00DJ&N(;;D ) 6 6D =%i<<<<)2)E)E&,,t~~HHDK&+777"mmEEKK!5 '55DJ&33DJ%r  c                @   > U R                  5         [        TU ]	  5       $ r  )_init_compiler_clssuper__init_subclass__)cls	__class__s    r  r  Compiled.__init_subclass__  s     w(**r  c                    g r  r  r  s    r  r  Compiled._init_compiler_cls  s    r  c                    U R                   (       a  UR                  XU5      $ [        R                  " U R                  5      er  )r  _execute_compiledr2   ObjectNotExecutableErrorr2  )r  
connectiondistilled_paramsr  s       r  _execute_on_connectionCompiled._execute_on_connection  s=     //(9  ..t~~>>r  c                D    [         R                  " U [        U5      5      Uer  r2   UnsupportedCompilationErrorr  r  elementerrkws       r  visit_unsupported_compilation&Compiled.visit_unsupported_compilation  s    --dDMBKr  c                    [        5       e)zReturn a Compiled that is capable of processing SQL expressions.

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

NotImplementedErrorrB  s    r  sql_compilerCompiled.sql_compiler  s     "##r  c                (    UR                   " U 40 UD6$ r  _compiler_dispatch)r  objkwargss      r  r  Compiled.process  s    %%d5f55r  c                V    U R                   [        R                  L a  U R                  $ g)z3Return the string text of the generated SQL or DDL.r  )r  ru  rw  r  rB  s    r  __str__Compiled.__str__  s#     ::555;;r  c                    [        5       e)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  paramsextracted_parametersescape_namess       r  construct_paramsCompiled.construct_params  s     "##r  c                "    U R                  5       $ )z0Return the bind params for this compiled object.r  rB  s    r  r  Compiled.params  s     $$&&r  )
r  r  r  r  r  r  r  r  r2  r  )
r  rk   r2  r  r  r  r  r)  r  Mapping[str, Any])r  r  r  SQLCompiler)r  rb   r  r   r  r   r  r   NNTr  "Optional[_CoreSingleExecuteParams]r  &Optional[Sequence[BindParameter[Any]]]r  r)  r  z)Optional[_MutableCoreSingleExecuteParams])#r  r  r	  r
  r  r2  r  r  is_sqlis_ddlr  r  r  r&   
EMPTY_DICTr  r  r(  r  r  immutabledictr  r  classmethodr  r  r  rH  r  r  r  r  r  r  __classcell__r  s   @r  r  r    s   
 *.I&-FC4-FF7;4;:>O7>=A:A)-8
 ! $(OOL/3,0M)0 15-4	 %)I!(	  BF(-,0,>,>,@7(7( +7( ?	7(
 "&7( *7(r+  ?L $ $6 6:GK!	$2$ E$ 	$
 
3$ ' 'r  r  c                  J    \ rS rSrSrSrS	S jrS
S jr        SS jrSr	g)TypeCompileri  z2Produces DDL specification for TypeEngine objects.z	visit_\w+c                    Xl         g r  r  )r  r  s     r  r  TypeCompiler.__init__  s    r  c                    UR                   (       aG  U R                  R                  UR                   ;   a#  UR                   U R                  R                     nUR                  " U 40 UD6$ r  )_variant_mappingr  r   r  r  r  r  s      r  r  TypeCompiler.process  sS    ""!!U%;%;;**4<<+<+<=E''333r  c                0    [         R                  " X5      Uer  )r2   r  r  s       r  r  *TypeCompiler.visit_unsupported_compilation  s     --d<#Er  r  N)r  rk   )r  r  r  r   r  r   )r  r   r  	Exceptionr  r   r  r   )
r  r  r	  r
  r  ensure_kwargr  r  r  r  r  r  r  r  r    s>    <L4FF!*F25F	Fr  r  c                  P    \ rS rSrSrSrSrSS jr\S 5       r	\S 5       r
S rS	rg
)_CompileLabeli  z;lightweight label object which acts as an expression.Label.labelr  r   
_alt_namesc                2    Xl         X l        U4U-   U l        g r  r  )r  colr   	alt_namess       r  r  _CompileLabel.__init__  s    	&9,r  c                .    U R                   R                  $ r  r  	proxy_setrB  s    r  r"  _CompileLabel.proxy_set      ||%%%r  c                .    U R                   R                  $ r  r  r  rB  s    r  r  _CompileLabel.type      ||   r  c                    U $ r  r  r  r  s     r  
self_group_CompileLabel.self_group      r  )r  r  r   N)r  )r  r  r	  r
  r  __visit_name__	__slots__r  rH  r"  r  r+  r  r  r  r  r  r    sD     FN/I-
 & & ! !r  r  c                  R    \ rS rSrSrSrSrS r\S 5       r	\S 5       r
S rS	 rS
rg)ilike_case_insensitivei  zproduce 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                2    Xl         UR                  U l        g r  r3  )r  r  s     r  r  ilike_case_insensitive.__init__  s    !,,r  c                .    U R                   R                  $ r  r!  rB  s    r  r"   ilike_case_insensitive.proxy_set	  r$  r  c                .    U R                   R                  $ r  r&  rB  s    r  r  ilike_case_insensitive.type  r(  r  c                    U $ r  r  r*  s     r  r+  !ilike_case_insensitive.self_group  r-  r  c                J    [        U R                  R                  U5      5      $ r  )r1  r  _with_binary_element_type)r  r  s     r  r>  0ilike_case_insensitive._with_binary_element_type  s!    %LL2259
 	
r  )r4  r  N)r  r  r	  r
  r  r.  r/  r  rH  r"  r  r+  r>  r  r  r  r  r1  r1    sJ    	 6N'I- & & ! !
r  r1  c                     \ rS rSr% Sr\r\R                  " SSSSSSSSS.5      r	S	\
S
'    S\
S'   S	\
S'   Sr\rSrS\
S'   SrS\
S'   SrS\
S'    S\
S'    SrS\
S'    SrS\
S'    SrS\
S'    SrS\
S'   S\
S'    S \
S!'    S"\
S#'    SrS\
S$'    SrS\
S%'    SrS\
S&'    S'\
S('    S'\
S)'    S'\
S*'    S+\
S,'    SrS\
S-'    SrS\
S.'    SrS\
S/'    SrS\
S0'    SrS\
S1'    SrS\
S2'    SrS3\
S4'    SrS5\
S6'    Sr S7\
S8'   Sr!S9\
S:'   Sr"S;\
S<'   \#" 5       r$S=\
S>'    \#" 5       r%S=\
S?'    \RL                  r'S@\
SA'    Sr( Sr) Sr*SB\
SC'    Sr+S7\
SD'    Sr,S7\
SE'   Sr-S7\
SF'   Sr.S\
SG'   SH\
SI'   SJ\
SK'   SL\
SM'   S\
SN'   \/R`                  " SO5      r1\/R`                  " SP5      r2\/R`                  " \2Rf                   SQ\1Rf                   35      r4\5SR 5       r6\5SS 5       r7SSS\8S4               GSSU jjr9\:GSSV j5       r;\Rx                  GS	SW j5       r=\:SX 5       r>\:SY 5       r?\:SZ 5       r@\R                  GS
S[ j5       rB\R                  GSS\ j5       rD\ER                  S] 5       rGS^ rHS_ rI\R                    GSS` j5       rJSa rK\:GSSb j5       rL  GS     GSSc jjrM      GS             GSSd jjrN\R                  Se 5       rO\:Sf 5       rP GS     GSSg jjrQ\R                  " Sh5      Si 5       rSSj\
Sk'   \R                  GSSl j5       rT\R                  \R                  " Sm5      Sn 5       5       rU\R                  \R                  " Sm5      So 5       5       rVGSSp jrWSq rXGSSr jrYSs rZ GSSt jr[ GSSu jr\     GSSv jr]Sw r^Sx r_    GS             GSSy jjr`Sz raS{ rbS| rcS} rdS~ reS rfGSS jrg GSS jrhGSS jriGSS jrjGSS jrkS rlS rmS rnS roS rpS rqS rrS rsS rtS ruS rvS rwS rxS ry GS       GSS jjrzS r{S r|GSS jr} GS S jr~S rS r GS!S jrS rS rS rS rS rS rS rS r GSS jrS r    GS"S jrS rS rS rS rS r GS         GS#S jjrS rS r\R                  S 5       rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r        GS$S jr        GS$S jr        GS$S jr     GS%S jrS r\S4S jr      GS&S jrS r      GS'S jrGS(S jr      GS)                 GS*S jjrS rSSSSS\GRn                  " S5      4                 GS+S jjrS rS r        GS,S jrS rS rGSS jrS rGS S jrS rS r          GS-S jr GSS jr       GS.S jrS rS r      GS/S jrS rS rS\
S'   \GR                  (       d"  \R                  " S\#" 5       4S\#" 5       4/5      r GSS jrSrST\
S'           GS0S jr    GS1S jrS rS rS r  GSS jrS rGS2S jrS rS rS r          GS3S jrS r   GS4S jr        GS5S jrGS S jrS r\R                  " \GR                  \GR                  \GR                  \GR                  \GR                  \GR                  \GR                  \GR                  \GR                  \GR                  05      r\GR                  \GR                  \GR                  05      r    GS6S jr                GS7S jr GS8S jrS rS rS rS r GS       GS9S jjrGS  rGS rGSGS jrGS rGS rGS rGSrg(:  r  i  zvDefault 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_matchr7  _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                $    U R                  5         g r  )_init_bind_translater  s    r  r  SQLCompiler._init_compiler_clsC  s      "r  c                    [         R                  " SR                  U R                  5      5      n[         R                  " SU S35      U l        U R                  U l        g )Nr  rK  rL  )reescaper   rN  compilerO  rP  )r  regs     r  r|   SQLCompiler._init_bind_translateG  sF    ii > >?@!#auAJ!7$'$B$B!r  r   c                   X@l         X0l        U(       a=  US    V	s0 s H  oR                  U	_M     n
n	US    V	s0 s H  oU	/_M     nn	X4U l        XPl        X`l        0 U l        [        R                  " 5       U l	        / U l
        / U l        UR                  U l        U R                  (       aN  UR                  R                  S5      =U l        nU(       a  UR                  S:X  a  SOSU l        ["        U l        O[&        UR                     U l        SU l        UR*                  =(       d    UR,                  U l        [/        5       U l        0 U l        0 U l        [6        R8                  " XU40 UD6  U R:                  (       d"  U R<                  (       d  U R>                  (       a  [@        (       a  [C        U[D        5      (       d   eU R:                  (       d  U R<                  (       a  [@        (       a  [C        U[F        5      (       d   eURH                  (       a  SU l%        OUU R                  (       aD  U R:                  (       a,  U RL                  RN                  (       a  URP                  (       a  SU l%        [&        UR                     U l)        U(       aP  U RT                  RW                  URT                  RY                  5        VVs0 s H  u  pUS;  d  M  X_M     snn5        U RZ                  [\        R^                  L av  U R                  (       a2  U R                  (       a  U Ra                  5         OU Rc                  5         U Rd                  (       a!  U Rg                  S	SS
9nU Ri                  USS9  gggs  sn	f s  sn	f s  snnf )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.

r   r   r   r   rI  NT>   r  r  r  
positionalr_  rf  r`  Fr  _no_postcompile)_populate_self)5column_keysr  r=  rr  for_executemanylintingrZ  r&   column_dictr[  r  r  r  
paramstyle
startswithrf  ra  _pyformat_templater`  BIND_TEMPLATESrv  label_lengthmax_identifier_lengthr0   anon_maptruncated_names_truncated_countersr  r  rR  rS  rQ  r   r  r@   rB   _inlineru  r  insert_executemany_returning_return_defaultsr_  __dict__updateitemsr  ru  rw  _process_numeric_process_positionalrg  r  #_process_parameters_for_postcompile)r  r  r2  r  r  r  r  _supporting_againstr  bcksmckbmnbkvr3  s                   r  r  SQLCompiler.__init__M  s   @ '"&/l3lEE1HlD3$-aL1LqsFLD1*.D&
  / 
 **, 
! ",,??'.'9'9'D'DY'OOD""--1AACs 3 -?D),:7;M;M,ND)	   AG$A$A 	 () <>35 $=f===DMMT]]}!)Z8888}} =%i<<<<$$"&DK))AA%66 #'DK*7+=+=>MM   !4 < < B B D D	 AD D" ::555&&))+,,.''!22!&$( 3 

 88t 9  ( 6y 41Vs   M>NN
N
c                J    U R                   c  gU R                   R                  $ )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)rm  rL  rB  s    r  insert_single_values_expr%SQLCompiler.insert_single_values_expr  s%     !!)))<<<r  c                   U R                   (       a  U R                   $ U R                  bS  [        U R                  5      (       a9  U R                  R                   Vs/ s H  n[	        U5      (       d  M  UPM     sn$ gs  snf )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

N)rX  r2  r(   _all_selected_columnsr'   )r  cs     r  effective_returningSQLCompiler.effective_returning  so     ""***^^'F4>>,B,B ===A$Q' =  s   A?5A?c                    U R                   $ )zFbackwards compatibility; returns the
effective_returning collection.

)r  rB  s    r  	returningSQLCompiler.returning  s     '''r  c                d     U R                   S   S   $ ! [         a  n[        S5      UeSnAff = f)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_executableSQLCompiler.current_executable  s;    <	M::b>,// 	MCD"L	Ms    
/*/c                X    [        U R                  5      [        U R                  5      -   $ r  )listrU  rV  rB  s    r  prefetchSQLCompiler.prefetch6  s#    D(()D1E1E,FFFr  c                    0 $ r  r  rB  s    r  _global_attributesSQLCompiler._global_attributes:  s    	r  c                f    [         R                  " 5       nXl        0 U l        0 U l        SU l        U$ )zzInitialize collections related to CTEs only if
a CTE is located, to save on the overhead of
these collections otherwise.

F)r&   OrderedDictrv  rw  rx  ry  )r  rv  s     r  _init_cte_stateSQLCompiler._init_cte_state>  s8     *.)9)9);	 #% "$#r  c              #    #    U R                   U R                  p!/ SsU l         U l         U R                  (       a  U R                  S   nSUS'   OSnU R                   U R                  4v   U(       a  UR                  S5        UUsU l         U l        g! W(       a  UR                  S5        UUsU l         U l        f = f7f)z;special API to support the use case of 'nested result sets'Fr  Tr*  N)r  rd  r  r  )r  result_columnsordered_columnsentrys       r  _nested_resultSQLCompiler._nested_resultV  s        !! ( 79%3d3	zz

26:23&&(=(===		67 8D $"7 		67 8D $"7s   'C AB ,(C )B==C c                <  ^^	 U R                   (       a   eU R                  [        R                  L d   eU R                  (       a   eU R
                  R                  S:X  a  SmOU R
                  R                  S:X  d   eSm/ m	SUU	4S jjn[        R                  " U R                  XR                  5      U l
        U R                  (       ay  U R                  R                  5        VVs0 s H  u  p#X2_M	     nnn[        U R                  5      [        U5      :X  d   eT	 Vs/ s H  oTR                  XU5      PM     snU l         OT	U l         U R                  (       a  / m	[        R                  " U R                  UU R                  R                   5      nU R                  R"                   Vs/ s H4  nUS   US   [        R                  " U R                  XS   5      US	   4PM6     nnU R                  R%                  UUS
9U l        g g s  snnf s  snf s  snf )Nr   %sr   r   c                   > U R                  S5      nU(       a  TR                  U5        T$ TR                  U R                  S5      5        U R                  S5      $ )Nr   r1   r   )r   append)mnormal_bindplaceholder	positionss     r  find_position6SQLCompiler._process_positional.<locals>.find_position{  sM    ''!*K  -""   ,wwqz!r  r   r   r1   r  rL  rN  )r  zre.Match[str]r  r   )r7  r  ru  rw  rf  r  r  r  sub_positional_patternr  rq  r  lengetrm  rL  rN  _replace)
r  r  r  r  reverse_escaper   rL  rN  r  r  s
           @@r  r  SQLCompiler._process_positionaln  s   ####zz]99999&&&&<<""h.K<<**g555K		" 	" ff$$m[[
 ""/3/F/F/L/L/NO/Ntqad/NNOt../3~3FFFF;D ;D4""4.9 D  )D!!I!#((&&99" //BB" CA aDaDFF433]aDIaD	 C  " &*%;%;%D%D#5#5 &E &D"% " P "s   ,H%H0;Hc                  ^ ^ T R                   (       d   eT R                  [        R                  L d   eSn0 mT R                  (       a_  T R
                  bR  [        R                  " U 4S jT R                  R                  5        5       T R                  R                  5       5      nOT R                  R                  5       nU H[  nUT;   a  M  T R                  U   nUT R                  ;   d  UT R                  ;   a  S TU'   MA  T R                   U 3nUS-  nUTU'   M]     UT l        [        T5      T l        T R"                  (       a[  [%        T5      nTR'                  5        VVs0 s H!  u  pxT R"                  R)                  Xw5      U_M#     snnm[%        T5      U:X  d   eT R*                  R-                  U4S jT R.                  5      T l        T R                  (       al  T R                  R0                  T-  n	T R                  R2                   V
s/ s H  n
U
S   U
S   SU
S   4PM     nn
T R                  R5                  U	US9T l        g g s  snnf s  sn
f )Nr   c              3  L   >#    U  H  nUTR                   ;  d  M  Uv   M     g 7fr  )rs  )r<  r   r  s     r  r>  /SQLCompiler._process_numeric.<locals>.<genexpr>  s(       84#9#99 D 8s   $	$c                ,   > TU R                  S5         $ Nr   r   r  	param_poss    r  <lambda>.SQLCompiler._process_numeric.<locals>.<lambda>  s    i
+r  r   r  r  r  )rf  r  ru  rw  rm  rs  	itertoolschainr[  valuesrZ  rp  ro  ra  next_numeric_posr  r7  rq  r  r  r  _pyformat_patternr  r  rL  rN  r  )r  numr   	bind_namebindph
len_beforer   posrL  r  rN  r  s   `           @r  r  SQLCompiler._process_numeric  sJ   """"zz]99999$&	!!d&<&<&H OO $ 6 6 8
 &&(E OO**,EII%::i(D0004666 (,	)$;;<SEBq')	)$   !$	?""YJ "+!2!2ID ''++D7<!2I y>Z/// ,,00+T[[
 !! &&99  //BB"BA 1qtT1Q4(B  "
 &*%;%;%D%D#5#5	 &E &D" "$"s   *(IIc                p   ^  U 4S jT R                    5        VVs0 s H  u  pUc  M
  X_M     snn$ s  snnf )Nc           	   3  0  >#    U  H  nTR                   U   UR                  R                  (       d%  UR                  R                  TR                  5      O6[        U4S  j[        [        UR                  5      R                   5       5      4v   M     g7f)c              3  Z   >#    U  H   nUR                  TR                  5      v   M"     g 7fr  )_cached_bind_processorr  )r<  	elem_typer  s     r  r>  9SQLCompiler._bind_processors.<locals>.<genexpr>.<genexpr>  s.      #.$	 &<<T\\JJ.$   (+N)	r[  r  _is_tuple_typer  r  rA  r   r/   types)r<  	bindparamr  s     r  r>  /SQLCompiler._bind_processors.<locals>.<genexpr>  s~       "1I OOI.  )~~<< "==dllK" #-1 )9>>.#e.$#  "1s   BB)r[  )r  r=  values   `  r  _bind_processorsSQLCompiler._bind_processors  sG     "&

  # CJ
 	
 
s   	22c                2    [        U R                  5      S:  $ r  )r  r  rB  s    r  is_subquerySQLCompiler.is_subquery  s    4::""r  c                    U $ r  r  rB  s    r  r  SQLCompiler.sql_compiler  s    r  c                F    U R                  UUSS9nU R                  U5      $ )a*  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

Tr  )r  r  )r  r  r  r3  s       r  construct_expanded_state$SQLCompiler.construct_expanded_state  s:     **%  + 


 77
 	
r  c                   U R                   (       aR  U(       dK  U R                  c   eU(       d  [        U R                  R                  5      $ [        R
                  " S5      eU=(       a    [        U R                  5      nU(       au  U R                  c  [        R                  " S5      eU R                  S   nU R                  n	U	c   eU	u  p[        X5       VVVs0 s H  u  pX     H  nX_M     M     nnnnOSnU(       Ga6  0 nU R                  R                  5        GH  u  nnU(       a  U R                  R                  UU5      OUnUR                  U;   a  UUR                     UU'   MP  UU;   a
  UU   UU'   M`  U(       a^  UR                   (       aM  U(       a$  [        R
                  " SUR                  U4-  SS9e[        R
                  " SUR                  -  SS9eU(       a  UR                  UU5      nOUnUR"                  (       a  UR$                  UU'   GM  UR&                  UU'   GM     U$ 0 nU R                  R                  5        H  u  nnU(       a  U R                  R                  UU5      OUnU(       a^  UR                   (       aM  U(       a$  [        R
                  " SUR                  U4-  SS9e[        R
                  " SUR                  -  SS9eU(       a  UR                  UU5      nOUnUR"                  (       a  UR$                  UU'   M  UR&                  UU'   M     U$ s  snnnf )	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   z@A value is required for bind parameter %r, in parameter group %dcd3x)codez)A value is required for bind parameter %r)rg  rh  dictr3  r2   r@  r)  rq  r  CompileErrorrr  zipr[  r  r  r=  requiredcallableeffective_valuer  )r  r  r  r  _group_number_checkr  has_escaped_namesorig_extracted
ckbm_tupler  rE  r  	extractedr  resolved_extractedpdr  r   escaped_namevalue_params                        r  r  SQLCompiler.construct_params-  s7    ##O44@@@D==HHII--4  )JT$2I2I-J ~~%&&J 
 "&!233J))) GD %($M"$MLA GD # $M  " "&B#'??#8#8#:	4 ) ++//d;  ==F*'-imm'<B|$V^'-d|B|$	 2 2$!554(}}m<= "(	  "55G'mm,!'  *&8&<&<%y' '0 ))+6+F+F<(+6+<+<<(K $;L IB#'??#8#8#:	4 ) ++//d;  i00$!554(}}m<= "(	  "55G'mm,!'  &"4"8"8I"NK"+K%%'2'B'BB|$'2'8'8B|$= $;@ Ig"s   L=c                  ^^^^	 U R                   mTR                  m	TR                  mTR                  mUUUU	4S jn0 nU R                  nU R
                   Hx  nXC;   a  M
  UR                  R                  (       a?  [        [        UR                  5      R                   Vs/ s H  nU" U5      PM     snX$'   Md  U" UR                  5      X$'   Mz     U$ s  snf )Nc                t   > U R                  T5      R                  T5      nUb  Tb  UT;  a  Tb  UT;   a  U$ g r  )_unwrapped_dialect_implget_dbapi_type)typdbtypedbapir  exclude_typesinclude_typess     r  lookup_type<SQLCompiler._get_set_input_sizes_lookup.<locals>.lookup_type  sH    009HHOF ""*fM.I"*f.Er  )r  include_set_input_sizesexclude_set_input_sizesr!  ro  r[  r  r  r   r/   r  )
r  r$  
inputsizesro  r  r  r!  r  r"  r#  s
         @@@@r  _get_set_input_sizes_lookup'SQLCompiler._get_set_input_sizes_lookup  s    ,,7777
	 
	 
!%!<!<I2~~,,  $Iy~~>DD)D  $D)
%
 )4INN(C
% ) )s   #Cc                     U R                  SS9$ )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  rB  s    r  r  SQLCompiler.params  s     $$E$22r  c                4  ^^^^^ 0 nU R                   nUc  U R                  nU R                  (       a  / nU R                  nUc  U R                  nOS=pVU R
                  n[        SU5      m[        SU5      m0 n0 m0 n	Sn
U R                  (       a  Ub  UnU R                  (       a  / n
OU R                  R                  5       nU R                  nU GH  mU(       a  UR                  TT5      OTnU R                  T   nXR                  ;   a*  UT;  a"  U R                  UUR                  U5      S9TU'   Mg  XR                   ;   Ga  UT;   a  X   nSnO1UR                  T5      nU R#                  XU5      nUu  nnXU'   UTU'   UR$                  (       d  UR'                  U5        UR(                  R*                  (       a,  Uc   eUR'                  UU4S j[-        US5       5       5        OUR'                  UU4S jU 5       5        U
b  U
R/                  S U 5       5        OUb  UR/                  S	 U 5       5        U VVs/ s H  u  nnUPM
     snnUT'   GM  GM  Uc  GM  UR1                  T5        GM     U4S
 jn[2        R4                  " U R6                  UU5      nU
bp  Uc   e[-        XR8                  5       VVs0 s H  u  nnUU R:                   U 3_M     snnmU R<                  R5                  U4S jU5      nUR/                  U
5        [?        UUUUU5      nU(       aZ  X@l         X`l        UR@                  U l        U R                  (       a  [C        UR                  =(       d    S5      OSU l        UU l"        U$ s  snnf s  snnf )af  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.

Nr4  z/Mapping[str, Sequence[_BindProcessorType[Any]]]render_literal_valuec              3     >#    U  HK  u  p[        US 5        H5  u  p4TT;   d  M  TT   US -
     c  M  T< SU< SU< 3TT   US -
     4v   M7     MM     g7f)r   NrE  )	enumerate)r<  ituple_elementjrE  r   tuple_processorss        r  r>  BSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>N  s{      	.
 5I 0(1-(C#'77 !1 6q1u =.2Aq 9 0 6q1u =
 )D 5Is   A
A#Ar   c              3  F   >#    U  H  u  pTT;   d  M  UTT   4v   M     g 7fr  r  )r<  r=  rE  r   single_processorss      r  r>  r6  Y  s0      .*3#'88 ;S"3D"9:*3s   !!c              3  *   #    U  H	  u  pUv   M     g 7fr  r  r<  r   rE  s      r  r>  r6  _  s      309WTD	   c              3  *   #    U  H	  u  pUv   M     g 7fr  r  r:  s      r  r>  r6  f  s     .M9t9r;  c                  >^^ U R                  S5      nTU   nU R                  S5      (       aV  U R                  S5      R                  S5      nUS   US   smmSR                  UU4S jUR                  S5       5       5      nU$ )Nr   r1   ~~r  r   c              3  :   >#    U  H  nT< U< T< 3v   M     g 7fr  r  )r<  expbe_leftbe_rights     r  r>  ]SQLCompiler._process_parameters_for_postcompile.<locals>.process_expanding.<locals>.<genexpr>v  s      !/ !(h7/s   )r   splitr   )r  r=  exprtokrA  rB  replacement_expressionss       @@r  process_expandingJSQLCompiler._process_parameters_for_postcompile.<locals>.process_expandingm  s    ''!*C*3/D wwqzzggaj&&t,$'FCF!yy !#zz$/!  Kr  c                ,   > TU R                  S5         $ r  r  r  s    r  r  ASQLCompiler._process_parameters_for_postcompile.<locals>.<lambda>  s    )AGGAJ/r  r  )#rj  r  r  rl  r7  r  r   rf  r[  r  rq  r  rZ  ro  render_literal_bindparamr  rp  $_literal_execute_expanding_parameterliteral_executer  r  r  r1  extendr  r  r  _post_compile_patternr  ra  r  r1  r2  r  rh  )r  r3  r  expanded_parameterspre_expanded_stringnew_positiontuppre_expanded_positiontupr5  new_processorsto_update_setsnumeric_positiontupnamesebnr  	parameter	to_updater  leep_resreplacement_expr
expand_keyrE  rH  r2  r  r=  expanded_stater   r  rG  r8  r5  s                             @@@@@r  r  /SQLCompiler._process_parameters_for_postcompile  s   $ ! #77&"&++?? O'+'E'E$'/+/+;+;( :>=O**
 3Z
  =z
 >@24)+ 48??7C#;E""&(#OO**,E%%D253774.4L

4(I777'>>55%1;1M 6  ,L9 444#:: . <I!F (^^D1F#HH$ H 5=1Y 03<<0<L+L9 00%%i0 ~~44%111&-- 	.
 5>fa4H	. 	 '-- .*3. 
 +6+22 3093  )4 (...M9.MM8A18A}z1
	1'-; 1@ !,&&t,S V	 FF&&(9;N
	 *"... !*')>)>!!HC ;;<SEBB!I ..22/I ""#67&
  )<%-E*(22DK ?? ^//526 
 1?D-{16s   	N	Nzsqlalchemy.engine.cursorc                    [         R                  R                  nUR                  R	                  U R
                  5      $ )z(utility method used for unit tests only.)r&   	preloadedengine_cursorrc   _create_description_match_mapr  )r  cursors     r  _create_result_mapSQLCompiler._create_result_map  s5     --**HH  
 	
r  _BindNameForColProtocol_get_bind_name_for_colc                    U R                   nU$ r  )ri  )r  getters     r  _within_exec_param_key_getter)SQLCompiler._within_exec_param_key_getter  s    ,,r  zsqlalchemy.engine.resultc           	       ^^	^
^^^ [         R                  R                  nU R                  nU R                  c   eU R                  R
                  n[        (       a  [        U[        5      (       d   eUR                  nUR                   Vs/ s H#  n[        R                  " SU" U5      S 5      U4PM%     snmS m	UR                  mTbG  TR                  R                  U R                   S 5      mU" T5      m
T
U R"                  ;   a  U
4S jnUm	OS mUR%                  UR                   Vs/ s H  oUR&                  PM     sn5      mUU	UUU4S jnU$ s  snf s  snf )Nr  c                6   > UR                  TU 5      nUb  U$ U $ r  r  )	lastrowidr3  param_valueautoinc_keys      r  _autoinc_getterPSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>._autoinc_getter  s)    ",..i"HK".
  +*  )(r  c                r   >^ ^ Tb  T" T 5      m T c  T" U4S jT 5       5      $ T" UUU U4S jT 5       5      $ )zgiven 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.

c              3  8   >#    U  H  u  pU" T5      v   M     g 7fr  r  )r<  rk  r  r3  s      r  r>  WSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>  s     LG[VfZ00G   c              3  ^   >#    U  H"  u  pUTL a  Tb	  T" TT5      O	TOU" T5      v   M$     g 7fr  r  )r<  rk  r  autoinc_colautoinc_getterrq  r3  s      r  r>  rx    sI       (/ +-  .9 +9jA!* $J/0 (/   *-r  )rq  r3  r{  r|  getterslastrowid_processorrow_fns   ``r  r  DSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get  sH     #./	:	 LGLLL  (/  r  )r&   rb  engine_resultrl  r(  r2  r   r  r>   r   primary_keyoperatormethodcaller_autoincrement_columnr  _cached_result_processorr  rZ  result_tupler=  )r  resultparam_key_getterr2  r   r  rt  r  r{  r|  rs  r~  r  r  s           @@@@@@r  +_inserted_primary_key_from_lastrowid_getter7SQLCompiler._inserted_primary_key_from_lastrowid_getter  sQ    --==!!---&&00	=i0000 ((
( ""5*:3*?FL(

 11""-"2"2"K"Kd# +;7K djj(
) "1 #'$$9J9J%K9J#gg9J%KL	 	4 
G
N &Ls   *E.Ec                  ^
^ [         R                  (       a  SSKJn  O[        R
                  R                  nU R                  c   eU R                  R                  n[        (       a  [        U[        5      (       d   eU R                  nUR                  nU R                  nUc   e[        U5       VVs0 s H  u  pgXv_M	     nnn[        SUR                    Vs/ s HB  nXx;   a  ["        R$                  " X   5      S4O["        R&                  " SU" U5      S 5      S4PMD     sn5      m
UR)                  UR                    Vs/ s H  owR*                  PM     sn5      mU
U4S jn	U	$ s  snnf s  snf s  snf )Nr1   )r  z'List[Tuple[Callable[[Any], Any], bool]]Tr  Fc                .   >^ ^ T" UU 4S jT 5       5      $ )Nc              3  V   >#    U  H  u  pU(       a  U" T5      OU" T5      v   M      g 7fr  r  )r<  rk  use_rowr3  rows      r  r>  WSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get.<locals>.<genexpr>3	  s*      '.OF  'sF:,>>'.s   &)r  )r  r3  r~  r  s   ``r  r  DSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get2	  s     '.  r  )typingr   enginer  r&   rb  r  r(  r2  r  r>   rl  r   rX  r1  r   r  r  
itemgetterr  r  r=  )r  r  r2  r  r   r  idxr  retr  r~  r  s             @@r  +_inserted_primary_key_from_returning_getter7SQLCompiler._inserted_primary_key_from_returning_getter
	  sf    '^^11F!!---&&00	=i0000==++	$$$(1)(<=(<HCsx(<=5 !,, -C z ((2D9 !--!#3C#8$ 	 -
" $$9J9J%K9J#gg9J%KL	 
7 > &Ls   7E*A	E0
E5c                    g)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  rB  s    r  default_fromSQLCompiler.default_from:	  s     r  c                   UR                   R                  " U 40 UD6nUR                   GHM  nX@R                  ;  a  M  U R                  U   nUR	                  UR                  UR
                     SSS9nU R                  U   nU=U R                  U'   U R                  U'   XpR                  U'   U R                  R                  US5        XPR                  ;   a  U =R                  U1-  sl        XPR                  ;   a  U =R                  U1-  sl	        U R                  nU(       d  GM  Uu  pUR                   H6  nUR
                  U
;   d  M  XR
                     nX   R                  U5        M8     GMP     U$ )aB  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  	translaterZ  _with_valuer=  r[  r  rp  ro  rr  _cloned_setr  )r  override_bindsr  sqltextr  bpnew_bpr   r  r  r  cbs               r  visit_override_binds SQLCompiler.visit_override_bindsD	  sR   " !((;;DGBG  ))A

"AB ^^((0! $ F ??2&D/55DJJqMDJJt,&*OOF#OOD)---((VH4(000++x7+33Jz'
..Bvv~!&&\/ )? *H r  c                H    SUR                   R                  " U 40 UD6-   S-   $ NrG  rH  r  r  )r  groupingasfromr  s       r  visit_groupingSQLCompiler.visit_grouping	  (    X%%88HHH3NNr  c                H    SUR                   R                  " U 40 UD6-   S-   $ r  r  )r  r  r  s      r  visit_select_statement_grouping+SQLCompiler.visit_select_statement_grouping	  r  r  c                $   U R                   (       a  U R                  R                  (       a   [        SU R                   S   S   5      nUR                  u  nnnU(       a  Un	OUn	UR                  R                  n
U
bK  U
R                  U	;   a;  U
R                  XR                     5      (       a  UR                  R                  US'   U R                  " UR                  4SU0UD6$ ! [         a  n[
        R                  " S5      UeS nAff = f)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   KeyErrorr2   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_reference!SQLCompiler.visit_label_reference	  s    ::$,,EE	 $=JJrN?3! 11	$)( $OOCCM )!&&,6!00 !3!34 
 OO;; ./ ||OO
"7
 
 	
A  &&/ s   C) )
D3D

Dc                F   U R                   (       d  U R                  UR                  5      $  [        SU R                   S   S   5      nWR                  u  pgn U(       a  XqR                     n	OXaR                     n	XS'   U R                  " U	4SU0UD6$ ! [         a9  n[
        R                  " UR                  S[        R                  US9   S nANS nAff = f! [         a9  n
[
        R                  " UR                  S[        R                  U
S9   S n
A
g S n
A
ff = f)Nr  r  r(  r  )extraexc_clsr  r  r  )r  r  _text_clauser   r  r   _no_text_coercionr  r2   r  r  )r  r  r  r  r(  r  r  r  r  r  r  s              r  visit_textual_label_reference)SQLCompiler.visit_textual_label_reference	  s    zz<< 4 455	 9

2/M ,9+L+L(	y	$ 10 /2*+<<+@DJ ;  		''/ ((		"  		''/ ((		s/   B $C 
C!/CC
D '/DD c                   U=(       a    U(       + nXQL n	U	(       d  U(       aR  [        UR                  [        R                  5      (       a  U R	                  SUR                  5      n
OUR                  n
U(       a  Ub0  U" W
UR                  X4UR
                  -   U-   UR                  5        UR                  R                  " U 4SSS.UD6[        [        R                     -   U R                  R                  UW
5      -   $ U	(       a  U R                  R                  UW
5      $ UR                  R                  " U 4SS0UD6$ )NcolidentT)r  within_label_clauser  F)r  r   r   rC   _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_labelSQLCompiler.visit_label	  s:    "=*=&= 	 2: 4%**h&?&?@@ 66z5::N	!JJ	 ,!JJ&)9)99<NNJJ	 00*.(, 	 IMM*+ --,,UI>?	 ==--eY??==33,157 r  c                .    [         R                  " S5      e)Nz:Cannot compile Column object until its 'name' is assigned.r2   r  r  r   s     r  _fallback_column_name!SQLCompiler._fallback_column_name
  s    H
 	
r  c                @    UR                   nU R                  " U40 UD6$ r  )	_resolvedr  )r  r  r  sql_elements       r  visit_lambda_element SQLCompiler.visit_lambda_element
  s!    ''||K.2..r  c                   UR                   =pxUc  U R                  U5      nUR                  n	U	(       d1  [        U[        R
                  5      (       a  U R                  SU5      nUbD  XUR                  4U-   n
UR                  (       a  XR                  4-  n
U" XxXR                  5        U	(       a  U R                  U5      nOU R                  R                  U5      nUR                  nUb  U(       a  UR                  (       d  U$ U R                  R                  U5      nU(       a  U R                  R!                  U5      S-   nOSn["        (       a  [        U[$        5      (       d   eUR                   nU(       d  U(       a	  X;   a  X^   n[        U[        R
                  5      (       a  U R                  SU5      nXR                  R                  U5      -   S-   U-   $ )Nr  rJ  r  alias)r   r  
is_literalr  r   rC   r  r=  	_tq_labelr  escape_literal_columnr  quoter   named_with_columnschema_for_objectquote_schemar   rZ   )r  r   r  include_tabler  ambiguous_table_name_mapr  r   	orig_namer  targetsr   effective_schemaschema_prefix	tablenames                  r  visit_columnSQLCompiler.visit_column 
  s    ";;&<--f5D&&
jx/H/HII--j$?D(VZZ03EEG,,..dwD --d3D==&&t,D=U5L5LK#}}>>uEMM../?@3F  !#}!%9999

I %,94?	)X%>%>?? 66w	J	 ==#6#6y#AACG$NNr  c                L    U R                   R                  UR                  5      $ r  )r  format_collation	collationr  r  r  s      r  visit_collationSQLCompiler.visit_collation[
  s    }}--g.?.?@@r  c                    UR                   $ r  r   )r  
fromclauser  s      r  visit_fromclauseSQLCompiler.visit_fromclause^
  s    r  c                    UR                   $ r  r  )r  r  r  s      r  visit_indexSQLCompiler.visit_indexa
  s    zzr  c                    XS'   U R                   US'   U R                  R                  R                  " UR                  40 UD6$ )Ntype_expressionr  )r  r  type_compiler_instancer  r  )r  
typeclauser  s      r  visit_typeclauseSQLCompiler.visit_typeclaused
  sF     *$(MM !||22::OO
!
 	
r  c                `    U R                   R                  (       a  UR                  SS5      nU$ NrF  %%r  _double_percentsreplacer  texts     r  post_process_textSQLCompiler.post_process_textk
  $    ==))<<T*Dr  c                `    U R                   R                  (       a  UR                  SS5      nU$ r  r  r  s     r  r  !SQLCompiler.escape_literal_columnp
  r  r  c           	       ^ ^^ UU U4S jnT R                   (       d  ST l        U(       a  U" S S T4[        R                  5        [        R                  S [        R                  UT R                  TR                  5      5      5      $ )Nc                   > U R                  S5      nUTR                  ;   a   TR                  " TR                  U   40 TD6$ TR                  " U40 TD6$ r  )r   _bindparamsr  bindparam_string)r  r   r  r  
textclauses     r  do_bindparam2SQLCompiler.visit_textclause.<locals>.do_bindparamv
  sS    771:Dz---||J$:$:4$@GBGG,,T8R88r  Tc                $    U R                  S5      $ r  r  )r  s    r  r  .SQLCompiler.visit_textclause.<locals>.<lambda>
  s    aggajr  )	r  rY  r%   NULLTYPEBIND_PARAMS_ESCr  BIND_PARAMSr  r  )r  r  r  r  r  s   `` ` r  visit_textclauseSQLCompiler.visit_textclauseu
  sl    	9 zz#D dD:-9J9JK "" OOd44Z__E
 	
r  c                   U R                   (       + nU(       a  U R                  OU R                   S   n[        5       [        5       US.nU R                   R                  U5        UR                  (       a  U R                  X5        U=(       d7    US:H  =(       a    UR                  SS5      =(       d    UR                  SS5      nU(       ax  UR                  =U l        U l	        UR                  (       + =(       a    [        UR                  5      U l        UR                   H  n	U R                  U	SU R                  S9  M      U R                  " UR                  40 UD6n
U R                   (       a0  U(       d  [#        U R                   5      OS nU R%                  US	9U
-   n
U R                   R'                  S5        U
$ )
Nr  r$  r#  r$   r   r+  Fr*  T)r  r  nesting_level)r  _default_stack_entryr~   r  _independent_ctes_dispatch_independent_ctesr  r  rd  rb  r)  column_argsre  r  _add_to_result_mapr  rv  r  _render_cte_clauser  )r  tafcompound_indexr  r  toplevelr  	new_entrypopulate_result_mapr  r  r*  s               r  visit_textual_select SQLCompiler.visit_textual_select
  sw    zz>-5))4::b>  #uE*
	
 	

)$  ++C4  >!# EII<eD>
 yy5u= 	 D!D$A 47>>/A 0dGD, __*.&*&=&=   % ||CKK.2.993;C

OM***G$ND

rr  c                    gNNULLr  r  rE  r  s      r  
visit_nullSQLCompiler.visit_null
      r  c                <    U R                   R                  (       a  gg)Nr   1r  supports_native_booleanr;  s      r  
visit_trueSQLCompiler.visit_true
  s    <<//r  c                <    U R                   R                  (       a  gg)Nr   0rA  r;  s      r  visit_falseSQLCompiler.visit_false
  s    <<//r  c                L   ^ ^ UR                  S UU 4S jU 5        5       5      $ )Nc              3  8   #    U  H  nU(       d  M  Uv   M     g 7fr  r  r<  ss     r  r>  7SQLCompiler._generate_delimited_list.<locals>.<genexpr>
  s      
I AI   	c              3  H   >#    U  H  oR                   " T40 TD6v   M     g 7fr  r  r<  r  r  r  s     r  r>  rM  
  s     I1**4626   "r   )r  r   	separatorr  s   `  `r  _generate_delimited_list$SQLCompiler._generate_delimited_list
  s&    ~~ 
II
 
 	
r  c                v  ^ ^ [         R                  R                  [        R                  [         R
                  R                  [         R                  R                  U5      u  p1US:X  a  US   R                  " T 40 TD6$ [        [        R                     nUR                  S UU 4S jU 5        5       5      $ )Nr   r   c              3  8   #    U  H  nU(       d  M  Uv   M     g 7fr  r  rK  s     r  r>  ;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>
  s      "LA LrN  c              3  H   >#    U  H  oR                   " T40 TD6v   M     g 7fr  r  rP  s     r  r>  rX  
  s     LGq..t:r:GrQ  )r   BooleanClauseList_process_clauses_for_booleanr!   and_rL   
_singletonrI   r  r  r   )r  clausesr  lccrS  s   ` `  r  _generate_delimited_and_list(SQLCompiler._generate_delimited_and_list
  s    11NNNNNN%%OO&&	
 !81:00<<<!)..1I>> "LGL"  r  c                .    SU R                   " U40 UD6-  $ N(%s))visit_clauselist)r  
clauselistr  s      r  visit_tupleSQLCompiler.visit_tuple
  s    --j?B???r  c                    UR                   nUc  SnO[        UR                      nU R                  " UR                  U40 UD6$ NrM  )r  r  rT  r^  )r  rf  r  seps       r  re  SQLCompiler.visit_clauselist
  sE    !!;CJ//0C,,Z-?-?KKKr  c                   UR                   nU R                  USS 5      nU(       a	  U" X40 UD6$  [        U   nSUS'   U R                  " UR                  U40 UD6$ ! [
         a  n[        R                  " X5      UeS nAff = f)Nexpression_clauselistT_in_operator_expression)r  _get_operator_dispatchr  rT  r^  r  r2   r  )r  rf  r  	operator_dispopstringr  s          r  visit_expression_clauselist'SQLCompiler.visit_expression_clauselist
  s    ''	**.
 
444	 +H -1B()00""H02 	  	L11$BK	Ls   	A 
B'A>>Bc                h   SnUR                   b"  X1R                   R                  " U 40 UD6S-   -  nUR                   H8  u  pEUSUR                  " U 40 UD6-   S-   UR                  " U 40 UD6-   S-   -  nM:     UR                  b&  USUR                  R                  " U 40 UD6-   S-   -  nUS-  nU$ )NzCASE rM  zWHEN z THEN zELSE END)r  r  whenselse_)r  clauser  xcondr  s         r  
visit_caseSQLCompiler.visit_case  s    <<#00@@3FFA"LLLD))$9&9: ++D;F;< 	A ) <<#&,,99$I&IICOA 	
U
r  c                <    UR                   R                  " U 40 UD6$ r  )typed_expressionr  )r  type_coercer  s      r  visit_type_coerceSQLCompiler.visit_type_coerce  s    ++>>tJrJJr  c                "   UR                   R                  " U 40 UD6n[        R                  " SU5      nSUR                  R                  " U 40 UD6< SU(       a  UR                  S5      OU< SU(       a  UR                  S5      < 3$ S< 3$ )Nz(.*)( COLLATE .*)zCAST(r   r   rH  r1   r  )r	  r  r  matchrz  r   )r  r   r  type_clauser  s        r  
visit_castSQLCompiler.visit_cast  s    oo88HH,k:KK**4:6:#EKKN4#EKKN+
 	
 *,+
 	
r  c           
        US   [         R                  L a  SOUS   [         R                  L a  SOmUS   S:  a7  U R                  " [         R                  " [        US   5      5      40 UD6< S3O-U R                  " [         R                  " US   5      40 UD6< S3< SUS   [         R                  L a  S< 3$ US   [         R                  L a  S< 3$ US   S:  a:  U R                  " [         R                  " [        US   5      5      40 UD6< S3< 3$ U R                  " [         R                  " US   5      40 UD6< S3< 3$ )	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_clause SQLCompiler._format_frame_clause'  su    !9 8 88 & ayH$:$:: " "!9q=	 !LL ( 0 0VAY @DF  <<(8(8(CJrJM( !9 8 88 & +'
 '	
2 ayH$:$:: "+'
 '	
B "!9q=	 !LL ( 0 0VAY @DF+'
 '	
F  <<(8(8(CJrJM+'
 '	
r  c                h   UR                   R                  " U 40 UD6nUR                  b!  SU R                  " UR                  40 UD6-  nO^UR                  b!  SU R                  " UR                  40 UD6-  nO0UR
                  b!  SU R                  " UR
                  40 UD6-  nOS nU< SSR                  SUR                  4SUR                  44 VVs/ s H6  u  pVUc  M
  [        U5      (       d  M  U< SUR                  " U 40 UD6< 3PM8     snnU(       a  U/O/ -   5      < S	3$ s  snnf )
NzRANGE BETWEEN %szROWS BETWEEN %szGROUPS BETWEEN %sz OVER (rM  	PARTITIONORDERz BY rH  )
r  r  r  r  rowsgroupsr   partition_byorder_byr  )r  overr  r  r  wordrz  s          r  
visit_overSQLCompiler.visit_overQ  sU   ||..t>v>;;"'$*C*C+%+ F YY"&)B)B		*#* F [[$(4+D+D,%, F F HH
 %d&7&78 $--0)) H /2&kHV66tFvFH)  &F82	/
 	
s   	D.%D.7D.c                    UR                   R                  " U 40 UD6< SUR                  R                  " U 40 UD6< S3$ )Nz WITHIN GROUP (ORDER BY rH  )r  r  r  )r  withingroupr  s      r  visit_withingroupSQLCompiler.visit_withingroupr  s>    224B6B  33DCFC
 	
r  c                    UR                   R                  " U 40 UD6< SUR                  R                  " U 40 UD6< S3$ )Nz FILTER (WHERE rH  )funcr  	criterion)r  
funcfilterr  s      r  visit_funcfilterSQLCompiler.visit_funcfilterx  s<    OO..t>v>  33DCFC
 	
r  c                    U R                   R                  UR                  UR                  5      nSU< SUR                  R                  " U 40 UD6< S3$ )NzEXTRACT(r   rH  )extract_mapr  fieldrE  r  )r  extractr  r  s       r  visit_extractSQLCompiler.visit_extract~  sF      $$W]]GMMBLL++D;F;
 	
r  c                v    U R                   " UR                  40 UD6nU R                  " U40 UD6nSU< SU< 3$ )NrG  z).)visit_functionfnr  )r  r  r  compiled_fncompiled_cols        r  visit_scalar_function_column(SQLCompiler.visit_scalar_function_column  s;    ))'**;;((7B7'66r  c           	        Ub4  U" UR                   UR                   UR                   4UR                  5        [        U SUR                   R                  5       -  S 5      nU(       a  U" U40 UD6nGOY[        R                  UR                  5       R                  S 5      nU(       a  UR                  (       a  US-  nOmUR                   nU R                  R                  U5      (       d  [        U[        R                  5      (       a  U R                  R                  U5      OUnUS-   nSR                  UR                    Vs/ s H_  nU R                  R                  U5      (       d  [        U[        R                  5      (       a  U R                  R                  U5      OUPMa     snU/-   5      SU R"                  " U40 UD60-  nUR$                  (       a  US-  nU$ s  snf )Nzvisit_%s_funcz%(expr)srJ  rE  z WITH ORDINALITY)r   r  getattrlowerr   r  _deannotater  	_has_argsr  _requires_quotes_illegal_charsr  r   r.   r  r   packagenamesfunction_argspec_with_ordinality)r  r  r  r  rr  r  r   rF  s           r  r  SQLCompiler.visit_function  s    (diiTYYL$))Lt_tyy/@@$G ''D==!1!1!3!=!=tDD>>J&Dyy }}CCDII!$(<(<== MM''- 	  j(88  $00  1	  ==GGLL%dH,@,@AA ++C0 !!
  1 &	 ..t>v>?@D   &&Ds   A&G#c                8    U R                  UR                  5      $ r  )visit_sequencesequence)r  
next_valuer  s      r  visit_next_value_func!SQLCompiler.visit_next_value_func  s    "":#6#677r  c                F    [        SU R                  R                  -  5      e)Nz2Dialect '%s' does not support sequence increments.r  r  r   r  r  r  s      r  r  SQLCompiler.visit_sequence  s$    !@ll 
 	
r  c                <    UR                   R                  " U 40 UD6$ r  )clause_exprr  )r  r  r  s      r  r  SQLCompiler.function_argspec  s    224B6BBr  c           
       ^ ^^ T R                   (       + nUR                  " UT 40 TD6nU(       a  T R                  (       d  UT l        UR                  nU(       a  T R                  OT R                   S   nU=(       d     U(       + =(       a    UR                  SS5      n	US:X  a  XS'   T R                   R                  US   US   UUU	S.5        UR                  (       a  T R                  UT5        T R                  UR                     n
S	U
-   S	-   R                  UUU 4S
 j[        UR                  5       5       5      nSTS'   UT R                  " U40 [        SST0TD6D6-  nUT R                   " U40 TD6-  nUR"                  (       a  UT R$                  " U40 TD6-  nT R&                  (       a1  U(       d  [)        T R                   5      OS nT R+                  USS9U-   nT R                   R-                  S5        U$ )Nr  r+  Fr   r,  r$  r#  )r$  r#  r$   r(  r+  rM  c              3  T   >#    U  H  u  pUR                   " T4TUS .TD6v   M     g7f))r  r2  Nr  )r<  r2  r  r  r  r  s      r  r>  4SQLCompiler.visit_compound_select.<locals>.<genexpr>  s>       2DA $$!'=C 2r  r  r  Tr*  include_following_stackr  )r  _compile_state_factoryr(  r2  r+  r  r  r,  r-  compound_keywordskeywordr   r1  selectsgroup_by_clauser
  order_by_clause_has_row_limiting_clause_row_limit_clauserv  r  r0  r  )r  csr  r2  r  r3  r(  compound_stmtr  need_result_mapr  r  r*  s   ` ` `        r  visit_compound_select!SQLCompiler.visit_compound_select  s    zz>11"dEfED..!.D%//-5))4::b>" 
 A		8%@ 	 Q "*

#():#; %n 5 !.0?	
 **++M6B((4g#)) &bjj1	
 #($$RI4+Hv+H+HII$$R2622&&D**2888D993;C

OM''"/,0 (  	  	

rr  c                h    UR                   b  U R                  " U40 UD6$ U R                  " U40 UD6$ r  )_fetch_clausefetch_clauselimit_clause)r  r  r  s      r  r  SQLCompiler._row_limit_clause  s:    '$$R2622$$R2622r  c                `    SUR                   < SU< U(       a  SU-   OS< 3n[        XS 5      $ )Nvisit_rE  r  )r  r  )r  rq  
qualifier1
qualifier2attrnames        r  rp  "SQLCompiler._get_operator_dispatch  s3     *C*2

 tt,,r  c                P   Ub  X14-  nX$S'   X4S'   UR                   (       a  UR                  (       a  [        R                  " S5      eU R	                  UR                   SS5      nU(       a  U" XR                   40 UD6$ U R
                  " U[        UR                      40 UD6$ UR                  (       a\  U R	                  UR                  SS5      nU(       a  U" XR                  40 UD6$ U R                  " U[        UR                     40 UD6$ [        R                  " S5      e)Nr  r  zFUnary expression does not support operator and modifier simultaneouslyunaryr  modifierz,Unary expression has no operator or modifier)r  r  r2   r  rp   _generate_generic_unary_operatorr   _generate_generic_unary_modifier)r  r  r  r  r  rr  s         r  visit_unarySQLCompiler.visit_unary  s*    ((*&7"#'9#$>>~~&&2  ..D E>>8R88<<9U^^48:  ^^..D E>>8R88<<9U^^48:  ""> r  c                   U R                   R                  (       a  U R                  " UR                  40 UD6S-   U R                  " [        R
                  " UR                  UR                  R                  R                  [        R                  L a  UR                  R                  O[        R                  " 5       5      40 UD6-   $ U R                  " UR                  40 UD6S-   U R                  " UR                  40 UD6-   $ )N / )r  div_is_floordivr  r   r   Castr   r  _type_affinityr%   Numericr  r   r  r  s       r  visit_truediv_binary SQLCompiler.visit_truediv_binary9  s    <<''V[[/B/ ,,MM  &||00??'// 0 #LL-- "*!1!1!3 	( V[[/B/,,v||2r23r  c                   U R                   R                  (       ao  UR                  R                  R                  [
        R                  L a>  U R                  " UR                  40 UD6S-   U R                  " UR                  40 UD6-   $ SU R                  " UR                  40 UD6S-   U R                  " UR                  40 UD6-   -  $ )Nr  z	FLOOR(%s))	r  r  r   r  r  r%   Integerr  r   r  s       r  visit_floordiv_binary!SQLCompiler.visit_floordiv_binaryT  s    LL((!!00H4D4DD V[[/B/,,v||2r23 V[[/B/,,v||2r23 r  c                    UR                   (       d  U R                  R                  (       a  U R                  " UR                  40 UD6$ SU R                  " UR                  40 UD6-  $ )Nz%s = 1_is_implicitly_booleanr  rB  r  r  r  r  r  r  s       r  visit_is_true_unary_operator(SQLCompiler.visit_is_true_unary_operatore  sM    **||33<<6266dll7??AbAAAr  c                    UR                   (       d  U R                  R                  (       a   SU R                  " UR                  40 UD6-  $ SU R                  " UR                  40 UD6-  $ )NNOT %sz%s = 0r  r  s       r  visit_is_false_unary_operator)SQLCompiler.visit_is_false_unary_operatorn  sR    **||33dll7??AbAAAdll7??AbAAAr  c                D    SU R                  U[        R                  S9-  $ )Nr  )override_operator)visit_binaryr!   match_opr  s       r  visit_not_match_op_binary%SQLCompiler.visit_not_match_op_binaryw  s,    $++i&8&8 , 
 
 	
r  c                >    SU R                   " U[        U   40 UD6-  $ rc  )_generate_generic_binaryr  r  s       r  visit_not_in_op_binary"SQLCompiler.visit_not_in_op_binary|  s0     55Ih'
+-
 
 	
r  c                   U[         R                  L a+  [        U5      S:  a  SSR                  S U 5       5      -  $ gU[         R                  L a+  [        U5      S:  a  SSR                  S U 5       5      -  $ gU R                  U5      $ )	Nr   z(%s)) OR (1 = 1r   c              3  &   #    U  H  nS v   M	     g7fr:  Nr  r<  r  s     r  r>  6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>       :EfE   zNULL) OR (1 = 1z(%s)) AND (1 != 1c              3  &   #    U  H  nS v   M	     g7fr  r  r  s     r  r>  r    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_expr#SQLCompiler.visit_empty_set_op_expr  s    	+++5zA~(II:E::  ))//)5zA~*II:E::  +,,U33r  c                F    [        SU R                  R                  -  5      e)Nz3Dialect '%s' does not support empty set expression.r  r  element_typesr  s      r  r   SQLCompiler.visit_empty_set_expr  s$    !All 
 	
r  c                |  ^ ^^	^
 TR                   R                  T R                  5      nU(       d  UR                  (       aT  T R                  R                  (       a  SOST R                  TR                   R                  TR                  5      -   nSU4$ T R                  TR                   /TR                  5      n SU4$ UR                  (       dQ  UR                  (       a  [        US   [        R                  5      (       a  [        US   [        [        45      (       de  UR                  (       a  [        S5      eT R                  R                  (       a  SOSSR!                  UU 4S j[#        U5       5       5      -   nSU4$ U(       a  T R$                  nUR'                  U5      nU(       a  UR)                  S5      (       d   S5       eUR)                  S5      R+                  S	5      nUS
   US   sm	m
SR!                  U	U
UU 4S jU 5       5      nSU4$ SR!                  UU 4S jU 5       5      nSU4$ )NVALUES r  r   z?bind_expression() on TupleType not supported with literal_bindsr   c           	   3     >#    U  HC  u  pS SR                  U4S j[        UTR                  R                  5       5       5      -  v   ME     g7f)rd  r   c              3  J   >#    U  H  u  pTR                  X5      v   M     g 7fr  r.  )r<  r  
param_typer  s      r  r>  [SQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>.<genexpr>  s-      2-E 11%DD2r  N)r   r  r  r  )r<  r2  r3  rZ  r  s      r  r>  QSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>  sQ       ):$A II 14)9>>+?+?2  ):s   AAr1   )unexpected format for expanding parameterr>  r   r  c              3  n   >#    U  H*  nT< TR                  UTR                  5      < T< 3v   M,     g 7fr  r/  r  )r<  r  rA  rB  rZ  r  s     r  r>  r'    s8      3 "(	  11%H 	 "(   25c              3  \   >#    U  H!  nTR                  UTR                  5      v   M#     g 7fr  r*  )r<  r  rZ  r  s     r  r>  r'    s,      3!' --eY^^DD!'s   ),r  )r  r  r  r  tuple_in_valuesr  r  r  _isnullr  collections_abcr   r   bytes_has_bind_expressionr  r   r1  rP  searchr   rD  )r  rZ  r  bind_expression_templatetyp_dialect_implreplacement_expressionpost_compile_patternr  rF  rA  rB  s   ``       @@r  2_literal_execute_expanding_parameter_literal_binds>SQLCompiler._literal_execute_expanding_parameter_literal_binds  s"    %>>AA$,,O
  ..!%!=!=I200NN(()*=*=*&z )))m *.)E)E^^$i&9&9*&l )))e ,,$$6!9o&>&>??vay3,7744)$  "\\99	r		  )2&(9 &"N )))1 ('+'A'A$(//0HIQWW  ?>?  ggaj&&t,$'FCF!)- 3 "(3 *& ))) *. 3!'3 *&
 )))r  c                  ^ ^^
^^^ TR                   (       a  T R                  TU5      $ T R                  nTR                  R	                  U5      mT R
                  (       a  T R                  mOT R                  mT R                  R                  (       a  TR                  (       a
  UUU U4S jm
OU4S jm
U(       ds  / mTR                  (       a4  T R                  TR                  R                  TR                  5      nTU4$ T R                  TR                  /TR                  5      n TU4$ TR                  (       dQ  TR                  (       a  [        US   [         R"                  5      (       a  [        US   [$        [&        45      (       d  TR(                  (       a   e[+        US5       VVVV	s/ s H*  u  pg[+        US5        H  u  pU< SU< SU< 3U	4PM     M,     sn	nnnmUR,                  (       a  SOSSR/                  U
U4S	 j[+        U5       5       5      -   nTU4$ [+        US5       VV	s/ s H  u  piU< SU< 3U	4PM     sn	nmSR/                  U
4S
 jT 5       5      nTU4$ s  sn	nnnf s  sn	nf )Nc                H   > TR                  TR                  TTSU 0-  5      $ Nr   )render_bind_castr  )r   bind_templaterZ  r  r4  s    r  _render_bindtemplateNSQLCompiler._literal_execute_expanding_parameter.<locals>._render_bindtemplate  s,    ,,NN$!VTN2 r  c                   > TSU 0-  $ r;  r  )r   r=  s    r  r>  r?    s    $~55r  r   r   rE  r"  r  r   c              3     >^^#    U  H2  u  mmS SR                  UUUU4S j[        T5       5       5      -  v   M4     g7f)rd  r   c              3  b   >#    U  H$  u  pT" TT[        T5      -  U-      S    5      v   M&     g7f)r   N)r  )r<  r4  r  r>  r2  r[  r3  s      r  r>  MSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>.<genexpr>!  sF       )AHA -%a#m*<&<q&@A!D  )A   ,/N)r   r1  )r<  r2  r3  r>  r[  s    @@r  r>  CSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>  sF       ):$A} II  )2-(@	  ):s   :?c              3  8   >#    U  H  u  pT" U5      v   M     g 7fr  r  )r<  r=  r  r>  s      r  r>  rE  /  s      /<Ejc$S))Iry  )rN  r7  r  r  r  rf  r`  r_  _bind_typing_render_castsr<  r  r  r  r  r.  r  r/  r   r   r0  	_is_arrayr1  r-  r   )r  r   rZ  r  r  r5  r2  r3  r4  r  r>  r=  r[  r4  s   ` `       @@@@r  rM  0SQLCompiler._literal_execute_expanding_parameter  sO   $$JJ6  ,,$>>AA'J 99M --M LL22 11 6 I..)-)E)ENN(()*=*=*&V 000O *.)E)E^^$i&9&9*&N 000G ,,$$6!9o&>&>??vay3,77'1111 )2&!(<(<$A )- ;HA  $Q*E2 ; 3(<I %44	"		  )2&(9 &". 000 !*&! 4 4HA !!$e, 4I &*YY /<E/ &" 000;*s   71I6
<I>c           	        U(       Ga
  [         R                  " UR                  5      (       a  Ubx  US   nUR                  R	                  [
        R                  " [        UR                  R                  U/-   5      [        UR                  R                  U/-   5      5      5        OjUR                  R	                  [
        R                  " [        UR                  R                  5      [        UR                  R                  5      5      5        U R                  (       aW  [        UR                  [        R                  5      (       a.  [        UR                  [        R                  5      (       a  SUS'   U=(       d    UR                  nU R                  USS 5      n	U	(       a	  U	" X40 UD6$  [         U   n
U R"                  " UU
4UUS.UD6$ ! [$         a  n[&        R(                  " X5      UeS nAff = f)Nenclosing_lateralTrN  r   )from_linterlateral_from_linter)r!   is_comparisonr  r  r  r  productr)   r   r*   r   r^  r  r   rE   rp  r  r  r  r2   r  )r  r   r  eager_groupingrL  rM  r  rK  rq  rr  rs  r  s               r  r  SQLCompiler.visit_binary5  s    9226??CC".$&':$;!#))00%%!"KK559J8KK ""LL66:K9LL		 !!((%%!&++";";<!&,,"<"<=   6;;(>(>??6<<)?)?@@$(B !%8	**9hE0R00$Y/ 44 !,(;	
    P55dFCOPs   4	G 
G:G55G:c                <    U R                   " UR                  40 UD6$ r  )r  sql_functionr  s       r  &visit_function_as_comparison_op_binary2SQLCompiler.visit_function_as_comparison_op_binarym  s    ||G007B77r  c                0   U R                   R                  (       a>  U R                  " UR                  40 UD6S-   U R                  " UR                  40 UD6-   $ U R                  " UR                  40 UD6S-   U R                  " UR                  40 UD6-   $ )Nz %% r   )r  r  r  r   r   r  s       r  visit_mod_binarySQLCompiler.visit_mod_binaryp  s    ==))V[[/B/,,v||2r23 V[[/B/,,v||2r23r  c                    UR                   US'   U R                  " USU R                  UR                  5      -   S-   40 UD6$ )NrP  rM  )rP  r  r  rs  r  s       r  visit_custom_op_binary"SQLCompiler.visit_custom_op_binary~  sQ    '66,,$,,X->->??#E
 
 	
r  c                `    U R                   " XR                  UR                  5      S-   40 UD6$ rj  )r  r  rs  r  s       r  visit_custom_op_unary_operator*SQLCompiler.visit_custom_op_unary_operator  s6    44//0A0ABSH
LN
 	
r  c                b    U R                   " USU R                  UR                  5      -   40 UD6$ rj  )r  r  rs  r  s       r  visit_custom_op_unary_modifier*SQLCompiler.visit_custom_op_unary_modifier  s8    44S455h6G6GHH
LN
 	
r  c                    UR                  SS5      nSUS'   UR                  US'   UR                  R                  " U 4SU0UD6U-   UR                  R                  " U 4SU0UD6-   nU(       a  U(       a  SU-  nU$ )Nro  FT
_binary_oprP  rd  )r  r  r   r  r   )r  r   rs  rP  r  ro  r  s          r  r  $SQLCompiler._generate_generic_binary  s     #%&&)BE"J(,$%!??<KK**%379  ll--%379	 	 #~D=Dr  c                @    X!R                   R                  " U 40 UD6-   $ r  r  r  r  rs  r  s       r  r  ,SQLCompiler._generate_generic_unary_operator  s    --::4F2FFFr  c                B    UR                   R                  " U 40 UD6U-   $ r  r  rf  s       r  r  ,SQLCompiler._generate_generic_unary_modifier  s!    }}//;;hFFr  c                H    [         R                  " S[        R                  S9$ )Nz'%')r  )r   literal_columnr%   
STRINGTYPErB  s    r  _like_percent_literal!SQLCompiler._like_percent_literal  s    &&uH4G4GHHr  c                D    SUR                   R                  " U 40 UD6 S3$ )Nzlower(rH  r  r  s      r  $visit_ilike_case_insensitive_operand0SQLCompiler.visit_ilike_case_insensitive_operand  s&    ::4F2FGqIIr  c                    UR                  5       nU R                  nUR                  UR                  5      R                  U5      Ul        U R                  " X40 UD6$ r  _clonerm  concatr   visit_like_op_binaryr  r   r  r  percents        r  visit_contains_op_binary$SQLCompiler.visit_contains_op_binary  sM    ,,~~fll3::7C((@R@@r  c                    UR                  5       nU R                  nUR                  UR                  5      R                  U5      Ul        U R                  " X40 UD6$ r  rt  rm  ru  r   visit_not_like_op_binaryrw  s        r  visit_not_contains_op_binary(SQLCompiler.visit_not_contains_op_binary  sM    ,,~~fll3::7C,,VDDDr  c                   UR                  5       nU R                  n[        UR                  5      Ul        UR	                  [        UR
                  5      5      R	                  U5      Ul        U R                  " X40 UD6$ r  rt  rm  r1  r   ru  r   visit_ilike_op_binaryrw  s        r  visit_icontains_op_binary%SQLCompiler.visit_icontains_op_binary  sh    ,,,V[[9~~"6<<0

&/ 	 ))&AbAAr  c                   UR                  5       nU R                  n[        UR                  5      Ul        UR	                  [        UR
                  5      5      R	                  U5      Ul        U R                  " X40 UD6$ r  rt  rm  r1  r   ru  r   visit_not_ilike_op_binaryrw  s        r  visit_not_icontains_op_binary)SQLCompiler.visit_not_icontains_op_binary  sh    ,,,V[[9~~"6<<0

&/ 	 --fE"EEr  c                    UR                  5       nU R                  nUR                  UR                  5      Ul        U R                  " X40 UD6$ r  )rt  rm  _rconcatr   rv  rw  s        r  visit_startswith_op_binary&SQLCompiler.visit_startswith_op_binary  sD    ,,''5((@R@@r  c                    UR                  5       nU R                  nUR                  UR                  5      Ul        U R                  " X40 UD6$ r  )rt  rm  r  r   r}  rw  s        r  visit_not_startswith_op_binary*SQLCompiler.visit_not_startswith_op_binary  sD    ,,''5,,VDDDr  c                    UR                  5       nU R                  n[        UR                  5      Ul        UR	                  [        UR
                  5      5      Ul        U R                  " X40 UD6$ r  )rt  rm  r1  r   r  r   r  rw  s        r  visit_istartswith_op_binary'SQLCompiler.visit_istartswith_op_binary  sZ    ,,,V[[9''(>v||(LM))&AbAAr  c                    UR                  5       nU R                  n[        UR                  5      Ul        UR	                  [        UR
                  5      5      Ul        U R                  " X40 UD6$ r  )rt  rm  r1  r   r  r   r  rw  s        r  visit_not_istartswith_op_binary+SQLCompiler.visit_not_istartswith_op_binary  sZ    ,,,V[[9''(>v||(LM--fE"EEr  c                    UR                  5       nU R                  nUR                  UR                  5      Ul        U R                  " X40 UD6$ r  rs  rw  s        r  visit_endswith_op_binary$SQLCompiler.visit_endswith_op_binary  sB    ,,~~fll3((@R@@r  c                    UR                  5       nU R                  nUR                  UR                  5      Ul        U R                  " X40 UD6$ r  r|  rw  s        r  visit_not_endswith_op_binary(SQLCompiler.visit_not_endswith_op_binary  sB    ,,~~fll3,,VDDDr  c                    UR                  5       nU R                  n[        UR                  5      Ul        UR	                  [        UR
                  5      5      Ul        U R                  " X40 UD6$ r  r  rw  s        r  visit_iendswith_op_binary%SQLCompiler.visit_iendswith_op_binary  sX    ,,,V[[9~~&<V\\&JK))&AbAAr  c                    UR                  5       nU R                  n[        UR                  5      Ul        UR	                  [        UR
                  5      5      Ul        U R                  " X40 UD6$ r  r  rw  s        r  visit_not_iendswith_op_binary)SQLCompiler.visit_not_iendswith_op_binary  sX    ,,,V[[9~~&<V\\&JK--fE"EEr  c                   UR                   R                  SS 5      nUR                  R                  " U 40 UD6< SUR                  R                  " U 40 UD6< 3Ub%  SU R                  U[        R                  5      -   -   $ S-   $ )Nr  z LIKE  ESCAPE r  	modifiersr  r   r  r   r/  r%   rl  r  r   r  r  r  s        r  rv   SQLCompiler.visit_like_op_binary  s    !!%%h5 KK**4626LL++D7B7

 ! 2268;N;NOO	
 	
 
 	
r  c                   UR                   R                  SS 5      nUR                  R                  " U 40 UD6< SUR                  R                  " U 40 UD6< 3Ub%  SU R                  U[        R                  5      -   -   $ S-   $ )Nr  z
 NOT LIKE r  r  r  r  s        r  r}  $SQLCompiler.visit_not_like_op_binary  s    !!%%h5KK**4626LL++D7B7

 ! 2268;N;NOO	
 	
 
 	
r  c                    U[         R                  L aD  UR                  5       n[        UR                  5      Ul        [        UR
                  5      Ul        U R                  " X40 UD6$ r  )r!   ilike_oprt  r1  r   r   rv  r  s       r  r  !SQLCompiler.visit_ilike_op_binary  sS    y)))]]_F0=FK1&,,?FL ((@R@@r  c                    U[         R                  L aD  UR                  5       n[        UR                  5      Ul        [        UR
                  5      Ul        U R                  " X40 UD6$ r  )r!   not_ilike_oprt  r1  r   r   r}  r  s       r  r  %SQLCompiler.visit_not_ilike_op_binary(  sS    y---]]_F0=FK1&,,?FL ,,VDDDr  c                r    UR                   R                  SS5      nU R                  " X(       a  SOS40 UD6$ )Nr   Fz BETWEEN SYMMETRIC z	 BETWEEN r  r  r  r  r   r  r  r   s        r  visit_between_op_binary#SQLCompiler.visit_between_op_binary1  s?    $$((e<	,,Y)K
KM
 	
r  c                t    UR                   R                  SS5      nU R                  " UU(       a  SOS40 UD6$ )Nr   Fz NOT BETWEEN SYMMETRIC z NOT BETWEEN r  r  s        r  visit_not_between_op_binary'SQLCompiler.visit_not_between_op_binary7  sB    $$((e<	,,)2%
 
 	
r  c                \    [         R                  " SU R                  R                  -  5      eNz/%s dialect does not support regular expressionsr2   r  r  r   r  s       r  visit_regexp_match_op_binary(SQLCompiler.visit_regexp_match_op_binary?  ,     =ll 
 	
r  c                \    [         R                  " SU R                  R                  -  5      er  r  r  s       r   visit_not_regexp_match_op_binary,SQLCompiler.visit_not_regexp_match_op_binaryG  r  r  c                \    [         R                  " SU R                  R                  -  5      e)Nz;%s dialect does not support regular expression replacementsr  r  s       r  visit_regexp_replace_op_binary*SQLCompiler.visit_regexp_replace_op_binaryO  s,     Ill 
 	
r  c           	        U(       Gd  UR                   R                  U R                  5      nUR                  (       a  UR	                  U5      n	U R
                  " U	4SUU=(       a    UR                  (       + UUS.UD6n
UR                  (       a  [        R                  " SU
5      nU(       d   S5       eSUR                  S5      < SUR                  S5      < S	UR                  S
5      < S3n
U(       a  U R                  " U4SU
S.UD6nSU-  $ U
$ U(       dG  U=(       d(    UR                  =(       d    U=(       a    U R                  nU=(       d    UR                  nOSnU(       a-  U R                  " U4SS0UD6nUR                  (       a  SU-  nU$ U R                  U5      nXR                  ;   Gac  U R                  U   nXLGaO  UR                  (       d  UR                  (       am  UR                   R#                  UR                   5      (       dC  UR$                  R#                  UR$                  5      (       d  [&        R(                  " SU-  5      eUR                  UR                  :w  a  [&        R(                  " SU< S35      eUR*                  (       d  UR*                  (       ai  UR*                  (       a'  UR*                  (       a  [&        R(                  " S5      e[&        R(                  " SUR,                   SUR,                   S35      eU=U R                  UR,                  '   U R                  U'   U R.                  nU(       aM  Uu  nnUR$                   H8  nUR,                  U;   d  M  UUR,                     nUU   R1                  U5        M:     UR2                  (       a  SU l        U(       aB  U(       a  SU l        U(       a  U =R8                  U1-  sl        OU =R:                  U1-  sl        U R<                  " U4UUR                  UR                   S.UD6nUR                  (       a  SU-  nU$ )NT)skip_bind_expressionr  literal_bindsrN  render_postcompilez&^(.*)\(__\[POSTCOMPILE_(\S+?)\]\)(.*)$r(  z(__[POSTCOMPILE_r1   r>  r   z~~REPL~~r  z~~]))r  r3  rd  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  r1  bind_expressionr  r  r  r  r   rL  rN  r^  _truncate_bindparamrZ  r   r"  intersectionr  r2   r  _is_crudr=  rr  r  
isoutparamhas_out_parametersrg  ro  rp  r  )r  r  r  r  r  rN  r  r  implr  wrappedr  r  r  r   existingr  r  r  r  r  s                        r  visit_bindparamSQLCompiler.visit_bindparamW  s    $>>..t||<D(("&"6"6y"A,,#)-*?"/"K	8K8K4K$3'9  && A7A III1


G %";;%265< %	  &|+ D,,D)Bd.B.B 
 +Ai.A.AL L//159?C ""slJ''	2::zz$'H(__	(8(8$..;;!++  %00==!--  **ACGH  ''9+>+>>** :>@  &&)*<*<((Y-?-? "..&
 
 "..0 @" #,--5	 	 8A@

9==!DJJt$4 //
#JD$++66T>bffBHOOI. ,
 &*D#!+/(++	{:+((YK7(##
%))$>>	

 
 3,C
r  c                    [        5       er  r  )r  r  
dbapi_typer  s       r  r<  SQLCompiler.render_bind_cast  s    !##r  c                   U[         La  UnOUR                  c  UR                  c  UR                  SS 5      nU(       aF  U[        R
                  [        R                  4;  a"  [        R                  " SUR                  45        U R                  " [        R                  40 UD6$ UR                  nUR                  (       a  U R                  nU" UUUS9u  pU	$ U R!                  XQR"                  5      $ )Nrc  zBound parameter '%s' rendering literal NULL in a SQL expression; comparisons to NULL should not use operators outside of 'is' or 'is not')r3  )r-   r  r  r  r!   is_is_notr&   warn_limitedr=  r  r%   r"  r  r  r7  r/  r  )
r  r  r/  r3  r  r  opleepr[  r]  s
             r  rL  $SQLCompiler.render_literal_bindparam  s      v-(E&9+=+=+EVVL$/"Y]]I4D4D$EE%%@ #(	 ||H$5$5<<<--EJJD*.)A+'I
 $#,,UNNCCr  c                   Uc>  UR                   (       d-  U R                  [        R                  R	                  5       5      $ UR                  U R                  5      nU(       a	   U" U5      $ [        R                  " S[        R                  " U5       SU 35      e! [         a7  n[        R                  " S[        R                  " U5       SU S35      UeSnAff = f)zRender 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   rK   	_instance_cached_literal_processorr  r  r2   r  sql_util_repr_single_value)r  r  r  	processores        r  r/   SQLCompiler.render_literal_value   s     =!;!; << 7 7 9::33DLLA		 '' ""//67 8!!&)   && 33E:; <%g ## s   %B 
C'2CCc                    XR                   ;   a  U R                   U   $ UR                  n[        U[        R                  5      (       a  U R                  SU5      nX R                   U'   U$ )Nr  )r[  r=  r  r   rC   r  )r  r  r  s      r  r  SQLCompiler._truncate_bindparamG  s]    '??9--MM	i!:!:;;22;	JI &/	"r  c                   X4U R                   ;   a  U R                   X4   $ UR                  U R                  5      n[        U5      U R                  S-
  :  a]  U R
                  R                  US5      nUS[        U R                  S-
  S5       S-   [        U5      SS  -   nUS-   U R
                  U'   OUnXPR                   X4'   U$ )N   r   r   rE  r1   )	r  	apply_mapr  r  r  r  r  maxhex)r  ident_classr   anonnamecounter	truncnames         r  r  !SQLCompiler._truncated_identifierT  s     $"6"66''(;<<>>$--0x=4,,q00..22;BGS!2!2Q!6:;g,qr"# 
 5<aKD$$[1 I4=k01r  c                    XR                   -  $ r  r  r  r   s     r  
_anonymizeSQLCompiler._anonymizei  s    mm##r  c                &  ^  Ub  UR                  U5        Ub  UR                  U5        U(       dD  T R                  R                  U5      (       a$  T R                  R	                  U 4S jU5      n	UnU	nU(       a!  T R
                  R                  XA05      T l        U(       aQ  SU-  n
U(       a  U
$ Ub>  UR                  T R                  5      nUR                  (       a  T R                  X[U
5      n
U
$ T R                  [        R                  L a  T R                  SU0-  n
OT R                  SU0-  n
UbY  T R                  R                   (       a>  UR                  T R                  5      nUR                  (       a  T R                  X[U
5      n
U
$ )Nc                @   > TR                   U R                  S5         $ )Nr   )rP  r   )r  r  s    r  r  .SQLCompiler.bindparam_string.<locals>.<lambda>  s    d88Dr  z__[POSTCOMPILE_%s]r   )addr  rO  r2  r  rq  r   r  r  render_literal_castr<  r  ru  rv  r`  r_  rG  )r  r   r  r  escaped_fromr  accumulate_bind_namesvisited_bindparamr  new_namer  	type_impls   `           r  r  SQLCompiler.bindparam_stringl  sp    !,!%%d+($$T*&&--d33  2266D  $&*&=&=&C&C$'D# &-C 
 )*BBLL	 00//3OCJZZ=222//64.@C##vtn4C &66&>>t||LI))++NsK
r  c                    UR                  5       nUR                  SS 5        [        UR                  UR                  5       H  u  pEUR
                  " U 4SU0UD6  M     g )Ncte_opts)copyr  r  r,  _independent_ctes_optsr  )r  stmtr  local_kwcteopts         r  r-  &SQLCompiler._dispatch_independent_ctes  sW    779Z&""D$?$?
HC ""4B#BB
r  c                6  ^  T R                  5       n	U	T R                  L d   eXS'   UR                  n
[        U
[        R
                  5      (       a  T R                  SU
5      n
SnSnUR                  5       nUR                  =(       d    UR                  nUT R                  ;   a  T R                  U   u  nnnUU
:X  d   eX4nT R                  U   nUR                  (       a|  UR                  (       a  [        R                  " S5      eX4nU(       a  [        T R                  5      OSnX4=nnT R                  U	 UT R                  U'   UU4-   T R                  U'   OCU(       a  [        T R                  5      OSnX4nUT R                  ;   a  T R                  U   nOS nUb  UUL nUUR                  L d  UUL a  SnOUUR                  L a/  U	U	 UR                  5       nUUL d   eUUL d   eT R                  U	 Od[!        U5      [!        U5      :X  d0  UR"                  c  UR"                  b  UR%                  U5      (       a  SnO[        R                  " SU
-  5      eU(       d  U(       d  g UR&                  bT  UR&                  nUR&                  R                  n[        U[        R
                  5      (       a  T R                  SU5      nOUnS nU(       Ga  UT R                  U'   UU4-   T R                  U'   UT R                  ;  a  T R(                  " U40 UD6  U(       Gd  X;  Ga{  UR*                  (       a  ST l        T R.                  R1                  X5      nUR*                  (       an  UR2                  nUR5                  S5       VVVVVs/ s H  u  nnnnnU(       a  M  U=(       d    UPM     nnnnnnUSS	R7                  U 4S
 jU 5       5      -  -  nUR9                  SS5      SL d   eT R                  (       d  UR2                  R:                  " T 4SU0UD6$ T R<                  " XR>                  40 UD6n UR2                  R:                  " T 4SS0UD6n!USU < SU!< S3-  nUR@                  (       a#  UST R<                  " XR@                  40 UD6-   -  nUX'   U(       a  U(       a  XRB                  URE                  5       '   U(       d"  U(       a  T R.                  R1                  X5      $ U(       am  T R.                  R1                  UU5      nT R.                  RG                  U
5      (       a  T R.                  RI                  U
5      n
UT RK                  U
5      -  nU$ T R.                  R1                  X5      $ g s  snnnnnf )Nvisiting_cter  TFz6CTE is stated as 'nest_here' in more than one locationr   z5Multiple, unrelated CTEs found with the same name: %rrd  r   c              3  l   >#    U  H)  nTR                   R                  UTR                  S 9v   M+     g7f)r  N)r  format_label_namer  )r<  identr  s     r  r>  (SQLCompiler.visit_cte.<locals>.<genexpr>[  s9      " *4 !MM;; % <  *4s   14subqueryr  r   z
(rH  rM  )&r  rv  r   r  r   rC   r  _get_reference_ctenestingrx  rw  r2   r  r  r  	_restateshash_is_clone_ofcompare
_cte_alias	visit_cte	recursivery  r  format_aliasr  _generate_columns_plus_namesr   r  r  _generate_prefixes	_prefixes	_suffixesr  r)   _requires_quotesr  get_render_as_alias_suffix)"r  r  r  ashint	fromhintsr  rL  r  r  	self_ctescte_name
is_new_cteembedded_in_current_named_cte_reference_cter  	cte_levelrE  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
proxy_namefallback_label_namer  repeated
recur_colsprefixesr   s"   `                                 r  r  SQLCompiler.visit_cte  s    ((*	DII%%%!$~88h 9 9::11'8DH
(-%//1++1!1!1 T333.2.D.D/+Iq+ = ='2N22>BL
 $,,**1 
 #,!6/6C

OA	3<2GG++N;:F''79GK :&&~6
 ,3DJJI'2N!8!88#66~F##,8L,H) l,,,|0C"
. l+-9-L-L-N*1^CCC1\AAA**+EF
 #Y$|"44  ,,8+88D  KK55 "'J
 **,.67 
 j>>%NNM!$!4!4,h.G.GHH%)%?%?/&"  M!%69D##N35CG 6D"">2 DII-}77%#*>==*.D'}}11#@==!$J" )EEdK" L&/$' :+9z9 L  "  F		 " *4	"  D zz*e4===zz ;;99%+/5   $66]] .4 H  KK::%)-3E h>>D==C$"9"9]]#.4#  D "&	5=!!#--/2"?}}11#@@!}}11#7IJ==11(;;#}}228<H77AA}}11#@@G"s   V0Vc                    UR                   (       a  S US'   UR                  (       a  U R                  " U40 UD6$ U R                  " U40 UD6$ )NrL  )joins_implicitly_is_lateralvisit_lateralvisit_aliasr  s      r  visit_table_valued_alias$SQLCompiler.visit_table_valued_alias  sJ    ## $B}%%g444##G2r22r  c                (    U R                   " U40 UD6$ r  )r  r  s      r  visit_table_valued_column%SQLCompiler.visit_table_valued_column  s      /B//r  c
           
     p  ^ ^^
 U(       a6  ST
;  a  TR                   (       d   eTT
S'   U	(       a  ST
;  a  ST
;   a  U	T
S'   UbQ  UR                  TL aB  TR                  R                  " T 4UUUUUTS.T
D6nU(       a  U(       d  U(       a  SU< S3nU$ TT
S'   U(       d  U(       aR  [        TR                  [
        R                  5      (       a  T R                  STR                  5      nOTR                  nU(       a  T R                  R                  TW5      $ U(       a  U	(       a  WU	R                  TR                  5       '   TR                  R                  " T 4SUS	.T
D6nU(       a  SU< S3nUT R                  T R                  R                  TW5      5      -   nTR                  (       a>  TR                  (       a-  US
SR                  UU
U 4S jTR                    5       5      -  -  nU(       a  TU;   a  T R#                  UTUT   U5      nU$ TR                  R                  " T 4SU0T
D6$ )NrK  rM  )r  r'  iscrudr(  lateralenclosing_aliasrG  rH  rK  r  T)r  rJ  rd  r   c              3    >#    U  Hu  nTR                   R                  UR                  5      < TR                  (       a4  S TR                  R
                  R                  " UR                  40 TD6-  OS< 3v   Mw     g7f) %sr  N)r  r  r   _render_derived_w_typesr  r  r  r  )r<  r  r  r  r  s     r  r>  *SQLCompiler.visit_alias.<locals>.<genexpr>  sz       $+C !MM//9 $)#@#@	 !&"&,,"E"E"M"M$'HH#"06#"!"
 &(!(	 $+s   A=B rJ  )r@  r  r  r  r   r   rC   r  r  r   r  r)   r&  _supports_derived_columns_render_derivedr   r  format_from_hint_text)r  r  r  r'  rI  r(  r  rJ  rK  rL  r  r   
alias_namer  s   ``        `   r  rB  SQLCompiler.visit_alias  s,    "&0 ((((.3*+
 )7'610;,-&?+B+Be+KMM44	# %	 	E Vw"')L(-F$%V%**h&?&?@@!77L
"ZZ
==--eZ@@7A!!%//"34MM44!76<E "')$99**5*= C ..53H3HvII  $)77  $ Ui/00	% 0& J ==33%)/ r  c                2    SUS'   U R                   " U40 UD6$ )NTr  rB  )r  r  r  s      r  visit_subquerySQLCompiler.visit_subquery  s!    :/B//r  c                8    SUS'   SU R                   " U40 UD6-  $ )NTrJ  z
LATERAL %srV  )r  lateral_r  s      r  rA  SQLCompiler.visit_lateral  s&    9d..x>2>>>r  c                    U R                   " U4SS0UD6< SUR                  5       R                  " U 40 UD6< 3nUR                  b#  USUR                  R                  " U 40 UD6-  -  nU$ )Nr  Tz TABLESAMPLE z REPEATABLE (%s))rB  _get_methodr  seed)r  tablesampler  r  r  s        r  visit_tablesampleSQLCompiler.visit_tablesample  s}    [<<<##%88DD

 '&  33D?B? D r  c                   ^ ^^ TR                  STR                  5        SR                  UUU 4S jTR                   5       5      nSU 3$ )Nr  r   c           	   3     >#    U  HN  nU  HD  nTR                   " [        R                  " US TR                  06R	                  5       40 TD6v   MF     MP     g7f)r  N)r  r   r   _column_typesr+  )r<  chunkelemr  r  r  s      r  r>  -SQLCompiler._render_values.<locals>.<genexpr>  sb      	
 ' LL26!//*, 	  's   AAr"  )
setdefaultr  r   _data)r  r  r  tupless   ``` r  _render_valuesSQLCompiler._render_values  sG    
ow'<'<= 	
 !	
 	
 !!r  c           
     t  ^ ^ T R                   " U40 TD6nUR                  (       a  S nOR[        UR                  [        R
                  5      (       a  T R                  SUR                  5      nOUR                  nUR                  (       a  SnOSnU(       a  U(       a"  Ub  UOSUR                  UR                  5       '   U(       ae  STS'   U< SU< ST R                  T R                  R                  U5      5      < S	S
R                  UU 4S jUR                   5       5      < S3nU$ U< SU< S3nU$ )Nr  zLATERAL r  z(unnamed VALUES element)Fr  rG  rH   (r   c              3  J   >#    U  H  nUR                   " T40 TD6v   M     g 7fr  r  rP  s     r  r>  +SQLCompiler.visit_values.<locals>.<genexpr>=  s(      "%4 00<<%4r  )rk  _unnamedr  r   r   rC   r  r@  r  r)   r&  r  r  r   columns)r  r  r  rL  r  r  r   rJ  s   `   `   r  visit_valuesSQLCompiler.visit_values!  s   .2.Dh&?&?@@--hED<<D GG ,D2L !!'"3"3"56 &+?#33DMM4G4G4MN		 "%,__" 
  !(+r  c                0    SU R                   " U40 UD6 S3$ r  )rk  r  s      r  visit_scalar_valuesSQLCompiler.visit_scalar_valuesG  s"    4&&w5"56a88r  c                    SU-   $ )Nr   r  )r  alias_name_texts     r  r&  &SQLCompiler.get_render_as_alias_suffixJ  s    ''r  c                    U(       d   eUb  US:X  a  SU l         SU l        UR                  (       a  [        R                  " S5      eU R
                  R                  [        XX45      5        g )N*FTzxMost backends don't support SELECTing from a tuple() object.  If this is an ORM query, consider using the Bundle object.)rd  rc  r  r2   r  r  r  r   r  s        r  r/  SQLCompiler._add_to_result_mapM  sg     w?gn$)D!#'D ""4 
 	##wg=	
r  c                :    U R                   " SUUSUc  0 OU40 UD6$ )a$  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   r5  column_clause_argsr  s         r  _label_returning_column#SQLCompiler._label_returning_columnf  s8     (($,B2D
 
 	
r  c                  ^^ TR                   R                  U R                  5      nUR                  (       a   U(       d  U(       a  UR	                  T5      nOTnU(       a+  U R
                  nU
(       a	  UmU4S jnOUTLa	  UmUU4S jnOSnU	(       d   S5       e[        T[        R                  5      (       a+  UTLa"  [        UTR                  TR                  4S9nGOuUnGOqU(       a#  Uc   S5       e[        UUUTR                  4S9nGOGUTLa  SnO[        T[        R                  5      (       a0  U=(       a&    TR                  (       + =(       a    TR                  SLnO[        T[        R                   5      (       a  SnOf[        T[        R"                  5      (       a  TR$                  =(       d    UnO1[        T[        R&                  5      (       d  TR(                  c  SnOSnU(       a_  U(       d  U
(       a   eTR*                  n[        U[        R,                  5      (       d  [        R,                  " U5      OUn[        XU4S9nOUnUR/                  U	UUS	9  UR0                  " U 40 UD6$ )
z.produce labeled columns present in a select().c                   > T" XU 4U5        g r  r  )r   r   r  r  r/  s       r  r  ;SQLCompiler._label_select_column.<locals>.add_to_result_map  s    &wwj%Hr  c                "   > T" XT4U-   U5        g r  r  )r   r   r  r  r/  r   s       r  r  r    s    &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  r  r  _has_column_expressioncolumn_expressionr/  r  r   rJ   r  r   r  r  rG   r  r   
TextClauseUnaryExpressionwraps_column_expressionNamedColumn_non_anon_label_anon_name_labelrC   r  r  )r  r   r   r5  r  r  r   r8  r9  r  column_is_repeatedneed_column_expressionsr  r  col_exprr  result_exprrender_with_labelr/  s     `               @r  r   SQLCompiler._label_select_column{  sv     {{''5&&#':--f5HH
 !% 7 7
 "%6"I
 '%6" !% % 	
:	
$ fhnn--v%+fkkfnn5F ' &<;<& ( $$K& v% %)!FH$9$9::  1"---1D0 "
 FH$7$788$)!FH$<$<==$*$B$B$Lf!
 vx';';<< **2$(!$)! *
  211*0*A*A' &+X-F-F  --.AB - $ ,j] '!!"7/' 	" 	

 --dI6HIIr  c                F    U R                  X#5      nU(       a  USU-   -  nU$ rj  )get_from_hint_text)r  r  r   hintrI  hinttexts         r  rR  !SQLCompiler.format_from_hint_text  s(    **57sX~%Gr  c                    g r  r  )r  byfromss     r  get_select_hint_text SQLCompiler.get_select_hint_text%      r  c                    g r  r  r  r   r  s      r  r  SQLCompiler.get_from_hint_text(  s     r  c                    g r  r  r  s      r  get_crud_hint_textSQLCompiler.get_crud_hint_text-  r  r  c                $    SR                  U5      $ rj  rR  )r  
hint_textss     r  get_statement_hint_text#SQLCompiler.get_statement_hint_text0  s    xx
##r  r'  r+  r$  r#  c                    U R                   (       + nU(       a  U R                  OU R                   S   nUR                  X5      nUS   nUS   n	U(       a(  U(       d!  UR                  UR	                  U	5      SS9n
U
$ UR                  UU	S9n
U
$ )Nr  r$  r#  r  explicit_correlate_fromsimplicit_correlate_froms)r  r+  r  _get_display_froms
difference)r  select_stmtr  rJ  r  r3  r  r(  r$  r#  r  s              r  _display_froms_for_select%SQLCompiler._display_froms_for_select:  s     zz>-5))4::b>#::;M 12^,'!44)8)C)C * *,	 5 E 	 "44)8)5 5 E r  translate_select_structurec	                  ^% Ub   S5       eSU	S'   UR                   " X40 U	D6n
U
R                  U	S'   U
R                  nU R                  (       + nU(       a  U R                  (       d  Xl        US L=(       d    UnU R
                  (       a>  U R
                  " U4SU0U	D6nXLa%  U
nUnUnUR                   " X40 U	D6n
U
R                  nU(       a  U R                  OU R                  S   nU=(       d+    UR                  SS5      =(       d    UR                  SS5      =nnU(       a  SnU(       d	  S	U	;   a  U	S		 U R                  XXXu5      nU	R                  5       nUR                  SSS
.5        SnUR                  (       a$  U R                  U5      u  nnU(       a  UUS-   -  nOS nUR                  (       a  U R                  X5        UR                  (       a   UU R                   " XR                  40 U	D6-  nUU R"                  " U40 U	D6-  nU
R$                   VVVVVs/ s H!  u  nnnnnU R'                  UUUUUUUUUUS9
PM#     snnnnn Vs/ s H
  nUc  M  UPM     nnU(       a  Ub  [)        [+        U
R$                   VVVVVs/ s H  u  nnnnnUPM     snnnnnWR$                   VVVVVs/ s H  u  nnnnnUPM     snnnnn5      5      m%U R,                   VVVV s/ s H)  u  nnnn [/        UU[1        U%4S jU 5       5      U 5      PM+     sn nnnU l        U R3                  UUU
UUUUU	5      nUR4                  (       a]  UR4                   V!V"s/ s H&  u  n!n"U!SU R6                  R8                  4;   d  M$  U"PM(     n#n!n"U#(       a  USU R;                  U#5      -   -  nU R<                  (       a>  U(       a  U(       a0  U(       d  [?        U R                  5      OS n$U RA                  U$S9U-   nURB                  (       a#  USU R                   " XRB                  40 U	D6-   -  nU R                  RE                  S5        U$ s  snnnnnf s  snf s  snnnnnf s  snnnnnf s  sn nnnf s  sn"n!f )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 rM  )r   r8  r9  r  r  c              3  F   >#    U  H  nTR                  X5      v   M     g 7fr  rp  )r<  or  s     r  r>  +SQLCompiler.visit_select.<locals>.<genexpr>  s     $F#QY]]1%8%8#   !r|  r)  )#r  _ambiguous_table_name_mapr2  r  r(  r  r+  r  _setup_select_stackr	  r  _hints_setup_select_hintsr,  r-  r#  r"  get_select_precolumnscolumns_plus_namesr  r
  r  r  r   rA  _compose_select_body_statement_hintsr  r   r  rv  r  r0  r$  r  )&r  r  r  insert_intor(  r2  select_wraps_forrJ  rL  r  r(  r3  is_embedded_selectnew_select_stmtcompile_state_wraps_forr  r5  r  r  r  r  	hint_textbyfromr   r8  r9  r   r:  r  inner_columnsr=  r  r  dialect_namehtper_dialectr*  r  s&                                        @r  visit_selectSQLCompiler.visit_select^  s     ' 	
-	
' +0&'#::
!'
 33 	)* $--zz>D..!.+47F;
 **"==$*.4O 1*7'#. - + B B!)/! ,55-5))4::b>  >yy7?>yy5u=	
5 "'
 #':f'D*+((w
 $[[]!!$)EJ	
  $ 8 8 EIv	C'F((++K@  D++226< D 	**;A&AA. #55'& 6'# ))'&)(;'/,C * $ 6'
* -  	 
4 #3#?  +==	 >&/ $  >	$ 5GG	 H&/ $  H	I: .2-A-A	$ .B)CsE #u$F#$FF .B	$D  ((	
 '' +6*F*F*F&\2C):):#;; *F  
 d::;GGG 990H3;C

OM***G$ND  C$11226<  D 	

ry
@		$&s0   &(QQ"QQ:Q$,0Q-
#Q5Q5c                    UR                   R                  5        VVVs0 s H;  u  u  p#nUSU R                  R                  4;   d  M&  X$SUR	                  U SS90-  _M=     nnnnU R                  U5      nXe4$ s  snnnf )Nr|  r   T)r'  )r  r  r  r   r  r  )r  r   r  r  r  r  r  s          r  r  SQLCompiler._setup_select_hints+  s     /5mm.A.A.C
 /D* (3 1 122DEu//T/BCD D.C 	 
 --f5	  
s   %A9A9c           	        US   nUS   nUS:X  a  XS'   OmU(       af  US   n	[        U	R                  5      n
[        UR                  5      U
:w  a3  [        R                  " SSU
US-   [        UR                  5      4-  5      eU(       a'  U(       d   UR                  UR                  U5      SS9nOUR                  UUS9n[        [        U6 5      nUR                  U5      nUUUUS	.nU R                  R                  U5        U$ )
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  r2   r  r  r  r~   r*   r   r  r  )r  r   r(  r  r  rJ  r2  r$  r#  r,  numcolsr  new_correlate_fromsall_correlate_fromsr4  s                  r  r  SQLCompiler._setup_select_stack7  s9      12^,Q &*Z(H(889G=334?&&!
 &*F889			  '!44)8)C)C * *,	 5 E "44)8)5 5 E
 "-"78177H 02 *	*
	 	

)$r  c	                   USR                  U5      -  nU R                  [        -  (       a5  [        0 [	        5       5      n	U R                  [
        -  n
U(       a  Xl        OS n	Sn
U(       d  UR                  5       nU(       a  US-  nUR                  (       a;  USR                  U Vs/ s H  nUR                  " U 4SUU	S.UD6PM     sn5      -  nOLUSR                  U Vs/ s H  nUR                  " U 4SU	S.UD6PM     sn5      -  nOXR                  5       -  nUR                  (       a.  U R                  " UR                  4SU	0UD6nU(       a  USU-   -  nU
(       a  U	c   eU	R                  5         UR                  (       a  XR                  " U40 UD6-  nUR                   (       a,  U R                  " UR                   40 UD6nU(       a  US	U-   -  nUR"                  (       a  XR$                  " U40 UD6-  nUR&                  (       a  XR(                  " U40 UD6-  nUR*                  b  XR,                  " U40 UD6-  nU$ s  snf s  snf )
Nr   Fz 
FROM T)r  r(  rL  r  rL  rL  z 
WHERE z	 
HAVING )r   r  r|  r  r~   r}  rL  rstripr  r  r  _where_criteriar`  r  _group_by_clausesr  _having_criteria_order_by_clausesr  r  r  _for_update_argfor_update_clause)r  r  r   r(  r  r  r  r3  r  rL  warn_lintingfts                r  r   SQLCompiler._compose_select_bodyk  sw    			-((<<44$R/K<<,6L#. K L ;;=DJD}}		 "'	 "'A ,, #'&,(3	
 % "'	  		 "' "'A ,, #'(3 %	 "'
 
 %%''D!!11&&4?CIA a'***##((:6::D""11''+1A q((##((:6::D****6<V<<D!!-**6<V<<Dq	s   *!I
% I
c                Z   ^ ^ SR                  UU 4S jU 5       5      nU(       a  US-  nU$ )NrM  c              3     >#    U  H<  u  pUS ;   d  UTR                   R                  :X  d  M'  UR                  " T40 TD6v   M>     g7f))Nr|  N)r  r   r  )r<  prefixr  r  r  s      r  r>  1SQLCompiler._generate_prefixes.<locals>.<genexpr>  sF      
(0${*ldll>O>O.O 2F%%d1b1(0s
   &AArR  )r  r  r<  r  rz  s   `  ` r  r"  SQLCompiler._generate_prefixes  s1     
(0
 

 cMFr  c                   U R                   (       d  gU(       a  US:  a  [        R                  " 5       n[        U R                   R	                  5       5       H~  nU R
                  UR                  5          u  pVnUR                  =(       d    UR                  nXQ:H  =(       d    U=(       a    XQS-   :H  n	U(       a  U	(       d  Mm  U R                   U   X4'   M     OU R                   nU(       d  g[        U Vs/ s H  oDR                  PM     sn5      n
U R                  U
5      S-   nUSR                  UR                  5        Vs/ s H  oPM     sn5      -  nUS-  nU(       a|  US:  av  [        UR	                  5       5       HY  nU R
                  UR                  5          u  pVnU R                   U	 U R                  XV4	 U R
                  UR                  5       	 M[     U$ s  snf s  snf )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   rM  , 
z
 )rv  r&   r  r  keysrx  r  r  rv   r  get_cte_preambler   r  rw  )r  r*  r  rv  r  r.  r*  r  r  is_rendered_levelry  cte_texttxts                r  r0  SQLCompiler._render_cte_clause  s    yy ]Q.##%DDIINN,-040F0F**,1-	X ++9)9)9$-$> %+N	Q=N0N "  $5 IIcN	 . 99Dt<tmmt<=((83>FKK > >??E]Q.DIIK(040F0F**,1-	X IIcN++Y,AB**3+A+A+CD )  = !?s   8G$G)
c                    U(       a  gg)NzWITH RECURSIVEWITHr  )r  r  s     r  r  SQLCompiler.get_cte_preamble	  s    #r  c                x    UR                   (       a  [        R                  " SSS9  UR                  (       a  S$ S$ )zSCalled 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  !SQLCompiler.get_select_precolumns  s:    
   3
  %..{6B6r  c                    U R                   " UR                  [        [        R                     40 UD6nU(       a  SU-   $ g)z5allow dialects to customize how GROUP BY is rendered.z
 GROUP BY r  )rT  r  r  r!   comma_op)r  r   r  group_bys       r  r  SQLCompiler.group_by_clause  sE     00$$i	0B0B&C
GI
 (**r  c                    U R                   " UR                  [        [        R                     40 UD6nU(       a  SU-   $ g)z5allow dialects to customize how ORDER BY is rendered.z
 ORDER BY r  )rT  r  r  r!   r  )r  r   r  r  s       r  r  SQLCompiler.order_by_clause*  sE     00$$i	0B0B&C
GI
 (**r  c                    g)Nz FOR UPDATEr  r  s      r  r  SQLCompiler.for_update_clause6  s    r  c                   UR                  S[        R                  " U5      S9 VVVVV	s/ s H#  u  nnnnn	U R                  " UUU4UU	UUS.UD6PM%     n
nnnnn	SSR	                  U
5      -   $ s  sn	nnnnf )NT)cols)r9  r  r   r8  
RETURNING r   )r!  r   _select_iterablesr  r   )r  r  returning_colsr5  r  r   r8  r9  r   r:  rr  s              r  returning_clauseSQLCompiler.returning_clause9  s    2 22411.A 3 #
"# ((#	 %8#+%	 	 # 	 
, dii000-
s   *A/c                    SnUR                   b#  USU R                  " UR                   40 UD6-   -  nUR                  b5  UR                   c  US-  nUSU R                  " UR                  40 UD6-   -  nU$ )Nr  z
 LIMIT z

 LIMIT -1z OFFSET )_limit_clauser  _offset_clause)r  r   r  r  s       r  r  SQLCompiler.limit_clauseY  s    +K$,,v/C/C"Jr"JJJD  ,##+%Jf.C.C!Jr!JJJDr  c                   Uc  UR                   nUR                  nOSSS.nSnUR                  bU  UR                  nU(       a&  UR                  U5      (       a  UR	                  5       nU R
                  " U40 UD6n	USU	-  -  nOU(       a  US-  nUbf  U(       a&  UR                  U5      (       a  UR	                  5       nUSU R
                  " U40 UD6< US   (       a  SOS< S	US
   (       a  SOS< 3-  nU$ )NF)rx  	with_tiesr  z
 OFFSET %s ROWSz
 OFFSET 0 ROWSz
 FETCH FIRST rx  z PERCENTz ROWS r  z	WITH TIESONLY)r  _fetch_clause_optionsr
  _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  SQLCompiler.fetch_clausec  s    !//L#)#?#? /45#I   ,"11M2--m<< - D D Fm:r:J'*44D&&D#2--l;;+BBD\0R029=
2E3K@fL D
 r  c
                   U(       a  UR                   UR                  U'   U(       d  U(       Ga1  U R                  R                  U5      nU(       aL  U(       aE  U R                  R	                  U5      S-   U R                  R                  UR                  5      -   nOU R                  R                  UR                  5      nU	b  U	R                  ULai  U(       db  U(       a[  UR                  U;   aK  U R                  SXR                     5      nXR                  U R                  R                  S U5      5      -   nU(       a  X;   a  U R                  XXQ   U5      nU$ g)NrJ  r  r  )fullnamer  r  r  r  r  r   r  r  r&  r   rR  )r  r   r  rI  r'  r(  
use_schemarL  r  rK  r  r  r  	anon_names                 r  visit_tableSQLCompiler.visit_table  s/    ',~~Ke$V#}}>>uE.MM../?@mm))%**56  mm))%**5 (/*22%?,0

&>> $ : :!9**!E!I  ? ?224C! C U/00	 0& Jr  c                   U(       aj  UR                   R                  [        R                  " [	        UR
                  R                  5      [	        UR                  R                  5      5      5        UR                  (       a  SnOUR                  (       a  SnOSnUR
                  R                  " U 4SUS.UD6U-   UR                  R                  " U 4SUS.UD6-   S-   UR                  R                  " U 4SU0UD6-   $ )Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN Tr   ON rL  )r  r  r  rO  r)   r   r*   r   r   isouterr  onclause)r  r   r  rL  r  	join_types         r  
visit_joinSQLCompiler.visit_join  s   $$!!dii556djj667 99+I\\+I III((!{>D  jj++!{>D	  mm.."-17	
r  c                *   UR                   R                  5        VVVs0 s H(  u  u  p4nUSU R                  R                  4;   d  M&  X5_M*     nnnnUR                  U;   a)  U R                  X!R                  XaR                     S5      nXb4$ s  snnnf )Nr|  T)r  r  r  r   r   rR  )r  r  
table_textr   r  r  dialect_hintss          r  _setup_crud_hintsSQLCompiler._setup_crud_hints  s     04{{/@/@/B
/B+ )3 1 122 E/B 	 

 ::&33JJjj(A4J ((
s   %BBc                   U R                   R                  nUR                  nUR                  nUc  gUR                  (       a'  U R
                  R                  UR                  S5      nO&U R                  R                  UR                  S5      nX%-  (       a  U$ UR                  (       a4  [        R                  " SUS    SU R                   R                   S35      eg)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_characteristicsrr  
is_autoinc_sentinel_col_autoinc_lookupr  default_characterization _sentinel_col_non_autoinc_lookupis_explicitr2   r@  r   )r  r   sentinel_optssentinel_characteristics	sent_colsbitmasks         r  _get_sentinel_column_for_table*SQLCompiler._get_sentinel_column_for_table  s     GG#(#I#I ,44	#..77;;(AA1G ;;??(AA1G "#// )))A, (><<$$% &@
@  r  c              #  L  ^ ^^@^A^B^C^D#    T R                   nUc   eUR                  (       d  S n	O[        R                  " UR                  6 n	[	        U5      n
UR
                  (       a   T R                  R                  (       d  SnSnOZT R                  R                  (       a6  U(       a4  T R                  (       a#  UR                  b  UR                  (       a  SnSnOSnSnU(       aS  [        [        S[        X#5      5      S5       H/  u  nu  p[        UUTU/U	(       a	  U	" U5      /O/ SUU
UU5
      v   M1     g U(       a*  [         R"                  " T R$                  R&                  US9nOS nUR(                  nU(       a  U" U5      nSU S3nUR+                  US5      nT R                  R,                  nU(       aA  [	        T R.                  5      n[	        UR0                  5      nUU-
  n[3        UUU-
  U-  5      n[        S	[5        U5      5      n[        S	[5        U5      5      nS nSnX-  X-  (       a  SOS
-   nUR0                  nUc   eU(       a'  U VVVVs/ s H  u  nnnnUUU" U5      U4PM     nnnnnS
=mCmDT R6                  (       d  T R8                  (       a  T R8                  mAO0 mA[;        US
   5      n UAU 4S jm@UR<                  (       a  Sn!OSn!SSR?                  U@4S jU 5       5       U! S3n"U RA                  UA4S jU 5       5      n#U RC                  U#5       Vs0 s H  nUUS
   U   _M     n$nSmBGOSn"[;        5       n#0 n$UR<                  (       a  SU S3mBOSU S3mB[;        5       n%UR0                   H  n&U%RE                  U&S   5        M     U%(       af  T RF                  n'U'c   e[        U'5       V(V)s1 s H  u  n(n)U)U%;   d  M  U(iM     n*n(n)[3        U*5      mC[I        U*5      S-   mD[	        U*5      TDTC-
  :X  d   eT RJ                  (       a;  [L        RN                  " T RP                  5      n+[L        RR                  " U+ S3STB5      mBU(       Ga  US
U n,US
U n-/ US
U& / US
U& U(       a  Un.O[	        U,5      n.T(       a0  U4S j[U        U.5       5        V/V0V1s/ s H  u  n/n0n1U/U0U14PM     nn0n/n1T R6                  (       Ga  URV                  n2U2[	        U,S
   5      :X  a  S=n3n4U,n5OU,S
   S TC n3U,S
   TDS  n4UCUD4S jU, 5       n5UR<                  (       a(  SR?                  UB4S j[        U,5       5       5      S S n6OTBU.-  S S n6T RJ                  (       a@  U2S
:  a:  U4(       a   eTCS-   n7U2U.-  U7-   n8[Y        U 4S j[U        U7U85       5       5      n9U6U9-  n6UR+                  SU65      n:[Y        [Z        R\                  R_                  U55      5      n;U3U;-   U4-   n;O/ n<U$Ra                  5       n;[        U,5       H  u  n=nU"R+                  S[c        U=5      5      n>UR<                  (       a  U>R+                  S[c        U=5      5      n>U<Re                  U>5        U;RE                  U# Vs0 s H  nU SU= 3UU   _M     sn5        M     UR+                  SSR?                  U<5      5      n:[        U:U;UU,U	(       a  U- V?s/ s H  n?U	" U?5      PM     sn?O/ U.UUUS5
      v   US-  nU(       a  GM  g g s  snnnnf s  snf s  sn)n(f s  sn1n0n/f s  snf s  sn?f 7f)NTFzKSequence[Tuple[_DBAPISingleExecuteParams, _MutableCoreSingleExecuteParams]]r   r  rG  rH  __EXECMANY_TOKEN__zList[Sequence[Any]]r   c                   > U  HG  nTR                  X"5      nUR                  TR                  SU0-  TR                  SU S30-  5      nMI     U$ )Nr   __EXECMANY_INDEX__)r  r  r_  )r  	formattedr=  rq  r  s      r  apply_placeholdersISQLCompiler._deliver_insertmanyvalues_batches.<locals>.apply_placeholders  se    C,00:C ) 1 1))VSM9))!cU*<#=>?!I   ! r  z, _IMV_VALUES_COUNTERr  r   c              3  <   >#    U  H  u    pnT" X25      v   M     g 7fr  r  )r<  rE  r=  	bind_keysr>  s       r  r>  @SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>  s'      62D.AqY #9882Ds   c              3  b   >#    U  H$  u      pU  H  nTR                  X35      v   M     M&     g 7fr  rp  )r<  rE  rA  r=  rq  s       r  r>  rB    s:      4*<&Aq!$C #&&s00$ 1*<rD  z, _IMV_VALUES_COUNTER), z), r  z\d+r  c              3  P   >#    U  H  nT  H  u  p#nU S U 3X44v   M     M     g7f)rE  Nr  )r<  r  r=  len_r  generic_setinputsizess        r  r>  rB  0  s9      /%>E.CNCs  5%)45.C 6%>s   #&r  c              3  .   >#    U  H
  nUTT v   M     g 7fr  r  )r<  r  expand_pos_lower_indexexpand_pos_upper_indexs     r  r>  rB  E  s!      &!&A 01GH!&s   c              3  ^   >#    U  H"  u  pTR                  S [        U5      5      v   M$     g7f)_IMV_VALUES_COUNTERN)r  r   )r<  r2  rE  executemany_values_w_commas      r  r>  rB  L  s7        )9 7>> 5s1v  )9r}  c              3  D   >#    U  H  nTR                    U 3v   M     g 7fr  )ra  )r<  r2  r  s     r  r>  rB  i  s(      &!2A  >>?sC!2s    EXECMANY_INDEX__rK  __)3rm  rV  r  r  r  rK  r  supports_default_metavaluesupports_multivalues_insertr  rT  rR  r1  r   r  rZ  	functoolspartialr  r  rL  r  insertmanyvalues_max_parametersr[  rN  minr  r  rq  r~   rX  r   r  r  r  r7  r  rf  r  r  ra  r  rangerP  rA  r  r  from_iterabler	  r   r  )Er  r2  r3  compiled_parametersrF  
batch_sizerQ  r  imv_sentinel_from_params	lenparamsuse_row_at_a_time
downgradedrb  paramcompiled_paramrstimv_single_values_exprexecutemany_values
max_paramstotal_num_of_paramsnum_params_per_batchnum_params_outside_of_batchbatchescompiled_batchesr^  rc  rN  r  r=  rE  stall_keysimv_values_counterformatted_values_clausekeys_to_replacebase_parametersall_names_we_will_expandrf  r7  r  r   all_expand_positionsescapedr_  compiled_batchra  new_keyrE  r  num_ins_paramsextra_params_leftextra_params_rightbatch_iteratorexpanded_values_stringr  rx   r  r[  r\  replaced_values_clausesr2  fmvr  r>  rq  rL  rH  rI  sE   `   `                                                           @@@@@r  !_deliver_insertmanyvalues_batches-SQLCompiler._deliver_insertmanyvalues_batchesI  s     $$&&$(!$,$7$7((%! 
O	t||'N'N !%J99#$$%%-1N1N
 !%J %J5>a
8 6115 -)G 1 /~>?+ 6. ##77%9C
 C!$!7!7%()?%@" !7 8:%%&8:NO	 \\AA
"%doo"6#&s'='=#> #&:: ( "==+,J ,d:.>?!4(;#<
 HL!/'AQ
 !33!--- +="*<&CdB c3t9b)*<  " ;<;!7&&%)%<%<"%'":a=)H! ''%<"%'"*+DII 62D6 - , ""!''#
 '33 4*<4 O $..??C Z]3''?   *,&&(#!eO O''.//GH + 011G0H-L*14$..(//Q8 / (".."... &/{%;(%;	T77 %; % (
 *--A)B&),-A)BQ)F&,--0FFGG ""))D$G$GH-/VVy$d,F.* Aj)E-a
;N$&GAj!-/Qz*%/"%(Z"$/%*+=%>/+/*s dC(/ ( + !$!B!B "Sq]2=??%(:%*N(-a1H2H(I%).q2H2I)J&&!&&N
 ++   )2%(8	   r.* 46HHr.* &&>A+=  2112Q6E(,>?%GC !& &!&uc!2& !I .Di-O*%.%6%6(*@&" ',OO11.A'#
 &)*() $ +-'&5&:&:&<# )% 0HAu199*CFC //!kk*?QH+2237'..>MNosC51#c
2oN !1 &/%6%6(II56&"
 )"#' - :HH2*2.H"'   MHI go"P:(D+x O Is_   I\$\ 
:B4\$.\B	\$
\\!C\$.\F7\$8\
A \$\\$>&\$c                  ^  UR                   " UT 40 UD6nUR                  nUb  X4S'   SnOT R                  (       + nU(       a7  ST l        T R                  (       d  UT l        T R
                  (       d  UT l        T R                  R                  [        5       [        5       US.5        SnS nT R                  (       a  Uc  / n[        R                  " T UUU4SU0UD6nT R                  (       aI  UbF  [        U5      nT R                  (       a*  T R                  b  T =R                  U-  sl        OUT l        UR                  n	U	(       d~  T R                  R                   (       dc  T R                  R"                  (       dH  T R                  R$                  (       d-  [&        R(                  " ST R                  R*                  -  5      eUR,                  (       a  T R                  R.                  (       d-  [&        R(                  " ST R                  R*                  -  5      eT R0                  (       d  UR2                  (       a'  UR4                  (       a  [&        R(                  " S	5      eUR                  n	OUR                  n	T R6                  n
T R                  R                   nS
nUR8                  (       a   UT R:                  " XR8                  40 UD6-  nUS-  nU
R=                  UR>                  5      nUR@                  (       a  T RC                  X5      u  pURD                  (       a  T RG                  X5        X-  nU	(       d  U(       d-  USSRI                  U	 VVs/ s H  u  p  oPM
     snn5      -  -  nURJ                  nS nS nSnT R0                  =(       d    UR2                  nU(       Ga  URL                  nUb  U(       d   eU	 VVVs0 s H  u  n  nnUU_M     nnnn/ nU H<  nUU;  a  S n  O3T RO                  U5      nUUU   ;  a  S n  OUR                  U5        M>     UcJ  T R                  RP                  [R        RT                  -  (       a  SnOUS   RV                  (       a   S5       e[Y        U5      [Y        U5      -   nT R[                  UUUS9nT R\                  (       a  USU-   -  nOS nUR^                  b  T R`                  " T R                  S   S   4SS0UD6nT Rb                  (       aU  T R                  Rd                  (       a:  U(       d  [        T R                  5      OS nUST Rg                  USS9< U< 3-  nGO$USU-  -  nGOU	(       dq  U(       aj  US-  nU(       a\  [i        ST R                  Rj                  [m        SU	5      UUR4                  URn                  S LUU(       a  [        U5      OSUS9	T l8        GOUR,                  (       a+  USSRI                  S URr                   5       5      < 3-  nGOfSRI                  [m        SU	5       VVs/ s H
  u    nnnUPM     snn5      nU(       Ga"  U(       a  T R                  RP                  [R        Rt                  -  (       a  URv                  (       d  SnT R                  RP                  [R        Rx                  -  n SRI                  S [{        U	5       5       5      n!U (       a%  SRI                  U 4S j[{        U	5       5       5      n"OU!n"USU" SU SU! S 3-  nOSnUS!U S"3-  n[i        SU[m        SU	5      UUR4                  URn                  S LUU(       a  [        U5      OSUUUS#9T l8        O	US!U S"3-  nURn                  b,  T R`                  " URn                  40 UD6n#U#(       a  USU#-   -  nU(       a  T R\                  (       d  USU-   -  nT Rb                  (       aL  T R                  Rd                  (       d1  U(       d  [        T R                  5      OS nT Rg                  USS9U-   nT R                  R}                  S5        U$ s  snnf s  snnnf s  snnf )$Nr  FTr(  r   r  zWThe '%s' dialect with current database version settings does not support empty inserts.zcThe '%s' dialect with current database version settings does not support in-place multirow inserts.zcRETURNING cannot be determinstically sorted when using an INSERT which includes multi-row values().zINSERT zINTO  (%s)r   zTsentinel selection rules should have prevented us from getting here for this dialectr5  rM  r  r.  r  r  rM  z DEFAULT VALUESrM  )rQ  rR  rT  rU  rW  z VALUES c              3  X   #    U  H   nS SR                  S U 5       5      -  v   M"     g7f)rd  r   c              3  ,   #    U  H
  u    pov   M     g 7fr  r  )r<  rE  r  s      r  r>  5SQLCompiler.visit_insert.<locals>.<genexpr>.<genexpr>  s      L^>1a^s   NrR  )r<  crud_param_sets     r  r>  +SQLCompiler.visit_insert.<locals>.<genexpr>  s2       +N yy L^ LLN*Ms   (*c              3  0   #    U  H  u  pS U 3v   M     g7fpNr  )r<  r2  rE  s      r  r>  r    s      ),IDA!A3,Is   c              3     >#    U  HL  u  ntp#TR                  UR                  UR                  R                  TR                  5      S U 35      v   MN     g7fr  )r<  r  r  r  )r<  r2  r  rE  r  s       r  r>  r    sZ      4 1N9C !11 # # @ @ N"#A3 
 1Ns   AAz SELECT z FROM (VALUES (z)) AS imp_sen(z#, sen_counter) ORDER BY sen_counterz	 VALUES (rH  )rK  rL  rN  rP  rQ  rR  rT  rU  rV  rW  rX  )?r  r2  r  rR  r  r(  r  r~   r  r   _get_crud_paramsr  rf  rs  single_paramsr  supports_default_valuesrQ  supports_empty_insertr2   r  r   _has_multi_parametersrR  rX  
_returning_sort_by_parameter_orderr  r#  r"  format_tabler   r  r(  r,  r-  r   use_insertmanyvaluesuse_sentinel_columnsrl  r+  rg  rp  _insert_sentinelr  r  r\  r   r  rv  cte_follows_insertr0  rJ  default_metavalue_tokenr   _post_values_clauserm  all_multi_paramsrr  is_default_metavalue_onlyrs  r1  r  )$r  insert_stmtr  r  r  r(  r3  counted_bindparamcrud_params_structcrud_params_singler  r  r  r&  rE  rE  r  named_sentinel_paramsadd_sentinel_colsrW  r  r  param_names_params_by_col_add_sentinel_col
param_namer  select_textr*  r  r  embed_sentinel_valuerender_bind_castscolnamescolnames_w_castpost_values_clauses$   `                                   r  visit_insertSQLCompiler.visit_insert  sr    $::
!#
 $--#!-~H::~H DM)))6&%%%2"

#&5 #)	
  ! ??|3
 !#!22	

 0
 
 ??0< #$5 6""))5**.??*->D*/== #LL88LL;;LL66""!\\../  ..<<;;&&137<<3D3DE  '';+A+A66&&I  "4!A!A!3!A!A=="&,,"F"F  D++2268 D 	**;+<+<=
 22;KMA((++K<%<Gdii+=>+=-!1a+=>  D  2FF9= !00JK4J4J 2 G G ,+++ 3E"2D.Q; $2D  " )+%):%(>04-!%!C!C)"J "8I)JJ04-)00< *; )0 GG6HHI -1) $5Q#7#H#H DH "&n!5=N8O!O#44$,  5   --...  $),,

234BFJLK yyT\\<<7?DJJT++&304 ,     ++#(?%%D#):LL889;M &#<< $77tC%62C-.&7#*&& 00		  +=*M*M  D )-		 +/9*++1eQ +)% $%GG6MMN
 0II ,0( GG6NNO &
  $yy ),56H,I)  H ) +/)) 4 1::L0M4 + +3"?"3 4$$=#> ?&&.Z 0//D ,1(i(A'B!DDD):$)'@'+9*( 3D#<< $77tC%62C-.(=&7)=)*&0 )$=#>a@@**6!%//"35" "000D$B$BC***D99T\\<<3;C

OM''"/,0 (  	  	

rs ?0"^s   %aa2a
c                    g)z3Provide a hook for MySQL to add LIMIT to the UPDATENr  )r  update_stmts     r  update_limit_clauseSQLCompiler.update_limit_clause      r  c                    g)z3Provide a hook for MySQL to add LIMIT to the DELETENr  )r  delete_stmts     r  delete_limit_clauseSQLCompiler.delete_limit_clause  r  r  c                6    SUS'   UR                   " U 4SS0UD6$ )zdProvide a hook to override the initial table clause
in an UPDATE statement.

MySQL overrides this.

Tr  rI  r  )r  r  
from_tableextra_fromsr  s        r  update_tables_clause SQLCompiler.update_tables_clause  s(     8,,TE$E"EEr  c                    [        S5      e)zfProvide 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_clauseSQLCompiler.update_from_clause(  s     "%
 	
r  c                   UR                   " X40 UD6n[        (       a  [        U[        5      (       d   eUR                  nUb  X#S'   SnOU R
                  (       + nU(       a5  SU l        U R                  (       d  X@l        U R                  (       d  X@l        U R                  [        -  (       a5  [        0 [        5       5      nU R                  [        -  nU(       a  X`l        OS nSnUR                  n[!        U5      n	U	(       aI  [        [#        UR$                  5      5      n
U Vs/ s H  oU
;  d  M
  UPM     nnU
R'                  U5      nO/ nUR$                  1nU R
                  R)                  UUUS.5        SnUR*                  (       a  XR,                  " XR*                  40 UD6-  nU R.                  " UUR$                  U4SU0UD6n[0        R2                  " XXE40 UD6nUR4                  nUR6                  (       a  U R9                  X5      u  nnOS nUR:                  (       a  U R=                  X5        X-  nUS-  nUSR?                  S	 [A        S
U5       5       5      -  nU RB                  (       d  URD                  (       aE  U RF                  (       a4  USU RI                  UU RB                  =(       d    URD                  US9-   -  nU(       a1  U RJ                  " UUR$                  UU4SU0UD6nU(       a  USU-   -  nURL                  (       a.  U RN                  " URL                  4SU0UD6nU(       a  USU-   -  nU RQ                  U5      nU(       a  USU-   -  nU RB                  (       d  URD                  (       aE  U RF                  (       d4  USU RI                  UU RB                  =(       d    URD                  US9-   -  nU RR                  (       a0  U(       d  [U        U R
                  5      OS nU RW                  US9U-   nU(       a  Uc   eURY                  SS9  U R
                  R[                  S5        U$ s  snf )Nr  FTr(  zUPDATE rL  z SET r   c              3  8   #    U  H  u  pp1US -   U-   v   M     g7f)=Nr  )r<  rE  rE  r  s       r  r>  +SQLCompiler.visit_update.<locals>.<genexpr>  s)      
&! 3J&s   zList[Tuple[Any, str, str, Any]]rM  r   WHERE r)  UPDATEr  r  ).r  r   r  rA   r2  r  rS  r  r(  r  r|  r  r~   r}  rL  _extra_fromsr)  r*   r   r   r  r#  r"  r  r   r  r  r  r(  r,  r-  r   r   rX  r  r\  r  r  r  r`  r  rv  r  r0  r  r  )r  r  r  r  r(  r3  rL  r  r  is_multitable
main_fromsr  render_extra_fromsr$  r  r&  r  crud_paramsr'  extra_from_textr  r  r*  s                          r  visit_updateSQLCompiler.visit_update6  sD    $::
!#
 =m^<<<<#--#!-~H::~H DM)))6&%%%2"<<44$R/K<<,6L#. K L#00[)];+<+<=>J&"&a:*=;  " )..{;O!#*001O

#2 /)	
   ++2268 D ..
 $	

 

 "22}
:<
 )66(,(>(>)%M: !M((++K<		 
%)1;&
 
 	
 ""k&<&<--d33++E{/E/E(0 4    "55!!"	
 ( O o--&&11++9DHJA 	A%//<C,&&D ##{'='=00C$//''A;+A+A$, 0   D 993;C

OM***G$ND***x0

rS"s   *	Q7Qc                    [        S5      e)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_clause$SQLCompiler.delete_extra_from_clause  s     "%
 	
r  c                .    UR                   " U 4SSS.UD6$ )NT)r  rI  r  )r  r  r  r  r  s        r  delete_table_clauseSQLCompiler.delete_table_clause  s*    ,,
d
.0
 	
r  c                   UR                   " X40 UD6nUR                  nUb  X#S'   SnOU R                  (       + nU(       a5  SU l        U R                  (       d  X@l        U R
                  (       d  X@l        U R                  [        -  (       a5  [        0 [        5       5      nU R                  [        -  nU(       a  X`l        OS nSnUR                  nUR                  1R                  U5      n	U R                  R                  U	U	US.5        Sn
UR                   (       a  XR"                  " XR                   40 UD6-  n
U
S-  n
 U R%                  UUR                  UUS9n[*        R,                  " XXE40 UD6  UR.                  (       a  U R1                  X5      u  pOS nUR2                  (       a  U R5                  X5        X-  n
U R6                  (       d  UR8                  (       aE  U R:                  (       a4  U
SU R=                  UU R6                  =(       d    UR8                  US	9-   -  n
U(       a1  U R>                  " UUR                  UU4S
U0UD6nU(       a  U
SU-   -  n
UR@                  (       a.  U RB                  " UR@                  4S
U0UD6nU(       a  U
SU-   -  n
U RE                  U5      nU(       a  U
SU-   -  n
U R6                  (       d  UR8                  (       aE  U R:                  (       d4  U
SU R=                  UU R6                  =(       d    UR8                  US	9-   -  n
U RF                  (       a0  U(       d  [I        U R                  5      OS nU RK                  US9U
-   n
U(       a  Uc   eURM                  SS9  U R                  RO                  S5        U
$ ! [&         aA    U R%                  XR                  U5      nU(       a  U R)                  UR                  US9n GNf = f)Nr  FTr(  zDELETE FROM )rL  rM  r  rL  r  r)  DELETEr  r  )(r  r2  r  rQ  r  r(  r  r|  r  r~   r}  rL  r  r   r   r  r#  r"  r  	TypeErrorr  r   r  r  r(  r,  r-  rX  r  r\  r  r  r  r`  r  rv  r  r0  r  r  )r  r  r  r  r(  r3  rL  r  r  r$  r  r&  rE  r'  r  r  r  r*  s                     r  visit_deleteSQLCompiler.visit_delete  s   #::
!#
 $--#!-~H::~H DM)))6&%%%2"<<44$R/K<<,6L#. K L#00&,,-33K@

#2 /)	
   ++2268 D 		M11!!'	 2 J 	dOBO(,(>(>)%M: !M((++K< ##{'='=,,C$//''A;+A+A$, 0   D ";;!!	
 ( O o--&&11++9DHJA 	A%//<C,&&D ##{'='=00C$//''A;+A+A$, 0   D 993;C

OM***G$ND***x0

rU  	M 11..J LL!2!2LL	Ms   N& &AO10O1c                >    SU R                   R                  U5      -  $ )NzSAVEPOINT %sr  format_savepointr  savepoint_stmtr  s      r  visit_savepointSQLCompiler.visit_savepointb  s     > >~ NNNr  c                >    SU R                   R                  U5      -  $ )NzROLLBACK TO SAVEPOINT %sr  r  s      r  visit_rollback_to_savepoint'SQLCompiler.visit_rollback_to_savepointe  s#    )DMM,J,J-
 
 	
r  c                >    SU R                   R                  U5      -  $ )NzRELEASE SAVEPOINT %sr  r  s      r  visit_release_savepoint#SQLCompiler.visit_release_savepointj  s#    %(F(F)
 
 	
r  )-rc  rr  rm  re  rf  ra  rd  rh  rl  rj  rg  r  rb  r  rs  r  r[  rZ  r_  r  r  r`  r(  rv  rw  ry  r  rq  r  rL  r  ru  rQ  rR  rY  rS  r  rx  r  r  r  r7  r  r  r  )r  rk   r2  r  r  r  r  r6  r  r)  r  rz  r  zOptional[SQLCompiler]r  r   )r  ri  )r  rW  )r  zDict[Any, Any])r  zMutableMapping[CTE, str])r  zVMutableMapping[str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]]])r  r6   )NT)r  r  r  r)  r  r1  )NNTNTF)r  r  r  r  r  r)  r  Optional[int]r  r)  r  r)  r  rj   F)r3  rj   r  r)  r  r1  )r  zCallable[[Any], str]r  )NFFNr  )NTr  N)r   ColumnClause[Any]r  Optional[_ResultMapAppender]r  r)  r  r  r  z Optional[_AmbiguousTableNameMap]r  r   r  r   r  )NF)rE  rK   r  r   r  r   )rE  rL   r  r   r  r   )rE  rI   r  r   r  r   )r  Function[Any]r  r  r  r   r  r   )r  r  r  r   r  r   )FNNr  )NFNN)
r   BinaryExpression[Any]rs  r   rP  r)  r  r   r  r   )r   r  r  r   r  r   r  r   )FFFFF)r  r   r  zsqltypes.TypeEngine[Any]r  r   )r  r   r   rC   r  r   )r   r   r  r   )FFNNNN)r   r   r  r)  r  r)  r  ri  r  zOptional[TypeEngine[Any]]r  zOptional[Set[str]]r  rk  r  r   r  r   )r  rX   r  r)  r'  r)  r(  zOptional[_FromHintsType]r  Optional[CTE]rL  zOptional[FromLinter]r  zselectable._CTEOptsr  r   r  ri  )FFFNFFNN)
r   r   r   r   r  r  r  r  r  r  )NNNTFFT)r   rY   r  ri  r  ri  )FFNNNFN)r   r-  r  zTuple[str, _FromHintsType])r   r-  r  r   r  r   
r  r@   r  zSequence[_ColumnsClauseElement]r5  r)  r  r   r  r   )NFF)FFFNTNNN)r   rS   r  rS  )r2  r   r3  rf   rY  z%List[_MutableCoreSingleExecuteParams]rF  r]  rZ  rO  rQ  r)  r  r  r  z Iterator[_InsertManyValuesBatch]r  )r  r?   r  r  r  r   r  r   )r  r  r	  r
  r  EXTRACT_MAPr  r&   r  rN  r  r  COMPOUND_KEYWORDSr  rQ  rR  rS  rU  rV  rX  rY  r\  r]  r^  rb  rc  rd  re  rf  rg  rh  rj  rl  rm  rn  	frozensetro  rp  r  rq  r  postfetch_lastrowidrr  r7  rs  rt  ru  r  r  rP  r  patternr  r  r  r|  r{  r  rH  r  ro_memoized_propertyr  r  r  r  memoized_propertyr  memoized_instancemethodr  
contextlibcontextmanagerr  r  r  r  r   r  r  r  r)  r  r  preload_modulerf  rl  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r%  r6  r<  rC  rG  rT  r`  rg  re  rt  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rp  r  r  r  r  r  r	  r  r  r  r7  rM  r  rT  rW  rZ  r]  r`  r  r  r  rm  rp  ry  r~  r  r  r  r  r  r  r  r  r  r  rv  r}  r  r  r  r  r  r  r  r  r<  r-   rL  r/  r  r  r  r  r-  r$   _CTEOptsr  rC  rF  rB  rW  rA  r`  rk  rs  rv  r&  r/  r  r  rR  r  r  r  r  r  r   r+  r  r  r  r  r  r  r"  r0  r  r  r  r  r  r  r  r  r  r#  r(  r,   
CLIENTSIDErg  rq  SENTINEL_DEFAULTNONErn  ro  r0  r   rm  r.  r6  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r    s    K 			
  ; : /.66F)HdHdHd
 +*% .0O*/ .0O*/$ BF>E K((I--6 %$4 ',t+ 5:+T9
 "OT! B!! %('
 .-
 &+d* "OT! "d! ).- !ND  !&% =A "9@ +/-.
 6:295929=A:A<EK9G
 :C6D
 8<4F
   % 	    (,K$+ .2*1.2+2FD
,, 32 GFJJ'LM

#45**$$
%Q'<'D'D&EF # # C C )-/3 %%59PP +P &	P
 -P P P 3P Pd = =$ 
 0 ( (  M  MD G G 
  
!! ".  .9vGR 



 
8#  
 6:!
2
 
 
	
2 6:GK!'+ %~2~ E~ 	~
 %~ ~ ~ 
)~@ 
!!$ "$L 
3 
3  %C3C C 
	CJ 
34
 5
 43	  
	34P 5 Pd 
	34, 5 ,\>@OO .3-
` .3+` !#"/b

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

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


  %	%  	
  
2GG 
I IJAEBFAEBFAEBF

	
AE


+
7:
BE
	

+
7:
BE
	

+
7:
BE
	
 $" cJ$ $!%	DB%%!9%	%N&6	*$ #&*484815AA A 	A
 $A 2A  2A /A A 
AFC .2&*,0(2(;(;E(BVV V 	V
 ,V $V *V &V V 
Vp30 bH0?"$L9(

 
 !	

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

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


r  r  c                     ^  \ rS rSrSrS r\R                  " S5      U 4S j5       rS r	S r
S rS	 r          SS
 jrS rS rS rS rS rS rS rS rSrU =r$ )StrSQLCompilerip  a_  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                    g)Nz<name unknown>r  r  s     r  r  $StrSQLCompiler._fallback_column_name  s    r  zsqlalchemy.engine.urlc                X  > UR                   S:w  a  [        R                  R                  nUR                  R                  UR                   5      R                  5       " 5       nUR                  US U S9n[        U[        5      (       d  UR                  " U40 UD6$ [        TU ]1  X5      $ )Nr   )r  )stringify_dialectr&   rb  
engine_urlURLr   get_dialectstatement_compilerr  r  r  r  r  )r  r  r  r  urlr  compilerr  s          r  r  ,StrSQLCompiler.visit_unsupported_compilation  s    $$	1..++CggnnW%>%>?KKMOG114 2 H h77''6266w4WBBr  c                    U R                   " UR                  40 UD6< SU R                   " UR                  40 UD6< S3$ )NrK  rL  )r  r   r   r  s       r  visit_getitem_binary#StrSQLCompiler.visit_getitem_binary  s6    LL++LL,,
 	
r  c                (    U R                   " X40 UD6$ r  r  r  s       r  visit_json_getitem_op_binary+StrSQLCompiler.visit_json_getitem_op_binary      ((@R@@r  c                (    U R                   " X40 UD6$ r  r  r  s       r  !visit_json_path_getitem_op_binary0StrSQLCompiler.visit_json_path_getitem_op_binary  r  r  c                @    SU R                   R                  U5       S3$ )Nz<next sequence value: >)r  format_sequencer  s      r  r  StrSQLCompiler.visit_sequence  s#    $T]]%B%B8%L$MQO	
r  c          
         [         R                  " U5       Vs/ s H  nU R                  S USS0 5      PM     nnSSR                  U5      -   $ s  snf )NTFr  r   )r   r  r  r   )r  r  r  r5  r  r  rr  s          r  r  StrSQLCompiler.returning_clause  s]     ++N;
; %%dAtUB?; 	 
 dii000	
s   Ac                R   ^ ^^ STS'   SSR                  UUU 4S jU 5       5      -   $ )NTr  r  r   c              3  N   >#    U  H  nUR                   " T4S T0TD6v   M     g7fr(  Nr  r<  r  r  r  r  s     r  r>  4StrSQLCompiler.update_from_clause.<locals>.<genexpr>  s-      #
    BBrB    "%rR  r  s   `   ``r  r  !StrSQLCompiler.update_from_clause  s3     8 #
 #
 
 
 	
r  c                R   ^ ^^ STS'   SSR                  UUU 4S jU 5       5      -   $ )NTr  r   c              3  N   >#    U  H  nUR                   " T4S T0TD6v   M     g7fr!  r  r"  s     r  r>  :StrSQLCompiler.delete_extra_from_clause.<locals>.<genexpr>  s-       
    BBrB r$  rR  r  s   `   ``r  r  'StrSQLCompiler.delete_extra_from_clause  s3     8dii  
  
 
 
 	
r  c                    g)NzSELECT 1 WHERE 1!=1r  r  s      r  r  #StrSQLCompiler.visit_empty_set_expr  s    $r  c                    SU-  $ )Nz[%s]r  r  s      r  r  !StrSQLCompiler.get_from_hint_text  s    }r  c                *    U R                   " US40 UD6$ )Nz
 <regexp> r  r  s       r  r  +StrSQLCompiler.visit_regexp_match_op_binary  s    ,,V\HRHHr  c                *    U R                   " US40 UD6$ )Nz <not regexp> r/  r  s       r  r  /StrSQLCompiler.visit_not_regexp_match_op_binary  s    ,,V5ELLLr  c                    SUR                   R                  " U 40 UD6< SUR                  R                  " U 40 UD6< S3$ )Nz<regexp replace>(r   rH  )r   r  r   r  s       r  r  -StrSQLCompiler.visit_regexp_replace_op_binary  s:    KK**4626LL++D7B7
 	
r  c                    SUR                   R                  " U 40 UD6< SUR                  R                  " U 40 UD6< S3$ )Nz	TRY_CAST(r   rH  )rz  r  r	  )r  r   r  s      r  visit_try_castStrSQLCompiler.visit_try_cast  s:    KK**4:6:OO..t>v>
 	
r  r  r  )r  r  r	  r
  r  r  r&   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r6  r  r  r	  s   @r  r  r  p  s    &  
01C 2C
AA

11 81
 "1 1 
1

%IM

 
r  r  c                  H   \ rS rSrSr\(       a     S4         S5S jjr\R                  S6S j5       r	\R                  S 5       r   S7       S8S jjrS rS	 rS
 rS rS9S jr S:S jrS rS rS;S jr S<S jrS r S9     S=S jjrS rS rS rS rS rS rS rS r S:S jr!S r"S r#S r$S  r%S! r&S>S" jr'S?S# jr(S$ r)S% r*S& r+      S@S' jr,S( r-S) r.      SAS* jr/      SAS+ jr0    SBS, jr1    SBS- jr2    SBS. jr3SCS/ jr4S0 r5S1 r6S2 r7S3r8g)DDDLCompileri  Tc                    g r  r  r  s         r  r  DDLCompiler.__init__  s     r  c                `    U R                   R                  U R                   S U R                  S9$ )Nr9  )r  r
  r  rB  s    r  r  DDLCompiler.sql_compiler  s/    ||..LL$T5N5N / 
 	
r  c                .    U R                   R                  $ r  )r  r  rB  s    r  type_compilerDDLCompiler.type_compiler  s    ||222r  Nc                    g r  r  r  s       r  r  DDLCompiler.construct_params  s     r  c                   UR                   n[        UR                  [        R                  5      (       a  UR                  5       nU R                  nUR                  UR                  5      n[        U5      S:X  a  US   SpvO	US   US   pvUR                  SU5        UR                  SU5        UR                  SUR                  UR                  5      5        U R                  R                  UR                  U-  5      $ )Nr   r   r  r  r   r#   r  )contextr  targetr#   rS   r	  r  format_table_seqr  rh  r  r  r  r2  )r  ddlr  rD  r  pathr   schs           r  	visit_ddlDDLCompiler.visit_ddl  s    ++cjj&,,//llnG}}H,,SZZ8D4yA~!!Wbs!"XtAwsw.x-z8+@+@+LM  223==73JKKr  c                    SnUR                   (       a  US-  nX0R                  R                  UR                  5      -   $ )NzCREATE SCHEMA IF NOT EXISTS )if_not_existsr  format_schemar  )r  r   r  r  s       r  visit_create_schemaDDLCompiler.visit_create_schema  s7    $$Dmm11&..AAAr  c                    SnUR                   (       a  US-  nX0R                  R                  UR                  5      -  nUR                  (       a  US-  nU$ )NzDROP SCHEMA 
IF EXISTS  CASCADE)	if_existsr  rO  r  cascader  dropr  r  s       r  visit_drop_schemaDDLCompiler.visit_drop_schema  sI    >>L D++DLL99<<JDr  c                n   UR                   nU R                  nSnUR                  (       a!  USR                  UR                  5      S-   -  nUS-  nUR                  (       a  US-  nXTR                  U5      S-   -  nU R                  U5      nU(       a  XVS-   -  nUS-  nSnSnUR                   H]  n	U	R                   n
 U R                  XR                  =(       a    U(       + S9nUb  XW-  nS	nUS
U-   -  nU
R                  (       a  SnM]  M_     U R                  UUR                   S9nU(       a
  XWS
-   U-   -  nUSU R#                  U5      -  -  nU$ ! [        R                   aI  n[        R                  " SUR                  < SU
R                  < SUR                  S   < 35      UeS nAff = f)Nz
CREATE rM  zTABLE rM  rG  
Ffirst_pkr  	Tz(in table 'z', column 'z'): r   ) _include_foreign_key_constraintsz
)%s

)r  r  r#  r   rN  r  create_table_suffixrr  r  r  r2   r  descriptionr   argscreate_table_constraintsinclude_foreign_key_constraintspost_create_table)r  r   r  r   r  r  ra  rS  r^  create_columnr   	processedceconsts                 r  visit_create_tableDDLCompiler.visit_create_table!  s   ==??CHHU__-33D$$D%%e,s22"66u=#--D	 #^^M"**F LL!,>,>,Ox< ) 	 (%D &ID9,,D%%#H & ,$ ---3-S-S . 
 $u,,Dd44U;;; ## &&((&++rwwqzC s   AEF4+AF//F4c                   ^  UR                   nUR                  (       a  g T R                  XBS9nSR                  U 4S jUR                   5       5      nU(       a  USU-   -  nU$ )Nr]  rM  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  )r  r<  r   r  s     r  r>  2DDLCompiler.visit_create_column.<locals>.<genexpr>\  s!      
7IDLL$$7Ir  )r  systemget_column_specificationr   constraints)r  r   r^  r  r   r  rj  s   `      r  visit_create_columnDDLCompiler.visit_create_columnU  sb    ==,,V,G 
7=7I7I
 
 C%KDr  c                  ^  / nUR                   (       a  UR                  UR                   5        UR                  nUb  UR                  U5      nO
[	        5       nUR                  UR                   Vs/ s H  nXqR                   Ld  M  Xv;  d  M  UPM     sn5        SR                  S U 4S jU 5        5       5      $ s  snf )Nz, 
	c              3  0   #    U  H  nUc  M  Uv   M     g 7fr  r  )r<  r  s     r  r>  7DDLCompiler.create_table_constraints.<locals>.<genexpr>{  s"      
  As   	c              3     >#    U  H]  nUR                  T5      (       d  M  TR                  R                  (       a  [        US S5      (       a  MJ  TR	                  U5      v   M_     g7f)	use_alterFN)_should_create_for_compilerr  supports_alterr  r  ro  s     r  r>  rx  }  sT      "-J::4@ ) 33":{EB )Z(("-s   A(+A(A()r  r  foreign_key_constraintsr  r~   rO  _sorted_constraintsr   )r  r   r`  r  rs  all_fkcs	omit_fkcsr  s   `       r  rd  $DDLCompiler.create_table_constraintsd  s    
 u00100+7 ++,LMII 222A--- 232D 2	
 }} 
"-
 
 	
s   4C 
C C c                    SnUR                   (       a  US-  nX0R                  R                  UR                  5      -   $ )Nz
DROP TABLE rS  )rU  r  r  r  rW  s       r  visit_drop_tableDDLCompiler.visit_drop_table  s4    >>L Dmm00>>>r  c                R    SU R                   R                  UR                  5      -   $ )Nz
DROP VIEW r  r  r  r  rX  r  s      r  visit_drop_viewDDLCompiler.visit_drop_view  s      : :4<< HHHr  c                d    UR                   c#  [        R                  " SUR                  -  5      eg )Nz,Index '%s' is not associated with any table.)r   r2   r  r   )r  r  s     r  _verify_index_tableDDLCompiler._verify_index_table  s0    ;;"">K  r  c           	       ^  UR                   nT R                  U5        T R                  nSnUR                  (       a  US-  nUR                  c  [
        R                  " S5      eUS-  nUR                  (       a  US-  nUT R                  XRS9< SUR                  UR                  US9< S	S
R                  U 4S jUR                   5       5      < S3-  nU$ )NzCREATE UNIQUE z0CREATE INDEX requires that the index have a namezINDEX rM  include_schemar  r  rn  r   c              3  Z   >#    U  H   nTR                   R                  US SS9v   M"     g7f)FTr  r  N)r  r  )r<  rE  r  s     r  r>  1DDLCompiler.visit_create_index.<locals>.<genexpr>  s9       .D !!))T *  .r  rH  )r  r  r  r   r   r2   r  rN  _prepared_index_namer  r   r   expressions)r  r   r  include_table_schemar  r  r  r  s   `       r  visit_create_indexDDLCompiler.visit_create_index  s       '==<<ID::""B  	$$D%%e%K!!(< "  II  "--	 
 	
 r  c                    UR                   nUR                  c  [        R                  " S5      eSnUR                  (       a  US-  nX@R                  USS9-   $ )Nz.DROP INDEX requires that the index have a namez
DROP INDEX rS  Tr  )r  r   r2   r  rU  r  )r  rX  r  r  r  s        r  visit_drop_indexDDLCompiler.visit_drop_index  s\    ::""@  >>L D//d/KKKr  c                   UR                   b&  U R                  R                  UR                   5      nOS nU(       a#  U(       a  U R                  R                  U5      nOS nU R                  R	                  U5      nU(       a  US-   U-   nU$ NrJ  )r   r  r  r  format_index)r  r  r  r  schema_name
index_names         r  r   DDLCompiler._prepared_index_name  sy     ;;"#}}>>u{{K#.--445EFKK]]//6
$s*Z7Jr  c                    SU R                   R                  UR                  R                  5      < SU R	                  UR                  5      < 3$ )NALTER TABLE z ADD )r  r  r  r   r  r  r   r  s      r  visit_add_constraint DDLCompiler.visit_add_constraint  s8    MM&&v~~';';<LL(
 	
r  c                    SU R                   R                  UR                  5      < SU R                  R	                  UR                  R
                  [        R                  " 5       5      < 3$ )NzCOMMENT ON TABLE r   )r  r  r  r  r/  commentr%   Stringr  s      r  visit_set_table_comment#DDLCompiler.visit_set_table_comment  sL    MM&&v~~622&&(9
 	
r  c                R    SU R                   R                  UR                  5      -  $ )NzCOMMENT ON TABLE %s IS NULLr  r  s      r  visit_drop_table_comment$DDLCompiler.visit_drop_table_comment  s'    ,t}}/I/ILL0
 
 	
r  c                    SU R                   R                  UR                  SSS9< SU R                  R	                  UR                  R
                  [        R                  " 5       5      < 3$ )NzCOMMENT ON COLUMN T)	use_tabler  r   )r  format_columnr  r  r/  r  r%   r  r  s      r  visit_set_column_comment$DDLCompiler.visit_set_column_comment  sZ    MM''$4 (  22&&(9	
 	
r  c                P    SU R                   R                  UR                  SS9-  $ )NzCOMMENT ON COLUMN %s IS NULLT)r  )r  r  r  r  s      r  visit_drop_column_comment%DDLCompiler.visit_drop_column_comment  s/    -0K0KLLD 1L 1
 
 	
r  c                B    [         R                  " U [        U5      5      er  r  r  s      r  visit_set_constraint_comment(DDLCompiler.visit_set_constraint_comment  s    --dDLAAr  c                B    [         R                  " U [        U5      5      er  r  r  s      r  visit_drop_constraint_comment)DDLCompiler.visit_drop_constraint_comment  s    --dDJ??r  c                   / nUR                   b  UR                  SUR                   -  5        UR                  b  UR                  SUR                  -  5        UR                  b  UR                  SUR                  -  5        UR                  b  UR                  SUR                  -  5        UR
                  b  UR                  S5        UR                  b  UR                  S5        UR                  b  UR                  SUR                  -  5        UR                  b$  UR                  UR                  (       a  SOS	5        S
R                  U5      $ )NzINCREMENT BY %dzSTART WITH %dzMINVALUE %dzMAXVALUE %dzNO MINVALUEzNO MAXVALUEzCACHE %dCYCLEzNO CYCLErM  )
	incrementr  r  minvaluemaxvalue
nominvalue
nomaxvaluecachecycler   )r  identity_optionsr  s      r  get_identity_options DDLCompiler.get_identity_options  s   %%1KK),<,F,FFG!!-KK*:*@*@@A$$0KK(8(A(AAB$$0KK(8(A(AAB&&2KK&&&2KK&!!-KK
%5%;%;;<!!-KK#3#9#9zJxx~r  c                    SnUR                   (       a  US-  nX@R                  R                  UR                  5      -  nU(       a  XB-  nU R	                  UR                  5      nU(       a  USU-   -  nU$ )NzCREATE SEQUENCE rM  rM  )rN  r  r  r  r  )r  r   r  r  r  optionss         r  visit_create_sequence!DDLCompiler.visit_create_sequence  sj    !$$D--fnn==ND++FNN;C'M!Dr  c                    SnUR                   (       a  US-  nX0R                  R                  UR                  5      -   $ )NzDROP SEQUENCE rS  )rU  r  r  r  rW  s       r  visit_drop_sequenceDDLCompiler.visit_drop_sequence   s4    >>L Dmm33DLLAAAr  c                   UR                   nUR                  b  U R                  R                  U5      nOS nUc#  [        R
                  " SUR                   -  5      eSU R                  R                  UR                   R                  5      < SUR                  (       a  SOS< U< UR                  (       a  S< 3$ S< 3$ )Nz<Can't emit DROP CONSTRAINT for constraint %r; it has no namer  z DROP CONSTRAINT rS  r  rT  )
r  r   r  format_constraintr2   r  r  r   rU  rV  )r  rX  r  r   formatted_names        r  visit_drop_constraint!DDLCompiler.visit_drop_constraint&  s    \\
??&!]]<<ZHN!N!""!#'<<0  " MM&&t||'9'9: NNL2,,J.	
 	
 -/.	
 	
r  c                J   U R                   R                  U5      S-   U R                  R                  R	                  UR
                  US9-   nU R                  U5      nUb  USU-   -  nUR                  b!  USU R	                  UR                  5      -   -  nUR                  b<  U R                  R                  (       a!  USU R	                  UR                  5      -   -  nUR                  (       d1  UR                  (       a  U R                  R                  (       d  US-  nU$ )NrM  )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  rr  $DDLCompiler.get_column_specification9  s    MM''/ll1199V :  	 008{W,,G??&sT\\&//:::G OO'66sT\\&//:::Gt||'M'M{"Gr  c                    gNr  r  r  r   s     r  ra  DDLCompiler.create_table_suffixT      r  c                    gr  r  r  s     r  rf  DDLCompiler.post_create_tableW  r  r  c                    [        UR                  [        R                  5      (       a%  U R	                  UR                  R
                  5      $ g r  )r  server_defaultr#   DefaultClauserender_default_stringargr  s     r  r  %DDLCompiler.get_column_default_stringZ  s;    f++V-A-ABB--f.C.C.G.GHHr  c                    [        U[        5      (       a*  U R                  R                  U[        R
                  5      $ U R                  R                  USS9$ )NT)r  )r  r   r  r/  r%   rl  r  )r  r   s     r  r  !DDLCompiler.render_default_string`  sQ    gs##$$99,,  $$,,WD,IIr  c                h    UR                   (       a  U R                  U5      $ U R                  U5      $ r  )is_column_levelvisit_column_check_constraintvisit_check_constraintr  r   r  s      r  &visit_table_or_column_check_constraint2DDLCompiler.visit_table_or_column_check_constrainth  s-    %%55jAA..z::r  c                    SnUR                   b&  U R                  R                  U5      nUb  USU-  -  nUSU R                  R	                  UR
                  SSS9-  -  nX0R                  U5      -  nU$ Nr  CONSTRAINT %s z
CHECK (%s)FTr  r   r  r  r  r  r  define_constraint_deferrabilityr  r   r  r  r  s        r  r  "DDLCompiler.visit_check_constraintn      ??&!]]<<ZHN)(>99t0088e4  9  
 
 	
 	44Z@@r  c                    SnUR                   b&  U R                  R                  U5      nUb  USU-  -  nUSU R                  R	                  UR
                  SSS9-  -  nX0R                  U5      -  nU$ r  r  r  s        r  r  )DDLCompiler.visit_column_check_constraintz  r  r  c                T  ^  [        U5      S:X  a  gSnUR                  b&  T R                  R                  U5      nUb  USU-  -  nUS-  nUSSR	                  U 4S jUR
                  (       a  UR                  OUR                   5       5      -  -  nUT R                  U5      -  nU$ )Nr   r  r  zPRIMARY KEY rd  r   c              3  n   >#    U  H*  nTR                   R                  UR                  5      v   M,     g 7fr  r  r  r   r<  r  r  s     r  r>  ;DDLCompiler.visit_primary_key_constraint.<locals>.<genexpr>  s5      #
(  MM''(r+  )	r  r   r  r  r   _implicit_generatedcolumns_autoinc_firstrr  r  r  s   `    r  visit_primary_key_constraint(DDLCompiler.visit_primary_key_constraint  s     z?a??&!]]<<ZHN)(>99 #
 11 00''(#
 
 
 	
 	44Z@@r  c           
     $  ^ U R                   mSnUR                  b&  U R                   R                  U5      nUb  USU-  -  n[        UR                  5      S   R
                  R                  nUSSR                  U4S jUR                   5       5      < SU R                  XT5      < SSR                  U4S	 jUR                   5       5      < S
3-  nX0R                  U5      -  nX0R                  U5      -  nX0R                  U5      -  nU$ )Nr  r  r   zFOREIGN KEY(r   c              3  n   >#    U  H*  nTR                  UR                  R                  5      v   M,     g 7fr  )r  parentr   r<  r  r  s     r  r>  ;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>  )      7J!qxx}}--7Jr+  z) REFERENCES rn  c              3  n   >#    U  H*  nTR                  UR                  R                  5      v   M,     g 7fr  )r  r   r   r
	  s     r  r>  r	    r	  r+  rH  )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_constraint(DDLCompiler.visit_foreign_key_constraint  s
   ==??&!]]<<ZHN)(>99J//03::@@II 7A7J7J  //( II 7A7J7J 

 
	
 	,,Z88//
;;44Z@@r  c                $    UR                  U5      $ )z=Format the remote table clause of a CREATE CONSTRAINT clause.)r  )r  r   r   r  s       r  r	  *DDLCompiler.define_constraint_remote_table  s     $$U++r  c                *  ^  [        U5      S:X  a  gSnUR                  b&  T R                  R                  U5      nUb  USU-  -  nUST R                  " U40 UD6< SSR                  U 4S jU 5       5      < S3-  nUT R                  U5      -  nU$ )	Nr   r  r  r  rG  r   c              3  n   >#    U  H*  nTR                   R                  UR                  5      v   M,     g 7fr  r 	  r	  s     r  r>  6DDLCompiler.visit_unique_constraint.<locals>.<genexpr>  s'     F:admm))!&&11:r+  rH  )r  r   r  r  !define_unique_constraint_distinctr   r  r  s   `    r  visit_unique_constraint#DDLCompiler.visit_unique_constraint  s     z?a??&!]]<<ZHN)(>9922:DDIIF:FF
 	
 	44Z@@r  c                    gr  r  r  s      r  r	  -DDLCompiler.define_unique_constraint_distinct  s     r  c                    SnUR                   b  X R                  U5      -  nUR                  b  X R                  U5      -  nU$ r  )ondelete"define_constraint_ondelete_cascadeonupdate"define_constraint_onupdate_cascader  r   r  s      r  r	  &DDLCompiler.define_constraint_cascades  sL     *;;JGGD*;;JGGDr  c                \    SU R                   R                  UR                  [        5      -  $ )Nz ON DELETE %s)r  validate_sql_phraser	  FK_ON_DELETEr  r   s     r  r 	  .DDLCompiler.define_constraint_ondelete_cascade  -     !B!B"
 
 	
r  c                \    SU R                   R                  UR                  [        5      -  $ )Nz ON UPDATE %s)r  r&	  r!	  FK_ON_UPDATEr(	  s     r  r"	  .DDLCompiler.define_constraint_onupdate_cascade  r*	  r  c                    SnUR                   b  UR                   (       a  US-  nOUS-  nUR                  b0  USU R                  R                  UR                  [        5      -  -  nU$ )Nr  z DEFERRABLEz NOT DEFERRABLEz INITIALLY %s)r   r   r  r&	  FK_INITIALLYr#	  s      r  r  +DDLCompiler.define_constraint_deferrability  sq      ,$$%))+Odmm&G&G$$l'  D r  c                H    SnUR                   b  USUR                   -  -  nU$ )Nr  z	 MATCH %s)r  r#	  s      r  r	  #DDLCompiler.define_constraint_match  s-    'K*"2"222Dr  c                    SU R                   R                  UR                  SSS9-  nUR                  SL a  US-  nU$ UR                  SL a  US-  nU$ )NzGENERATED ALWAYS AS (%s)FTr  z STOREDz VIRTUAL)r  r  r  	persisted)r  	generatedr  r  s       r  visit_computed_column!DDLCompiler.visit_computed_column  sr    )D,=,=,E,EU$ -F -
 
 $&ID    E)JDr  c                z    SUR                   (       a  SOS< S3nU R                  U5      nU(       a  USU-  -  nU$ )Nz
GENERATED ALWAYSz
BY DEFAULTz AS IDENTITYr  )alwaysr  )r  r  r  r  r  s        r  visit_identity_column!DDLCompiler.visit_identity_column  s@     H\9
 ++H5Gg%%Dr  r  )...)
r  rk   r2  r=   r  r  r  r)  r  r  r  r  r   r  r  )r  rQ   r  r  )FT)r  rQ   r  r)  r  r   )r   zColumn[Any]r  ri  )r   zUnion[Visitable, str]r  r   )r   rR   r  r   r  r   )r   rT   r  r   r  r   )r   rP   r  r   )r   rO   r  r   )9r  r  r	  r
  r  r   r  r&   r  r  r  r?  r  rJ  rP  rY  rk  rt  rd  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rr  ra  rf  r  r  r  r  r  r	  r	  r	  r	  r	  r	  r 	  r"	  r  r	  r6	  r;	  r  r  r  r  r9  r9    s;   F FI,/03		 ,	 #C		
 &*	 .	 

 

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




B@(B
&6J;

.69	,0,
*25	"*25	
	.			
.
	

.
	
r  r9  c                  >   \ rS rSrS3S jrS4S jr      S5S jrS6S jrS7S jrS8S jr	S9S jr
S:S	 jrS;S
 jrS<S jrS=S jrS>S jrS?S jrS@S jrSAS jr        SBS jrSCS jrSDS jrSES jrSFS jrSAS jrSGS jrSHS jrSIS jrSJS jrSKS jrSGS jr      SHS jrSKS jr S?S jr!S=S  jr"S>S! jr#S;S" jr$      S:S# jr%S9S$ jr&S6S% jr'S3S& jr(S4S' jr)S7S( jr*SES) jr+SLS* jr,SAS+ jr-      SMS, jr.SNS- jr/S. r0      SOS/ jr1      SPS0 jr2S1r3g2)QGenericTypeCompileri  c                    g)NFLOATr  r  s      r  visit_FLOATGenericTypeCompiler.visit_FLOAT      r  c                    g)NDOUBLEr  r  s      r  visit_DOUBLE GenericTypeCompiler.visit_DOUBLE      r  c                    g)NzDOUBLE PRECISIONr  r  s      r  visit_DOUBLE_PRECISION*GenericTypeCompiler.visit_DOUBLE_PRECISION  s     "r  c                    g)NREALr  r  s      r  
visit_REALGenericTypeCompiler.visit_REAL  r>  r  c                    UR                   c  gUR                  c  SSUR                   0-  $ SUR                   UR                  S.-  $ )NNUMERICzNUMERIC(%(precision)s)	precisionz!NUMERIC(%(precision)s, %(scale)s)rR	  scalerS	  r  s      r  visit_NUMERIC!GenericTypeCompiler.visit_NUMERIC  M    ??"[[ +{EOO.LLL6"__:  r  c                    UR                   c  gUR                  c  SSUR                   0-  $ SUR                   UR                  S.-  $ )NDECIMALzDECIMAL(%(precision)s)rR	  z!DECIMAL(%(precision)s, %(scale)s)rS	  rS	  r  s      r  visit_DECIMAL!GenericTypeCompiler.visit_DECIMAL)  rW	  r  c                    g)NINTEGERr  r  s      r  visit_INTEGER!GenericTypeCompiler.visit_INTEGER4      r  c                    g)NSMALLINTr  r  s      r  visit_SMALLINT"GenericTypeCompiler.visit_SMALLINT7      r  c                    g)NBIGINTr  r  s      r  visit_BIGINT GenericTypeCompiler.visit_BIGINT:  rH	  r  c                    g)N	TIMESTAMPr  r  s      r  visit_TIMESTAMP#GenericTypeCompiler.visit_TIMESTAMP=  s    r  c                    g)NDATETIMEr  r  s      r  visit_DATETIME"GenericTypeCompiler.visit_DATETIME@  re	  r  c                    g)NDATEr  r  s      r  
visit_DATEGenericTypeCompiler.visit_DATEC  r>  r  c                    g)NTIMEr  r  s      r  
visit_TIMEGenericTypeCompiler.visit_TIMEF  r>  r  c                    g)NCLOBr  r  s      r  
visit_CLOBGenericTypeCompiler.visit_CLOBI  r>  r  c                    g)NNCLOBr  r  s      r  visit_NCLOBGenericTypeCompiler.visit_NCLOBL  rC	  r  c                J    UnU(       a	  USU S3-  nU(       a	  USU S3-  nU$ )NrG  rH  z
 COLLATE "r  r  )r  r   lengthr  r  s        r  _render_string_type'GenericTypeCompiler._render_string_typeO  s9     axqM!Dj1--Dr  c                P    U R                  SUR                  UR                  5      $ )NCHARr	  r	  r  r  s      r  
visit_CHARGenericTypeCompiler.visit_CHARY      ''eooNNr  c                P    U R                  SUR                  UR                  5      $ )NNCHARr	  r  s      r  visit_NCHARGenericTypeCompiler.visit_NCHAR\  s    ''uOOr  c                P    U R                  SUR                  UR                  5      $ )NVARCHARr	  r  s      r  visit_VARCHAR!GenericTypeCompiler.visit_VARCHAR_  s$    ''u||U__
 	
r  c                P    U R                  SUR                  UR                  5      $ )NNVARCHARr	  r  s      r  visit_NVARCHAR"GenericTypeCompiler.visit_NVARCHARd  s$    ''eoo
 	
r  c                P    U R                  SUR                  UR                  5      $ )NTEXTr	  r  s      r  
visit_TEXTGenericTypeCompiler.visit_TEXTi  r	  r  c                    g)NUUIDr  r  s      r  
visit_UUIDGenericTypeCompiler.visit_UUIDl  r>  r  c                    g)NBLOBr  r  s      r  
visit_BLOBGenericTypeCompiler.visit_BLOBo  r>  r  c                ^    SUR                   =(       a    SUR                   -  =(       d    S-   $ )NBINARY(%d)r  r	  r  s      r  visit_BINARY GenericTypeCompiler.visit_BINARYr  s$    5<<AFU\\,AGRHHr  c                ^    SUR                   =(       a    SUR                   -  =(       d    S-   $ )N	VARBINARYr	  r  r	  r  s      r  visit_VARBINARY#GenericTypeCompiler.visit_VARBINARYu  s$    ellDv/DJKKr  c                    g)NBOOLEANr  r  s      r  visit_BOOLEAN!GenericTypeCompiler.visit_BOOLEANx  r`	  r  c                    UR                   (       a  U R                  R                  (       d  U R                  SSS S9$ U R                  " U40 UD6$ )Nr	      )r	  r  )native_uuidr  supports_native_uuidr	  r	  r  s      r  
visit_uuidGenericTypeCompiler.visit_uuid{  sC      (I(I++F2+NN??5/B//r  c                (    U R                   " U40 UD6$ r  )r	  r  s      r  visit_large_binary&GenericTypeCompiler.visit_large_binary       u+++r  c                (    U R                   " U40 UD6$ r  )r	  r  s      r  visit_boolean!GenericTypeCompiler.visit_boolean      !!%.2..r  c                (    U R                   " U40 UD6$ r  )rx	  r  s      r  
visit_timeGenericTypeCompiler.visit_time      u+++r  c                (    U R                   " U40 UD6$ r  )rp	  r  s      r  visit_datetime"GenericTypeCompiler.visit_datetime  s    ""5/B//r  c                (    U R                   " U40 UD6$ r  )rt	  r  s      r  
visit_dateGenericTypeCompiler.visit_date  r	  r  c                (    U R                   " U40 UD6$ r  )rh	  r  s      r  visit_big_integer%GenericTypeCompiler.visit_big_integer        -"--r  c                (    U R                   " U40 UD6$ r  )rc	  r  s      r  visit_small_integer'GenericTypeCompiler.visit_small_integer  s     ""5/B//r  c                (    U R                   " U40 UD6$ r  )r^	  r  s      r  visit_integer!GenericTypeCompiler.visit_integer  r	  r  c                (    U R                   " U40 UD6$ r  )rN	  r  s      r  
visit_realGenericTypeCompiler.visit_real  r	  r  c                (    U R                   " U40 UD6$ r  )rA	  r  s      r  visit_floatGenericTypeCompiler.visit_float  s    ,,,r  c                (    U R                   " U40 UD6$ r  )rF	  r  s      r  visit_double GenericTypeCompiler.visit_double  r	  r  c                (    U R                   " U40 UD6$ r  )rU	  r  s      r  visit_numeric!GenericTypeCompiler.visit_numeric  r	  r  c                (    U R                   " U40 UD6$ r  r	  r  s      r  visit_string GenericTypeCompiler.visit_string  r	  r  c                (    U R                   " U40 UD6$ r  r	  r  s      r  visit_unicode!GenericTypeCompiler.visit_unicode  r	  r  c                (    U R                   " U40 UD6$ r  r	  r  s      r  
visit_textGenericTypeCompiler.visit_text  r	  r  c                (    U R                   " U40 UD6$ r  r	  r  s      r  visit_unicode_text&GenericTypeCompiler.visit_unicode_text  r	  r  c                (    U R                   " U40 UD6$ r  r	  r  s      r  
visit_enumGenericTypeCompiler.visit_enum  r	  r  c                4    [         R                  " SU-  5      e)NzKCan't generate DDL for %r; did you forget to specify a type on this Column?r  r  s      r  r<  GenericTypeCompiler.visit_null  s"    #%*+
 	
r  c                Z    U R                   " UR                  U R                  5      40 UD6$ r  )r  type_enginer  r  s      r  visit_type_decorator(GenericTypeCompiler.visit_type_decorator  s'     ||E--dll;BrBBr  c                &    UR                   " S0 UD6$ r  )get_col_specr  s      r  visit_user_defined&GenericTypeCompiler.visit_user_defined  s     !!'B''r  r  N)r  zsqltypes.Float[Any]r  r   r  r   )r  zsqltypes.Double[Any]r  r   r  r   )r  zsqltypes.DOUBLE_PRECISION[Any]r  r   r  r   )r  zsqltypes.REAL[Any]r  r   r  r   )r  zsqltypes.Numeric[Any]r  r   r  r   )r  zsqltypes.DECIMAL[Any]r  r   r  r   )r  zsqltypes.Integerr  r   r  r   )r  zsqltypes.SmallIntegerr  r   r  r   )r  zsqltypes.BigIntegerr  r   r  r   )r  zsqltypes.TIMESTAMPr  r   r  r   )r  zsqltypes.DateTimer  r   r  r   )r  zsqltypes.Dater  r   r  r   )r  zsqltypes.Timer  r   r  r   )r  zsqltypes.CLOBr  r   r  r   )r  zsqltypes.Textr  r   r  r   )r   r   r	  r  r  ri  r  r   )r  zsqltypes.CHARr  r   r  r   )r  zsqltypes.NCHARr  r   r  r   )r  zsqltypes.Stringr  r   r  r   )r  zsqltypes.NVARCHARr  r   r  r   )r  zsqltypes.Uuid[Any]r  r   r  r   )r  zsqltypes.LargeBinaryr  r   r  r   )r  zsqltypes.BINARYr  r   r  r   )r  zsqltypes.VARBINARYr  r   r  r   )r  zsqltypes.Booleanr  r   r  r   )r  zsqltypes.Unicoder  r   r  r   )r  zsqltypes.UnicodeTextr  r   r  r   )r  zsqltypes.Enumr  r   r  r   )r  zTypeDecorator[Any]r  r   r  r   )r  zUserDefinedType[Any]r  r   r  r   )4r  r  r	  r
  rA	  rF	  rJ	  rN	  rU	  rZ	  r^	  rc	  rh	  rl	  rp	  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>	    s   "3";>"	"
		!.;H	OP



OIL0,),14,	,
/,0,.0*0250	0
/,-.///,,),14,	,
/
C'C/2C	C
()(14(	(r  r>	  c                  2    \ rS rSrS rS rS rS rS rSr	g)	StrSQLTypeCompileri  c                t     UR                   nU" U 40 UD6$ ! [         a    U R                  " U40 UD6s $ f = fr  )r  AttributeError_visit_unknown)r  r  r  r  s       r  r  StrSQLTypeCompiler.process  sL    	2!&!9!9 &d1b11  	4&&u333	4s    77c                \    UR                  S5      (       a  U R                  $ [        U5      e)Nr  )r  r	  r	  )r  r=  s     r  __getattr__StrSQLTypeCompiler.__getattr__  s(    >>(##&&& %%r  c                    UR                   R                  UR                   R                  R                  5       :X  a  UR                   R                  $ [        U5      $ r  )r  r  upperreprr  s      r  r	  !StrSQLTypeCompiler._visit_unknown  sA    ??##u'?'?'E'E'GG??+++;r  c                    gr9  r  r  s      r  r<  StrSQLTypeCompiler.visit_null  r>  r  c                b     UR                   nU" S0 UD6$ ! [         a    [        U5      s $ f = fr  )r	  r	  r
  )r  r  r  r	  s       r  r	  %StrSQLTypeCompiler.visit_user_defined  s=    	& --L  %"%%  	;	s    ..r  N)
r  r  r	  r
  r  r
  r	  r<  r	  r  r  r  r  r	  r	    s    2&&r  r	  c                      \ rS rSrSS jrSrg)_SchemaForObjectCallablei  c                    g r  r  )r  _SchemaForObjectCallable__objs     r  r  !_SchemaForObjectCallable.__call__  s    3r  r  N)r
  r   r  r   r  r  r  r  r
  r
    s    .r  r
  c                      \ rS rSrSS jrSrg)rh  i  c                    g r  r  )r  r  s     r  r   _BindNameForColProtocol.__call__  s    sr  r  N)r  r  r  r   r  r  r  r  rh  rh    s    :r  rh  c                     \ rS rSr% Sr\r\r\	r
S\S'   S\S'   S\S'   \R                  " S5      rS	\S
'    SrS\S'        S-           S.S jjrS r      S/S jrS0S jrS0S jrS rS0S jrS1S jrS rS2S3S jjrS2S4S jjrS r S5     S6S jjr S2     S7S jjr S2     S8S jjrS2S jr\ RB                  " S5       S5     S9S  jj5       r" S5     S:S! jjr# S5     S:S" jjr$        S;S# jr%S<S$ jr&  S=       S>S% jjr'S& r( S2S' jr)     S?             S@S( jjr*S5S) jr+\ RX                  S* 5       r-SAS+ jr.S,r/g)Br  i  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_translateNc                    Xl         X l        U=(       d    U R                  U l        X@l        U R                  S-  U l        X`l        XPl        0 U l        U R                   R                  S;   U l	        g)a+  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.
r1   )r   r   N)
r  r
  r
  escape_quoteescape_to_quoteomit_schemaquote_case_sensitive_collationsr
  r  r  )r  r  r
  r
  r
  r
  r
  s          r  r  IdentifierPreparer.__init__  sj    . *&<$*<*<(#0014&/N, $ 7 7 <
 !
r  c                   ^ U R                   R                  U R                   5      nUR                  R                  U R                  5        S U;   mU4S jnX2l        TUl        U$ )Nc                   > U R                   nU R                  (       aH  Uc  T(       a>  Ub%  SU;   d  SU;   a  [        R                  " SU-  5      e[	        SU=(       d    S-  SS9$ U R                   $ )NrK  rL  zJSquare bracket characters ([]) not supported in schema translate name '%s'z__[SCHEMA_%s]_noneFr  )r#   _use_schema_mapr2   r  r.   )r  r   includes_nones     r  symbol_getter@IdentifierPreparer._with_schema_translate.<locals>.symbol_getter;  sw    ::D""(8M#t**8:>?  ##tw7u  zz!r  )r  __new__r  r  r  r
  )r  r  prepr%
  r$
  s       @r  r  )IdentifierPreparer._with_schema_translate5  sV    ~~%%dnn5T]]+ 44	" "//<,r  c                   ^ ^ UmS T;   a/  T R                   (       d  [        R                  " S5      eTS    TS'   UU 4S jn[        R                  " SX15      $ )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                  > U R                  S5      nUT;   a  TU   nOUS;   a  [        R                  " S5      eUnU(       d3  TR                  R                  nU(       d  [        R
                  " S5      eTR                  U5      $ )Nr1   )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   r2   r@  r  default_schema_namer  r  )r  r   r  dr  s      r  r  =IdentifierPreparer._render_schema_translates.<locals>.replace]  s    771:Dqy#$T7 ?*11=  $( ##'<<#C#C '**=  $$%566r  z(__\[SCHEMA_([^\]]+)\]))r
  r2   r@  r  r  )r  r2  r  r  r-
  s   `   @r  r  ,IdentifierPreparer._render_schema_translatesM  sZ     !1977--9  4AgJ	72 vv0'EEr  c                    UR                  U R                  U R                  5      nU R                  (       a  UR                  SS5      nU$ )zhEscape an identifier.

Subclasses should override this to provide database-dependent
escaping behavior.
rF  r  )r  r
  r
  r  r  r  s     r  _escape_identifier%IdentifierPreparer._escape_identifierx  s>     d//1E1EF  MM#t,Er  c                N    UR                  U R                  U R                  5      $ )zCanonicalize an escaped identifier.

Subclasses should override this to provide database-dependent
unescaping behavior that reverses _escape_identifier.
)r  r
  r
  r1
  s     r  _unescape_identifier'IdentifierPreparer._unescape_identifier  s!     }}T1143D3DEEr  c                    Ub?  UR                  U5      (       d)  [        R                  " SU< SUR                  < S35      eU$ )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

zUnexpected SQL phrase: z (matching against rH  )r  r2   r  r  )r  r  r  s      r  r&	  &IdentifierPreparer.validate_sql_phrase  s@     syy'9'9""CKK)  r  c                X    U R                   U R                  U5      -   U R                  -   $ )zfQuote an identifier.

Subclasses should override this to provide database-dependent
quoting behavior.
)r
  r2
  r
  r1
  s     r  quote_identifier#IdentifierPreparer.quote_identifier  s3     %%e,-	
r  c                    UR                  5       nX R                  ;   =(       dM    US   U R                  ;   =(       d4    U R                  R	                  [        U5      5      (       + =(       d    X!:g  $ )z5Return True if the given identifier requires quoting.r   )r  reserved_wordsillegal_initial_characterslegal_charactersr  r   )r  r  lc_values      r  r%  #IdentifierPreparer._requires_quotes  sb    ;;=+++ #Qx4:::#((..s5z::# !		
r  c                T    U R                   R                  [        U5      5      (       + $ )zbReturn True if the given identifier requires quoting, but
not taking case convention into account.)r?
  r  r   r1
  s     r  r  1IdentifierPreparer._requires_quotes_illegal_chars  s"     ((..s5z:::r  c                T    Ub  [         R                  " SSS9  U R                  U5      $ )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`.

zThe IdentifierPreparer.quote_schema.force parameter is deprecated and will be removed in a future release.  This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().0.9r  )r&   r  r  )r  r#   forces      r  r  IdentifierPreparer.quote_schema  s5    .    !  zz&!!r  c                f   Ub  [         R                  " SSS9  [        USS5      nUcp  XR                  ;   a  U R                  U   $ U R	                  U5      (       a  U R                  U5      U R                  U'   OXR                  U'   U R                  U   $ U(       a  U R                  U5      $ U$ )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().rE
  r  r  )r&   r  r  r
  r%  r:
  )r  r  rF
  s      r  r  IdentifierPreparer.quote  s    ,    !  w-=%}}U++((//+/+@+@+GDMM%(+0MM%(}}U++((//Lr  c                J    U R                   (       a  U R                  U5      $ U$ r  )r
  r  )r  collation_names     r  r  #IdentifierPreparer.format_collation  s     //::n--!!r  c                    U R                  UR                  5      nU R                  U5      nU R                  (       d!  U(       a  Ub  U R	                  U5      S-   U-   nU$ r  )r  r   r  r
  r  )r  r  r  r   r  s        r  r  "IdentifierPreparer.format_sequence  s[     zz(--(11(;    ,$$%56<tCDr  c                J    U R                  U=(       d    UR                  5      $ r  r  r   )r  r  r   s      r  r  IdentifierPreparer.format_label+  s     zz$,%**--r  c                j    Uc   Uc   eU R                  UR                  5      $ U R                  U5      $ r  rP
  )r  r  r   s      r  r   IdentifierPreparer.format_alias0  s7     <$$$::ejj))::d##r  c                ~    U=(       d    UR                   nU R                  U5      (       a  U R                  U5      nU$ r  )r  r%  r:
  )r  	savepointr   r  s       r  r  #IdentifierPreparer.format_savepoint9  s8     '	  ''))%0Er  zsqlalchemy.sql.namingc                   [         R                  R                  nUR                  [        L a   UR                  XR                  5      nUc  g OUR                  nUc   eUR                  S:X  a  U R                  XBS9$ U R                  XBS9$ )Nr  )_alembic_quote)
r&   rb  
sql_namingr   r+   _constraint_name_for_tabler   r.  truncate_and_render_index_name#truncate_and_render_constraint_name)r  r   rX
  namingr   s        r  r  $IdentifierPreparer.format_constraintB  s     **??j(44,,D |  ??D$$/66 7   ;; <  r  c                    U R                   R                  =(       d    U R                   R                  nU R                  XU5      $ r  )r  max_index_name_lengthr   _truncate_and_render_maxlen_namer  r   rX
  max_s       r  r[
  1IdentifierPreparer.truncate_and_render_index_name\  sB     LL.. 2||11 	 44
 	
r  c                    U R                   R                  =(       d    U R                   R                  nU R                  XU5      $ r  )r  max_constraint_name_lengthr  ra
  rb
  s       r  r\
  6IdentifierPreparer.truncate_and_render_constraint_namej  sB     LL33 2||11 	 44
 	
r  c                   [        U[        R                  5      (       a5  [        U5      U:  a%  USUS-
   S-   [        R
                  " U5      SS  -   nOU R                  R                  U5        U(       d  U$ U R                  U5      $ )Nr   ri  rE  )	r  r   rC   r  r&   md5_hexr  validate_identifierr  )r  r   rc
  rX
  s       r  ra
  3IdentifierPreparer._truncate_and_render_maxlen_namex  sw     dH55664y4Aq)C/$,,t2DRS2IILL,,T2K::d##r  c                2    U R                  U5      nUc   eU$ r  )r  )r  r  r   s      r  r  IdentifierPreparer.format_index  s#    %%e,r  c                   Uc.  [         (       a  [        U[        5      (       d   eUR                  nU R	                  U5      nU R                  U5      nU R                  (       d%  U(       a  U(       a  U R                  U5      S-   U-   nU$ )z'Prepare a quoted table and schema name.rJ  )r   r  rZ   r   r  r  r
  r  )r  r   r  r   r  r  s         r  r  IdentifierPreparer.format_table  sw     <}!%9999::DD!11%8J3C&&'783>GFr  c                $    U R                  U5      $ )zPrepare a quoted schema name.r"
  r  s     r  rO   IdentifierPreparer.format_schema  s     zz$r  c                    Ub0  [        U[        R                  5      (       a  UR                  U5      nU R	                  U5      $ )Prepare a quoted column name.)r  r   rC   r  r  )r  r   r  s      r  r  $IdentifierPreparer.format_label_name  s@     J(++%
 %
 >>(+Dzz$r  c                   Uc  UR                   nUc   eUb0  [        U[        R                  5      (       a  UR	                  U5      n[        USS5      (       dG  U(       a/  U R                  UR                  XTS9S-   U R                  U5      -   $ U R                  U5      $ U(       a   U R                  UR                  XTS9S-   U-   $ U$ )rt
  r  F)r  r   rJ  )	r   r  r   rC   r  r  r  r   r  )r  r   r  r   
table_namer  r  s          r  r   IdentifierPreparer.format_column  s     <;;D###J(++%
 %
 >>(+Dv|U33%% &   jj&	' zz$''
 %% &   	 r  c                    U R                  U5      nU R                  (       d/  U(       a(  U(       a!  U R                  U5      U R                  USS94$ U R                  USS94$ )z(Format table name and schema as a tuple.Fr  )r  r
  r  r  )r  r   r  r  s       r  rF  #IdentifierPreparer.format_table_seq  sj      11%8J3C!!"23!!%E!: 
 %%e%>@@r  c                    S U R                   U R                  U R                  U R                  5      4 5       u  pn[        R                  " SXUS.-  5      nU$ )Nc              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr  )r  r  rK  s     r  r>  4IdentifierPreparer._r_identifiers.<locals>.<genexpr>  s%      )
 IIaLLs   #%zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)initialfinalrs  )r
  r
  r2
  r  r  )r  r~
  r
  escaped_finalrs        r  _r_identifiers!IdentifierPreparer._r_identifiers  sl    )
 ""  ''(8(89)
% JJ$ "mLM
 r  c                    U R                   nUR                  U5       VVs/ s H  u  p4U=(       d    UPM     snn Vs/ s H  nU R                  U5      PM     sn$ s  snnf s  snf )z:Unpack 'schema.table.column'-like strings into components.)r
  findallr5
  )r  identifiersr
  ar  r2  s         r  unformat_identifiers'IdentifierPreparer.unformat_identifiers  sf      *+;)?@)?af1f)?@
@ %%a(@
 	
@
s
   AA")	r  r
  r  r
  r
  r
  r
  r
  r
  )r  Nr  TF)r  rk   r
  r   r
  ri  r
  r   r
  r)  r
  r)  )r2  r   r  rl   r  r   )r  r   r  r   )r  r   r  r)  r  )r#   r   rF
  r   r  r   )r  r   rF
  r   r  r   )T)r  zschema.Sequencer  r)  r  r   )r  z
Label[Any]r   ri  r  r   )r  zOptional[AliasedReturnsRows]r   ri  r  r   )r   zUnion[Constraint, Index]rX
  r)  r  ri  )r   r   rX
  r)  r  r   )r   r   rc
  rO  rX
  r)  r  r   )r  rQ   r  r   )TN)r   rY   r  r)  r   ri  r  r   )FNNFN)r   zColumnElement[Any]r  r)  r   ri  rw
  ri  r  r)  r  zOptional[Mapping[str, Any]]r  r   )r
  r   r  zSequence[str])0r  r  r	  r
  r  RESERVED_WORDSr=
  LEGAL_CHARACTERSr?
  ILLEGAL_INITIAL_CHARACTERSr>
  r  r  
attrgetterr  r
  r  r  r  r2
  r5
  r&	  r:
  r%  r  r  r  r  r  r  r   r  r&   r  r  r[
  r\
  ra
  r  r  rO  r  r  rF  r  r
  r
  r  r  r  r  r  r    s   J#N'!;&&2:2E2Eh2O/O -2#T1
 !%)04!"
"
 "
 #	"

 "
 *."
 "
H0)F)F4J)F	)FV
F$

;
%"N2h" =A'59	  8<..'4.	. JN$1$9F$	$ 
01KO2DH	 24 15

)-
	
 15

)-
	
$$"$48$	$  "	  	
 
(   "  "$( 04,", , 	,
 ", , ., 
,\A" 
 "
r  r  )r  
__future__r   r  collections.abcabcr/  r  enumr   rS  r  r  r  timer   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  _typingr'   r(   r)   r*   r+   r,   r-   r.   r/   visitorsr0   r2   r3   util.typingr4   r5   r6   r7   
annotationr8   r9   r:   r;   r  r<   rG  r=   dmlr>   r?   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]   type_apir^   r_   r`   ra   rb   engine.cursorrc   engine.interfacesrd   re   rf   rg   rh   ri   rj   rk   rl   r   _FromHintsTyper
  r  Ir
  LEGAL_CHARACTERS_PLUS_SPACErW  r   r
  r'	  r,	  r/	  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  r  r  r  r  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  r  _CompoundSelectKeywordr   	UNION_ALLr   
EXCEPT_ALLr   INTERSECT_ALLr  r   r  r  r  r  r   r"  r'  r1  rJ  rZ  rg  ru  rz  rA  r{  r|  r}  r~  
namedtupler  r  EnsureKWArgr  BinaryElementRoleCompilerColumnElementr  r1  r  r  r9  r>	  r	  r
  rh  r  )r{  s   0r  <module>r
     s%  " #  )      	             !                       &     2  !  %    ! "  #	+," #)#**''&' #",,(1./&+'"','$)#4<:<=3=C+: lC'(_B ::.5  jj):BDDA .3Arl;lc!fl;AA3%H zz<bdd zz<bdd zz5rtt<jjA2::N**92::F$ "$.NNG. MM6. MM5	.
 MM5. MM5. MM5. MM3. LL%. LL&. LL&. LL%. LL&. LL%.  4.  ""$<!." #.$ 	%.& M'.( OOV).* +., -.. OOX/.0 MM61.2 MM63.4 j5.6 {7.: i;.< ;=.> MM6?.@ fA.B fC.F wG.H fI.J nK.L ]eUec[.	b 
NN!4N.hyNNNFNNFh_-	) & ""$(& %%++W%%//%%,,h%%00,%%//%%33_  >   ! *   
J  i $1 $:J :zt
 tnZ 2!; !$G  g . FKF B
&l
?#''w6HI ?#DI' I'XF4## F0	C ("@"@2#
	C ("@"@#
LSU
( SU
ljl
[ l
^m( m`z(, z(z&, &B/x /;h ;U
 U
_ <s   c+