Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/__pycache__/compiler.cpython-312.pyc
�

���g}4���UdZddlmZddlZddlmZddlZddlm	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*dd l&m+Z+dd!l&m,Z,dd"l&m-Z-dd#l&m.Z.dd$l&m/Z/dd%l&m0Z0dd&l&m1Z2dd'l3m4Z4dd(l3m5Z5dd)l'm6Z6dd*l'm7Z7dd+l'm8Z8dd,l'm9Z9dd-l'm:Z:dd.l'm;Z;dd/l*m<Z<dd0l*m=Z=dd1l.m>Z>dd2l0m?Z?dd3l@mAZAdd4lBmCZCdd5lBmDZDd6d7l&mEZEd6d&l&m1Z1d6d8l1mFZFd6d9lGmHZHd6d:lGmIZId6d;lGmJZJejHr�dd<lKmLZLdd=l'mMZMdd>l'mNZNdd?lOmPZPdd@lQmRZRddAlSmTZTddBlSmUZUddClSmVZVddDl*mWZWddEl*mXZXddFl*mYZYddGl*mZZZddHl*m[Z[ddIl+m\Z\ddJl.m]Z]ddKl/m^Z^ddLl/m_Z_ddMl/m`Z`ddNl/maZaddOl/mbZbddPl/mcZcddQl/mdZdddRl/meZeddSl@mfZfd6dTlgmhZhd6dUlimjZjd6dVlimkZkd6dWlimlZld6dXlimmZmd6dYlimnZnd6dZlimoZod6d[limpZpd6d\limqZqd6d]limrZred^esfZthd_�Zue
j�d`e
j��Zxe
j�dae
j��Zyezddb�D�chc]
}es|���c}j�dcg�Z|e
j�dde
j��Z}e
j�dde
j��Z~e
j�dee
j��Ze
j�dfe
�j�Z�e
j�dge
�j�Z�dhZ�e�didjdkdldmdn�Z�ie,�j
do�e,�jdp�e,�jdq�e,�jdr�e,�jds�e,�jdt�e,�jdu�e,�jdv�e,�jdw�e,�jdx�e,�jdy�e,�j dz�e,�j"d{�e,�j$d|�e,�j&d}�e,�j(d~�e,�j*d�ie,�j,d��e,�j.d��e,�j0d��e,�j2d��e,�j4d��e,�j6d��e,�j8d��e,�j:d��e,�j<d��e,�j>d��e,�j@d��e,�jBd��e,�jDd��e,�jFd��e,�jHd��e,�jJd��e,�jLd���e,�jNd�e,�jPd�e,�jRd�e,�jTd�e,�jVd�e,�jXd�e,�jZd�i�Z�e+�j^d�e+�j`d�e+�jbd�e+�jdd�e+�jfd�e+�jhd�e+�jjd�e+�jld�e+�jnd�e+�jpd�e+�jrd�e+�jtd�e+�jvd�e+�jxd�iZ�d�e�d�<d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��Z�e/�j��j�d�e/�j��j�d�e/�j��j�d�e/�j��j�d�e/�j��j�d�e/�j��j�d�iZ�Gd��d�e�Z�Gd��d�eI�Z�dZ�d�e�d�<dZ�d�e�d�<d6Z�d�e�d�<d�Z�d�e�d�<Gd˄d�eJ�Z�Gd̈́d�e�dϬЫZ�Gdфd�e�Z�Gdӄd�e�Z�GdՄd�e�Z�Gdׄd�eF�Z�Gdلd�e	�Z�Gdۄd�e	�Z�e�eի\Z�Z�Z�Z�Gd݄d�e�j�d�d�d�g��Z�Gd�d�Z�Gd�d�e1�j��Z�Gd�d�e-�j�ee*�j��Z�Gd�d�e-�j�ee*�j��Z�Gd�d�eݫZ�Gd�d�e�Z�Gd�d�eݫZ�Gd�d�e߫Z�Gd�d�e�Z�Gd�d�eI�Z�Gd��d�eI�Z�Gd��d��Z�ycc}w)�a]Base SQL and DDL compiler implementations.

Classes provided include:

:class:`.compiler.SQLCompiler` - renders SQL
strings

:class:`.compiler.DDLCompiler` - renders DDL
(data definition language) strings

:class:`.compiler.GenericTypeCompiler` - renders
type specification strings.

To generate user-defined SQL strings, see
:doc:`/ext/compiler`.

�)�annotationsN)�IntEnum)�perf_counter)�Any)�Callable)�cast)�ClassVar)�Dict)�	FrozenSet)�Iterable)�Iterator)�List)�Mapping)�MutableMapping)�
NamedTuple)�NoReturn)�Optional)�Pattern)�Sequence)�Set)�Tuple)�Type)�
TYPE_CHECKING)�Union�)�base)�	coercions)�crud)�elements)�	functions)�	operators)�roles)�schema)�
selectable)�sqltypes)�util)�is_column_element)�is_dml)�	_de_clone)�
_from_objects)�
_NONE_NAME)� _SentinelDefaultCharacterization)�
Executable)�NO_ARG)�
ClauseElement)�quoted_name)�Column)�	TupleType)�
TypeEngine)�prefix_anon_map)�	Visitable�)�exc)�FastIntFlag)�Literal)�Protocol)�	TypedDict)�_AnnotationDict)�_AmbiguousTableNameMap)�CompileState)�CacheKey)�ExecutableDDLElement)�Insert)�
UpdateBase)�
ValuesBase)�_truncated_label)�
BindParameter)�ColumnClause)�
ColumnElement)�Label)�Function)�Table)�AliasedReturnsRows)�CompoundSelectState)�CTE)�
FromClause)�NamedFromClause)�ReturnsRows)�Select)�SelectState)�_BindProcessorType)�CursorResultMetaData)�_CoreSingleExecuteParams)�_DBAPIAnyExecuteParams)�_DBAPIMultiExecuteParams)�_DBAPISingleExecuteParams)�_ExecuteOptions)�_GenericSetInputSizesType)�_MutableCoreSingleExecuteParams)�Dialect)�SchemaTranslateMapTyperN>^�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 zEXISTS �	DISTINCT zNOT zANY zALL 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 SETSzDict[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�@�eZdZUdZded<	ded<	ded<	ded<y	)
�ResultColumnsEntryaTracks a column expression that is expected to be represented
    in the result rows for this statement.

    This normally refers to the columns clause of a SELECT statement
    but may also refer to a RETURNING clause, as well as for dialect-specific
    emulations.

    �str�keyname�name�Tuple[Any, ...]�objects�TypeEngine[Any]�typeN��__name__�
__module__�__qualname__�__doc__�__annotations__���H/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/compiler.pyr�r�[s1����L�;�

�I�%�
�����r�r�c�(�eZdZ										dd�Zy)�_ResultMapAppenderc��y�Nr���selfr�r�r��type_s     r��__call__z_ResultMapAppender.__call__{s��r�N)
r�r�r�r�r�z
Sequence[Any]rr��return�None�r�r�r�rr�r�r�rrzs7��������	�
��
�
r�rz
Literal[0]�RM_RENDERED_NAMEz
Literal[1]�RM_NAMEz
Literal[2]�
RM_OBJECTS�z
Literal[3]�RM_TYPEc�,�eZdZUded<ded<ded<y)�_BaseCompilerStackEntryzSet[FromClause]�asfrom_froms�correlate_fromsrPr$N�r�r�r�r�r�r�r�rr�s��!�!�$�$��r�rc�@�eZdZUded<ded<ded<ded<ded	<y
)�_CompilerStackEntryr>�
compile_state�bool�need_result_map_for_nested�need_result_map_for_compoundrP�select_0�Select[Any]�insert_from_selectNrr�r�r�rr�s ���� $�$�"&�&���#�#r�rF)�totalc�r�eZdZUdZded<	ded<	ded<	ded	<	d
ed<	edd��Zedd
��Zy)�
ExpandedStatea�represents state to use when producing "expanded" and
    "post compile" bound parameters for a statement.

    "expanded" parameters are parameters that are generated at
    statement execution time to suit a number of parameters passed, the most
    prominent example being the individual elements inside of an IN expression.

    "post compile" parameters are parameters where the SQL literal value
    will be rendered into the SQL statement at execution time, rather than
    being passed as separate parameters to the driver.

    To create an :class:`.ExpandedState` instance, use the
    :meth:`.SQLCompiler.construct_expanded_state` method on any
    :class:`.SQLCompiler` instance.

    r��	statementrU�
parameters�%Mapping[str, _BindProcessorType[Any]]�
processors�Optional[Sequence[str]]�positiontupzMapping[str, List[str]]�parameter_expansionc����j�tjd��t�fd��jD��S)zrTuple of positional parameters, for statements that were compiled
        using a positional paramstyle.

        z.statement does not use a positional paramstylec3�<�K�|]}�j|���y�wr�r!)�.0�keyrs  �r��	<genexpr>z6ExpandedState.positional_parameters.<locals>.<genexpr>�s�����F�5E�c�T�_�_�S�)�5E�s�)r%r7�InvalidRequestError�tuple�rs`r��positional_parametersz#ExpandedState.positional_parameters�s@������#��)�)�@��
��F�T�5E�5E�F�F�Fr�c��|jS)z.synonym for :attr:`.ExpandedState.parameters`.r)r/s r��additional_parametersz#ExpandedState.additional_parameters�s�����r�N)rr�)rrU)r�r�r�r�r��propertyr0r2r�r�r�rr�si���"�N�=�(�(��6�5�+�(�(��1�0���	G��	G����r�rc��eZdZUdZded<	ded<	ded<	ded	<	d
Zded<	d
Zded<	d
Zded<	dZded<	d
Z	ded<	d
Z
ded<	d
Zded<y
)�_InsertManyValuesarepresents state to use for executing an "insertmanyvalues" statement.

    The primary consumers of this object are the
    :meth:`.SQLCompiler._deliver_insertmanyvalues_batches` and
    :meth:`.DefaultDialect._deliver_insertmanyvalues_batches` methods.

    .. versionadded:: 2.0

    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_columnsr$�sentinel_param_keys�implicit_sentinel�embed_values_counter)r�r�r�r�r�r<r=r?r@rArBrCr�r�r�r5r5�s�������
���8�7�M�#&�&�
�%*��T�)��',��t�+��9=��5�<��!"��#�!��48��0�7�� $��t�#�	�"'��$�&�	r�r5c�v�eZdZUdZded<ded<ded<ded	<d
ed<ded
<ded<ded<ded<ded<y)�_InsertManyValuesBatchasrepresents an individual batch SQL statement for insertmanyvalues.

    This is passed through the
    :meth:`.SQLCompiler._deliver_insertmanyvalues_batches` and
    :meth:`.DefaultDialect._deliver_insertmanyvalues_batches` methods out
    to the :class:`.Connection` within the
    :meth:`.Connection._exec_insertmany_context` method.

    .. versionadded:: 2.0.10

    r��replaced_statementrV�replaced_parameters�#Optional[_GenericSetInputSizesType]�processed_setinputsizesz#Sequence[_DBAPISingleExecuteParams]�batchzSequence[Tuple[Any, ...]]�sentinel_valuesr:�current_batch_size�batchnum�
total_batchesr�rows_sorted�
is_downgradedNr�r�r�r�rErENsD��
���/�/�@�@�.�.�.�.����M������r�rEc�B�eZdZdZdZdZdZdZeezezZeezZ	dZ
dZy)	�InsertmanyvaluesSentinelOptszcbitflag enum indicating styles of PK defaults
    which can work as implicit sentinel columns

    rr6����@N)r�r�r�r��
NOT_SUPPORTED�
AUTOINCREMENT�IDENTITY�SEQUENCE�ANY_AUTOINCREMENT�_SUPPORTED_OR_NOT�USE_INSERT_FROM_SELECT�RENDER_SELECT_COL_CASTSr�r�r�rRrRgsE���
�M��M��H��H�%��0�8�;��%�(9�9���� �r�rRc��eZdZdZ	dZ	dZy)�
CompilerStaterrr6N)r�r�r��	COMPILING�STRING_APPLIED�NO_STATEMENTr�r�r�r`r`ys ���I�=��N���L�r�r`c�,�eZdZdZdZ	dZ	dZ	eezZy)�Lintingz�represent preferences for the 'SQL linting' feature.

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

    rrr6N)r�r�r�r��
NO_LINTING�COLLECT_CARTESIAN_PRODUCTS�WARN_LINTING�FROM_LINTINGr�r�r�rere�s5����J��!"����L�2�-��<�L�r�rec� �eZdZdZdd�Zdd�Zy)�
FromLinterzKrepresents current state for the "cartesian product" detection
    feature.Nc���	�|j}|syt|j�}t|�}|�|}|j|�n|j	�}tj|g�}|rg|re|j��	|j�	�|D�chc]	}�	|vs�|��}}|j�	fd�|D��|j|�|r|r�e|r||fSycc}w)N�NNc3�H�K�|]}||j�����y�wr)�index)r*�edge�nodes  �r�r,z"FromLinter.lint.<locals>.<genexpr>�s#�����N�I�D�T�d�j�j��&6�"6�7�I���")�fromsro�edges�remove�pop�collections�deque�popleft�discard�
extendleft�difference_update)
r�startrsrt�the_rest�
start_with�stackrp�	to_removerqs
         @r��lintzFromLinter.lint�s�����
�
�����D�J�J����u�:�����J��O�O�J�'�!����J��!�!�:�,�/�����=�=�?�D����T�"�+0�@�%�$�4�4�<��%�I�@�
���N�I�N�N��#�#�I�.��� ��Z�'�'���As�	C� Cc�����j�\}}|rX|}|rSd}dj�fd�|D��}|j||�j|��}t	j
|�yyy)Nz�{stmt_type} statement has a cartesian product between FROM element(s) {froms} and FROM element "{start}".  Apply join condition(s) between each element to resolve.r�c3�D�K�|]}d�j|�d����y�w)�"N)rs)r*�from_rs  �r�r,z"FromLinter.warn.<locals>.<genexpr>�s(�����&�:?��a��
�
�5�)�*�!�,�%��� )�	stmt_typersr})r�rwr�rsr&�warn)rr�r~rrs�template�	froms_str�messages`       r�r�zFromLinter.warn�s����#�y�y�{���*���E��7��!�I�I�&�:?�&��	�#�/�/�'�#��*�*�Z�0�*����	�	�'�"�!�r�r)�SELECT)r�r�r�r�r�r�r�r�r�rkrk�s���#�J#r�rkrsrtc���eZdZUdZdZded<	dZded<	ded	<	d
Zd
ZdZ	ded<dZ
d
ed<dZded<ejZded<	ded<ejZded<dZded<	dZded<	dZded<	ded<	dd
ej&�f									d(d�Zd)�fd�Zed ��Zd!�Zd"�Zed#��Zd*d$�Zd+d%�Z			d,							d-d&�Zed'��Z�xZ S).�CompiledaRepresent a compiled SQL or DDL expression.

    The ``__str__`` method of the ``Compiled`` object should produce
    the actual text of the statement.  ``Compiled`` objects are
    specific to their underlying database dialect, and also may
    or may not be specific to the columns referenced within a
    particular set of bind parameters.  In no case should the
    ``Compiled`` object be dependent on the actual values of those
    bind parameters, even though it may reference those values as
    defaults.
    N�Optional[ClauseElement]r �r��stringr`�stateFzOptional[CursorResultMetaData]�_cached_metadataz"Optional[List[ResultColumnsEntry]]�_result_columns� Optional[SchemaTranslateMapType]�schema_translate_maprY�execution_options�IdentifierPreparer�preparerr<�_annotationszOptional[CompileState]r�dml_compile_state�Optional[CacheKey]�	cache_key�float�	_gen_timec��||_|jj|_|r'||_|jj	|�|_|��t
j|_||_|j|_
|j|_|jr)trt|t�sJ�|j|_|j"|jfi|��|_|r+|jj'|j$|�|_t
j(|_nt
j*|_t-�|_y)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_translater`rar�r �supports_execution�can_executer�r�
isinstancer-�_execution_optionsr��processr��_render_schema_translatesrbrcrr��rr�r r��render_schema_translate�compile_kwargss      r��__init__zCompiled.__init__;s��4������8�8��
��(<�D�%� �M�M�@�@�$��D�M�� �&�0�0�D�J�&�D�N�(�;�;�D�� )� 6� 6�D����� �%�i��<�<�<�)2�)E�)E��&�&�$�,�,�t�~�~�H��H�D�K�&�"�m�m�E�E��K�K�!5����'�5�5�D�J�&�3�3�D�J�%���r�c�@��|j�t�|�	�Sr)�_init_compiler_cls�super�__init_subclass__)�cls�	__class__s �r�r�zCompiled.__init_subclass__ss������ ��w�(�*�*r�c��yrr��r�s r�r�zCompiled._init_compiler_clsws��r�c�~�|jr|j|||�Stj|j��r)r��_execute_compiledr7�ObjectNotExecutableErrorr )r�
connection�distilled_paramsr�s    r��_execute_on_connectionzCompiled._execute_on_connection{s@������/�/��&�(9��
��.�.�t�~�~�>�>r�c�B�tj|t|��|�r�r7�UnsupportedCompilationErrorr��r�element�err�kws    r��visit_unsupported_compilationz&Compiled.visit_unsupported_compilation�s���-�-�d�D��M�B��Kr�c��t��)z�Return a Compiled that is capable of processing SQL expressions.

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

        ��NotImplementedErrorr/s r��sql_compilerzCompiled.sql_compiler�s
��"�#�#r�c�(�|j|fi|��Sr��_compiler_dispatch)r�obj�kwargss   r�r�zCompiled.process�s��%�s�%�%�d�5�f�5�5r�c�T�|jtjur|jSy)z3Return the string text of the generated SQL or DDL.r�)r�r`rbr�r/s r��__str__zCompiled.__str__�s#���:�:��5�5�5��;�;��r�c��t��)z�Return 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_paramszCompiled.construct_params�s
��"�#�#r�c�"�|j�S)z0Return the bind params for this compiled object.�r�r/s r�r�zCompiled.params�s���$�$�&�&r�)
r�r\r r�r�r�r�rr��Mapping[str, Any])rr)r�r5r�rrr�)rr��NNT�r��"Optional[_CoreSingleExecuteParams]r��&Optional[Sequence[BindParameter[Any]]]r�rrz)Optional[_MutableCoreSingleExecuteParams])!r�r�r�r�r r�r��is_sql�is_ddlr�r�r�r&�
EMPTY_DICTr�r�rr�r��
immutabledictr�r��classmethodr�r�r�r3r�r�r�r�r��
__classcell__�r�s@r�r�r��s����
�*.�I�&�-���F�C��4���-�
�F�
�F�7;��4�;�:>�O�7�>�=A��:�A�)-�����8��
!� �$(�O�O�L�/�3�,0�M�)�0�
�15��-�4�	�%)�I�!�(�	����BF�(-�,>�D�,>�,>�,@�
6(��6(�+�6(�?�	6(�
"&�6(�*�
6(�p+��
��
�?�L��$��$�6��6:�GK�!�	
$�2�
$�E�
$��	
$�

3�
$��'��'r�r�c�<�eZdZdZdZdd�Zdd�Z								d	d�Zy)
�TypeCompilerz2Produces DDL specification for TypeEngine objects.z	visit_\w+c��||_yr)r�)rr�s  r�r�zTypeCompiler.__init__�s	����r�c���|jrE|jj|jvr#|j|jj}|j|fi|��Sr)�_variant_mappingr�r�r��rrr�s   r�r�zTypeCompiler.process�sU���"�"����!�!�U�%;�%;�;��*�*�4�<�<�+<�+<�=�E�'�u�'�'��3��3�3r�c�0�tj||�|�r)r7r�r�s    r�r�z*TypeCompiler.visit_unsupported_compilation�s���-�-�d�G�<�#�Er�N)r�r\)rr�r�rrr�)r�rr��	Exceptionr�rrr)r�r�r�r��ensure_kwargr�r�r�r�r�r�r�r��s>��<��L��4�F��F�!*�F�25�F�	�Fr�r�c�F�eZdZdZdZdZd	d�Zed��Zed��Z	d�Z
y)
�
_CompileLabelz;lightweight label object which acts as an expression.Label.�label�r�r��
_alt_namesc�6�||_||_|f|z|_yrr�)r�colr��	alt_namess    r�r�z_CompileLabel.__init__�s�������	��&�9�,��r�c�.�|jjSr�r��	proxy_setr/s r�r�z_CompileLabel.proxy_set�����|�|�%�%�%r�c�.�|jjSr�r�r�r/s r�r�z_CompileLabel.type�����|�|� � � r�c��|Srr��rr�s  r��
self_groupz_CompileLabel.self_group�����r�N)r�)r�r�r�r��__visit_name__�	__slots__r�r3r�r�r�r�r�r�r�r��sD��F��N�/�I�-�
�&��&��!��!�r�r�c�J�eZdZdZdZdZd�Zed��Zed��Z	d�Z
d�Zy	)
�ilike_case_insensitiveaproduce a wrapping element for a case-insensitive portion of
    an ILIKE construct.

    The construct usually renders the ``lower()`` function, but on
    PostgreSQL will pass silently with the assumption that "ILIKE"
    is being used.

    .. versionadded:: 2.0

    �ilike_case_insensitive_operand�r��
comparatorc�4�||_|j|_yrr)rr�s  r�r�zilike_case_insensitive.__init__�s�����!�,�,��r�c�.�|jjSrr�r/s r�r�z ilike_case_insensitive.proxy_set�r�r�c�.�|jjSrr�r/s r�r�zilike_case_insensitive.type�r�r�c��|Srr�r�s  r�r�z!ilike_case_insensitive.self_groupr�r�c�J�t|jj|��Sr)rr��_with_binary_element_type)rrs  r�rz0ilike_case_insensitive._with_binary_element_types!��%��L�L�2�2�5�9�
�	
r�N)r�r�r�r�rrr�r3r�r�r�rr�r�r�rr�sJ��	�6�N�'�I�-��&��&��!��!��
r�rc�H�eZdZUdZeZejddddddddd��Zde	d	<	d
e	d<de	d<d
Z
eZdZ
de	d<dZde	d<dZde	d<	de	d<	dZde	d<	dZde	d<	dZde	d<	dZde	d<de	d<	de	d <	d!e	d"<	dZde	d#<	dZde	d$<	dZde	d%<	d&e	d'<	d&e	d(<	d&e	d)<	d*e	d+<	dZde	d,<	dZde	d-<	d
Zde	d.<	dZde	d/<	dZde	d0<	dZde	d1<	dZd2e	d3<	dZd4e	d5<	dZd6e	d7<dZ d8e	d9<dZ!d:e	d;<e"�Z#d<e	d=<	e"�Z$d<e	d><	ejJZ&d?e	d@<	dZ'	dZ(	dZ)dAe	dB<	dZ*d6e	dC<	dZ+d6e	dD<dZ,d6e	dE<dZ-de	dF<dGe	dH<dIe	dJ<dKe	dL<de	dM<e.j^dN�Z0e.j^dO�Z1e.j^e1jd�dPe0jd���Z3e4dQ��Z5e4dR��Z6ddde7df															�ddT�Z8e9�ddU��Z:ejv�ddV��Z<e9dW��Z=e9dX��Z>e9dY��Z?ej��ddZ��ZAej��d	d[��ZCeDj�d\��ZFd]�ZGd^�ZHej�		�d
d_��ZId`�ZJe9da��ZK		�d					�ddb�ZL						�d
													�ddc�ZMej�dd��ZNe9de��ZO	�d					�ddf�ZPej�dg�dh��ZRdie	dj<ej��ddk��ZSej�ej�dl�dm���ZTej�ej�dl�dn���ZUdo�ZVdp�ZW�ddq�ZXdr�ZY	�dds�ZZ	�ddt�Z[					�ddu�Z\dv�Z]dw�Z^				�d													�ddx�Z_dy�Z`dz�Zad{�Zbd|�Zcd}�Zdd~�Ze�dd�Zf	�dd��Zgd��Zhd��Zid��Zjd��Zkd��Zld��Zmd��Znd��Zod��Zpd��Zqd��Zrd��Zsd��Ztd��Zud��Zvd��Zwd��Zx	�d							�dd��Zyd��Zzd��Z{d��Z|	�dd��Z}d��Z~d��Z	�dd��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�	�dd��Z�d��Z�				�dd��Z�d��Z�d��Z�d��Z�d��Z�d��Z�	�dd��Z�d��Z�d��Z�ej�d���Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d„Z�dÄZ�					�ddĄZ�dńZ�e�dfdƄZ�dDŽZ�dȄZ�						�ddɄZ��ddʄZ�						�d																	�dd˄Z�d̄Z�ddddde��jld�f																	�d d̈́Z�d΄Z�dτZ�								�d!dЄZ�dфZ�d҄Z��ddӄZ�dԄZ��ddՄZ�dքZ�dׄZ�										�d"d؄Z�	�ddلZ�							�d#dڄZ�dۄZ�d܄Z�d݄Z�dބZ�d߄Z�d�e	d�<eʐj�s"ejd�e"�fd�e"�fg�Z�	�dd�Z�dZ�dSe	d�<								�d$d�Z�				�d%d�Z�d�Z�d�Z�d�Z�		�dd�Z�d�Z�d�Z�d�Z�d�Z�d�Z�										�d&d�Z�d�Z�			�d'd�Z�							�d(d�Zݐdd��Z�d��Z�eje�j�e�j�e�j�e�j�e�j�e�j�e�j�e�j�e�j�e�j�i�Z�e�j�e�j�e�j�i�Z�				�d)d��Z�																�d*d��Z�	�d+d��Z�d��Z�d��Z�d��Z�d��Z�dd��Z�d��Z�d�Z��d�d�Z��d�Z��d�Z��d�Z�y(,�SQLCompilerz~Default implementation of :class:`.Compiled`.

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

    �P�A�Z�C�_)�%�(�)�:�.�[�]� zClassVar[Mapping[str, str]]�bindname_escape_characterszClassVar[Pattern[str]]�_bind_translate_re�_bind_translate_charsTFr�isdelete�isinsert�isupdatezOptional[List[Column[Any]]]�	postfetchr�zSequence[Column[Any]]�insert_prefetch�update_prefetchN�&Optional[Sequence[ColumnElement[Any]]]�implicit_returning�isplaintextzDict[str, BindParameter[Any]]�bindszDict[BindParameter[Any], str]�
bind_nameszList[_CompilerStackEntry]r��returning_precedes_values�'render_table_with_column_in_update_from�ansi_bind_rulesr��bindtemplate�compilation_bindtemplate�_numeric_binds_identifier_charzList[ResultColumnsEntry]r��_textual_ordered_columns�_ad_hoc_textual�_ordered_columns�_loose_column_name_matching�_numeric_binds�_render_postcompilezOptional[ExpandedState]�_post_compile_expanded_state�
Optional[str]�_pre_expanded_string�Optional[List[str]]�_pre_expanded_positiontupzOptional[_InsertManyValues]�_insertmanyvaluesz!Optional[crud._CrudParamSequence]�_insert_crud_paramszFrozenSet[BindParameter[Any]]�literal_execute_params�post_compile_paramszutil.immutabledict[str, str]�escaped_bind_nameszbOptional[Tuple[Dict[BindParameter[Any], List[BindParameter[Any]]], Dict[str, BindParameter[Any]]]]�_cache_key_bind_matchr%�_values_bindparam�_visited_bindparam�inlinez"Optional[MutableMapping[CTE, str]]�cteszDict[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�$�|j�yr)�_init_bind_translater�s r�r�zSQLCompiler._init_compiler_cls2s��� � �"r�c��tjdj|j��}tjd|�d��|_|j|_y)Nr�rr)�re�escaperwr�compilerr)r��regs  r�rJz SQLCompiler._init_bind_translate6sF���i�i����� >� >�?�@��!#���a��u�A�J�!7���$'�$B�$B��!r�rc�>�||_||_|r:|dD�	cic]}	|	j|	��}
}	|dD�	cic]}	|	|	g��}}	||
f|_||_||_i|_tj�|_	g|_
g|_|j|_|jrH|jjd�x|_}|r|jdk(rdnd|_t"|_nt&|j|_d|_|j*xs|j,|_t/�|_i|_i|_t7j8|||fi|��|j:s|j<s|j>r�t@rtC|tD�sJ�|j:s|j<rmt@rtC|tF�sJ�|jHrd|_%nA|jr5|j:r"|jLjNr|jPrd|_%t&|j|_)|rK|jTjW|jTjY�D�
�cic]\}
}|
dvr|
|��c}}
�|jZt\j^urm|jr-|jr|ja�n|jc�|jdr'|jgd	d�
�}|ji|d��yyycc}	wcc}	wcc}}
w)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.

        rr�r�r�rNT>r�r�r��
positionalr-r4r.F�r��_no_postcompile)�_populate_self)5�column_keysr�r+r@�for_executemany�lintingr(r&�column_dictr)r�r�rQ�
paramstyle�
startswithr4r/�_pyformat_templater.�BIND_TEMPLATESrD�label_length�max_identifier_lengthr4�anon_map�truncated_names�_truncated_countersr�r�r r!rrr�rBrC�_inlinerCr��insert_executemany_returning�_return_defaultsr-�__dict__�update�itemsr�r`rb�_process_numeric�_process_positionalr5r��#_process_parameters_for_postcompile)rr�r r�rUrVrW�_supporting_againstr��b�cksm�ckbm�nb�k�vr!s                r�r�zSQLCompiler.__init__<s���@'���"����&/��l�3�l��A�E�E�1�H�l�D�3�$-�a�L�1�L�q�A��s�F�L�D�1�*.���D�&�
 /��������
��*�*�,�����
�!���"�,�,����?�?�'.�'9�'9�'D�'D�Y�'O�O�D��"��"�-�-�1A�A�C�s��3�-?�D�)�,:�7�;M�;M�,N�D�)���	�
� � �A�G�$A�$A�	
��(�)��
�<>���35�� ����$���=�f�=��=�=�D�M�M�T�]�]��!�)�Z�8�8�8��}�}��
�
� �%�i��<�<�<��$�$�"&�D�K��)�)��
�
����A�A�%�6�6�#'�D�K�*�7�+=�+=�>�����M�M� � �!4� <� <� B� B� D�
� D���1���	��q�D� D�
�
�"�:�:��5�5�5�����&�&��)�)�+��,�,�.��'�'�!�2�2�!&�$(�3��
�
�8�8��t�9��
(�6��y4��1��V
s�L�L�,L
c�H�|j�y|jjS)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)r;r7r/s r��insert_single_values_exprz%SQLCompiler.insert_single_values_expr�s%���!�!�)���)�)�<�<�<r�c���|jr|jS|j�Dt|j�r/|jjD�cgc]}t	|�r|��c}Sycc}w)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)r&r r(�_all_selected_columnsr')r�cs  r��effective_returningzSQLCompiler.effective_returning�sl���"�"��*�*�*�
�^�^�
'�F�4�>�>�,B����=�=��=�A�$�Q�'��=��
���s�A*c��|jS)zVbackwards compatibility; returns the
        effective_returning collection.

        )rwr/s r��	returningzSQLCompiler.returning�s���'�'�'r�c�b�	|jddS#t$r}td�|�d}~wwxYw)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_executablezSQLCompiler.current_executables;��<	M��:�:�b�>�,�/�/���	M��C�D�"�L��	M�s��	.�)�.c�X�t|j�t|j�zSr)�listr#r$r/s r��prefetchzSQLCompiler.prefetch%s#���D�(�(�)�D��1E�1E�,F�F�Fr�c��iSrr�r/s r��_global_attributeszSQLCompiler._global_attributes)s���	r�c�f�tj�}||_i|_i|_d|_|S)z�Initialize collections related to CTEs only if
        a CTE is located, to save on the overhead of
        these collections otherwise.

        F)r&�OrderedDictrDrErFrG)rrDs  r��_init_cte_statezSQLCompiler._init_cte_state-s:��*.�)9�)9�);����	�#%���"$���#����r�c#�hK�|j|j}}gdc|_|_	|jr|jd}d|d<nd}|j|jf��|r|jd�||c|_|_y#r|jd�||c|_|_wxYw�w)z;special API to support the use case of 'nested result sets'Fr{TrN)r�r2r�rv)r�result_columns�ordered_columns�entrys    r��_nested_resultzSQLCompiler._nested_resultEs�����
� � ��!�!�(��79�%�3���d�3�
	��z�z��
�
�2���6:��2�3����&�&��(=�(=�=�=���	�	�6�7���
8�D� �$�"7����	�	�6�7���
8�D� �$�"7�s�(B2�=B�(#B2�$B/�/B2c���	�|jrJ�|jtjusJ�|jrJ�|j
jdk(rd�n|j
jdk(sJ�d�g�	d��	fd�}tj|j||j�|_
|jrv|jj�D��cic]\}}||��
}}}t|j�t|�k(sJ��	D�cgc]}|j||���c}|_n�	|_|jr�g�	tj|j||jj �}|jj"D�cgc]3}|d|dtj|j||d�|d	f��5}}|jj%||�
�|_yycc}}wcc}wcc}w)Nr��%sr�r�c���|jd�}|r�j|��S�j|jd��|jd�S)Nrr6r)r��append)�m�normal_bind�placeholder�	positionss  ��r��
find_positionz6SQLCompiler._process_positional.<locals>.find_positionjsM����'�'�!�*�K��� � ��-�"�"�� � ������,��w�w�q�z�!r�rrr6r
�r7r9)r�z
re.Match[str]rr�)r%r�r`rbr4r�rYrL�sub�_positional_patternr�r?rg�len�getr;r7r9�_replace)
rr�rprq�reverse_escaper�r7r9r�r�s
        @@r�rizSQLCompiler._process_positional]s�����#�#�#�#��z�z�]�9�9�9�9�9��&�&�&�&��<�<�"�"�h�.��K��<�<�*�*�g�5�5�5��K��	�	"��f�f��$�$�m�T�[�[�
����"�"�/3�/F�/F�/L�/L�/N�O�/N�t�q�!�a��d�/N�N�O��t�.�.�/�3�~�3F�F�F�F�;D� �;D�4��"�"�4��.�9� �D�� )�D���!�!��I�!#����(�(���&�&�9�9�"���/�/�B�B�"�C�A��a�D��a�D��F�F�4�3�3�]�A�a�D�I��a�D�	�C�
�"�&*�%;�%;�%D�%D�#5�#5�&E�&�D�"�%"��P�� ��"s�
G1�G7�8G<c�t����jsJ��jtjusJ�d}i��jr\�j
�Pt
j�fd��jj�D��jj��}n�jj�}|D]R}|�vr��j|}|�jvs|�jvrd�|<�9�j�|��}|dz
}|�|<�T|�_t���_�j"rYt%��}�j'�D��cic]"\}}�j"j)||�|��$c}}�t%��|k(sJ��j*j-�fd��j.��_�jrl�jj0�z}	�jj2D�
cgc]}
|
d|
dd|
df��}}
�jj5|	|���_yycc}}wcc}
w)Nrc3�>�K�|]}|�jvr|���y�wr)rA)r*r�rs  �r�r,z/SQLCompiler._process_numeric.<locals>.<genexpr>�s'������ 8���4�#9�#9�9�� 8���c�,���|jd�S�Nr�r��r��	param_poss �r��<lambda>z.SQLCompiler._process_numeric.<locals>.<lambda>�s���i�����
�+r�rr�r
r�)r4r�r`rbr;rA�	itertools�chainr)�valuesr(r>r=r/�next_numeric_posr�r%r?r�rgr��_pyformat_patternr�r�r7r9r�)
r�numr��	bind_name�bind�ph�
len_beforer��posr7rqr9r�s
`           @r�rhzSQLCompiler._process_numeric�sN����"�"�"�"��z�z�]�9�9�9�9�9���$&�	��!�!�d�&<�&<�&H��O�O�� $��� 6� 6� 8��
���&�&�(�
�E��O�O�*�*�,�E��I��I�%���:�:�i�(�D���0�0�0��4�6�6�6�(,�	�)�$��;�;�<�S�E�B���q���')�	�)�$�� !$����	�?����"�"��Y��J�"+���!2��!2�I�D�#��'�'�+�+�D�$�7��<�!2��I��y�>�Z�/�/�/��,�,�0�0�+�T�[�[�
����!�!��&�&�9�9���
��/�/�B�B�"�B�A��1��q��t�T�1�Q�4�(�B�
�"�
&*�%;�%;�%D�%D�#5�#5�	&E�&�D�"�"����$"s�
'H/�3H5c�f���fd��jD�D��cic]
\}}|�||��c}}Scc}}w)Nc	3��K�|]�}�j||jjs%|jj�j�n5t�fd�t
t|j�jD��f����y�w)c3�T�K�|]}|j�j����!y�wr)�_cached_bind_processorr�)r*�	elem_typers  �r�r,z9SQLCompiler._bind_processors.<locals>.<genexpr>.<genexpr>�s,�����#�.$�	�&�<�<�T�\�\�J�.$�s�%(N)	r)r��_is_tuple_typer�r�r.rr2�types)r*�	bindparamrs  �r�r,z/SQLCompiler._bind_processors.<locals>.<genexpr>�s������"1�I��O�O�I�.� )�~�~�<�<�"���=�=�d�l�l�K�"�#�-1� )�9�>�>�.�#�e�.$�#���"1�s�B
B
)r))rr+�values`  r��_bind_processorszSQLCompiler._bind_processors�sL����"&����
��
��U� � �#
��J��
�	
��
s�-c�2�t|j�dkDSr�)r�r�r/s r��is_subqueryzSQLCompiler.is_subquery�s���4�:�:���"�"r�c��|Srr�r/s r�r�zSQLCompiler.sql_compilers���r�c�L�|j||d��}|j|�S)aRReturn a new :class:`.ExpandedState` for a given parameter set.

        For queries that use "expanding" or other late-rendered parameters,
        this method will provide for both the finalized SQL string as well
        as the parameters that would be used for a particular parameter set.

        .. versionadded:: 2.0.0rc1

        TrR)r�rj)rr�r�r!s    r��construct_expanded_statez$SQLCompiler.construct_expanded_states:���*�*��%� �+�
�
�
�7�7��
�	
r�c��|jrF|sD|j�J�|st|jj�St	j
d��|xrt
|j�}|rq|j�t	jd��|jd}|j}	|	�J�|	\}
}t||�D��
�cic]\}}
|
|D]}||
���}}
}}nd}|�ri}|jj�D]�\}}|r|jj||�n|}|j|vr||j||<�G||vr	||||<�T|rX|j rL|r&t	j
d|j|fzd���t	j
d|jzd���|r|j||�}n|}|j"r|j$||<��|j&||<��|Si}|jj�D]�\}}|r|jj||�n|}|rX|j rL|r&t	j
d|j|fzd���t	j
d|jzd���|r|j||�}n|}|j"r|j$||<��|j&||<��|Scc}}
}w)	z5return a dictionary of bind parameter keys and valuesNz�can't construct new parameters when render_postcompile is used; the statement is hard-linked to the original parameters.  Use construct_expanded_state to generate a new statement and parameters.zcThis compiled object has no original cache key; can't pass extracted_parameters to construct_paramsrz@A value is required for bind parameter %r, in parameter group %d�cd3x)�codez)A value is required for bind parameter %r)r5r6�dictr!r7r-rr?r��CompileErrorr@�zipr)rgr�r+�required�callable�effective_valuer�)rr�r�r��
_group_number�_checkrS�has_escaped_names�orig_extracted�
ckbm_tuplernrrl�	extractedr��resolved_extracted�pdr�r��escaped_name�value_params                     r�r�zSQLCompiler.construct_paramss?���#�#�O��4�4�@�@�@���D�=�=�H�H�I�I��-�-�4���)�J�T�$�2I�2I�-J����~�~�%��&�&�J���
"&����!2���3�3�J��)�)�)� �G�D�!�%(��8L�$M�"�$M�L�A�y� ��G�D��i��#��$M�
�"�"&����B�#'�?�?�#8�#8�#:��	�4�)��+�+�/�/��d�;����=�=�F�*�'-�i�m�m�'<�B�|�$��V�^�'-�d�|�B�|�$��	� 2� 2�$�!�5�5�4�(�}�}�m�<�=�"(�	��"�5�5�G�'�m�m�,�!'���*�&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�'�m�m�,�!'���&�"4�"8�"8��I�"N�K�"+�K��%�%�'2�'B�'B�B�|�$�'2�'8�'8�B�|�$�=$;�@�I��g"s�Kc�����	�|j��j�	�j��j�����	fd�}i}|j}|j
D]n}||vr�|jjr<tt|j�jD�cgc]
}||���c}||<�Z||j�||<�p|Scc}w)Nc�f��|j��j��}|���|�vr��|�vr|Syr)�_unwrapped_dialect_impl�get_dbapi_type)�typ�dbtype�dbapir��
exclude_types�
include_typess  ����r��lookup_typez<SQLCompiler._get_set_input_sizes_lookup.<locals>.lookup_type�sH����0�0��9�H�H��O�F��"�"�*�f�M�.I�"�*�f�
�.E��
�r�)r��include_set_input_sizes�exclude_set_input_sizesr�r=r)r�r�rr2r�)
rr��
inputsizesr=r�r�r�r�r�r�s
      @@@@r��_get_set_input_sizes_lookupz'SQLCompiler._get_set_input_sizes_lookup�s�����,�,���7�7�
��7�7�
��
�
��
	��
�!%�!<�!<�����I��2�2���~�~�,�,� $�I�y�~�~�>�D�D�)�D�� ��$�D�)�
�9�%�
)4�I�N�N�(C�
�9�%�)����)s�C
c�&�|jd��S)z�Return 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�r/s r�r�zSQLCompiler.params�s���$�$�E�$�2�2r�c�������i}|j}|�|j}|jrg}|j}|�|j}ndx}}|j
}t
d|��t
d|��i}i�i}	d}
|jr|�|}|jrg}
n|jj�}|j}|D�]��|r|j���n�}
|j�}||jvr*|
�vr%|j||j|
����|
<�a||j v�r|
�vr|	|
}d}n3|j��}|j#|
||�}|\}}||	|
<|�|
<|j$r��|j'|�|j(j*r*|�J�|j'��fd�t-|d�D��n|j'��fd�|D��|
�|
j/d�|D��n|�|j/d	�|D��|D��cgc]\}}|��	c}}|�<��w|���{|j1������fd
�}t3j4|j6||�}|
�l|�J�t-|
|j8�D��cic]\}}||j:�|����c}}�|j<j5�fd�|�}|j/|
�t?|||||�}|rR||_||_|j@|_|jrtC|jxsd�nd|_||_"|Scc}}wcc}}w)
a�handle special post compile parameters.

        These include:

        * "expanding" parameters -typically IN tuples that are rendered
          on a per-parameter basis for an otherwise fixed SQL statement string.

        * literal_binds compiled with the literal_execute flag.  Used for
          things like SQL Server "TOP N" where the driver does not accommodate
          N as a bound parameter.

        Nr"z/Mapping[str, Sequence[_BindProcessorType[Any]]]��render_literal_valuec3��K�|]?\}}t|d�D]+\}}��vr"��|dz
���d|�d|����|dz
f���-�Ay�w)rNr)�	enumerate)r*�i�
tuple_element�jrr��tuple_processorss     ��r�r,zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>=sy�����	.�
5I� 0��=�(1�-��(C���1�#�'7�7� 0�� 6�q�1�u� =� I�
/3�A�q� 9� 0�� 6�q�1�u� =��
)D��5I�s�AArc3�:�K�|]\}}��vr	|��f���y�wrr�)r*r+rr��single_processorss   ��r�r,zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>Hs1�����.�*3���Q�#�'8�8�!�"3�D�"9�:�*3���c3�&K�|]	\}}|���y�wrr��r*r�rs   r�r,zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>Ns����3�09�W�T�1�D�	���c3�&K�|]	\}}|���y�wrr�r�s   r�r,zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>Us����.M�9���a�t�9�r�c�����|jd�}�|}|jd�rU|jd�jd�}|d|dc��dj��fd�|jd�D��}|S)Nrr6�~~r
r�c3�.�K�|]}��|�������y�wrr�)r*�exp�be_left�be_rights  ��r�r,z]SQLCompiler._process_parameters_for_postcompile.<locals>.process_expanding.<locals>.<genexpr>es �����!�/��!(��h�7�/�s�)r��splitrw)r�r+�expr�tokr�r��replacement_expressionss    @@�r��process_expandingzJSQLCompiler._process_parameters_for_postcompile.<locals>.process_expanding\s~����'�'�!�*�C�*�3�/�D��w�w�q�z��g�g�a�j�&�&�t�,��$'��F�C��F�!����y�y�!�#�z�z�$�/�!����Kr�c�,���|jd�Sr�r�r�s �r�r�zASQLCompiler._process_parameters_for_postcompile.<locals>.<lambda>ys���)�A�G�G�A�J�/r�r�)#r8r�rQr:r%r�rr4r)r�r?r�r(r=�render_literal_bindparamrvr>�$_literal_execute_expanding_parameter�literal_executerfr�r�r��extendr�rLr��_post_compile_patternr�r/r�rr r�r6)rr!rT�expanded_parameters�pre_expanded_string�new_positiontup�pre_expanded_positiontupr#�new_processors�to_update_sets�numeric_positiontup�names�ebnr��	parameter�	to_updater��leep_res�replacement_expr�
expand_keyrr�r r�r+�expanded_stater�r�r�r�r�s                          @@@@@r�rjz/SQLCompiler._process_parameters_for_postcompile�s����$!��#�7�7���&�"&�+�+���?�?� �O�'+�'E�'E�$�'�/�+/�+;�+;�(�:>�=�O�6��*�*�
� �3�Z�
�� �=�z�
��>@��24��)+��48���?�?�7�C�#;�E��"�"�&(�#��O�O�*�*�,�E��%�%���D�25�3�7�7�4��.�4�L��
�
�4�(�I��D�7�7�7��'>�>��5�5�%�1;����1M�6��,�L�9���D�4�4�4��#:�:� .�|� <�I�!�F�(�^�^�D�1�F�#�H�H�$�i�� �H�5=�1�Y� 0�3<�N�<�0�<L�+�L�9� �0�0��%�%�i�0� �~�~�4�4�%�1�1�1�&�-�-�	.�
5>�f�a�4H�	.�	�'�-�-�.�*3�.��
+�6�+�2�2�3�09�3��)�4�(�.�.�.M�9�.M�M�8A�1�8A�}�z�1�
�	�1�'��-�!�,��&�&�t�,�S�V
	��F�F��&�&�(9�;N�
�	��*�"�.�.�.�!*�'��)>�)>�!��!�H�C����;�;�<�S�E�B�B�!��I��.�.�2�2�/���I�
�"�"�#6�7�&������
���)<�D�%�-E�D�*�(�2�2�D�K��?�?��^�/�/�5�2�6��
��
1?�D�-����{1��6s�$M
�Mzsqlalchemy.engine.cursorc��tjj}|jj	|j
�S)z(utility method used for unit tests only.)r&�	preloaded�
engine_cursorrT�_create_description_match_mapr�)r�cursors  r��_create_result_mapzSQLCompiler._create_result_map�s5�����-�-���*�*�H�H�� � �
�	
r��_BindNameForColProtocol�_get_bind_name_for_colc��|j}|Sr)r)r�getters  r��_within_exec_param_key_getterz)SQLCompiler._within_exec_param_key_getter�s���,�,���
r�zsqlalchemy.engine.resultc	���	�
���
�tjj}|j}|j�J�|jj
}trt|t�sJ�|j}|jD�cgc]!}tjd||�d�|f��#c}�d�	|j���D�jj|j d��|���
�
|j"vr
�
fd�}|�	nd�|j%|jD�cgc]}|j&��c}��
��	���
fd�}|Scc}wcc}w)Nr�c�4��|j�|�}|�|S|Sr�r�)�	lastrowidr!�param_value�autoinc_keys   �r��_autoinc_getterzPSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>._autoinc_getter�s)���",�.�.��i�"H�K�"�.�
 +�*� )�(r�c�j��������������fd��D��S�����fd��D��S)agiven cursor.lastrowid value and the parameters used for INSERT,
            return a "row" that represents the primary key, either by
            using the "lastrowid" or by extracting values from the parameters
            that were sent along with the INSERT.

            c3�4�K�|]\}}|�����y�wrr�)r*rr�r!s   �r�r,zWSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>�s�����L�G�[�V�S�f�Z�0�G���c3�V�K�|] \}}|�ur
��	����n	�n|�����"y�wrr�)r*rr��autoinc_col�autoinc_getterrr!s   ����r�r,zWSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>�sL������(/�����+�-� .�9�+�9�j�A�!*�$�J�/�
0�(/���&)r�)rr!r'r(�getters�lastrowid_processor�row_fns``�����r�r�zDSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get�sH���#�.�/�	�:�	�� ��L�G�L�L�L���(/���r�)r&r�
engine_resultrrr rr�rAr��primary_key�operator�methodcaller�_autoincrement_columnr��_cached_result_processorr�r(�result_tupler+)r�result�param_key_getterr r�r�r"r�r'r(r!r*r+r,s        @@@@@@r��+_inserted_primary_key_from_lastrowid_getterz7SQLCompiler._inserted_primary_key_from_lastrowid_getter�sM������-�-���=�=���!�!�-�-�-��&�&�0�0�	���i��0�0�0������(�(�
�(���
"�
"�5�*:�3�*?��
F��L�(�
��
���1�1���"�"-�"2�"2�"K�"K����d�#��+�;�7�K��d�j�j�(�
)�"1��#'���$�$��9J�9J�%K�9J�#�c�g�g�9J�%K�L��	�	�4�
��G
��N&Ls�&E�Ec��
��tjrddlm}ntj
j}|j�J�|jj}trt|t�sJ�|j}|j}|j}|�J�t|�D��cic]\}}||��
}}}td|j D�cgc]?}||vrt#j$||�dfnt#j&d||�d�df��Ac}��
|j)|j D�cgc]}|j*��c}���
�fd�}	|	Scc}}wcc}wcc}w)Nr6)r4z'List[Tuple[Callable[[Any], Any], bool]]Tr�Fc�,�������fd��D��S)Nc3�H�K�|]\}}|r|��n|�����y�wrr�)r*r�use_rowr!�rows   ��r�r,zWSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get.<locals>.<genexpr>"	s-������'.�O�F�G� '��s��F�:�,>�>�'.�rrr�)r;r!r*r,s``��r�r�zDSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get!	s�����'.���
r�)�typingr�enginer4r&rr-rr r�rArr�r&r�rr.r/�
itemgetterr0r3r+)rr4r r5r�ry�idxr��retr�r*r,s          @@r��+_inserted_primary_key_from_returning_getterz7SQLCompiler._inserted_primary_key_from_returning_getter�sk������'��^�^�1�1�F��!�!�-�-�-��&�&�0�0�	���i��0�0�0��=�=�������+�+�	��$�$�$�(1�)�(<�=�(<�H�C��s�C�x�(<��=��5�!�,�,�
�-�C��c�z��(�(��S��2�D�9�!�-�-�!�#3�C�#8�$���	��-�
�
��"�$�$��9J�9J�%K�9J�#�c�g�g�9J�%K�L��	��
��7>��
��&Ls�&
E�
AE
�.Ec��y)z�Called 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�r/s r��default_fromzSQLCompiler.default_from)	s��r�c���|jj|fi|��}|jD�]C}||jvr�|j|}|j	|j|j
dd��}|j|}|x|j|<|j|<||j|<|jj|d�||jvr|xj|hzc_||jvr|xj|hzc_	|j}|s��|\}	}
|jD]4}|j
|
vs�|
|j
}|	|j|��6��F|S)a�SQL compile the nested element of an _OverrideBinds with
        bindparams swapped out.

        The _OverrideBinds is not normally expected to be compiled; it
        is meant to be used when an already cached statement is to be used,
        the compilation was already performed, and only the bound params should
        be swapped in at execution time.

        However, there are test cases that exericise this object, and
        additionally the ORM subquery loader is known to feed in expressions
        which include this construct into new queries (discovered in #11173),
        so it has to do the right thing at compile time as well.

        TF)�maintain_keyr�N)
r�r��	translater(�_with_valuer+r)rvr>r=r@�_cloned_setr�)r�override_bindsr��sqltextrp�bp�new_bpr�r�rnrm�cbs            r��visit_override_bindsz SQLCompiler.visit_override_binds3	s`��"<�.�(�(�;�;�D�G�B�G�� �)�)�A���
�
�"�����A��B��^�^��(�(����0�!��$��F��?�?�2�&�D�/5�5�D�J�J�q�M�D�J�J�t�,�&*�D�O�O�F�#��O�O����D�)��T�-�-�-��(�(�V�H�4�(��T�0�0�0��+�+��x�7�+��3�3�J��'�
��d��.�.�B��v�v��~�!�"�&�&�\���R�����/�)�?*�H�r�c�H�d|jj|fi|��zdzS�Nrr�r�r�)r�grouping�asfromr�s    r��visit_groupingzSQLCompiler.visit_groupings	�+���8�X�%�%�8�8��H��H�H�3�N�Nr�c�H�d|jj|fi|��zdzSrPrQ)rrRr�s   r��visit_select_statement_groupingz+SQLCompiler.visit_select_statement_groupingv	rUr�c���|jr�|jjr�	td|jdd�}|j\}}}|r|}	n|}	|jj}
|
�E|
j|	vr7|
j|	|
j�r|jj|d<|j|jfd|i|��S#t$r}tjd�|�d}~wwxYw)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�KeyErrorr7r��_label_resolve_dictr��_order_by_label_elementr��shares_lineager�)rr�r\r�r�ke�	with_cols�
only_froms�	only_cols�resolve_dict�
order_by_elems           r��visit_label_referencez!SQLCompiler.visit_label_referencey	s���:�:�$�,�,�E�E�	
� $�=��J�J�r�N�?�3�!�
��1�1�	
����$�)��(��$�O�O�C�C�M��)�!�&�&�,�6�!�0�0� ��!3�!3�4��
�O�O�;�;��.�/��t�|�|��O�O�
�"7�
��
�	
��A�
��&�&�/�����
�s�C�	C7�C2�2C7c�>�|js|j|j�S	td|jdd�}j\}}}	|r||j}	n||j}	|	|d<|j|	fd|i|��S#t$r;}tj|jdtj|��Yd}~��d}~wwxYw#t$r;}
tj|jdtj|
��Yd}
~
yd}
~
wwxYw)NrYr{rrZ)�extra�exc_clsr�r[r\)r�r��_text_clauserr^r�_no_text_coercionr�r7r�r_)rr�r\r�rrbrcrdrer�r�s           r��visit_textual_label_referencez)SQLCompiler.visit_textual_label_reference�	s*���z�z��<�<�� 4� 4�5�5�	� �9��
�
�2���/��M�,9�+L�+L�(�	�:�y�	�$� ����1������0��/2�F�*�+��4�<�<���+@��DJ��
��;�		��'�'����/��(�(��
�
��		��"�		��'�'����/��(�(��
�
��		�s/�B�!C�	C�1C�C�	D�!1D�Dc�H�|xr|}||u}	|	s|rMt|jtj�r|j	d|j�}
n|j}
|r�|�1|
|j||
f|j
z|z|j�|jj|fddd�|��ttjz|jj|
�zS|	r|jj|
�S|jj|fddi|��S)N�colidentT)r\�within_label_clauser\F)r�r�rrD�_truncated_identifierr�r�r�r��	OPERATORSr!�as_r��format_label)rr��add_to_result_maprqr\r[�result_map_targetsr��render_label_with_as�render_label_only�	labelnames           r��visit_labelzSQLCompiler.visit_label�	s?��
"�=�*=�&=�	�2�U�:��� 4��%�*�*�h�&?�&?�@� �6�6�z�5�:�:�N�	�!�J�J�	�� �,�!���J�J��I�&��)9�)9�9�<N�N��J�J�	�1��
�
�0�0���*.�(,���	��I�M�M�*�
+��-�-�,�,�U�I�>�?�	
���=�=�-�-�e�Y�?�?�3�5�=�=�3�3���,1��57��
r�c�,�tjd��)Nz:Cannot compile Column object until its 'name' is assigned.�r7r��rr�s  r��_fallback_column_namez!SQLCompiler._fallback_column_name
s�����H�
�	
r�c�@�|j}|j|fi|��Sr)�	_resolvedr�)rr�r��sql_elements    r��visit_lambda_elementz SQLCompiler.visit_lambda_element
s#���'�'���t�|�|�K�.�2�.�.r�c�Z�|jx}}|�|j|�}|j}	|	s,t|tj
�r|j
d|�}|�C|||jf|z}
|jr|
|jfz
}
||||
|j�|	r|j|�}n|jj|�}|j}|�|r|js|S|jj|�}|r|jj!|�dz}
nd}
t"rt|t$�sJ�|j}|s|r	||vr||}t|tj
�r|j
d|�}|
|jj|�zdz|zS)Nrprr��alias)r�r�
is_literalr�rrDrrr+�	_tq_labelr��escape_literal_columnr��quoter��named_with_column�schema_for_object�quote_schemarrO)rr�rv�
include_tablerw�ambiguous_table_name_mapr�r��	orig_namer��targetsr��effective_schema�
schema_prefix�	tablenames               r��visit_columnzSQLCompiler.visit_column
s���"�;�;�&��y��<��-�-�f�5�D��&�&�
��j��x�/H�/H�I��-�-�j�$�?�D��(��t�V�Z�Z�0�3E�E�G�����F�,�,�.�.���d�I�w����D���-�-�d�3�D��=�=�&�&�t�,�D������=�
�U�5L�5L��K�#�}�}�>�>�u�E����M�M�.�.�/?�@�3�F��!#�
��!�%��9�9�9��
�
�I�%�,��!9�9�4�Y�?�	��)�X�%>�%>�?� �6�6�w�	�J�	� �4�=�=�#6�#6�y�#A�A�C�G�$�N�Nr�c�L�|jj|j�Sr)r��format_collation�	collation�rr�r�s   r��visit_collationzSQLCompiler.visit_collationJ
s���}�}�-�-�g�.?�.?�@�@r�c��|jSr�r�)r�
fromclauser�s   r��visit_fromclausezSQLCompiler.visit_fromclauseM
s�����r�c��|jSrr�)rror�s   r��visit_indexzSQLCompiler.visit_indexP
s���z�z�r�c��||d<|j|d<|jjj|jfi|��S)N�type_expressionr�)r�r��type_compiler_instancer�r�)r�
typeclauser�s   r��visit_typeclausezSQLCompiler.visit_typeclauseS
sJ�� *����$(�M�M�� �!�:�t�|�|�2�2�:�:��O�O�
�!�
�	
r�c�V�|jjr|jdd�}|S�Nr�%%�r��_double_percents�replace�r�texts  r��post_process_textzSQLCompiler.post_process_textZ
�$���=�=�)�)��<�<��T�*�D��r�c�V�|jjr|jdd�}|Sr�r�r�s  r�r�z!SQLCompiler.escape_literal_column_
r�r�c	��������fd�}�jsd�_|r|dd�ftj�tjd�tj|�j�j���S)Nc���|jd�}|�jvr �j�j|fi���S�j|fi���Sr�)r��_bindparamsr��bindparam_string)r�r�r�r�
textclauses  ���r��do_bindparamz2SQLCompiler.visit_textclause.<locals>.do_bindparame
sW����7�7�1�:�D��z�-�-�-�#�t�|�|�J�$:�$:�4�$@�G�B�G�G�,�t�,�,�T�8�R�8�8r�Tc�$�|jd�Sr�r�)r�s r�r�z.SQLCompiler.visit_textclause.<locals>.<lambda>w
s��a�g�g�a�jr�)	r�r'r%�NULLTYPE�BIND_PARAMS_ESCr��BIND_PARAMSr�r�)rr�rvr�r�s`` ` r��visit_textclausezSQLCompiler.visit_textclaused
sl���	9��z�z�#�D���
�d�D�:�-��9J�9J�K��"�"� ��O�O��d�4�4�Z�_�_�E�
�
�	
r�c�"�|j}|r|jn|jd}t�t�|d�}|jj|�|jr|j||�|xs-|dk(xr|j
dd�xs|j
dd�}|rp|jx|_|_	|jxrt|j�|_|jD] }	|j|	d|j���"|j|jfi|��}
|j r.|st#|j�nd}|j%|�	�|
z}
|jj'd�|
S)
Nr{�rrr$rrFrT)r\rv��
nesting_level)r��_default_stack_entryror��_independent_ctes�_dispatch_independent_ctesr�rQr2r0r�column_argsr3r��_add_to_result_mapr�rDr��_render_cte_clauserv)r�taf�compound_indexrSr��toplevelr��	new_entry�populate_result_maprvr�r�s            r��visit_textual_selectz SQLCompiler.visit_textual_select}
s{���z�z�>��-5��)�)�4�:�:�b�>�� #�u��E��*
�	�
	
�
�
���)�$�� � ��+�+�C��4�
�
>��!�#�E��I�I�<�e�D�
>�
�y�y�5�u�=�
	�����
�D�!�D�$A�47�>�>�/A�0�d����G�D�,��_�_������*.�&*�&=�&=���%��t�|�|�C�K�K�.�2�.���9�9�3;�C��
�
�O��M��*�*��*�G�$�N�D��
�
���r���r�c��y�N�NULLr��rr�r�s   r��
visit_nullzSQLCompiler.visit_null�
���r�c�2�|jjryy)Nr~�1�r��supports_native_booleanr�s   r��
visit_truezSQLCompiler.visit_true�
s���<�<�/�/��r�c�2�|jjryy)Nr��0r�r�s   r��visit_falsezSQLCompiler.visit_false�
s���<�<�/�/��r�c�J���|jd���fd�|D�D��S)Nc3�$K�|]}|r|���
y�wrr��r*�ss  r�r,z7SQLCompiler._generate_delimited_list.<locals>.<genexpr>�
s����
�I���
�I���c3�D�K�|]}|j�fi������y�wrr��r*rvr�rs  ��r�r,z7SQLCompiler._generate_delimited_list.<locals>.<genexpr>�
s%�����I��1�*�a�*�*�4�6�2�6��r��rw)rr�	separatorr�s`  `r��_generate_delimited_listz$SQLCompiler._generate_delimited_list�
s&����~�~�
�I��I�
�
�	
r�c�t���tjjtjtj
jtjj|�\}}|dk(r|dj�fi���Sttj}|jd���fd�|D�D��S)Nrrc3�$K�|]}|r|���
y�wrr�r�s  r�r,z;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>�
s����"�L�A���L�r�c3�D�K�|]}|j�fi������y�wrr�r�s  ��r�r,z;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>�
s%�����L�G�q�.�!�.�.�t�:�r�:�G�r�)r�BooleanClauseList�_process_clauses_for_booleanr!�and_�True_�
_singleton�False_r�rsrw)r�clausesr��lccr�s` `  r��_generate_delimited_and_listz(SQLCompiler._generate_delimited_and_list�
s�����1�1�N�N��N�N��N�N�%�%��O�O�&�&��	
���W��!�8�0�7�1�:�0�0��<��<�<�!�)�.�.�1�I��>�>�"�L�G�L�"��
r�c�.�d|j|fi|��zS�N�(%s))�visit_clauselist)r�
clauselistr�s   r��visit_tuplezSQLCompiler.visit_tuple�
s ���-��-�-�j�?�B�?�?�?r�c��|j}|�d}nt|j}|j|j|fi|��S�Nr)r/rsr�r�)rr�r��seps    r�r�zSQLCompiler.visit_clauselist�
sG���!�!���;��C��J�/�/�0�C�,�t�,�,�Z�-?�-?��K��K�Kr�c��|j}|j|dd�}|r
|||fi|��S	t|}d|d<|j|j|fi|��S#t
$r}t
j||�|�d}~wwxYw)N�expression_clauselistT�_in_operator_expression)r/�_get_operator_dispatchrsr�r�r^r7r�)rr�r��	operator_�disp�opstringr�s       r��visit_expression_clauselistz'SQLCompiler.visit_expression_clauselist�
s����'�'�	��*�*��.��
����
�I�4��4�4�	� ��+�H�-1�B�(�)�0�4�0�0��"�"�H��02��
��	�	L��1�1�$�	�B��K��	L�s�	A�	A>�"A9�9A>c�d�d}|j�#||jj|fi|��dzz
}|jD]8\}}|d|j|fi|��zdz|j|fi|��zdzz
}�:|j�&|d|jj|fi|��zdzz
}|dz
}|S)NzCASE rzWHEN z THEN zELSE �END)r�r��whens�else_)r�clauser��x�condr4s      r��
visit_casezSQLCompiler.visit_case�
s������<�<�#�
�0����0�0��@��@�3�F�F�A�"�L�L�L�D�&�
��)�$�)�)�$�9�&�9�:���,�&�+�+�D�;�F�;�<��	�
�A�)��<�<�#�
��9�&�,�,�9�9�$�I�&�I�I�C�O�
�A�	
�U�
���r�c�<�|jj|fi|��Sr)�typed_expressionr�)r�type_coercer�s   r��visit_type_coercezSQLCompiler.visit_type_coerce
s ��>�{�+�+�>�>�t�J�r�J�Jr�c��|jj|fi|��}tjd|�}d|jj|fi|���d|r|jd�n|�d|r|jd���Sd��S)Nz(.*)( COLLATE .*)zCAST(r�rrr6r�)r�r�rL�matchrr�)rrr��type_clauser
s     r��
visit_castzSQLCompiler.visit_cast
s���8�d�o�o�8�8��H��H�����,�k�:��*�D�K�K�*�*�4�:�6�:�#�E�K�K��N��4�#�E�K�K��N�+�
�	
�*,�+�
�	
r�c
�p�|dtjurdn|dtjurdnh|ddkr5|jtjt|d��fi|���d�n+|jtj|d�fi|���d��d|dtjurd��S|dtjurd��S|ddkr7|jtjt|d��fi|���d���S|jtj|d�fi|���d���S)	NrzUNBOUNDED PRECEDINGzCURRENT ROWz
 PRECEDINGz
 FOLLOWINGr�rzUNBOUNDED FOLLOWING)r�RANGE_UNBOUNDED�
RANGE_CURRENTr��literal�abs)r�range_r�s   r��_format_frame_clausez SQLCompiler._format_frame_clauses}���!�9�� 8� 8�8�&��a�y�H�$:�$:�:�"�"�!�9�q�=�	)�D�L�L� (� 0� 0��V�A�Y�� @��DF���(�4�<�<��(8�(8����(C�J�r�J�M��(�!�9�� 8� 8�8�&��+'
�'	
�2�a�y�H�$:�$:�:�"��+'
�'	
�B"�!�9�q�=�	)�D�L�L� (� 0� 0��V�A�Y�� @��DF���
�+'
�'	
�F(�4�<�<��(8�(8����(C�J�r�J�M��+'
�'	
r�c���|jj|fi|��}|jr!d|j|jfi|��z}n/|jr!d|j|jfi|��z}nd}|�ddjd|jfd|jffD��cgc]*\}}|�#t|�r|�d|j|fi|������,c}}|r|gngz��d�Scc}}w)	NzRANGE BETWEEN %szROWS BETWEEN %sz OVER (r�	PARTITION�ORDERz BY r)	r�r�rr�rowsrw�partition_by�order_byr�)r�overr�r�r�wordrs       r��
visit_overzSQLCompiler.visit_over@s ��.�t�|�|�.�.�t�>�v�>���;�;�'�*C�$�*C�*C����+�%�+��F��Y�Y�&�)B��)B�)B��	�	�*�#�*��F��F�
��H�H�
%�d�&7�&7�8� �$�-�-�0�)��)���f��)�c�&�k��6�V�6�6�t�F�v�F�H�)�� &�F�8�2�	/�
�
�	
��s�'/C)c�~�|jj|fi|���d|jj|fi|���d�S)Nz WITHIN GROUP (ORDER BY r)r�r�r)r�withingroupr�s   r��visit_withingroupzSQLCompiler.visit_withingroup]sB��2�K���2�2�4�B�6�B�3�K� � �3�3�D�C�F�C�
�	
r�c�~�|jj|fi|���d|jj|fi|���d�S)Nz FILTER (WHERE r)�funcr��	criterion)r�
funcfilterr�s   r��visit_funcfilterzSQLCompiler.visit_funcfiltercs@��.�J�O�O�.�.�t�>�v�>�3�J� � �3�3�D�C�F�C�
�	
r�c��|jj|j|j�}d|�d|jj|fi|���d�S)NzEXTRACT(r�r)�extract_mapr��fieldr�r�)r�extractr�r*s    r��
visit_extractzSQLCompiler.visit_extractisH��� � �$�$�W�]�]�G�M�M�B���+�G�L�L�+�+�D�;�F�;�
�	
r�c�r�|j|jfi|��}|j|fi|��}d|�d|��S)Nrz).)�visit_function�fnr�)rr�r��compiled_fn�compiled_cols     r��visit_scalar_function_columnz(SQLCompiler.visit_scalar_function_columnps?��)�d�)�)�'�*�*�;��;��(�t�(�(��7�B�7��'��6�6r�c	�x�|�4||j|j|jf|j�t|d|jj�zd�}|r||fi|��}�n8tj|j
�jd�}|r|jri|dz
}nc|j}|jj|�st|tj�r|jj|�n|}|dz}dj|j D�cgc]T}|jj|�st|tj�r|jj|�n|��Vc}|gz�d|j"|fi|��iz}|j$r|dz
}|Scc}w)Nz
visit_%s_funcz%(expr)srr�z WITH ORDINALITY)r�r��getattr�lowerr�r��_deannotater��	_has_argsr��_requires_quotes_illegal_charsr�rr0r�rw�packagenames�function_argspec�_with_ordinality)rr$rvr�r�r�r�r�s        r�r.zSQLCompiler.visit_functionus����(��d�i�i����T�Y�Y�L�$�)�)�L��t�_�t�y�y���/@�@�$�G�����'��'�D��=�=��!1�!1�!3�!=�!=�t�D�D���>�>��J�&�D��y�y���}�}�C�C�D�I�!�$��(<�(<�=��M�M�'�'��-��	��j�(���8�8� $�0�0�� 1��	 �=�=�G�G��L�%�d�H�,@�,@�A��
�
�+�+�C�0�!�!�
 1���&�	���.��.�.�t�>�v�>�?�@�D�� � ��&�&�D����s�*AF7c�8�|j|j�Sr)�visit_sequence�sequence)r�
next_valuer�s   r��visit_next_value_funcz!SQLCompiler.visit_next_value_func�s���"�"�:�#6�#6�7�7r�c�F�td|jjz��)Nz2Dialect '%s' does not support sequence increments.�r�r�r��rr>r�s   r�r=zSQLCompiler.visit_sequence�s$��!�@��l�l���
 �
�	
r�c�<�|jj|fi|��Sr)�clause_exprr�)rr$r�s   r�r:zSQLCompiler.function_argspec�s ��2�t���2�2�4�B�6�B�Br�c
������j}|j|�fi���}|r�js|�_|j}|r�jn�jd}|xs|xr|jdd�}	|dk(r||d<�jj
|d|d|||	d��|jr�j|���j|j}
d	|
zd	zj���fd
�t|j�D��}d�d<|�j|fitdd�i�����z
}|�j |fi���z
}|j"r|�j$|fi���z
}�j&r/|st)�j�nd}�j+|d
��|z}�jj-d�|S)Nr{rFrrrr)rrr$rrrc3�P�K�|]\}}|j�f�|d�������y�w))rSr�Nr�)r*r�rvrSr�rs   ���r�r,z4SQLCompiler.visit_compound_select.<locals>.<genexpr>�sC�����
�2�D�A�q�%��$�$���!'���=C��2�s�#&r�rST�r��include_following_stackr�)r��_compile_state_factoryrr r�r�r�r�r��compound_keywords�keywordrwr��selects�group_by_clauser��order_by_clause�_has_row_limiting_clause�_row_limit_clauserDr�r�rv)
r�csrSr�r�r�r�
compound_stmtr��need_result_maprLr�r�s
` ` `        r��visit_compound_selectz!SQLCompiler.visit_compound_select�s�����z�z�>��1��1�1�"�d�E�f�E�
��D�.�.�!.�D��%�/�/�
�-5��)�)�4�:�:�b�>��"�
���
A��	�	�8�%�@�	��Q�� "�E�*���
�
���#(�):�#;� %�n� 5� �!.�0?�
�	
��*�*��+�+�M�6�B��(�(����4���g�
��#�)�)�
�&�b�j�j�1�	
�
��#(�����$��$�$�R�I�4�+H�v�+H��+H�I�I���$��$�$�R�2�6�2�2��
�&�&��*�D�*�*�2�8��8�8�D��9�9�3;�C��
�
�O��M��'�'�"/�,0�(���	�
�	
�
�
���r���r�c�f�|j�|j|fi|��S|j|fi|��Sr)�
_fetch_clause�fetch_clause�limit_clause)rrRr�s   r�rQzSQLCompiler._row_limit_clause�s>��
���'�$�4�$�$�R�2�6�2�2�$�4�$�$�R�2�6�2�2r�c�R�d|j�d|�|rd|znd��}t||d�S)N�visit_rr�)r�r4)rr��
qualifier1�
qualifier2�attrnames     r�r�z"SQLCompiler._get_operator_dispatch�s5������ *�C�*���2�
��
�t�X�t�,�,r�c�"�|�||fz
}||d<||d<|jry|jrtjd��|j	|jdd�}|r|||jfi|��S|j
|t|jfi|��S|jrX|j	|jdd�}|r|||jfi|��S|j|t|jfi|��Stjd��)NrvrwzFUnary expression does not support operator and modifier simultaneously�unaryr/�modifierz,Unary expression has no operator or modifier)r/rar7r�r�� _generate_generic_unary_operatorrs� _generate_generic_unary_modifier)rr`rvrwr�r�s      r��visit_unaryzSQLCompiler.visit_unary�s8���(��5�(�*��&7�B�"�#�'9�B�#�$��>�>��~�~��&�&�2����.�.�������D���E�5�>�>�8�R�8�8�<�t�<�<��9�U�^�^�4��8:����^�^��.�.�������D���E�5�>�>�8�R�8�8�<�t�<�<��9�U�^�^�4��8:����"�"�>��
r�c��|jjr�|j|jfi|��dz|jt	j
|j|jjjtjur|jjntj��fi|��zS|j|jfi|��dz|j|jfi|��zS)N� / )r��div_is_floordivr�rxr�Castr�r��_type_affinityr%�Numeric�rr�r/r�s    r��visit_truediv_binaryz SQLCompiler.visit_truediv_binary$s����<�<�'�'�����V�[�[�/�B�/����$�,�,��M�M���� &�|�|�0�0�?�?�'�/�/� 0�#�L�L�-�-�"*�!1�!1�!3�
����	�
�(����V�[�[�/�B�/����$�,�,�v�|�|�2�r�2�3�
r�c��|jjrn|jjjt
jur>|j|jfi|��dz|j|jfi|��zSd|j|jfi|��dz|j|jfi|��zzS)Nrfz	FLOOR(%s))	r�rgr�r�rir%�Integerr�rxrks    r��visit_floordiv_binaryz!SQLCompiler.visit_floordiv_binary?s����L�L�(�(����!�!�0�0�H�4D�4D�D�����V�[�[�/�B�/����$�,�,�v�|�|�2�r�2�3�
������V�[�[�/�B�/����$�,�,�v�|�|�2�r�2�3��
r�c��|js|jjr|j|jfi|��Sd|j|jfi|��zS)Nz%s = 1��_is_implicitly_booleanr�r�r�r��rr�r/r�s    r��visit_is_true_unary_operatorz(SQLCompiler.visit_is_true_unary_operatorPsQ���*�*��|�|�3�3��4�<�<����6�2�6�6��l�d�l�l�7�?�?�A�b�A�A�Ar�c���|js|jjr d|j|jfi|��zSd|j|jfi|��zS)N�NOT %sz%s = 0rqrss    r��visit_is_false_unary_operatorz)SQLCompiler.visit_is_false_unary_operatorYsV���*�*��|�|�3�3��l�d�l�l�7�?�?�A�b�A�A�A��l�d�l�l�7�?�?�A�b�A�A�Ar�c�J�d|j|tj��zS)Nrv)�override_operator)�visit_binaryr!�match_oprks    r��visit_not_match_op_binaryz%SQLCompiler.visit_not_match_op_binarybs,���$�+�+��i�&8�&8�,�
�
�	
r�c�>�d|j|t|fi|��zSr�)�_generate_generic_binaryrsrks    r��visit_not_in_op_binaryz"SQLCompiler.visit_not_in_op_binarygs3���5��5�5��I�h�'�
�+-�
�
�	
r�c��|tjur*t|�dkDrddjd�|D��zSy|tjur*t|�dkDrddjd�|D��zSy|j|�S)	Nrz(%s)) OR (1 = 1r�c3� K�|]}d���y�w�r�Nr��r*r�s  r�r,z6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>s�����:�E��f�E���zNULL) OR (1 = 1z(%s)) AND (1 != 1c3� K�|]}d���y�wr�r�r�s  r�r,z6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>zr�r�zNULL) AND (1 != 1)r!�	not_in_opr�rw�in_op�visit_empty_set_expr)rr�	expand_opr�s    r��visit_empty_set_op_exprz#SQLCompiler.visit_empty_set_op_expros����	�+�+�+��5�z�A�~�(��I�I�:�E�:�:���)�
�)�/�/�
)��5�z�A�~�*��I�I�:�E�:�:���+��,�,�U�3�3r�c�F�td|jjz��)Nz3Dialect '%s' does not support empty set expression.rB�r�
element_typesr�s   r�r�z SQLCompiler.visit_empty_set_expr�s$��!�A��l�l���
 �
�	
r�c����	�
��jj�j�}|s�|jrO�jjrdnd�j�jj�j�z}d|fS�j�jg�j�}d|fS|jsB|jr�t|dtj�rst|dttf�sZ|jrtd���jjrdnddj!��fd�t#|�D��z}d|fS|r��j$}|j'|�}|r|j)d�sJd��|j)d�j+d	�}|d
|dc�	�
dj!�	�
��fd�|D��}d|fSdj!��fd
�|D��}d|fS)N�VALUES r�rz?bind_expression() on TupleType not supported with literal_bindsr�c	3��K�|]B\}}ddj�fd�t|�jj�D��z���Dy�w)r�r�c3�H�K�|]\}}�j||����y�wrr�)r*r��
param_typers   �r�r,z[SQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>.<genexpr>�s/������2�-�E�:��1�1�%��D�2�rrN)rwr�r�r�)r*r�r�rrs   ��r�r,zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>�sT������):�$�A�}���I�I��14�)�9�>�>�+?�+?�2����):�s�AAr6�)unexpected format for expanding parameterr�rr
c3�b�K�|]&}���j|�j��������(y�wr�r�r�)r*r�r�r�rrs  ����r�r,zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>�s9�����3�"(��	 ��1�1�%����H� �	�"(�s�,/c3�V�K�|] }�j|�j����"y�wrr�)r*r�rrs  ��r�r,zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>�s*�����3�!'���-�-�e�Y�^�^�D�!'�r)r�)r�r�r�r��tuple_in_valuesr�r�r��_isnullr��collections_abcrr��bytes�_has_bind_expressionr�rwr�r�searchr�r�)rrr��bind_expression_template�typ_dialect_impl�replacement_expression�post_compile_patternr�r�r�r�s``       @@r��2_literal_execute_expanding_parameter_literal_bindsz>SQLCompiler._literal_execute_expanding_parameter_literal_binds�s���%�>�>�A�A�$�,�,�O���
 �.�.�!%���!=�!=�I�2��0�0��N�N�(�(�)�*=�*=��*�&�z�)�)�)�m*.�)E�)E��^�^�$�i�&9�&9�*�&�l�)�)�)�e�
,�
,��$�$��6�!�9�o�&>�&>�?��v�a�y�3��,�7��4�4�)�$���"�\�\�9�9�	�r��	�	��)2�&�(9���
&�"�N�)�)�)�1(�'+�'A�'A�$�(�/�/�0H�I���Q�W�W���?�>�?���g�g�a�j�&�&�t�,��$'��F�C��F�!���)-���3�"(�3�*�&��)�)�)�*.���3�!'�3�*�&�
�)�)�)r�c�p���
���
��jr�j�|�S�j}�jj	|��
�j
r
�j�n�j��jjr�
jr	����
fd��
n�fd��
|smg��
jr4�j�jj�j�}�|fS�j�jg�j�}�|fS�
jsB�
jr�t|dt j"�r�t|dt$t&f�s��
j(rJ�t+|d�D����	cgc]%\}}t+|d�D]\}}	|�d|�d|��|	f���'c}	}}}�|j,rdnddj/�
�fd	�t+|�D��z}�|fSt+|d�D��	cgc]\}}	|�d|��|	f��c}	}�dj/�
fd
��D��}�|fScc}	}}}wcc}	}w)Nc�H���j�j��d|iz�S�Nr�)�render_bind_castr�)r��
bind_templaterrr�s ����r��_render_bindtemplatezNSQLCompiler._literal_execute_expanding_parameter.<locals>._render_bindtemplate�s,����,�,��N�N�$�!�V�T�N�2��r�c����d|izSr�r�)r�r�s �r�r�zNSQLCompiler._literal_execute_expanding_parameter.<locals>._render_bindtemplate�s���$���~�5�5r�rrrr�r�r�c3�z���K�|]0\��ddj����fd�t��D��z���2y�w)r�r�c3�^�K�|]$\}}���t��z|zd����&y�w)rN)r�)r*r�r�r�r�rr�s   ����r�r,zMSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>.<genexpr>
sD������)A�H�A�u�-�%�a�#�m�*<�&<�q�&@�A�!�D��)A�s�*-N)rwr�)r*r�r�r�rs @@��r�r,zCSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>	
sG������):�$�A�}���I�I��)2�-�(@�	���):�s�6;c3�4�K�|]\}}�|����y�wrr�)r*r+r�r�s   �r�r,zCSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>
s�����/�<E�j�c�5�$�S�)�I�r%)r�r�r�r�r�r4r.r-�_bind_typing_render_castsr�r�r�r�r�r�r�r�rr�r��	_is_arrayr�r�rw)rr�rr�r�r�r�r�r�r�r�r�rr�s` `       @@@@r�r�z0SQLCompiler._literal_execute_expanding_parameter�sO����$�$��J�J��6��
��,�,��$�>�>�A�A�'�J����� �9�9�M� �-�-�M�
�L�L�2�2� �1�1�
�
�
6���I��.�.�)-�)E�)E��N�N�(�(�)�*=�*=�*�&�V�0�0�0�O*.�)E�)E��^�^�$�i�&9�&9�*�&�N�0�0�0�G�
,�
,��$�$��6�!�9�o�&>�&>�?��v�a�y�3��,�7�'�1�1�1�1�)2�&�!�(<��(<�$�A�}� )�-�� ;�H�A�u� $�Q��*�E�2� ;�3�(<��I�%�4�4�	�"��	�	��)2�&�(9���
&�"�.�0�0�0�
!*�&�!� 4�� 4�H�A�u�!�!�$�e�,� 4��I�&*�Y�Y�/�<E�/�&�"��0�0�0��;��*s�=*H*
�5H2c	��|�rtj|j�r�|�w|d}|jj	tjt|jj|gz�t|jj|gz���ni|jj	tjt|jj�t|jj���|jrMt|jtj�r)t|jtj�rd|d<|xs|j}|j|dd�}	|	r
|	||fi|��S	t |}
|j"||
f||d�|��S#t$$r}t'j(||�|�d}~wwxYw)N�enclosing_lateralTr�r�)�from_linter�lateral_from_linter)r!�
is_comparisonr/rtrfr��productr)rxr*r�r,r�rrEr�rsr~r^r7r�)rr�ry�eager_groupingr�r�r�r�r�r�r�r�s            r�rzzSQLCompiler.visit_binary 
s����9�2�2�6�?�?�C�"�.�$&�':�$;�!�#�)�)�0�0��%�%�!�"�K�K�5�5�9J�8K�K��"�"�L�L�6�6�:K�9L�L��	�	��!�!�(�(��%�%�!�&�+�+�";�";�<�!�&�,�,�"<�"<�=���
� � ��6�;�;��(>�(>�?��6�<�<��)?�)?�@�$(�B� �!�%�8����	��*�*�9�h��E�����	�0�R�0�0�
�$�Y�/��5�t�4�4����!,�(;�	�
�����
P��5�5�d�I�F�C�O��
P�s�	F.�.	G�7G�Gc�<�|j|jfi|��Sr)r��sql_functionrss    r��&visit_function_as_comparison_op_binaryz2SQLCompiler.visit_function_as_comparison_op_binaryX
s���t�|�|�G�0�0�7�B�7�7r�c�&�|jjr>|j|jfi|��dz|j|jfi|��zS|j|jfi|��dz|j|jfi|��zS)Nz %% r�)r�r�r�rxr�rks    r��visit_mod_binaryzSQLCompiler.visit_mod_binary[
s����=�=�)�)�����V�[�[�/�B�/����$�,�,�v�|�|�2�r�2�3�
�����V�[�[�/�B�/����$�,�,�v�|�|�2�r�2�3�
r�c��|j|d<|j|d|j|j�zdzfi|��S)Nr�r)r�r~r�r�rss    r��visit_custom_op_binaryz"SQLCompiler.visit_custom_op_binaryi
sS��'�6�6����,�t�,�,���$�,�,�X�->�->�?�?�#�E�
��
�	
r�c�b�|j||j|j�dzfi|��Sr�)rbr�r�rss    r��visit_custom_op_unary_operatorz*SQLCompiler.visit_custom_op_unary_operatorq
s:��4�t�4�4��T�/�/��0A�0A�B�S�H�
�LN�
�	
r�c�b�|j|d|j|j�zfi|��Sr�)rcr�r�rss    r��visit_custom_op_unary_modifierz*SQLCompiler.visit_custom_op_unary_modifierv
s:��4�t�4�4��S�4�5�5�h�6G�6G�H�H�
�LN�
�	
r�c���|jdd�}d|d<|j|d<|jj|fd|i|��|z|jj|fd|i|��z}|r|rd|z}|S)Nr�FT�
_binary_opr�r�)r�r/rxr�r�)rr�r�r�r�r�r�s       r�r~z$SQLCompiler._generate_generic_binary{
s���#%�&�&�)B�E�"J��(,��$�%�!�?�?��<��*�F�K�K�*�*��
�%3�
�79�
��
�.�f�l�l�-�-���%3��79��	
�	
�#�~��D�=�D��r�c�B�||jj|fi|��zSrrQ�rr`r�r�s    r�rbz,SQLCompiler._generate_generic_unary_operator�
s$���:�%�-�-�:�:�4�F�2�F�F�Fr�c�B�|jj|fi|��|zSrrQr�s    r�rcz,SQLCompiler._generate_generic_unary_modifier�
s#��/�u�}�}�/�/��;��;�h�F�Fr�c�L�tjdtj��S)Nz'%')r)r�literal_columnr%�
STRINGTYPEr/s r��_like_percent_literalz!SQLCompiler._like_percent_literal�
s���&�&�u�H�4G�4G�H�Hr�c�D�d|jj|fi|���d�S)Nzlower(rrQr�s   r��$visit_ilike_case_insensitive_operandz0SQLCompiler.visit_ilike_case_insensitive_operand�
s)���:����:�:�4�F�2�F�G�q�I�Ir�c��|j�}|j}|j|j�j|�|_|j||fi|��Sr��_cloner��concatr��visit_like_op_binary�rr�r/r��percents     r��visit_contains_op_binaryz$SQLCompiler.visit_contains_op_binary�
sQ��������,�,���~�~�f�l�l�3�:�:�7�C���(�t�(�(���@�R�@�@r�c��|j�}|j}|j|j�j|�|_|j||fi|��Sr�r�r�r�r��visit_not_like_op_binaryr�s     r��visit_not_contains_op_binaryz(SQLCompiler.visit_not_contains_op_binary�
sQ��������,�,���~�~�f�l�l�3�:�:�7�C���,�t�,�,�V�X�D��D�Dr�c��|j�}|j}t|j�|_|j	t|j
��j	|�|_|j||fi|��Sr�r�r�rrxr�r��visit_ilike_op_binaryr�s     r��visit_icontains_op_binaryz%SQLCompiler.visit_icontains_op_binary�
sl��������,�,��,�V�[�[�9����~�~�"�6�<�<�0�
�
�&��/�	��*�t�)�)�&�(�A�b�A�Ar�c��|j�}|j}t|j�|_|j	t|j
��j	|�|_|j||fi|��Sr�r�r�rrxr�r��visit_not_ilike_op_binaryr�s     r��visit_not_icontains_op_binaryz)SQLCompiler.visit_not_icontains_op_binary�
sl��������,�,��,�V�[�[�9����~�~�"�6�<�<�0�
�
�&��/�	��.�t�-�-�f�h�E�"�E�Er�c��|j�}|j}|j|j�|_|j||fi|��Sr)r�r��_rconcatr�r�r�s     r��visit_startswith_op_binaryz&SQLCompiler.visit_startswith_op_binary�
sH��������,�,���'�'����5���(�t�(�(���@�R�@�@r�c��|j�}|j}|j|j�|_|j||fi|��Sr)r�r�r�r�r�r�s     r��visit_not_startswith_op_binaryz*SQLCompiler.visit_not_startswith_op_binary�
sH��������,�,���'�'����5���,�t�,�,�V�X�D��D�Dr�c���|j�}|j}t|j�|_|j	t|j
��|_|j||fi|��Sr)r�r�rrxr�r�r�r�s     r��visit_istartswith_op_binaryz'SQLCompiler.visit_istartswith_op_binary�
s^��������,�,��,�V�[�[�9����'�'�(>�v�|�|�(L�M���)�t�)�)�&�(�A�b�A�Ar�c���|j�}|j}t|j�|_|j	t|j
��|_|j||fi|��Sr)r�r�rrxr�r�r�r�s     r��visit_not_istartswith_op_binaryz+SQLCompiler.visit_not_istartswith_op_binary�
s^��������,�,��,�V�[�[�9����'�'�(>�v�|�|�(L�M���-�t�-�-�f�h�E�"�E�Er�c��|j�}|j}|j|j�|_|j||fi|��Srr�r�s     r��visit_endswith_op_binaryz$SQLCompiler.visit_endswith_op_binary�
sF��������,�,���~�~�f�l�l�3���(�t�(�(���@�R�@�@r�c��|j�}|j}|j|j�|_|j||fi|��Srr�r�s     r��visit_not_endswith_op_binaryz(SQLCompiler.visit_not_endswith_op_binary�
sF��������,�,���~�~�f�l�l�3���,�t�,�,�V�X�D��D�Dr�c���|j�}|j}t|j�|_|j	t|j
��|_|j||fi|��Srr�r�s     r��visit_iendswith_op_binaryz%SQLCompiler.visit_iendswith_op_binary�
s\��������,�,��,�V�[�[�9����~�~�&<�V�\�\�&J�K���)�t�)�)�&�(�A�b�A�Ar�c���|j�}|j}t|j�|_|j	t|j
��|_|j||fi|��Srr�r�s     r��visit_not_iendswith_op_binaryz)SQLCompiler.visit_not_iendswith_op_binary�
s\��������,�,��,�V�[�[�9����~�~�&<�V�\�\�&J�K���-�t�-�-�f�h�E�"�E�Er�c��|jjdd�}|jj|fi|���d|jj|fi|����|�%d|j|tj�zzSdzS)NrMz LIKE � ESCAPE r���	modifiersr�rxr�r�r�r%r��rr�r/r�rMs     r�r�z SQLCompiler.visit_like_op_binary�
s����!�!�%�%�h��5��
+�F�K�K�*�*�4�6�2�6�+�F�L�L�+�+�D�7�B�7�
�
�!�
��2�2�6�8�;N�;N�O�O�	
�	
��

�	
r�c��|jjdd�}|jj|fi|���d|jj|fi|����|�%d|j|tj�zzSdzS)NrMz
 NOT LIKE r�r�r�r�s     r�r�z$SQLCompiler.visit_not_like_op_binary�
s����!�!�%�%�h��5��*�F�K�K�*�*�4�6�2�6�+�F�L�L�+�+�D�7�B�7�
�
�!�
��2�2�6�8�;N�;N�O�O�	
�	
��

�	
r�c���|tjurD|j�}t|j�|_t|j
�|_|j||fi|��Sr)r!�ilike_opr�rrxr�r�rks    r�r�z!SQLCompiler.visit_ilike_op_binarysW���y�)�)�)��]�]�_�F�0����=�F�K�1�&�,�,�?�F�L�)�t�(�(���@�R�@�@r�c���|tjurD|j�}t|j�|_t|j
�|_|j||fi|��Sr)r!�not_ilike_opr�rrxr�r�rks    r�r�z%SQLCompiler.visit_not_ilike_op_binarysW���y�-�-�-��]�]�_�F�0����=�F�K�1�&�,�,�?�F�L�-�t�,�,�V�X�D��D�Dr�c�j�|jjdd�}|j||rdndfi|��S)Nr�Fz BETWEEN SYMMETRIC z	 BETWEEN �r�r�r~�rr�r/r�r�s     r��visit_between_op_binaryz#SQLCompiler.visit_between_op_binarysA���$�$�(�(��e�<�	�,�t�,�,��Y�)�K�
�KM�
�	
r�c�j�|jjdd�}|j||rdndfi|��S)Nr�Fz NOT BETWEEN SYMMETRIC z
 NOT BETWEEN r�r�s     r��visit_not_between_op_binaryz'SQLCompiler.visit_not_between_op_binarysD���$�$�(�(��e�<�	�,�t�,�,��)2�%��
��
�	
r�c�Z�tjd|jjz���Nz/%s dialect does not support regular expressions�r7r�r�r�rks    r��visit_regexp_match_op_binaryz(SQLCompiler.visit_regexp_match_op_binary&�*�����=��l�l���
 �
�	
r�c�Z�tjd|jjz��rrrks    r�� visit_not_regexp_match_op_binaryz,SQLCompiler.visit_not_regexp_match_op_binary,rr�c�Z�tjd|jjz��)Nz;%s dialect does not support regular expression replacementsrrks    r��visit_regexp_replace_op_binaryz*SQLCompiler.visit_regexp_replace_op_binary2s*�����I��l�l���
 �
�	
r�c	�^�|s�|jj|j�}|jr�|j	|�}	|j
|	fd||xr
|j||d�|��}
|jrutjd|
�}|sJd��d|jd��d|jd��d	|jd
��d�}
|r|j|fd|
d�|��}d
|zS|
S|s3|xs|jxs|xr|j}|xs|j}
nd}
|r(|j|fddi|��}|jrd
|z}|S|j|�}||jv�r5|j|}||u�r!|js|jrb|j j#|j �s=|j$j#|j$�st'j(d|z��|j|jk7rt'j(d|�d���|j*s|j*r]|j*r!|j*rt'j(d��t'j(d|j,�d|j,�d���|x|j|j,<|j|<|j.}|rH|\}}|j$D]4}|j,|vs�||j,}||j1|��6|j2rd|_|
r8|rd|_|r|xj8|hzc_n|xj:|hzc_|j<|f|
|j|jd�|��}|jrd
|z}|S)NT)�skip_bind_expressionr\�
literal_bindsr��render_postcompilez&^(.*)\(__\[POSTCOMPILE_(\S+?)\]\)(.*)$r�z(__[POSTCOMPILE_r6r�rz~~REPL~~r
z~~]))r\r�r�Fr\zIBind parameter '%s' conflicts with unique bind parameter of the same namez"Can't reuse bound parameter name 'z�' in both 'expanding' (e.g. within an IN expression) and non-expanding contexts.  If this parameter is to receive a list/array value, set 'expanding=True' on it for expressions that aren't IN, otherwise use a different parameter name.a)Encountered unsupported case when compiling an INSERT or UPDATE statement.  If this is a multi-table UPDATE statement, please provide string-named arguments to the values() method with distinct names; support for multi-table UPDATE statements that target multiple tables for UPDATE is very limitedzbindparam() name 'z�' is reserved for automatic usage in the VALUES or SET clause of this insert/update statement.   Please use a name other than column name when using bindparam() with insert() or update() (for example, 'b_z').)�post_compile�	expanding�bindparam_type)r��dialect_implr�r��bind_expressionr�rrLr
r�r�r�r,�_truncate_bindparamr(r�r��intersectionrHr7r��_is_crudr+r@r��
isoutparam�has_out_parametersr5r=r>r�)rr�r\rrr�r
r��implr�wrappedr�r@rr��existingr�rnrmrKrMs                     r��visit_bindparamzSQLCompiler.visit_bindparam8s���$��>�>�.�.�t�|�|�<�D��(�(�"&�"6�"6�y�"A��&�$�,�,�#��)-�*?�"/�"K�	�8K�8K�4K�$3�'9�
�����&�&����A�7��A��I�I�I�1�����
�����
�����
��G�%�;�d�;�;�%��26�5<��%�	�� &��|�+�����D��,�,�D�)�B�d�.B�.B�
�
+�A�i�.A�.A�L� �L��/�$�/�/���15��9?��C��"�"��s�l���J��'�'�	�2���4�:�:���z�z�$�'�H��y�(��_�_�	�(8�(8�$�.�.�;�;�!�+�+��%�0�0�=�=�!�-�-���*�*�A�CG�H����'�'�9�+>�+>�>��*�*�:>�@����&�&�)�*<�*<��(�(�Y�-?�-?�"�.�.�&�
�
�"�.�.�0�����@"�#,�-�-���5�	�	�8A�@��
�
�9�=�=�!�D�J�J�t�$4��/�/�
��#�J�D�$��+�+���6�6�T�>��b�f�f��B���H�O�O�I�.�,�
���&*�D�#��!�+/��(���+�+�	�{�:�+��(�(�Y�K�7�(�#�d�#�#��
�%��)�)�$�>�>�	
�
�
������3�,�C��
r�c��t��rr�)rr�
dbapi_typerJs    r�r�zSQLCompiler.render_bind_cast�s��!�#�#r�c���|tur|}n�|j��|j�x|jdd�}|rC|tj
tjfvr!tjd|jf�|jtjfi|��S|j}|jr|j}||||��\}}	|	S|j!||j"�S)Nr�z�Bound parameter '%s' rendering literal NULL in a SQL expression; comparisons to NULL should not use operators outside of 'is' or 'is not')r�)r.r�r�r�r!�is_�is_notr&�warn_limitedr+r�r%r�r�rr�r�r�)
rr�r�r�r�r��op�leeprrs
          r�r�z$SQLCompiler.render_literal_bindparam�s��� �v�-�(�E����&�9�+=�+=�+E��V�V�L�$�/���"�Y�]�]�I�4D�4D�$E�E��%�%�@�#���(�	�$�t�|�|�H�$5�$5�<��<�<��-�-�E�����J�J�D�*.���)A�+�'�I�'�
$�#��,�,�U�I�N�N�C�Cr�c��|�9|js-|jtjj	��S|j|j�}|r		||�Stjdtj|��d|����#t$r5}tjdtj|��d|�d��|�d}~wwxYw)aRender the value of a bind parameter as a quoted literal.

        This is used for statement sections that do not accept bind parameters
        on the target driver/database.

        This should be implemented by subclasses using the quoting services
        of the DBAPI.

        Nz Could not render literal value "z" with datatype z); see parent stack trace for more detail.z:No literal value renderer is available for literal value ")�should_evaluate_noner�r�Null�	_instance�_cached_literal_processorr�r�r7r��sql_util�_repr_single_value)rr�r�	processor�es     r�r�z SQLCompiler.render_literal_values����=��!;�!;��<�<��
�
� 7� 7� 9�:�:��3�3�D�L�L�A�	��	
� ��'�'��"�"���/�/��6�7�8!�!&��)��
���
��&�&�� �3�3�E�:�;�<%��g�#�#���
��
�s�B�	C�0C	�	Cc���||jvr|j|S|j}t|tj�r|jd|�}||j|<|S)Nr�)r)r+r�rrDrr)rr�r�s   r�rzSQLCompiler._truncate_bindparam&s^������'��?�?�9�-�-��M�M�	��i��!:�!:�;��2�2�;�	�J�I�&/����	�"��r�c��||f|jvr|j||fS|j|j�}t|�|jdz
kDr]|j
j
|d�}|dt|jdz
d�dzt|�ddz}|dz|j
|<n|}||j||f<|S)N�rrrr6)	r`�	apply_mapr_r�r]rar��max�hex)r�ident_classr��anonname�counter�	truncnames      r�rrz!SQLCompiler._truncated_identifier3s���
���$�"6�"6�6��'�'��d�(;�<�<��>�>�$�-�-�0���x�=�4�,�,�q�0�0��.�.�2�2�;��B�G���S��!2�!2�Q�!6��:�;����g�,�q�r�"�#�
�
5<�a�K�D�$�$�[�1� �I�4=����k�4�0�1��r�c� �||jzSr�r_�rr�s  r��
_anonymizezSQLCompiler._anonymizeHs���d�m�m�#�#r�c����|�|j|�|�|j|�|s>�jj|�r#�jj	�fd�|�}	|}|	}|r"�j
j
||i��_|rGd|z}
|r|
S|�:|j�j�}|jr�j|||
�}
|
S�jtjur�jd|iz}
n�jd|iz}
|�P�jj r:|j�j�}|jr�j|||
�}
|
S)Nc�@���j|jd�S)Nr)rr�)r�rs �r�r�z.SQLCompiler.bindparam_string.<locals>.<lambda>es���d�8�8������Dr�z__[POSTCOMPILE_%s]r�)�addr�rr�r�r?r�r�r��render_literal_castr�r�r`rar.r-r�)rr�rr�escaped_fromr�accumulate_bind_names�visited_bindparamr��new_namer@�	type_impls`           r�r�zSQLCompiler.bindparam_stringKss���!�,�!�%�%�d�+��(��$�$�T�*���&�&�-�-�d�3� �2�2�6�6�D���� $�����&*�&=�&=�&C�&C��t�$�'�D�#��&��-�C���
��)�*�B�B��L�L��	��0�0��/�/��	�3�O�C��J�
�Z�Z�=�2�2�
2��/�/�6�4�.�@�C��#�#�v�t�n�4�C�
�&����6�6�&�>�>�t�|�|�L�I��)�)��+�+�N�I�s�K���
r�c���|j�}|jdd�t|j|j�D]\}}|j
|fd|i|���y)N�cte_opts)�copyrvr�r��_independent_ctes_optsr�)r�stmtr��local_kw�cte�opts      r�r�z&SQLCompiler._dispatch_independent_ctes�s[���7�7�9�����Z��&���"�"�D�$?�$?�
�H�C��
#�C�"�"�4�B�#�B��B�
r�c�"
���j�}	|	�jusJ�||d<|j}
t|
tj
�r�j
d|
�}
d}d}|j�}
|jxs|j}|
�jvr��j|
\}}}||
k(sJ�||
f}�j|}|jr�|jrtjd��||
f}|rt�j�nd}||
fx}}�j|=|�j|<||fz�j|
<n=|rt�j�nd}||
f}|�jvr�j|}nd}|��||u}||jus||urd}n�||jur-|	|=|j�}||
usJ�||usJ��j|=n[t!|�t!|�k(s)|j"�|j"�|j%|�rd}ntjd|
z��|s|sy|j&�O|j&}|j&j}t|tj
�r�j
d|�}n|}d}|�r�|�j|<||fz�j|
<|�jvr�j(|fi|��|�s]||	v�rX|j*rd�_�j.j1||
�}|j*r^|j2}|j5d�D�����cgc]\}}}}}|s|xs|��}}}}}}|dd	j7�fd
�|D��zz
}|j9dd�dusJ��js|j2j:�fd|i|��S�j<||j>fi|��} |j2j:�fddi|��}!|d
| �d|!�d�z
}|j@r$|d�j<||j@fi|��zz
}||	|<|r�|r|
|jB|jE�<|s|r�j.j1||
�S|rh�j.j1||�}�j.jG|
�r�j.jI|
�}
|�jK|
�z
}|S�j.j1||
�Sycc}}}}}w)N�visiting_cter�TFz6CTE is stated as 'nest_here' in more than one locationrz5Multiple, unrelated CTEs found with the same name: %rr�r�c3�l�K�|]+}�jj|�j�����-y�w)r8N)r��format_label_namer_)r*�identrs  �r�r,z(SQLCompiler.visit_cte.<locals>.<genexpr>:s:�����"�*4��!�M�M�;�;� %��
�
�<��*4�s�14�subqueryrSr�z
(rr)&r�rDr�r�rrDrr�_get_reference_cte�nestingrFrEr7r�r�r��	_restates�hash�_is_clone_of�compare�
_cte_alias�	visit_cte�	recursiverGr��format_aliasr��_generate_columns_plus_namesrwr�r��_generate_prefixes�	_prefixes�	_suffixesrsr)�_requires_quotesr��get_render_as_alias_suffix)"rrJrS�ashint�	fromhintsrMr�rEr��	self_ctes�cte_name�
is_new_cte�embedded_in_current_named_cte�_reference_cterS�	cte_levelr�existing_cte_opts�cte_level_name�existing_cte�old_level_name�new_level_name�existing_cte_reference_cte�
pre_alias_cte�cte_pre_alias_namer��
col_source�
proxy_name�fallback_label_namerv�repeated�
recur_cols�prefixesr�s"`                                 r�rYzSQLCompiler.visit_cte�s�����(�(�*�	��D�I�I�%�%�%�!$��~���8�8���h�� 9� 9�:��1�1�'�8�D�H��
�(-�%��/�/�1���+�+�1��!1�!1���T�3�3�3�.2�.D�.D��/�+�I�q�+���=� �=�'��2�N��2�2�>�B�L�
���$�,�,��*�*�1���
#,�X�!6��/6�C��
�
�O�A�	�3<�h�2G�G����+�+�N�;�:F��'�'��7�9G��K�:��&�&�~�6�
,3��D�J�J���I�'��2�N���!8�!8�8�#�6�6�~�F��#���#�,8�L�,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� �K�K��5�"'�J�
�*�*�,�.6�7���
�j���>�>�%��N�N�M�!$���!4�!4���,�h�.G�.G�H�%)�%?�%?��/�&�"� �M�!%���69�D�#�#�N�3�5C��G�6�D�"�"�>�2��D�I�I�-�����}�7��7�%�#�Y�*>��=�=�*.�D�'��}�}�1�1�#�x�@���=�=�!$���J�")�E�E�d�K�"�L�
��&�/��$�'�,�9�z�9�L��"� �F��	�	�"�*4�	"����D��z�z�*�e�4��=�=�=��z�z�:�3�;�;�9�9���%+��/5��� 7�t�6�6��S�]�]� �.4� �H�;�C�K�K�:�:���%)��-3��E��h��>�>�D��=�=��C�"9�$�"9�"9��S�]�]�#�.4�#���D�"&�	�#����5=��!�!�#�-�-�/�2��"?��}�}�1�1�#�x�@�@�!��}�}�1�1�#�7I�J���=�=�1�1�(�;�#�}�}�2�2�8�<�H���7�7��A�A�����}�}�1�1�#�x�@�@���G"s�Tc��|jrd|d<|jr|j|fi|��S|j|fi|��S)Nr�)�joins_implicitly�_is_lateral�
visit_lateral�visit_aliasr�s   r��visit_table_valued_aliasz$SQLCompiler.visit_table_valued_aliasnsN���#�#� $�B�}�����%�4�%�%�g�4��4�4�#�4�#�#�G�2�r�2�2r�c�(�|j|fi|��Sr)r�r�s   r��visit_table_valued_columnz%SQLCompiler.visit_table_valued_columnvs�� �t� � ��/�B�/�/r�c

����
�|r&d�
vr�jsJ���
d<|	r
d�
vr	d�
vr|	�
d<|�@|j�ur2�jj�f|||||�d��
��}|r
|s|rd|�d�}|S�x}�
d<|s|rMt�jt
j�r�jd�j�}n�j}|r�jj��S|r�|	r|	j�j�<�jj�fd|d	��
��}|rd|�d�}|�j�jj���z}
�jr8�jr,|
d
dj��
�fd��j D��zz
}
|r�|vr�j#|
�|�|�}
|
S�jj�fd
|i�
��S)Nr�r�)rSrb�iscrudrc�lateral�enclosing_aliasrrr�r�T)rSr�r�r�c3���K�|]m}�jj|j���jr4d�jj
j|jfi���znd�����oy�w)� %sr�N)r�r�r��_render_derived_w_typesr�r�r�r�)r*r�r�r�rs  ���r�r,z*SQLCompiler.visit_alias.<locals>.<genexpr>�s}������$+�C�!�M�M�/�/����9�$)�#@�#@�	!&�"M�$�,�,�"E�"E�"M�"M�$'�H�H�#"�06�#"�!"�
&(�!(�	�$+�s�A3A6r�)rzr�r�r�r�rrDrrr�r[rsr)ra�_supports_derived_columns�_render_derivedrwrv�format_from_hint_text)rr�rSrbr�rcrQr�r�r�r�r��
alias_namer@s``        `   r�r|zSQLCompiler.visit_aliasys4����"�&�0��(�(�(�(�.3��*�+�
�)��7�'�6�1�0;��,�-��&�?�+B�+B�e�+K�4�E�M�M�4�4��	����#�� %�	��	�E��V�w��"'�)���L�:?�?�O�f�%6�7��V��%�*�*�h�&?�&?�@�!�7�7�����L�
�"�Z�Z�
���=�=�-�-�e�Z�@�@�
��7A��!�!�%�/�/�"3�4�4�E�M�M�4�4���!�7��6<��E��"'�)���$�9�9��
�
�*�*�5�*�=���C��.�.�5�3H�3H��v��I�I��$)�7�7������$�U�i�/��0�0���	�%� 0�&����J�4�5�=�=�3�3���%��)/��
r�c�2�d|d<|j|fi|��S)NTrQ�r|)rrQr�s   r��visit_subqueryzSQLCompiler.visit_subquery�s#����:���t����/�B�/�/r�c�8�d|d<d|j|fi|��zS)NTr�z
LATERAL %sr�)r�lateral_r�s   r�r{zSQLCompiler.visit_lateral�s)����9�
��.�d�.�.�x�>�2�>�>�>r�c���|j|fddi|���d|j�j|fi|����}|j�#|d|jj|fi|��zz
}|S)NrSTz
 TABLESAMPLE z REPEATABLE (%s))r|�_get_methodr��seed)r�tablesamplerSr�r�s     r��visit_tablesamplezSQLCompiler.visit_tablesample�s����D���[�<��<��<�8�K�#�#�%�8�8��D��D�
��
���'��&�3�� � �3�3�D�?�B�?��
�D��r�c������jd�j�dj���fd��jD��}d|��S)Nrr�c	3��K�|]I}|D]B}�jtj|d�ji�j	�fi������D�Ky�w)r�N)r�rr�
_column_typesr�)r*�chunk�elemr�r�rs   ���r�r,z-SQLCompiler._render_values.<locals>.<genexpr>�se�����	
�'����
�D�L�L����26��!�/�/���*�,�
��	
��
�'���AAr�)�
setdefaultrrw�_data)rr�r��tupless``` r��_render_valueszSQLCompiler._render_values�sG���
�
�
�o�w�'<�'<�=����	
�!���	
�	
�����!�!r�c
�(����j|fi���}|jrd}nMt|jtj
�r�j
d|j�}n|j}|jrd}nd}|r�|r!|�|nd|j|j�<|r`d�d<|�d|�d�j�jj|���d	d
j��fd�|jD���d�}|S|�d|�d�}|S)Nr�zLATERAL r�z(unnamed VALUES element)Fr�rr� (r�c3�D�K�|]}|j�fi������y�wrr�r�s  ��r�r,z+SQLCompiler.visit_values.<locals>.<genexpr>s+�����"�%4��1�A�0�0��<��<�%4�r�)r��_unnamedr�r�rrDrrrzrsr)rar�r�rw�columns)rr�rSr�r�rqr�r�s`   `   r��visit_valueszSQLCompiler.visit_valuess����D����.�2�.������D�
����h�&?�&?�
@��-�-�h����E�D��<�<�D���� �G��G��� �,�D�2L��!�!�'�"3�"3�"5�6��&+��?�#����3�3�D�M�M�4G�4G��4M�N��	�	�"�%,�_�_�"��
����!(��+���r�c�0�d|j|fi|���d�SrP)r�r�s   r��visit_scalar_valueszSQLCompiler.visit_scalar_values&s%���&�4�&�&�w�5�"�5�6�a�8�8r�c��d|zS)Nr�r�)r�alias_name_texts  r�raz&SQLCompiler.get_render_as_alias_suffix)s
����'�'r�c���|sJ�|�|dk(rd|_d|_|jrtjd��|j
j
t||||��y)N�*FTzxMost backends don't support SELECTing from a tuple() object.  If this is an ORM query, consider using the Bundle object.)r2r1r�r7r�r�r�r�rs     r�r�zSQLCompiler._add_to_result_map,sk����w��?�g��n�$)�D�!�#'�D� �����"�"�4��
�
	
���#�#��w��g�u�=�	
r�c�8�|jd||d|�in|fi|��S)aLRender a column with necessary labels inside of a RETURNING clause.

        This method is provided for individual dialects in place of calling
        the _label_select_column method directly, so that the two use cases
        of RETURNING vs. SELECT can be disambiguated going forward.

        .. versionadded:: 1.4.21

        NF)�_label_select_column)rrHr�r��column_clause_argsr�s      r��_label_returning_columnz#SQLCompiler._label_returning_columnEs:��)�t�(�(�����$�,�B�2D�
��

�	
r�c
�<����jj|j�}
|
jr|s|r|
j	��}n�}|r#|j
}|
r|��fd�}n|�ur|���fd�}nd}|	sJd��t
�tj�r-|�ur%t|�j�jf��}�n8|}�n4|r%|�Jd��t|||�jf��}�n
|�urd}n�t
�tj�r"|xr�jxr�jdu}nst
�tj �rd}nVt
�tj"�r�j$xs|}n+t
�tj&�s�j(�d}nd}|rS|s|
rJ��j*}t
|tj,�stj,|�n|}t|||f��}n|}|j/|	||�	�|j0|fi|��S)
z.produce labeled columns present in a select().c����|||f|�yrr�)r�r�r�rr�s    �r�rvz;SQLCompiler._label_select_column.<locals>.add_to_result_map�s���&�w��w�j�%�Hr�c�$���||�f|z|�yrr�)r�r�r�rr�r�s    ��r�rvz;SQLCompiler._label_select_column.<locals>.add_to_result_map�s���&����y�7�':�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\rvr�)r�rr��_has_column_expression�column_expressionr�r�rrHr�r�r�r�rFr�r��
TextClause�UnaryExpression�wraps_column_expression�NamedColumn�_non_anon_label�_anon_name_labelrDrfr�)rr�r�r�rSr�r�rsrtr\�column_is_repeated�need_column_expressionsr�r�col_exprrv�result_expr�render_with_labelr�s  `               @r�r�z SQLCompiler._label_select_columnZsf��� �{�{�'�'����5���&�&�#�':��-�-�f�5�H��H��
!%� 7� 7��
"�%6�"�I�
��'�%6�"��!%��%�	
�
:�	
�$��f�h�n�n�-��v�%�+��f�k�k�f�n�n�5F���'��
��&�
<�;�
<�&�(�����$�$���K�&�v�%�%)�!��F�H�$9�$9�:��1�"�-�-�-�1����D�0�"�
�F�H�$7�$7�8�$)�!��F�H�$<�$<�=�$*�$B�$B�$L�f�!�
�v�x�';�';�<��*�*�2�$(�!�$)�!� �*�
 2�1�1�*0�*A�*A�'�&�+�X�-F�-F���-�-�.A�B�-�$�,��1�j�]���'���!�!�"7�/�'�	"�	
�
.�{�-�-�d�I�6H�I�Ir�c�>�|j||�}|r|d|zz
}|Sr�)�get_from_hint_text)rrJr��hintr��hinttexts      r�r�z!SQLCompiler.format_from_hint_text�s*���*�*�5�$�7����s�X�~�%�G��r�c��yrr�)r�byfromss  r��get_select_hint_textz SQLCompiler.get_select_hint_text���r�c��yrr��rr�r�s   r�r�zSQLCompiler.get_from_hint_textr�r�c��yrr�r�s   r��get_crud_hint_textzSQLCompiler.get_crud_hint_text
r�r�c�$�dj|�Sr�r�)r�
hint_textss  r��get_statement_hint_textz#SQLCompiler.get_statement_hint_text
s���x�x�
�#�#r�rr�rrc��|j}|r|jn|jd}|j||�}|d}|d}	|r&|s$|j|j	|	�d��}
|
S|j||	��}
|
S)Nr{rrr���explicit_correlate_froms�implicit_correlate_froms)r�r�rJ�_get_display_froms�
difference)r�select_stmtrSr�r�r�r�rrrrss           r��_display_froms_for_selectz%SQLCompiler._display_froms_for_selects����z�z�>��-5��)�)�4�:�:�b�>��#�:�:�;��M�
�� 1�2���^�,���'�!�4�4�)8�)C�)C� �*�*,�	5��E���	"�4�4�)8�)5�5��E��r��translate_select_structurec	��%�|�Jd��d|	d<|j||fi|	��}
|
j|	d<|
j}|j}|r|js|
|_|duxs|}|j
r?|j
|fd|i|	��}
|
|ur&|
}|}|
}|j||fi|	��}
|
j}|r|jn|jd}|xs&|jdd�xs|jdd�x}}|rd}|sd	|	vr|	d	=|j||
||||�}|	j�}|jddd
��d}|jr|j|�\}}|r||dzz
}nd}|jr|j||	�|jr!||j ||jfi|	��z
}||j"|fi|	��z
}|
j$D�����cgc]#\}}}}}|j'||||||||||�
�
��%c}}}}}D�cgc]}|�|��}}|r�|��t)t+|
j$D�����cgc]
\}}}}}|��c}}}}}j$D�����cgc]
\}}}}}|��c}}}}}���%|j,D���� cgc]'\}}}} t/||t1�%fd�|D��| ���)c} }}}|_|j3|||
|||||	�}|j4rQ|j4D�!�"cgc]!\}!}"|!d|j6j8fvr|"��#}#}!}"|#r|d|j;|#�zz
}|j<r2|r|r.|st?|j�nd}$|jA|$��|z}|jBr$|d|j ||jBfi|	��zz
}|jjEd�|Scc}}}}}wcc}wcc}}}}}wcc}}}}}wcc} }}}wcc}"}!w)NzpSQLAlchemy 1.4 requires use of the translate_select_structure hook for structural translations of SELECT objectsFr\r�rSr{rrrv)rqr\zSELECT r)r�rsrtr�r�c3�B�K�|]}�j||����y�wrr)r*�orFs  �r�r,z+SQLCompiler.visit_select.<locals>.<genexpr>�s�����$F�#�Q�Y�]�]�1�a�%8�#�s�r�r�)#rJ�_ambiguous_table_name_mapr r�rr�r�r��_setup_select_stackrFrf�_hints�_setup_select_hintsr�r�r^r]�get_select_precolumns�columns_plus_namesr�r�r�r�r�r.�_compose_select_body�_statement_hintsr�r�r�rDr�r�r_rv)&rr�rS�insert_intorcr��select_wraps_forr�r�r�rr��is_embedded_select�new_select_stmt�compile_state_wraps_forr�r�r�rsr�r��	hint_text�byfromr�rsrtr�rurv�
inner_columnsr+r�r�dialect_name�ht�per_dialectr�rFs&                                     @r��visit_selectzSQLCompiler.visit_select;s ��� �'�	
�
-�	
�'�+0��&�'�:��:�:���
�!'�
�
�
�3�3�	�)�*�$�-�-���z�z�>���D�.�.�!.�D��+�4�7�F�;��
�*�*�=�d�=�=���$*��.4��O��k�1�*7�'�#.� �-�� B�� B� B���!�)/�!�
�,�5�5��-5��)�)�4�:�:�b�>��
�
>��y�y�7��?�
>��y�y�5�u�=�	
��5��"'��
#�':�f�'D��*�+��(�(����v�w��
��$�[�[�]���!�!�$)�E�J�	
������ $� 8� 8�� E��I�v���	�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��s�E�#���u�$F�#�$F�F���.B�	$�D� ��(�(���������	
���'�'�+6�*F�*F��*F�&�\�2��C����):�):�#;�;��*F�
��
���d�:�:�;�G�G�G���9�9�0�H�3;�C��
�
�O��M��*�*��*�G�$�N�D�� � ��C�1�$�1�1��[�2�2��6<���
�D�	
�
�
���r�����y��
��@	��	��$��&s$�&(O�O�O�+O(�,O1
�&O9c��|jj�D���cic];\\}}}|d|jjfvr||d|j	|d��iz��=}}}}|j|�}||fScc}}}w)Nr�r�T)rb)r�rgr�r�r�r�)rr�r�r�r�r�r�s       r�r�zSQLCompiler._setup_select_hintss���/5�m�m�.A�.A�.C�
�/D�*� ���(��3���� 1� 1�2�2�
�8��u�/�/��T�/�B�C�D�
D�.C�	�
��-�-�f�5�	��&� � ��
s�AA8c	��|d}|d}|dk(r||d<nf|rd|d}	t|	j�}
t|j�|
k7r2tjdd|
|dzt|j�fz��|r%|s#|j|j
|�d��}n|j||��}tt|��}|j|�}
||
||d	�}|jj|�|S)
Nrrrrz}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %drr�r�)rrr$r)r�rur�r7r�r�r�ror*r�r�r�)rr�rr�rSr�r�rrr�numcolsrs�new_correlate_froms�all_correlate_fromsr�s               r�r�zSQLCompiler._setup_select_stacks;�� � 1�2���^�,���Q�� &�E�*��
��Z�(�H��(�8�8�9�G��=�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	
�,�|dj|�z
}|jtzr1tit	��}	|jt
z}
|r|	|_nd}	d}
|s|j�}|r�|dz
}|jr8|dj|D�cgc]}|j|fd||	d�|����c}�z
}nJ|dj|D�cgc]}|j|fd|	d�|����c}�z
}n||j�z
}|jr)|j|jfd|	i|��}|r|d|zz
}|
r|	�J�|	j�|jr||j|fi|��z
}|j r'|j|j fi|��}|r|d	|zz
}|j"r||j$|fi|��z
}|j&r||j(|fi|��z
}|j*�||j,|fi|��z
}|Scc}wcc}w)
Nr�Fz 
FROM T)rSrcr��rSr�r�z 
WHERE z	 
HAVING )rwrWrgrkrorhr��rstripr�r�rC�_where_criteriar�r��_group_by_clausesrN�_having_criteria�_order_by_clausesrOrPrQ�_for_update_arg�for_update_clause)
rr�r�rr�rsr�r�r�r��warn_linting�f�ts
             r�r�z SQLCompiler._compose_select_bodyHs���	
��	�	�-�(�(���<�<�4�4�$�R���/�K��<�<�,�6�L��#.�� ��K� �L���;�;�=�D���J��D��}�}���	�	�"'�	�"'�A�-��,�,� ��#'�&,�(3�	�
%��"'�	������	�	�"'��"'�A�
-��,�,� ��#'�(3��%�	�"'��
�
��
�D�%�%�'�'�D��!�!�1��1�1��&�&��4?��CI��A����a��'����*�*�*������#�#��(�D�(�(��:�6�:�:�D��"�"�1��1�1��'�'��+1��A����q�(�(���#�#��(�D�(�(��:�6�:�:�D��*�*��*�D�*�*�6�<�V�<�<�D��!�!�-��*�D�*�*�6�<�V�<�<�D����q	��s�H
�
H
c�N���dj��fd�|D��}|r|dz
}|S)Nrc3��K�|]7\}}|dvs|�jjk(r|j�fi������9y�w))Nr�N)r�r�r�)r*�prefixr�r�rs   ��r�r,z1SQLCompiler._generate_prefixes.<locals>.<genexpr>�sI�����
�(0�$����{�*�l�d�l�l�>O�>O�.O�
&�F�%�%�d�1�b�1�(0�s�=Ar�)rrHrwr�rs`  ` r�r]zSQLCompiler._generate_prefixes�s1������
�(0�
�
��
��c�M�F��
r�c�v�|jsy|r�|dkDr�tj�}t|jj	��D]g}|j
|j
�\}}}|jxs|j}||k(xs|xr||dzk(}	|r|	s�V|j|||<�in|j}|syt|D�cgc]}|j��c}�}
|j|
�dz}|dj|j�D�cgc]}|��c}�z
}|dz
}|r{|dkDrvt|j	��D]Z}|j
|j
�\}}}|j|=|j||f=|j
|j
�=�\|Scc}wcc}w)z�
        include_following_stack
            Also render the nesting CTEs on the next stack. Useful for
            SQL structures like UNION or INSERT that can wrap SELECT
            statements containing nesting CTEs.
        r�rr�, 
z
 )rDr&r�r��keysrFrRrSrgrZ�get_cte_preamblerwr�rE)
rr�rIrDrJrirerErS�is_rendered_levelrG�cte_text�txts
             r�r�zSQLCompiler._render_cte_clause�s����y�y���]�Q�.��#�#�%�D��D�I�I�N�N�,�-��04�0F�0F��*�*�,�1�-�	�8�X��+�+�9��)9�)9��$-��$>�%�+�N�	�]�Q�=N�0N�"� �$5�� �I�I�c�N��S�	�.��9�9�D����t�<�t��c�m�m�t�<�=���(�(��8�3�>���F�K�K����
� >�
���
� >�?�?���E����]�Q�.��D�I�I�K�(��04�0F�0F��*�*�,�1�-�	�8�X��I�I�c�N��+�+�Y��,A�B��*�*�3�+A�+A�+C�D�
)����=��!?s�F1�	F6
c�
�|ryy)NzWITH RECURSIVE�WITHr�)rrZs  r�rzSQLCompiler.get_cte_preamble�s���#�r�c�h�|jrtjdd��|jrdSdS)zcCalled when building a ``SELECT`` statement, position is just
        before column list.

        aDISTINCT ON is currently supported only by the PostgreSQL dialect.  Use of DISTINCT ON for other backends is currently silently ignored, however this usage is deprecated, and will raise CompileError in a future release for all backends that do not support this syntax.z1.4��versionr�r�)�_distinct_onr&�warn_deprecated�	_distinct�rr�r�s   r�r�z!SQLCompiler.get_select_precolumns�s:��
���� � �3�
�

�%�.�.�{�6�B�6r�c�x�|j|jttjfi|��}|rd|zSy)z5allow dialects to customize how GROUP BY is rendered.z
 GROUP BY r�)r�r�rsr!�comma_op)rr�r��group_bys    r�rNzSQLCompiler.group_by_clause�sG��1�4�0�0��$�$�i�	�0B�0B�&C�
�GI�
����(�*�*�r�c�x�|j|jttjfi|��}|rd|zSy)z5allow dialects to customize how ORDER BY is rendered.z
 ORDER BY r�)r�r�rsr!r)rr�r�rs    r�rOzSQLCompiler.order_by_clausesG��1�4�0�0��$�$�i�	�0B�0B�&C�
�GI�
����(�*�*�r�c��y)Nz FOR UPDATEr�rs   r�r�zSQLCompiler.for_update_clauses��r�c���|jdtj|���D�����	cgc]"\}}}}}	|j|||f||	||d�|����$}
}}}}}	ddj	|
�zScc}	}}}}w)NT)�cols)rtr�r�rs�
RETURNING r�)r\r�_select_iterablesr�rw)rrH�returning_colsr�r�r�rsrtr�rur�s           r��returning_clausezSQLCompiler.returning_clauses���2�2�2��4�1�1�.�A�3��#
�"�
���#���
)�D�(�(���#�	
�%8�#+��%�	
��	
� �#	�
�,�d�i�i��0�0�0��-
s�'A.c���d}|j�#|d|j|jfi|��zz
}|j�4|j�|dz
}|d|j|jfi|��zz
}|S)Nr�z
 LIMIT z

 LIMIT -1z OFFSET )�
_limit_clauser��_offset_clause)rr�r�r�s    r�rYzSQLCompiler.limit_clause6s��������+��K�,�$�,�,�v�/C�/C�"J�r�"J�J�J�D�� � �,��#�#�+��
�%���J�����f�.C�.C�!J�r�!J�J�J�D��r�c��|�|j}|j}nddd�}d}|j�K|j}|r!|j|�r|j	�}|j
|fi|��}	|d|	zz
}n|r|dz
}|�O|r!|j|�r|j	�}|d|j
|fi|���|drdnd�d	|d
rdnd��z
}|S)
NF)r��	with_tiesr�z
 OFFSET %s ROWSz
 OFFSET 0 ROWSz
 FETCH FIRST r�z PERCENTz ROWS r!z	WITH TIES�ONLY)rW�_fetch_clause_optionsr�_simple_int_clause�render_literal_executer�)
rr�rX�require_offset�"use_literal_execute_for_simple_intr��fetch_clause_optionsr��
offset_clause�
offset_strs
          r�rXzSQLCompiler.fetch_clause@s����!�/�/�L�#)�#?�#?� �/4�5�#I� ���� � �,�"�1�1�M�2��-�-�m�<� -� D� D� F�
�%����m�:�r�:�J��'�*�4�4�D�
��&�&�D��#�2��-�-�l�;�+�B�B�D�������\�0�R�0�2�9�=�
�2�E�3�K�@��f�L��
�D�
�r�c	�R�|r|j|j|<|s|�r|jj|�}
|rG|
rE|jj	|
�dz|jj|j�z}n�|jj|j�}|
s]|r[|j|vrM|jd||j�}||j|jjd|��z}|r||vr|j|||||�}|Sy)Nrr�r�)�fullnamersr�r�r�r�r�rrrar[r�)
rr�rSr�rbrc�
use_schemar�r�r�r�r@�	anon_names
             r��visit_tablezSQLCompiler.visit_tableis%���',�~�~�K���e�$��V�#�}�}�>�>�u�E���.��M�M�.�.�/?�@����m�m�)�)�%�*�*�5�6���m�m�)�)�%�*�*�5��)�0��
�
�&>�>� $� :� :��!9�%�*�*�!E�!�I��� ?� ?��
�
�2�2�4��C�!��C��U�i�/��0�0���	�%� 0�&����J�r�c���|ri|jjtjt	|j
j�t	|jj���|jrd}n|jrd}nd}|j
j|fd|d�|��|z|jj|fd|d�|��zdz|jj|fd|i|��zS)Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN Tr�� ON r�)rtrfr�r�r)rxr*r�ru�isouterr��onclause)rrwrSr�r��	join_types      r��
visit_joinzSQLCompiler.visit_join�s
������$�$��!�!��d�i�i�5�5�6��d�j�j�6�6�7��
��9�9�+�I�
�\�\�+�I� �I�(�D�I�I�(�(��
�!�{�
�>D�
��
�,�d�j�j�+�+���!�{��>D��	
��
�/�d�m�m�.�.���"-��17��
�
	
r�c�"�|jj�D���cic]%\\}}}|d|jjfvr||��'}}}}|j|vr+|j||j||jd�}||fScc}}}w)Nr�T)r�rgr�r�r�r�)rrH�
table_textr�r�r��
dialect_hintss       r��_setup_crud_hintszSQLCompiler._setup_crud_hints�s���04�{�{�/@�/@�/B�
�/B�+� ���)��3���� 1� 1�2�2�
�9��/B�	�
�
�:�:��&��3�3��D�J�J�
�d�j�j�(A�4��J��j�(�(��
s�*B
c��|jj}|j}|j}|�y|jr'|j
j
|jd�}n&|jj
|jd�}||zr|S|jr3tjd|d�d|jj�d���y)a)given a :class:`.Table`, return a usable sentinel column or
        columns for this dialect if any.

        Return None if no sentinel columns could be identified, or raise an
        error if a column was marked as a sentinel explicitly but isn't
        compatible with this dialect.

        NrzColumn z@ can't be explicitly marked as a sentinel column when using the a� dialect, as the particular type of default generation on this column is not currently compatible with this dialect's specific INSERT..RETURNING syntax which can receive the server-generated value in a deterministic way.  To remove this error, remove insert_sentinel=True from primary key autoincrement columns; these columns are automatically used as sentinels for supported dialects in any case.)
r��"insertmanyvalues_implicit_sentinel� _sentinel_column_characteristicsr��
is_autoinc�_sentinel_col_autoinc_lookupr��default_characterization� _sentinel_col_non_autoinc_lookup�is_explicitr7r-r�)rr��
sentinel_opts�sentinel_characteristics�	sent_cols�bitmasks      r��_get_sentinel_column_for_tablez*SQLCompiler._get_sentinel_column_for_table�s������G�G�
�#(�#I�#I� �,�4�4�	����#�.�.��7�7�;�;�(�A�A�1��G��;�;�?�?�(�A�A�1��G��7�"���#�/�/��)�)��)�A�,��(>��<�<�$�$�%�&@�
@��
�r�c
#�����@�A�B�C�DK��j}|�J�|jsd}	ntj|j�}	t	|�}
|j
r�jjsd}d}nE�jjr&|r)�jr|j�|jrd}d}nd}d}|rNttdt||��d�D]*\}
\}}t||�|g|	r	|	|�gngd|
|
||�
���,y|r,t!j"�j$j&|��}nd}|j(}|r||�}d|�d�}|j+|d�}�jj,}|rAt	�j.�}t	|j0�}||z
}t3|||z
|z�}td	t5|��}td	t5|��}d}d}
|
|z|
|zrdnd
z}|j0}|�J�|r$|D����cgc]\}}}}||||�|f��}}}}}d
x�C�D�j6s��j8r
�j8�Ani�At;|d
�} �A�fd��@|j<rd}!nd
}!ddj?�@fd�|D���|!�d�}"| jA�Afd�|D��}#| jC|#�D�cic]}||d
|��
}$}d
�Bn�d
}"t;�}#i}$|j<rd|�d��Bnd|�d��Bt;�}%|j0D]}&|%jE|&d��|%r]�jF}'|'�J�t|'�D�(�)chc]\}(})|)|%vr|(��
}*}(})t3|*��CtI|*�dz�Dt	|*��D�Cz
k(sJ��jJr9tMjN�jP�}+tMjR|+�d�d�B��B|�r[|d
|},|d
|}-g|d
|g|d
||r|}.nt	|,�}.�r,�fd�tU|.�D�D�/�0�1cgc]\}/}0}1|/|0|1f��
}}0}/}1�j6�r|jV}2|2t	|,d
�k(rdx}3}4|,}5n|,d
d�C}3|,d
�Dd}4�C�Dfd�|,D�}5|j<r'd
j?�Bfd�t|,�D��dd}6n�B|.zdd}6�jJr9|2d
kDr4|4rJ��Cdz}7|2|.z|7z}8tY�fd�tU|7|8�D��}9|6|9z}6|j+d|6�}:tYtZj\j_|5��};|3|;z|4z};n�g}<|$ja�};t|,�D]�\}=}|"j+dtc|=��}>|j<r|>j+dtc|=��}>|<je|>�|;jE|#D�cic]
}|�d|=��||��c}���|j+ddj?|<��}:t|:|;||,|	r|-D�?cgc]
}?|	|?���c}?ng|.|
||d�
��|
dz
}
|r��Zyycc}}}}wcc}wcc})}(wcc}1}0}/wcc}wcc}?w�w)NTFzKSequence[Tuple[_DBAPISingleExecuteParams, _MutableCoreSingleExecuteParams]]r�r�rr�__EXECMANY_TOKEN__zList[Sequence[Any]]rc���|D]G}�j||�}|j�jd|iz�jd|�d�iz�}�I|S)Nr��__EXECMANY_INDEX__)r�r�r-)r�	formattedr+r?rs   ��r��apply_placeholderszISQLCompiler._deliver_insertmanyvalues_batches.<locals>.apply_placeholders�sg����C�,�0�0��c�:�C� )� 1� 1��)�)�V�S�M�9��)�)�!�c�U�*<�#=�>�?�!�I� �!� r�z, _IMV_VALUES_COUNTERr�r�c3�:�K�|]\}}}}�||����y�wrr�)r*rrL�	bind_keysrMs    �r�r,z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>�s)�����6�2D�.�A�q�)�Y�#�9�i�8�2D�r�c3�Z�K�|]"\}}}}|D]}�j||�����$y�wrr)r*rrOr+r?s    �r�r,z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>�s<�����4�*<�&�A�q�!�Y�$�C�#�&�&�s�C�0�$�1�*<���(+z, _IMV_VALUES_COUNTER), z), r
z\d+r�c3�H�K�|]}�D]\}}}|�d|��||f����y�w)rNr�)r*ror+�len_r��generic_setinputsizess     �r�r,z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>s>�����/�%>�E�.C�N�C��s� �5��%��)�4��5�.C�6�%>�rrr�c3�(�K�|]	}|�����y�wrr�)r*rl�expand_pos_lower_index�expand_pos_upper_indexs  ��r�r,z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>s"�����&�!&�A��0�1G�H�!&�s�c3�Z�K�|]"\}}�jdt|�����$y�w)�_IMV_VALUES_COUNTERN)r�r�)r*r�r�executemany_values_w_commas   �r�r,z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>$s5����� �)9���1�7�>�>� 5�s�1�v��)9�rQ���c3�>�K�|]}�j�|�����y�wr)r/)r*r�rs  �r�r,z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>As)�����&�!2�A� �>�>�?��s�C�!2�r��EXECMANY_INDEX__rY�__)3r;rAr/r>r�r6r��supports_default_metavalue�supports_multivalues_insertr�r?r=r�rr�rE�	functools�partialr�r�r7r��insertmanyvalues_max_parametersr)r9�minr�rQr?rorCrwrr�rfr%r1r4rLrMr/r��ranger;r.r�r��
from_iterablerFr�r�)Err r!�compiled_parametersrT�
batch_sizer<r��imv�_sentinel_from_params�	lenparams�use_row_at_a_time�
downgradedrM�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_batchesrIrNr9r�r+r��st�all_keys�imv_values_counter�formatted_values_clause�keys_to_replace�base_parameters�all_names_we_will_expandr�r%r?r��all_expand_positions�escapedrJ�compiled_batchrL�new_keyrSr��num_ins_params�extra_params_left�extra_params_right�batch_iterator�expanded_values_stringr}rir�rFrG�replaced_values_clausesr��fmvrMrMr?rZrVrWsE`   `                                                           @@@@@r��!_deliver_insertmanyvalues_batchesz-SQLCompiler._deliver_insertmanyvalues_batches!s������$�$�������&�&�$(�!�$,�$7�$7��(�(�%�!��
�O�	����t�|�|�'N�'N�!%���J����9�9�#��$�$��%�%�-��1N�1N�
!%���J� %���J��5>��a��
�$7�8���6�1��1�5�.�-���)��G�1�/�~�>�?�����+����6�.
���#�#��
�
�7�7�%9��C�
�C�!$�!7�!7���%(�)?�%@�"� �!7� 8��:���%�%�&8�:N�O�	��\�\�A�A�
��"%�d�o�o�"6��#&�s�'=�'=�#>� �#�&:�:�
(����"=�=�+�,��J��,�d�:�.>�?���!�4�(;�#<�
��HL����!�Z�/��Z�'�A�Q�
�
�!�3�3��!�-�-�-��+=�"�*<�&�C��d�B��c�3�t�9�b�)�*<�
�"�;<�;��!7�����&�&�%)�%<�%<�"�%'�"��:�a�=�)�H�
!��'�'�%<�"�%'�"�*+�D�I�I�6�2D�6�-�,�"�"�!�''�#�
'�3�3�4�*<�4��O�$�.�.��?��?�C��Z��]�3�'�'�?�
��*,�&�&(�#�!�e�O� �O��'�'��.�/�/G�H�+�01�1G�0H��-L�*�14��$��.�.��(�/�/��Q��8�/�(�"�.�.��"�.�.�.�&/�{�%;�(�%;�	��T��7�7��%;�%�(�
*-�-A�)B�&�),�-A�)B�Q�)F�&��,�-�-�0F�F�G��G��"�"��)�)�D�$G�$G�H��-/�V�V��y��$�d�,F�.�*���A�j�)�E�-�a�
�;�N�$&�G�A�j�!�-/��Q�z�*��%/�"�%(��Z�"�$�/�%*�+=�%>�/�+�/�*���s��d�C�(�/�(�+����!$�!B�!B��"�S��q��]�2�=?�?�%�(:�%*�N�(-�a��1H�2H�(I�%�).�q��2H�2I�)J�&�&�!&�&�N�
�+�+���� �)2�%�(8�	 ���r�.�*�4�6H�H��r�.�*��&�&�>�A�+=� 2�1�1�2�Q�6�E�(�,>�?�%�G�C�!&�&�!&�u�c�!2�&�!�I�.D�i�-O�*�%.�%6�%6�(�*@�&�"�',��O�O�1�1�.�A�'�#�
&�)�*�(�)�$�+-�'�&5�&:�&:�&<�#� )�%� 0�H�A�u�1�9�9�*�C��F��C��/�/�!�k�k�*?��Q��H��+�2�2�3�7�'�.�.�>M�N�o�s�C�5��1�#���c�
�2�o�N��!1�&/�%6�%6�(��I�I�5�6�&�"�
)�"�#�'��-�:H�H��2�*�2�.��H��"���'���
� 
��M�H�I��o"��P��:(��D+��xO��I�sX�HY%�Y
�1B"Y%�Y	�#A;Y%�Y�.B5Y%�#Y�3FY%�Y
�9Y%�Y �&Y%�?&Y%c
����|j|�fi|��}|j}|�||d<d}n
�j}|r-d�_�js|�_�j
s|�_�jj
t�t�|d��d}d}�jr|�g}tj�|||fd|i|��}�jrB|�@t|�}�jr)�j��xj|z
c_
n|�_
|j}	|	sn�jj sX�jj"sB�jj$s,t'j(d�jj*z��|j,r��jj.s,t'j(d�jj*z���j0s|j2r!|j4rt'j(d	��|j}	n|j}	�j6}
�jj }d
}|j8r!|�j:||j8fi|��z
}|dz
}|
j=|j>�}
|j@r�jC||
�\}}
|jDr�jG||�||
z
}|	s|s,|dd
jI|	D��cgc]	\}}}}|��c}}�zz
}|jJ}d}d}d}�j0xs|j2}|r�|jL}|��|sJ�|	D���cic]
\}}}}||��}}}}g}|D]7}||vrd}n/�jO|�}|||vrd}n|j
|��9|�@�jjPtRjTzrd}n|djVrJd��tY|�tY|�z}�j[|||��}�j\r|d|zz
}nd}|j^���j`�jddfddi|��}�jbrL�jjdr6|st�j�nd}|d�jg|d���|��z
}�n�|d|zz
}�n�|	sf|rd|dz
}|�r�tid�jjjtmd|	�||j4|jndu||rt|�nd|��	�_8�n}|j,r*|dd
jId�|jrD����z
}�nGd
jItmd|	�D��cgc]	\}}}}|��c}}�}|�r|r��jjPtRjtzr�|jvs�d}�jjPtRjxz} d
jId�t{|	�D��}!| r$d
jI�fd�t{|	�D��}"n|!}"|d|"�d|�d|!�d �z
}nd}|d!|�d"�z
}tid|tmd|	�||j4|jndu||rt|�nd|||�#��_8n	|d!|�d"�z
}|jn�'�j`|jnfi|��}#|#r|d|#zz
}|r�j\s|d|zz
}�jbrE�jjds/|st�j�nd}�jg|d��|z}�jj}d�|Scc}}wcc}}}wcc}}w)$NrMFTr�rrAzWThe '%s' dialect with current database version settings does not support empty inserts.zcThe '%s' dialect with current database version settings does not support in-place multirow inserts.zcRETURNING cannot be determinstically sorted when using an INSERT which includes multi-row values().zINSERT zINTO � (%s)r�zTsentinel selection rules should have prevented us from getting here for this dialect�r�rr{rr�rHr�z DEFAULT VALUESr8)r<r=r?r@rBz VALUES c3�RK�|]}ddjd�|D��z���!y�w)r�r�c3�*K�|]\}}}}|���
y�wrr�)r*rr�s   r�r,z5SQLCompiler.visit_insert.<locals>.<genexpr>.<genexpr>ts���� L�^�>�1�a����^�s�Nr�)r*�crud_param_sets  r�r,z+SQLCompiler.visit_insert.<locals>.<genexpr>rs3�����+N����y�y� L�^� L�L�N�*M�s�%'c3�,K�|]\}}d|�����y�w��pNr�)r*r�rs   r�r,z+SQLCompiler.visit_insert.<locals>.<genexpr>�s����)�,I�D�A�q�!�A�3��,I�s�c3��K�|]L\}^}}�j|j|jj�j�d|������Ny�wr�)r�r�r�r�)r*r�r�rrs    �r�r,z+SQLCompiler.visit_insert.<locals>.<genexpr>�sX�����4�1N���9�C�!�!�1�1� #��� #��� @� @���� N�"#�A�3���
1N�s�AAz SELECT z FROM (VALUES (z)) AS imp_sen(z#, sen_counter) ORDER BY sen_counterz	 VALUES (r)r6r7r9r;r<r=r?r@rArBrC)?rJr r�r r�rr�rorQr�_get_crud_paramsr�r4rA�
single_paramsr��supports_default_valuesr_�supports_empty_insertr7r�r��_has_multi_parametersr`r&�
_returning�_sort_by_parameter_orderr�r^r]�format_tabler�r�r9r�r�rw�use_insertmanyvalues�use_sentinel_columnsrr;rRr[�_insert_sentinelr�rr*r�r�rD�cte_follows_insertr�r5�default_metavalue_tokenr�_post_values_clauser;�all_multi_paramsr]�is_default_metavalue_onlyr^r�rv)$r�insert_stmtrArMr�rr��counted_bindparam�crud_params_struct�crud_params_singler�r�r�r7rr�r��named_sentinel_params�add_sentinel_colsrBrr��param_names�_params_by_col�_add_sentinel_col�
param_namer�select_textr�r�rs�embed_sentinel_value�render_bind_casts�colnames�colnames_w_cast�post_values_clauses$`                                   r��visit_insertzSQLCompiler.visit_insert|s����;��:�:���
�!#�
�
�$�-�-���#�!-�B�~���H��:�:�~�H�� �D�M��)�)�)6��&��%�%�%2��"��
�
���#&�5� #��)�
�	
���!���?�?�|�3�
!#��!�2�2�����	
�
0�
��

���?�?�0�<� #�$5� 6���"�"��)�)�5��*�*�.?�?�*�->�D�*�/�=�=��#��L�L�8�8��L�L�;�;��L�L�6�6��"�"��!�\�\�.�.�/��
��.�.��<�<�;�;��&�&�1�37�<�<�3D�3D�E����'�'�;�+A�+A��6�6��&�&�I���"4�!A�!A��!3�!A�!A���=�=��"&�,�,�"F�"F����� � ��+�D�+�+��[�2�2��68��
�D�	
�����*�*�;�+<�+<�=�
���� �2�2�;�
�K�M�A�z��(�(��+�+�K��<��
����%<��G�d�i�i�+=�>�+=�-�!�T�1�a��+=�>���
�D� 2�F�F��9=�� ��!���0�0�J�K�4J�4J��� 2� G� G�� �,�+�+�+�3E�"�2D�.��Q��;���$�2D��"�)+�%�):�%�(��>�04�-��!%�!C�!C�)�"�J�"��8I�)J�J�04�-��)�0�0��<�*;�)�0����G�G�6�H�H�I�-1�)�$5�Q�#7�#H�#H��D��H�"&�n�!5��=N�8O�!O��#�4�4���$,� 5� ���-�-���.�.�.�� $�����)�&�$�,�,��
�
�2��3�4��BF��JL��K��y�y�T�\�\�<�<�7?��D�J�J��T�
���+�+�&3�04�,�� �������+�+��#�(?��%�%�D�#�):���L�L�8�8��9�;M��&�#�<�<�$�7�7�t�C�%6�2C��-�.��&7�#*��&�&�
0�
0���	�	��+=�*M�*M����
�D�)-�	�	�+/�9�*�+��+���1�e�Q��+��)�%�$�%����G�G�6�M�M�N�
0�I�I�,0�(����G�G�6�N�N�O�&�
 $�y�y�)�,5�6H�,I�)� �H�)�+/�)�)�4�1:�:L�0M�
4�+��+3���"�?�"3�4$�$=�#>�?&�&.�Z�0/�/��D�,1�(��i�(A�'B�!�D�D�D�):�$)�'@�'+�9�*�(�3D�#�<�<�$�7�7�t�C�%6�2C��-�.��(=�&7�)=�)*��&�0�)�$=�#>�a�@�@���*�*�6�!-�����/�/�"�35�"��"���0�0�0���D�$B�$B��C�*�*�*�D��9�9�T�\�\�<�<�3;�C��
�
�O��M��'�'�"/�,0�(���	�
�	
�
�
���r�����s?��0"��^s�;]�]%�;],
c��y)z3Provide a hook for MySQL to add LIMIT to the UPDATENr�)r�update_stmts  r��update_limit_clausezSQLCompiler.update_limit_clause����r�c��y)z3Provide a hook for MySQL to add LIMIT to the DELETENr�)r�delete_stmts  r��delete_limit_clausezSQLCompiler.delete_limit_clause�r�r�c�6�d|d<|j|fddi|��S)z|Provide a hook to override the initial table clause
        in an UPDATE statement.

        MySQL overrides this.

        TrSr�r�)rr��
from_table�extra_fromsr�s     r��update_tables_clausez SQLCompiler.update_tables_clause�s*����8��,�z�,�,�T�E�$�E�"�E�Er�c��td��)z~Provide a hook to override the generation of an
        UPDATE..FROM clause.

        MySQL and MSSQL override this.

        zCThis backend does not support multiple-table criteria within UPDATEr��rr�r�r��
from_hintsr�s      r��update_from_clausezSQLCompiler.update_from_clauses��"�
%�
�	
r�c�|�|j||fi|��}|j}|�||d<d}n
|j}|r-d|_|js||_|j
s||_|jtzr1tit��}|jtz}|r||_nd}d}|j}t|�}	|	rDtt|j��}
|D�cgc]	}||
vs�|��}}|
j!|�}
ng}|jh}
|jj#|
|
|d��d}|j$r!||j&||j$fi|��z
}|j(||j|fd|i|��}t+j,||||fi|��}|j.}|j0r|j3||�\}}nd}|j4r|j7||�||z
}|dz
}|dj9d	�t;d
|�D��z
}|j<s|j>r>|j@r2|d|jC||j<xs|j>|��zz
}|r,|jD||j||fd|i|��}|r|d|zz
}|jFr)|jH|jFfd|i|��}|r|d
|zz
}|jK|�}|r|d|zz
}|j<s|j>r>|j@s2|d|jC||j<xs|j>|��zz
}|jLr.|stO|j�nd}|jQ|��|z}|r|�J�|jSd��|jjUd�|Scc}w)NrMFTr�zUPDATE r�z SET r�c3�6K�|]\}}}}|dz|z���y�w)�=Nr�)r*rr�r�s    r�r,z+SQLCompiler.visit_update.<locals>.<genexpr>`s.����
�&�!��4���
�3�J���&�s�zList[Tuple[Any, str, str, Any]]rr�� WHERE r��UPDATE�r�r{)+rJr r�r!r�rrWrgrkrorhr��_extra_fromsrr*r�r�r�r^r]r�rr�r�r�r9r�r�rwrr&r�r*rr�r�r�r�rDr�r�r�rv)rr�rMr�rr�r�r�r��
is_multitable�
main_fromsr��render_extra_fromsrr�r7r��crud_paramsr8�extra_from_textr�rYr�s                       r��visit_updatezSQLCompiler.visit_updatesN��:��:�:���
�!#�
�
�$�-�-���#�!-�B�~���H��:�:�~�H�� �D�M��)�)�)6��&��%�%�%2��"��<�<�4�4�$�R���/�K��<�<�,�6�L��#.�� ��K� �L�#�0�0���[�)�
���]�;�+<�+<�=�>�J�&�"�&�a�!�:�*=��;�
�"�)�.�.�{�;�O�!#��*�0�0�1�O��
�
���#2� /�)�
�	
���� � ��+�D�+�+��[�2�2��68��
�D�/�T�.�.������
�$�	
�
�
�
�"�2�2��+�}�h�
�:<�
��)�6�6�����(,�(>�(>��Z�)�%�M�:�!�M��(�(��+�+�K��<��
���������	�	�
�%)�1�;�&�
�
�	
���"�"�k�&<�&<��-�-���d�3�3���+�+�E�{�/E�/E�(0�4������5�d�5�5���!�!�"��	�
(���
�O����o�-�-���&�&�1��1�1��+�+��9D��HJ��A���	�A�
�%���/�/��<����C�,�&�&�D�
�#�#�{�'=�'=��0�0��C�$�/�/���'�'�A�;�+A�+A�$,�0���
�D��9�9�3;�C��
�
�O��M��*�*��*�G�$�N�D���*�*�*����x��0��
�
���r�����S"s�*	N9�4N9c��td��)z�Provide 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�s      r��delete_extra_from_clausez$SQLCompiler.delete_extra_from_clause�s��"�
%�
�	
r�c�.�|j|fddd�|��S)NT)rSr�r�)rr�r�r�r�s     r��delete_table_clausezSQLCompiler.delete_table_clause�s,��,�z�,�,��
��d�
�.0�
�	
r�c��|j||fi|��}|j}|�||d<d}n
|j}|r-d|_|js||_|j
s||_|jtzr1tit��}|jtz}|r||_nd}d}|j}|jhj|�}	|jj|	|	|d��d}
|j r!|
|j"||j fi|��z
}
|
dz
}
	|j%||j||��}t+j,||||fi|��|j.r|j1||�\}
}nd}
|j2r|j5||�|
|z
}
|j6s|j8r>|j:r2|
d|j=||j6xs|j8|�	�zz
}
|r,|j>||j||
fd
|i|��}|r|
d|zz
}
|j@r)|jB|j@fd
|i|��}|r|
d|zz
}
|jE|�}|r|
d|zz
}
|j6s|j8r>|j:s2|
d|j=||j6xs|j8|�	�zz
}
|jFr.|stI|j�nd}|jK|��|
z}
|r|�J�|jMd
��|jjOd�|
S#t&$r@|j%||j|�}|r|j)|j|��}Y��AwxYw)NrMFTr�zDELETE �FROM )r�rr�r�r�r��DELETEr�r{)(rJr r�rr�rrWrgrkrorhr�r�r�r�r�r^r]r��	TypeErrorr�rr�r�r9r�r�r&r�r*rr�r�r�r�rDr�r�r�rv)rr�rMr�rr�r�r�r�rr�r7rr8r�r�rYr�s                  r��visit_deletezSQLCompiler.visit_delete�s���:��:�:���
�!#�
�
�$�-�-���#�!-�B�~���H��:�:�~�H�� �D�M��)�)�)6��&��%�%�%2��"��<�<�4�4�$�R���/�K��<�<�,�6�L��#.�� ��K� �L�#�0�0��&�,�,�-�3�3�K�@���
�
���#2� /�)�
�	
���� � ��+�D�+�+��[�2�2��68��
�D�	
����	M��1�1���!�!��'�	2��J�	
���d�K���O�B�O����(,�(>�(>��Z�)�%�M�:�!�M��(�(��+�+�K��<��
���
�#�#�{�'=�'=��,�,��C�$�/�/���'�'�A�;�+A�+A�$,�0���
�D��;�d�;�;���!�!���	�
(���
�O����o�-�-���&�&�1��1�1��+�+��9D��HJ��A���	�A�
�%���/�/��<����C�,�&�&�D�
�#�#�{�'=�'=��0�0��C�$�/�/���'�'�A�;�+A�+A�$,�0���
�D��9�9�3;�C��
�
�O��M��*�*��*�G�$�N�D���*�*�*����x��0��
�
���r�����U�	M��1�1��[�.�.���J���L�L��!2�!2��L�L���	M�s�+M�AN�Nc�>�d|jj|�zS)NzSAVEPOINT %s�r��format_savepoint�r�savepoint_stmtr�s   r��visit_savepointzSQLCompiler.visit_savepoint3s����
�
� >� >�~� N�N�Nr�c�>�d|jj|�zS)NzROLLBACK TO SAVEPOINT %sr�r�s   r��visit_rollback_to_savepointz'SQLCompiler.visit_rollback_to_savepoint6s#��)�D�M�M�,J�,J��-
�
�	
r�c�>�d|jj|�zS)NzRELEASE SAVEPOINT %sr�r�s   r��visit_release_savepointz#SQLCompiler.visit_release_savepoint;s#��%��
�
�(F�(F��)
�
�	
r�)r�r\r r�r�r�rUr$rVrrWrerkzOptional[SQLCompiler]r�r)rr7)rr%)rzDict[Any, Any])rzMutableMapping[CTE, str])rzVMutableMapping[str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]]])NT)r�r�r�rrr)NNTNTF)r�r�r�r�r�rr�z
Optional[int]r�rrSrrr[�F)r!r[rTrrr)rzCallable[[Any], str])NFFNr�)NTr�N)r��ColumnClause[Any]rv�Optional[_ResultMapAppender]r�rrwr�r�z Optional[_AmbiguousTableNameMap]r�rrr�r)NF)r$z
Function[Any]rvr�r�rrr�)FN�Nr�)NFNN)FFFFF)r3r�r�rDrr�)r�r�rr�)FFNNNN)r�r�rrrrr?r7rzOptional[TypeEngine[Any]]r@zOptional[Set[str]]rAr9r�rrr�)rJrMrSrrbrrczOptional[_FromHintsType]rMz
Optional[CTE]r�zOptional[FromLinter]rEzselectable._CTEOptsr�rrr7)FFFNFFNN)
r�r�r�r�r�r�rr�rr)NNNTFFT)FFNNNFN)r�rrzTuple[str, _FromHintsType]�
rHrBrzSequence[ColumnElement[Any]]r�rr�rrr�)NFF)FFFNTNN)r�rJrr>)r r�r!rWrgz%List[_MutableCoreSingleExecuteParams]rTrHrhr:r<rr�r�rz Iterator[_InsertManyValuesBatch]rm)�r�r�r�r��EXTRACT_MAPr)r&r�rr�r��COMPOUND_KEYWORDSrKrr r!r#r$r&r'r*r+r,r0r1r2r3r4r5r6r8r:r;r<�	frozensetr=r>r�r?r�postfetch_lastrowidr@r%rArBrCrLrNrr��patternr�r�r�rJrfr�r3rs�ro_memoized_propertyrwryr~r��memoized_propertyr��memoized_instancemethodr��
contextlib�contextmanagerr�rirhr�r�r�r�r�r�r�rj�preload_modulerrr6rArCrNrTrWrhrnr{rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr"r'r,r2r.r@r=r:rUrQr�rdrlrortrwr|rr�r�r�r�rzr�r�r�r�r�r~rbrcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rr�r.r�r�rrrr:r�r�r$�_CTEOptsrYr}rr|r�r{r�r�r�r�rar�r�r�r�r�r�r�r�r<rr�r�r�r�r�r�r�r]r�rr�rNrOr�rrYrXr/r5r9r,�
CLIENTSIDErRr\�SENTINEL_DEFAULT�NONErYrZr@r�rXr>rFr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	s�
����K�	������������	
�	
�� ;�
��:/�.�6�6�
�F�)���H�d���H�d���H�d���
+�*�%�.0�O�*�/��.0�O�*�/�$�BF��>�E���K���(�(�I�-�-�6�%�$�4�',��t�+��5:�+�T�9��
"�O�T�!����B�!�!��%(�'��
.�-��
&+��d�*��"�O�T�!��"��d�!��).���-��!�N�D� ��!&���%��=A� �"9�@��+/��-�.��
6:��2�9�59��2�9�=A��:�A�<E�K��9�G��
:C���6�D��
8<����4�F��
��� ��%�	
���
��(,�K�$�+��.2��*�1�.2��+�2��F�D��
,�,�3�2�G�F���&�B�J�J�'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�vG�R
���
�
�
��
�8#�����
6:�!�
�2�
��
�
�	
�26:�GK�!�'+�� %�~�2�~�E�~��	~�
%�~��
~��~�
)�~�@
�!�!�$�"�$�L�
3��
3� %�C�3�C��C�
�	C�J�T���3�4�
�5�
�4�3�	������
����T���3�4�P�5��P�d
����T���3�4�,�5��,�\�>�@O�O�.3�-
�`.3�+�`�!�#�"��/�b
�
/�;?�"�.0�EI�
9O�!�9O�8�9O��	9O�
,�9O�#C�
9O��9O�

�9O�vA���
��
�

�405�2�h���
��"@�L��&�&K�
�(
�T
�:
�
�
�7�;?�,��,�8�,��	,�


�,�\8�
�C�04�?�B3�-�AC�$�L�6�"B�B�
�

�4�$
�;?�H*�TM1�d��� �
6�p8��
�
�

�05��*G�G�
���I��I�J�A�E�B�F�A�E�B�F�A�E�B�F�

�	
�A�E�
�
�
�
�
�$��"�� �c�J$�$�!%�	D�B#�J����&6��	��*$�#��&*�48�48�15�A��A��A��	A�
$�A�2�
A� 2�A�/�A��A�

�A�FC���.2�&*�,0�(;�
�(;�(;�E�(B�V�
�V��V��	V�
,�V�$�
V�*�V�&�V��V�
�V�p3�0���������b�H0�?��"�$�L9�(�
��
��
�!�	
�
�
�
�

�4EI�
�8�� �"� � %��bJ�H����$�.�-����1�t�1�1����
-��	��/L�M� 
��
,1��:'+���*���������K�Z
!�!�
!�	#�
!�2�h]�~�� %�3�j�7� 	�
��1��1�5�1�
"�1��
1�

�1�@���+0�'�X������!%�.�`
�<
)�"(:�t�'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
AE�p�d��F�
�K�Z
� 
�
A�FO�
�

r�rc���eZdZdZd�Zejd��fd��Zd�Zd�Z	d�Z
d�Z										dd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Z�xZS)�StrSQLCompilera�A :class:`.SQLCompiler` subclass which allows a small selection
    of non-standard SQL features to render into a string value.

    The :class:`.StrSQLCompiler` is invoked whenever a Core expression
    element is directly stringified without calling upon the
    :meth:`_expression.ClauseElement.compile` method.
    It can render a limited set
    of non-standard SQL constructs to assist in basic stringification,
    however for more substantial custom or dialect-specific SQL constructs,
    it will be necessary to make use of
    :meth:`_expression.ClauseElement.compile`
    directly.

    .. seealso::

        :ref:`faq_sql_expression_string`

    c��y)Nz<name unknown>r�r~s  r�rz$StrSQLCompiler._fallback_column_nameUs��r�zsqlalchemy.engine.urlc�T��|jdk7r�tjj}|jj|j�j
��}|j|d|��}t|t�s|j|fi|��St�|�1||�S)Nr�)rk)
�stringify_dialectr&r�
engine_url�URLr��get_dialect�statement_compilerr�r�r�r�r�)rr�r�r��urlr��compilerr�s       �r�r�z,StrSQLCompiler.visit_unsupported_compilationXs�����$�$�	�1��.�.�+�+�C�M�c�g�g�n�n�W�%>�%>�?�K�K�M�O�G��1�1���4�2��H��h��7�'�x�'�'��6�2�6�6��w�4�W�c�B�Br�c�~�|j|jfi|���d|j|jfi|���d�S)Nrr)r�rxr�rks    r��visit_getitem_binaryz#StrSQLCompiler.visit_getitem_binaryfs:���D�L�L����+��+��D�L�L����,��,�
�	
r�c�*�|j||fi|��Sr�rrks    r��visit_json_getitem_op_binaryz+StrSQLCompiler.visit_json_getitem_op_binaryl���(�t�(�(���@�R�@�@r�c�*�|j||fi|��Srrrks    r��!visit_json_path_getitem_op_binaryz0StrSQLCompiler.visit_json_path_getitem_op_binaryor
r�c�@�d|jj|��d�S)Nz<next sequence value: �>)r��format_sequencerCs   r�r=zStrSQLCompiler.visit_sequencers#��$�T�]�]�%B�%B�8�%L�$M�Q�O�	
r�c
��tj|�D�cgc]}|jd|ddi���}}ddj|�zScc}w)NTFrr�)rrr�rw)rrHrr�r�rvr�s       r�rzStrSQLCompiler.returning_clausews]���+�+�N�;�
�;��
�%�%�d�A�t�U�B�?�;�	�
��d�i�i��0�0�0��	
s�A
c�P����d�d<ddj���fd�|D��zS)NTrSr�r�c3�H�K�|]}|j�fd�i������y�w�rcNr��r*r�r�r�rs  ���r�r,z4StrSQLCompiler.update_from_clause.<locals>.<genexpr>�s0�����#
� ��
!�A� � ��B��B�r�B� �rrr�r�s`   ``r�r�z!StrSQLCompiler.update_from_clause�s3�����8������#
� �#
�
�
�	
r�c�P����d�d<ddj���fd�|D��zS)NTrSr�c3�H�K�|]}|j�fd�i������y�wrr�rs  ���r�r,z:StrSQLCompiler.delete_extra_from_clause.<locals>.<genexpr>�s0����� 
� ��
!�A� � ��B��B�r�B� �rrr�r�s`   ``r�r�z'StrSQLCompiler.delete_extra_from_clause�s3�����8���d�i�i� 
� � 
�
�
�	
r�c��y)NzSELECT 1 WHERE 1!=1r�r�s   r�r�z#StrSQLCompiler.visit_empty_set_expr�s��$r�c��d|zS)Nz[%s]r�r�s   r�r�z!StrSQLCompiler.get_from_hint_text�s����}�r�c�*�|j|dfi|��S)Nz
 <regexp> �r~rks    r�rz+StrSQLCompiler.visit_regexp_match_op_binary�s��,�t�,�,�V�\�H�R�H�Hr�c�*�|j|dfi|��S)Nz <not regexp> rrks    r�rz/StrSQLCompiler.visit_not_regexp_match_op_binary�s��,�t�,�,�V�5E�L��L�Lr�c��d|jj|fi|���d|jj|fi|���d�S)Nz<regexp replace>(r�r)rxr�r�rks    r�r	z-StrSQLCompiler.visit_regexp_replace_op_binary�s>��*�F�K�K�*�*�4�6�2�6�+�F�L�L�+�+�D�7�B�7�
�	
r�c��d|jj|fi|���d|jj|fi|���d�S)Nz	TRY_CAST(r�r)rr�r�)rrr�s   r��visit_try_castzStrSQLCompiler.visit_try_cast�s>��*�D�K�K�*�*�4�:�6�:�.�D�O�O�.�.�t�>�v�>�
�	
r�r�)r�r�r�r�rr&r�r�rr	rr=rr�r�r�r�rrr	rr�r�s@r�r�r�As�����& ��T���0�1�C�2�C�
�A�A�
�
1��1�5�1�
"�1��
1�

�1�
�
�%��I�M�
�
r�r�c��eZdZdZer			d0									d1d�Zejd��Zejd��Z				d2							d3d�Z
d�Zd�Zd	�Z
d
�Zd4d�Z	d5d�Zd
�Zd�Zd�Z	d6d�Zd�Zd4d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd5d�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+d(�Z,d)�Z-d*�Z.d+�Z/d,�Z0d-�Z1d.�Z2d/�Z3y)7�DDLCompilerTc��yrr�r�s      r�r�zDDLCompiler.__init__�s��r�c�f�|jj|jd|j��S)NrH)r�rr�r/s r�r�zDDLCompiler.sql_compiler�s/���|�|�.�.��L�L�$�T�5N�5N�/�
�	
r�c�.�|jjSr)r�r�r/s r��
type_compilerzDDLCompiler.type_compiler�s���|�|�2�2�2r�Nc��yrr�r�s    r�r�zDDLCompiler.construct_params�s��r�c��|j}t|jtj�r�|j�}|j}|j|j�}t|�dk(r|dd}}n
|d|d}}|jd|�|jd|�|jd|j|j��|jj|j|z�S)Nrrr�r{r�r#r,)�contextr��targetr#rJrFr��format_table_seqr�r�r�r�r�r )r�ddlr�r'r��pathr��schs        r��	visit_ddlzDDLCompiler.visit_ddl�s����+�+���c�j�j�&�,�,�/��l�l�n�G��}�}�H��,�,�S�Z�Z�8�D��4�y�A�~�!�!�W�b�s��!�"�X�t�A�w�s�����w��.����x��-����z�8�+@�+@����+L�M�� � �2�2�3�=�=�7�3J�K�Kr�c�x�d}|jr|dz
}||jj|j�zS)NzCREATE SCHEMA �IF NOT EXISTS )�
if_not_existsr��
format_schemar�)rr�r�r�s    r��visit_create_schemazDDLCompiler.visit_create_schema�s9��������$�$�D��d�m�m�1�1�&�.�.�A�A�Ar�c��d}|jr|dz
}||jj|j�z
}|jr|dz
}|S)NzDROP SCHEMA �
IF EXISTS � CASCADE)�	if_existsr�r1r��cascade�r�dropr�r�s    r��visit_drop_schemazDDLCompiler.visit_drop_schema�sK�����>�>��L� �D���
�
�+�+�D�L�L�9�9���<�<��J��D��r�c�,�|j}|j}d}|jr!|dj|j�dzz
}|dz
}|jr|dz
}||j|�dzz
}|j
|�}|r||dzz
}|dz
}d}d}|jD]P}	|	j}
	|j|	|
jxr|��}|�||z
}d	}|d
|zz
}|
jrd}�R|j||j ��}
|
r||d
z|
zz
}|d|j#|�zz
}|S#tj$rE}tjd|j�d
|
j�d|jd���|�d}~wwxYw)Nz
CREATE rzTABLE r/r�
F��first_pkr�	Tz(in table 'z', column 'z'): r)� _include_foreign_key_constraintsz
)%s

)r�r�r^rwr0r��create_table_suffixr�r�r.r7r��descriptionr��args�create_table_constraints�include_foreign_key_constraints�post_create_table)rr�r�r�r�r�rAr�r>�
create_columnr��	processed�ce�consts              r��visit_create_tablezDDLCompiler.visit_create_table�s��������=�=�����?�?��C�H�H�U�_�_�-��3�3�D���������$�$�D���%�%�e�,�s�2�2��"�6�6�u�=����'�#�-�-�D������	���#�^�^�M�"�*�*�F�
� �L�L�!�F�,>�,>�,O�x�<�)��	��(��I�%�D� &�I��D�9�,�,�D��%�%�#�H��,�$�-�-��-3�-S�-S�.�
����I��$�u�,�,�D���d�4�4�U�;�;�;������#�#�
��&�&��(�(�&�+�+�r�w�w�q�z�C�����
�s�5AD;�;F�AF�Fc���|j}|jry�j||��}dj�fd�|jD��}|r|d|zz
}|S)Nr=rc3�@�K�|]}�j|����y�wr)r��r*r�rs  �r�r,z2DDLCompiler.visit_create_column.<locals>.<genexpr>-s�����
�7I��D�L�L��$�7I�s�)r��system�get_column_specificationrw�constraints)rr�r>r�r�r�rJs`      r��visit_create_columnzDDLCompiler.visit_create_column&sd��������=�=���,�,�V�h�,�G�����
�7=�7I�7I�
�
����C�%�K��D��r�c�l��g}|jr|j|j�|j}|�|j|�}n
t	�}|j|jD�cgc]}||jur||vr|��c}�djd��fd�|D�D��Scc}w)Nz, 
	c3�$K�|]}|�|���
y�wrr�)r*r�s  r�r,z7DDLCompiler.create_table_constraints.<locals>.<genexpr>Ls#����
����}�
��r�c3��K�|]I}|j��r6�jjr
t|dd�s�j	|����Ky�w)�	use_alterFN)�_should_create_for_compilerr��supports_alterr4r�rNs  �r�r,z7DDLCompiler.create_table_constraints.<locals>.<genexpr>NsI������"-�J��:�:�4�@����3�3�"�:�{�E�B����Z�(�"-�r�)r.r��foreign_key_constraintsr�ror�_sorted_constraintsrw)rr�r@r�rQ�all_fkcs�	omit_fkcsrvs`       r�rDz$DDLCompiler.create_table_constraints5s����
��������u�0�0�1��0�0��+�7� �+�+�,L�M�I���I�����2�2�
�2�A��E�-�-�-�!�9�2D��2�
�	
��}�}�
��"-��
�
�	
��
s�.B1c�x�d}|jr|dz
}||jj|j�zS)Nz
DROP TABLE r4)r6r�r�r�r8s    r��visit_drop_tablezDDLCompiler.visit_drop_tableZs6�����>�>��L� �D��d�m�m�0�0����>�>�>r�c�R�d|jj|j�zS)Nz
DROP VIEW �r�r�r��rr9r�s   r��visit_drop_viewzDDLCompiler.visit_drop_view`s ����
�
� :� :�4�<�<� H�H�Hr�c�`�|j�"tjd|jz��y)Nz,Index '%s' is not associated with any table.)r�r7r�r��rros  r��_verify_index_tablezDDLCompiler._verify_index_tablecs0���;�;���"�"�>����K��
�r�c	���|j}�j|��j}d}|jr|dz
}|j�tjd��|dz
}|jr|dz
}|�j||���d|j|j|���d	d
j�fd�|jD���d�z
}|S)
NzCREATE �UNIQUE z0CREATE INDEX requires that the index have a namezINDEX r/��include_schemar1�r-r�r�c3�Z�K�|]"}�jj|dd�����$y�w)FT�r�rN)r�r�)r*r�rs  �r�r,z1DDLCompiler.visit_create_index.<locals>.<genexpr>�s:������.�D��!�!�)�)���T�*��.�rQr)
r�rer�r�r�r7r�r0�_prepared_index_namer�r�rw�expressions)rr�ri�include_table_schemar�ror�r�s`       r��visit_create_indexzDDLCompiler.visit_create_indexis��������� � ��'��=�=�����<�<��I��D��:�:���"�"�B��
�	
��������$�$�D���%�%�e�N�%�K��!�!����(<�
"�
�
�I�I��"�-�-�	�
�
�	
���r�c��|j}|j�tjd��d}|jr|dz
}||j|d��zS)Nz.DROP INDEX requires that the index have a namez
DROP INDEX r4Trh)r�r�r7r�r6rm)rr9r�ror�s     r��visit_drop_indexzDDLCompiler.visit_drop_index�s^�������:�:���"�"�@��
����>�>��L� �D��d�/�/��d�/�K�K�Kr�c��|j�&|jj|j�}nd}|r|r|jj|�}nd}|jj	|�}|r|dz|z}|S�Nr)r�r�r�r��format_index)rrorir��schema_name�
index_names      r�rmz DDLCompiler._prepared_index_name�sw���;�;�"�#�}�}�>�>�u�{�{�K��#���.��-�-�4�4�5E�F�K��K��]�]�/�/��6�
��$�s�*�Z�7�J��r�c��d|jj|jj��d|j	|j���S)N�ALTER TABLE z ADD )r�r�r�r�r��rr�r�s   r��visit_add_constraintz DDLCompiler.visit_add_constraint�s8���M�M�&�&�v�~�~�';�';�<��L�L����(�
�	
r�c���d|jj|j��d|jj	|jj
t
j����S)NzCOMMENT ON TABLE r�)r�r�r�r�r��commentr%�Stringrzs   r��visit_set_table_commentz#DDLCompiler.visit_set_table_comment�sL���M�M�&�&�v�~�~�6����2�2����&�&����(9�
�
�	
r�c�R�d|jj|j�zS)NzCOMMENT ON TABLE %s IS NULLr`ras   r��visit_drop_table_commentz$DDLCompiler.visit_drop_table_comment�s'��,�t�}�}�/I�/I��L�L�0
�
�	
r�c���d|jj|jdd���d|jj	|jj
t
j����S)NzCOMMENT ON COLUMN T)�	use_tabler-r�)r��
format_columnr�r�r�r}r%r~rzs   r��visit_set_column_commentz$DDLCompiler.visit_set_column_comment�sZ���M�M�'�'����$�4�
(�
�
���2�2����&�&����(9�
�	
�	
r�c�V�d|jj|jd��zS)NzCOMMENT ON COLUMN %s IS NULLT)r�)r�r�r�ras   r��visit_drop_column_commentz%DDLCompiler.visit_drop_column_comment�s/��-��
�
�0K�0K��L�L�D�1L�1
�
�	
r�c�@�tj|t|���rr�rzs   r��visit_set_constraint_commentz(DDLCompiler.visit_set_constraint_comment�s���-�-�d�D��L�A�Ar�c�@�tj|t|���rr�ras   r��visit_drop_constraint_commentz)DDLCompiler.visit_drop_constraint_comment�s���-�-�d�D��J�?�?r�c��g}|j�|jd|jz�|j�|jd|jz�|j�|jd|jz�|j�|jd|jz�|j
�|jd�|j�|jd�|j�|jd|jz�|j�|j|jrdnd	�d
j|�S)NzINCREMENT BY %dz
START WITH %dzMINVALUE %dzMAXVALUE %dzNO MINVALUEzNO MAXVALUEzCACHE %d�CYCLEzNO CYCLEr)
�	incrementr�r}�minvalue�maxvalue�
nominvalue�
nomaxvalue�cache�cyclerw)r�identity_optionsr�s   r��get_identity_optionsz DDLCompiler.get_identity_options�s�����%�%�1��K�K�)�,<�,F�,F�F�G��!�!�-��K�K��*:�*@�*@�@�A��$�$�0��K�K�
�(8�(A�(A�A�B��$�$�0��K�K�
�(8�(A�(A�A�B��&�&�2��K�K�
�&��&�&�2��K�K�
�&��!�!�-��K�K�
�%5�%;�%;�;�<��!�!�-��K�K�#3�#9�#9��z�J��x�x��~�r�c���d}|jr|dz
}||jj|j�z
}|r||z
}|j	|j�}|r|d|zz
}|S)NzCREATE SEQUENCE r/r)r0r�rr�r�)rr�rr�r��optionss      r��visit_create_sequencez!DDLCompiler.visit_create_sequence�sn��!������$�$�D���
�
�-�-�f�n�n�=�=����F�N�D��+�+�F�N�N�;����C�'�M�!�D��r�c�x�d}|jr|dz
}||jj|j�zS)NzDROP SEQUENCE r4)r6r�rr�r8s    r��visit_drop_sequencezDDLCompiler.visit_drop_sequence�s6�����>�>��L� �D��d�m�m�3�3�D�L�L�A�A�Ar�c�d�|j}|j�|jj|�}nd}|�"t	j
d|jz��d|jj
|jj��d|jrdnd�|�|jrd��Sd��S)Nz<Can't emit DROP CONSTRAINT for constraint %r; it has no nameryz DROP CONSTRAINT r4r�r5)
r�r�r��format_constraintr7r�r�r�r6r7)rr9r�r��formatted_names     r��visit_drop_constraintz!DDLCompiler.visit_drop_constraint�s����\�\�
��?�?�&�!�]�]�<�<�Z�H�N�!�N��!��"�"�!�#'�<�<�0��
�"�
�M�M�&�&�t�|�|�'9�'9�:� �N�N�L��2���,�,�J�.�	
�	
�-/�.�	
�	
r�c�"�|jj|�dz|jjj	|j
|��z}|j
|�}|�|d|zz
}|j�!|d|j	|j�zz
}|j�7|jjr!|d|j	|j�zz
}|js'|jr|jjs|dz
}|S)Nr)r�z	 DEFAULT z	 NOT NULL)r�r�r�r�r�r��get_column_default_string�computed�identity�supports_identity_columns�nullable)rr�r��colspecr�s     r�rPz$DDLCompiler.get_column_specifications����M�M�'�'��/��
��l�l�1�1�9�9����V�:��
�	��0�0��8�����{�W�,�,�G��?�?�&��s�T�\�\�&�/�/�:�:�:�G�
�O�O�'����6�6��s�T�\�\�&�/�/�:�:�:�G�������t�|�|�'M�'M��{�"�G��r�c��y�Nr�r��rr�s  r�rAzDDLCompiler.create_table_suffix#���r�c��yr�r�r�s  r�rFzDDLCompiler.post_create_table&r�r�c��t|jtj�r%|j	|jj
�Syr)r��server_defaultr#�
DefaultClause�render_default_string�argr~s  r�r�z%DDLCompiler.get_column_default_string)s8���f�+�+�V�-A�-A�B��-�-�f�.C�.C�.G�.G�H�H�r�c��t|t�r*|jj|tj
�S|jj
|d��S)NT)r)r�r�r�r�r%r�r�)rr�s  r�r�z!DDLCompiler.render_default_string/sN���g�s�#��$�$�9�9���,�,��
��$�$�,�,�W�D�,�I�Ir�c�^�|jr|j|�S|j|�Sr)�is_column_level�visit_column_check_constraint�visit_check_constraint�rr�r�s   r��&visit_table_or_column_check_constraintz2DDLCompiler.visit_table_or_column_check_constraint7s-���%�%��5�5�j�A�A��.�.�z�:�:r�c���d}|j�%|jj|�}|�|d|zz
}|d|jj	|j
dd��zz
}||j
|�z
}|S�Nr��CONSTRAINT %s z
CHECK (%s)FTrl�r�r�r�r�r�rJ�define_constraint_deferrability�rr�r�r�r�s     r�r�z"DDLCompiler.visit_check_constraint=������?�?�&�!�]�]�<�<�Z�H�N��)��(�>�9�9����t�0�0�8�8����e�4� 9� 
�
�	
��	
��4�4�Z�@�@���r�c���d}|j�%|jj|�}|�|d|zz
}|d|jj	|j
dd��zz
}||j
|�z
}|Sr�r�r�s     r�r�z)DDLCompiler.visit_column_check_constraintIr�r�c�B��t|�dk(ryd}|j�%�jj|�}|�|d|zz
}|dz
}|ddj	�fd�|j
r|jn|jD��zz
}|�j|�z
}|S)Nrr�r�zPRIMARY KEY r�r�c3�h�K�|])}�jj|j����+y�wr�r�r�r��r*rvrs  �r�r,z;DDLCompiler.visit_primary_key_constraint.<locals>.<genexpr>^s3�����#
�(��
�M�M������'�(���/2)	r�r�r�r�rw�_implicit_generated�columns_autoinc_firstr�r�r�s`    r��visit_primary_key_constraintz(DDLCompiler.visit_primary_key_constraintUs�����z�?�a������?�?�&�!�]�]�<�<�Z�H�N��)��(�>�9�9�����������#
��1�1��0�0��'�'�(�#
�
�
�	
��	
��4�4�Z�@�@���r�c
���|j�d}|j�%|jj|�}|�|d|zz
}t|j�dj
j}|ddj�fd�|jD���d|j||���ddj�fd	�|jD���d
�z
}||j|�z
}||j|�z
}||j|�z
}|S)Nr�r�rzFOREIGN KEY(r�c3�h�K�|])}�j|jj����+y�wr)r��parentr��r*r�r�s  �r�r,z;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>r�'������7J�!����q�x�x�}�}�-�7J�r�z
) REFERENCES r�c3�h�K�|])}�j|jj����+y�wr)r�r�r�r�s  �r�r,z;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>xr�r�r)r�r�r�r�rr�r�rw�define_constraint_remote_table�define_constraint_match�define_constraint_cascadesr�)rr�r�r�r��remote_tabler�s      @r��visit_foreign_key_constraintz(DDLCompiler.visit_foreign_key_constraintis����=�=�����?�?�&�!�]�]�<�<�Z�H�N��)��(�>�9�9���J�/�/�0��3�:�:�@�@����I�I��7A�7J�7J��
�
�/�/��L�(�
�
�I�I��7A�7J�7J��
�

�
	
��	
��,�,�Z�8�8����/�/�
�;�;����4�4�Z�@�@���r�c�$�|j|�S)z=Format the remote table clause of a CREATE CONSTRAINT clause.)r�)rr�r�r�s    r�r�z*DDLCompiler.define_constraint_remote_table�s���$�$�U�+�+r�c���t|�dk(ryd}|j�%�jj|�}|�|d|zz
}|d�j|fi|���ddj�fd�|D���d�z
}|�j
|�z
}|S)	Nrr�r�rgrr�c3�h�K�|])}�jj|j����+y�wrr�r�s  �r�r,z6DDLCompiler.visit_unique_constraint.<locals>.<genexpr>�s%�����F�:�a�d�m�m�)�)�!�&�&�1�:�r�r)r�r�r�r��!define_unique_constraint_distinctrwr�r�s`    r��visit_unique_constraintz#DDLCompiler.visit_unique_constraint�s�����z�?�a������?�?�&�!�]�]�<�<�Z�H�N��)��(�>�9�9���2�D�2�2�:�D��D��I�I�F�:�F�F�
�	
��	
��4�4�Z�@�@���r�c��yr�r�r�s   r�r�z-DDLCompiler.define_unique_constraint_distinct�r�r�c��d}|j�0|d|jj|jt�zz
}|j�0|d|jj|jt
�zz
}|S)Nr�z
 ON DELETE %sz
 ON UPDATE %s)�ondeleter��validate_sql_phrase�FK_ON_DELETE�onupdate�FK_ON_UPDATE�rr�r�s   r�r�z&DDLCompiler.define_constraint_cascades�s��������*��O�d�m�m�&G�&G��#�#�\�'��
�D����*��O�d�m�m�&G�&G��#�#�\�'��
�D��r�c���d}|j�|jr|dz
}n|dz
}|j�0|d|jj|jt�zz
}|S)Nr�z DEFERRABLEz NOT DEFERRABLEz
 INITIALLY %s)r�r�r�r��FK_INITIALLYr�s   r�r�z+DDLCompiler.define_constraint_deferrability�sq����� � �,��$�$��
�%���)�)�����+��O�d�m�m�&G�&G��$�$�l�'��
�D��r�c�F�d}|j�|d|jzz
}|S)Nr�z	 MATCH %s)r
r�s   r�r�z#DDLCompiler.define_constraint_match�s-�������'��K�*�"2�"2�2�2�D��r�c��d|jj|jdd��z}|jdur|dz
}|S|jdur|dz
}|S)NzGENERATED ALWAYS AS (%s)FTrlz STOREDz VIRTUAL)r�r�rJ�	persisted)r�	generatedr�r�s    r��visit_computed_columnz!DDLCompiler.visit_computed_column�sr��)�D�,=�,=�,E�,E����U�$�-F�-
�
�����$�&��I��D����
 �
 �E�
)��J��D��r�c�d�d|jrdnd�d�}|j|�}|r|d|zz
}|S)Nz
GENERATED �ALWAYSz
BY DEFAULTz AS IDENTITYr�)�alwaysr�)rr�r�r�r�s     r��visit_identity_columnz!DDLCompiler.visit_identity_column�s@�� ���H�\�9�
���+�+�H�5����G�g�%�%�D��r�)...)
r�r\r r@r�r�r�rr�r�r�r�r�r)FT)4r�r�r�r�rr�r&r�r�r$r�r-r2r:rKrRrDr^rbrerprrrmr{rr�r�r�r�r�r�r�r�r�rPrArFr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r r �s���
�F��FI�,/�03�
	��	�,�	�#C�		�
&*�	�.�
	�
���
��
�

���3��3�
6:�GK�!�	�2��E���	�

3��L�&B��2�h
� 7;�#
�J?�I��BF��@L�� 
�
�
�

�
�
B�@��(�B�
�&�6���J�;�
�
��(�0,�

��
����r�r c�(�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd1d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-�Z.d.�Z/d/�Z0d0�Z1y)2�GenericTypeCompilerc��y)N�FLOATr�r�s   r��visit_FLOATzGenericTypeCompiler.visit_FLOAT����r�c��y)N�DOUBLEr�r�s   r��visit_DOUBLEz GenericTypeCompiler.visit_DOUBLE����r�c��y)NzDOUBLE PRECISIONr�r�s   r��visit_DOUBLE_PRECISIONz*GenericTypeCompiler.visit_DOUBLE_PRECISION�s��!r�c��y)N�REALr�r�s   r��
visit_REALzGenericTypeCompiler.visit_REAL�r�r�c��|j�y|j�dd|jizSd|j|jd�zS)N�NUMERICzNUMERIC(%(precision)s)�	precisionz!NUMERIC(%(precision)s, %(scale)s)�r��scaler�r�s   r��
visit_NUMERICz!GenericTypeCompiler.visit_NUMERIC��M���?�?�"��
�[�[�
 �+�{�E�O�O�.L�L�L�6�"�_�_����:��
r�c��|j�y|j�dd|jizSd|j|jd�zS)N�DECIMALzDECIMAL(%(precision)s)r�z!DECIMAL(%(precision)s, %(scale)s)r�r�r�s   r��
visit_DECIMALz!GenericTypeCompiler.visit_DECIMAL�rr�c��y)N�INTEGERr�r�s   r��
visit_INTEGERz!GenericTypeCompiler.visit_INTEGER����r�c��y)N�SMALLINTr�r�s   r��visit_SMALLINTz"GenericTypeCompiler.visit_SMALLINT����r�c��y)N�BIGINTr�r�s   r��visit_BIGINTz GenericTypeCompiler.visit_BIGINT�r�r�c��y)N�	TIMESTAMPr�r�s   r��visit_TIMESTAMPz#GenericTypeCompiler.visit_TIMESTAMP�s��r�c��y)N�DATETIMEr�r�s   r��visit_DATETIMEz"GenericTypeCompiler.visit_DATETIME�rr�c��y)N�DATEr�r�s   r��
visit_DATEzGenericTypeCompiler.visit_DATE�r�r�c��y)N�TIMEr�r�s   r��
visit_TIMEzGenericTypeCompiler.visit_TIMEr�r�c��y)N�CLOBr�r�s   r��
visit_CLOBzGenericTypeCompiler.visit_CLOBr�r�c��y)N�NCLOBr�r�s   r��visit_NCLOBzGenericTypeCompiler.visit_NCLOBr�r�Nc��|}|r	|d|zz
}n|jr|d|jzz
}|jr|d|jzz
}|S)N�(%d)z
 COLLATE "%s")�lengthr�)rrr��length_overrider�s     r��_render_string_typez'GenericTypeCompiler._render_string_type	sR������F�_�,�,�D�
�\�\��F�U�\�\�)�)�D��?�?��O�e�o�o�5�5�D��r�c�&�|j|d�S)N�CHAR�r%r�s   r��
visit_CHARzGenericTypeCompiler.visit_CHAR����'�'��v�6�6r�c�&�|j|d�S)N�NCHARr(r�s   r��visit_NCHARzGenericTypeCompiler.visit_NCHARs���'�'��w�7�7r�c�&�|j|d�S)N�VARCHARr(r�s   r��
visit_VARCHARz!GenericTypeCompiler.visit_VARCHARs���'�'��y�9�9r�c�&�|j|d�S)N�NVARCHARr(r�s   r��visit_NVARCHARz"GenericTypeCompiler.visit_NVARCHARs���'�'��z�:�:r�c�&�|j|d�S)N�TEXTr(r�s   r��
visit_TEXTzGenericTypeCompiler.visit_TEXTr*r�c��y)N�UUIDr�r�s   r��
visit_UUIDzGenericTypeCompiler.visit_UUID"r�r�c��y)N�BLOBr�r�s   r��
visit_BLOBzGenericTypeCompiler.visit_BLOB%r�r�c�J�d|jxrd|jzxsdzS)N�BINARYr"r��r#r�s   r��visit_BINARYz GenericTypeCompiler.visit_BINARY(s$���5�<�<�A�F�U�\�\�,A�G�R�H�Hr�c�J�d|jxrd|jzxsdzS)N�	VARBINARYr"r�r?r�s   r��visit_VARBINARYz#GenericTypeCompiler.visit_VARBINARY+s$���e�l�l�D�v����/D�J��K�Kr�c��y)N�BOOLEANr�r�s   r��
visit_BOOLEANz!GenericTypeCompiler.visit_BOOLEAN.rr�c��|jr|jjs|j|dd��S|j|fi|��S)Nr'� )r$)�native_uuidr��supports_native_uuidr%r9r�s   r��
visit_uuidzGenericTypeCompiler.visit_uuid1sE��� � ����(I�(I��+�+�E�6�2�+�N�N�"�4�?�?�5�/�B�/�/r�c�(�|j|fi|��Sr)r<r�s   r��visit_large_binaryz&GenericTypeCompiler.visit_large_binary7����t���u�+��+�+r�c�(�|j|fi|��Sr)rFr�s   r��
visit_booleanz!GenericTypeCompiler.visit_boolean:���!�t�!�!�%�.�2�.�.r�c�(�|j|fi|��Sr)rr�s   r��
visit_timezGenericTypeCompiler.visit_time=rNr�c�(�|j|fi|��Sr)rr�s   r��visit_datetimez"GenericTypeCompiler.visit_datetime@���"�t�"�"�5�/�B�/�/r�c�(�|j|fi|��Sr)rr�s   r��
visit_datezGenericTypeCompiler.visit_dateCrNr�c�(�|j|fi|��Sr)rr�s   r��visit_big_integerz%GenericTypeCompiler.visit_big_integerF��� �t� � ��-�"�-�-r�c�(�|j|fi|��Sr)r
r�s   r��visit_small_integerz'GenericTypeCompiler.visit_small_integerIrVr�c�(�|j|fi|��Sr)rr�s   r��
visit_integerz!GenericTypeCompiler.visit_integerLrQr�c�(�|j|fi|��Sr)r�r�s   r��
visit_realzGenericTypeCompiler.visit_realOrNr�c�(�|j|fi|��Sr)r�r�s   r��visit_floatzGenericTypeCompiler.visit_floatRs���t����,��,�,r�c�(�|j|fi|��Sr)r�r�s   r��visit_doublez GenericTypeCompiler.visit_doubleUr[r�c�(�|j|fi|��Sr)r�r�s   r��
visit_numericz!GenericTypeCompiler.visit_numericXrQr�c�(�|j|fi|��Sr�r0r�s   r��visit_stringz GenericTypeCompiler.visit_string[rQr�c�(�|j|fi|��Srrir�s   r��
visit_unicodez!GenericTypeCompiler.visit_unicode^rQr�c�(�|j|fi|��Sr�r6r�s   r��
visit_textzGenericTypeCompiler.visit_textarNr�c�(�|j|fi|��Srrnr�s   r��visit_unicode_textz&GenericTypeCompiler.visit_unicode_textdrNr�c�(�|j|fi|��Srrir�s   r��
visit_enumzGenericTypeCompiler.visit_enumgrQr�c�2�tjd|z��)NzKCan't generate DDL for %r; did you forget to specify a type on this Column?r}r�s   r�r�zGenericTypeCompiler.visit_nulljs"�����
#�%*�
+�
�	
r�c�Z�|j|j|j�fi|��Sr)r��type_enginer�r�s   r��visit_type_decoratorz(GenericTypeCompiler.visit_type_decoratorqs'���t�|�|�E�-�-�d�l�l�;�B�r�B�Br�c�&�|jdi|��Sr�)�get_col_specr�s   r��visit_user_definedz&GenericTypeCompiler.visit_user_definedts��!�u�!�!�'�B�'�'r�r)2r�r�r�r�r�r�r�r�rrr
rrrrrrr r%r)r-r0r3r6r9r<r@rCrFrKrMrPrSrUrXrZr]r_rarcrergrjrlrorqrsr�rwrzr�r�r�r�r��s�����"��	�	�����������7�8�:�;�7���I�L��0�,�/�,�0�,�.�0�/�,�-�.�/�/�/�,�,�/�
�C�(r�r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�StrSQLTypeCompilerc�r�	|j}||fi|��S#t$r|j|fi|��cYSwxYwr)r��AttributeError�_visit_unknown)rrr�r�s    r�r�zStrSQLTypeCompiler.processysN��	2�!&�!9�!9��&�d�1�b�1�1���	4�&�4�&�&�u�3��3�3�	4�s��6�6c�R�|jd�r|jSt|��)Nr[)rZrr~)rr+s  r��__getattr__zStrSQLTypeCompiler.__getattr__�s%���>�>�(�#��&�&�&� ��%�%r�c��|jj|jjj�k(r|jjSt|�Sr)r�r��upper�reprr�s   r�rz!StrSQLTypeCompiler._visit_unknown�sA���?�?�#�#�u���'?�'?�'E�'E�'G�G��?�?�+�+�+���;�r�c��yr�r�r�s   r�r�zStrSQLTypeCompiler.visit_null�r�r�c�`�	|j}|di|��S#t$rt|�cYSwxYwr�)ryr~r�)rrr�rys    r�rzz%StrSQLTypeCompiler.visit_user_defined�s=��	&� �-�-�L� �%�"�%�%���	���;��	�s��-�-N)r�r�r�r�r�rr�rzr�r�r�r|r|xs��2�&���&r�r|c��eZdZdd�Zy)�_SchemaForObjectCallablec��yrr�)r�_SchemaForObjectCallable__objs  r�rz!_SchemaForObjectCallable.__call__�s��3r�N)r�rrr�r	r�r�r�r�r��s��.r�r�c��eZdZdd�Zy)rc��yrr�)rr�s  r�rz _BindNameForColProtocol.__call__�s��sr�N)r�r�rr�r	r�r�r�rr�s��:r�rc���eZdZUdZeZeZeZ	de
d<de
d<de
d<ejd�Z
de
d	<	d
Zde
d<					d+d�Zd�Zd�Zd,d�Zd,d�Zd�Zd,d�Zd-d�Zd�Zd.d/d�Zd.d0d�Zd�Zd1d�Z	d.					d2d�Z	d.					d3d�Zd.d�Zej@d�d1d��Z!d1d �Z"d1d!�Z#d"�Z$d#�Z%d4d$�Z&d%�Z'	d.d&�Z(					d5d'�Z)d1d(�Z*ejVd)��Z,d*�Z-y
)6r�z@Handle quoting and case-folding of identifiers based on options.r��
initial_quote�final_quotezMutableMapping[str, str]�_stringsr#r�r�Fr�_includes_none_schema_translateNc���||_||_|xs|j|_||_|jdz|_||_||_i|_|jjdv|_	y)asConstruct a new ``IdentifierPreparer`` object.

        initial_quote
          Character that begins a delimited identifier.

        final_quote
          Character that ends a delimited identifier. Defaults to
          `initial_quote`.

        omit_schema
          Prevent prepending schema name. Useful for databases that do
          not support schemae.
        r6)r�r�N)
r�r�r��escape_quote�escape_to_quote�omit_schema�quote_case_sensitive_collationsr�rYr�)rr�r�r�r�r�r�s       r�r�zIdentifierPreparer.__init__�st��.���*���&�<�$�*<�*<���(���#�0�0�1�4���&���/N��,���
� $��� 7� 7�<
�!
��r�c����|jj|j�}|jj|j�d|v��fd�}||_�|_|S)Nc���|j}|jr:|��r6|� d|vsd|vrtjd|z��t	d|xsdzd��S|jS)NrrzJSquare bracket characters ([]) not supported in schema translate name '%s'z
__[SCHEMA_%s]�_noneF�r�)r#�_use_schema_mapr7r�r0)r�r��
includes_nones  �r��
symbol_getterz@IdentifierPreparer._with_schema_translate.<locals>.symbol_getter�sw����:�:�D��"�"��(8�M��#�����t���*�*�8�:>�?���#�#�t��w�7�u����z�z�!r�)r��__new__rerfr�r�)rr��prepr�r�s    @r�r�z)IdentifierPreparer._with_schema_translate�sX����~�~�%�%�d�n�n�5���
�
���T�]�]�+�� 4�4�
�	"�"/���/<��,��r�c����|�d�vr)�jstjd���d�d<��fd�}tjd||�S)Nz�schema 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����|jd�}|�vr�|}n|dvrtjd��|}|s-�jj}|stj
d���j
|�S)Nr6)Nr�z�schema 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�r7r-r��default_schema_namer�r�)r�r�r��drs   ��r�r�z=IdentifierPreparer._render_schema_translates.<locals>.replaces�����7�7�1�:�D��q�y�#$�T�7� ��?�*��1�1�=���$(� �#�#'�<�<�#C�#C� �'��*�*�=����$�$�%5�6�6r�z(__\[SCHEMA_([^\]]+)\]))r�r7r-rLr�)rr r�r�r�s`   @r�r�z,IdentifierPreparer._render_schema_translates�sZ��� ���1�9��7�7��-�-�9����4��A�g�J�	7�2�v�v�0�'�9�E�Er�c��|j|j|j�}|jr|jdd�}|S)z�Escape an identifier.

        Subclasses should override this to provide database-dependent
        escaping behavior.
        rr�)r�r�r�r��rr�s  r��_escape_identifierz%IdentifierPreparer._escape_identifier"s>���
�
�d�/�/��1E�1E�F��� � ��M�M�#�t�,�E��r�c�N�|j|j|j�S)z�Canonicalize an escaped identifier.

        Subclasses should override this to provide database-dependent
        unescaping behavior that reverses _escape_identifier.
        )r�r�r�r�s  r��_unescape_identifierz'IdentifierPreparer._unescape_identifier.s!���}�}�T�1�1�4�3D�3D�E�Er�c�x�|�7|j|�s&tjd|�d|j�d���|S)z�keyword sequence filter.

        a filter for elements that are intended to represent keyword sequences,
        such as "INITIALLY", "INITIALLY DEFERRED", etc.   no special characters
        should be present.

        .. versionadded:: 1.3

        zUnexpected SQL phrase: z (matching against r)r
r7r�r�)rr�rOs   r�r�z&IdentifierPreparer.validate_sql_phrase7s=����s�y�y��'9��"�"��C�K�K�)��
��r�c�X�|j|j|�z|jzS)z~Quote an identifier.

        Subclasses should override this to provide database-dependent
        quoting behavior.
        )r�r�r�r�s  r��quote_identifierz#IdentifierPreparer.quote_identifierIs3��
����%�%�e�,�
-����
�	
r�c��|j�}||jvxs?|d|jvxs,|jj	t|��xs||k7S)z5Return True if the given identifier requires quoting.r)r5�reserved_words�illegal_initial_characters�legal_charactersr
r�)rr��lc_values   r�r`z#IdentifierPreparer._requires_quotesVsf���;�;�=����+�+�+�
#��Q�x�4�:�:�:�
#��(�(�.�.�s�5�z�:�:�
#��E�!�		
r�c�L�|jjt|��S)zjReturn True if the given identifier requires quoting, but
        not taking case convention into account.)r�r
r�r�s  r�r8z1IdentifierPreparer._requires_quotes_illegal_chars`s"���(�(�.�.�s�5�z�:�:�:r�c�V�|�tjdd��|j|�S)aConditionally quote a schema name.


        The name is quoted if it is a reserved word, contains quote-necessary
        characters, or is an instance of :class:`.quoted_name` which includes
        ``quote`` set to ``True``.

        Subclasses can override this to provide database-dependent
        quoting behavior for schema names.

        :param schema: string schema name
        :param force: unused

            .. deprecated:: 0.9

                The :paramref:`.IdentifierPreparer.quote_schema.force`
                parameter is deprecated and will be removed in a future
                release.  This flag has no effect on the behavior of the
                :meth:`.IdentifierPreparer.quote` method; please refer to
                :class:`.quoted_name`.

        z�The IdentifierPreparer.quote_schema.force parameter is deprecated and will be removed in a future release.  This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().�0.9r)r&rr�)rr#�forces   r�r�zIdentifierPreparer.quote_schemaes5��.��
� � �!��
��z�z�&�!�!r�c�R�|�tjdd��t|dd�}|�k||jvr|j|S|j	|�r|j|�|j|<n||j|<|j|S|r|j|�S|S)aConditionally quote an identifier.

        The identifier is quoted if it is a reserved word, contains
        quote-necessary characters, or is an instance of
        :class:`.quoted_name` which includes ``quote`` set to ``True``.

        Subclasses can override this to provide database-dependent
        quoting behavior for identifier names.

        :param ident: string identifier
        :param force: unused

            .. deprecated:: 0.9

                The :paramref:`.IdentifierPreparer.quote.force`
                parameter is deprecated and will be removed in a future
                release.  This flag has no effect on the behavior of the
                :meth:`.IdentifierPreparer.quote` method; please refer to
                :class:`.quoted_name`.

        Nz�The IdentifierPreparer.quote.force parameter is deprecated and will be removed in a future release.  This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().r�rr�)r&rr4r�r`r�)rrPr�s   r�r�zIdentifierPreparer.quote�s���,��
� � �!��
���w��-���=���
�
�%��}�}�U�+�+��(�(��/�+/�+@�+@��+G�D�M�M�%�(�+0�D�M�M�%�(��}�}�U�+�+�
��(�(��/�/��Lr�c�@�|jr|j|�S|Sr)r�r�)r�collation_names  r�r�z#IdentifierPreparer.format_collation�s ���/�/��:�:�n�-�-�!�!r�c��|j|j�}|j|�}|js|r|�|j	|�dz|z}|Srt)r�r�r�r�r�)rr>r-r�r�s     r�rz"IdentifierPreparer.format_sequence�sY���z�z�(�-�-�(���1�1�(�;��� � �� �,��$�$�%5�6��<�t�C�D��r�c�@�|j|xs|j�Sr�r�r�)rr�r�s   r�ruzIdentifierPreparer.format_label�s���z�z�$�,�%�*�*�-�-r�c�f�|�|�J�|j|j�S|j|�Srr�)rr�r�s   r�r[zIdentifierPreparer.format_alias�s7���<��$�$�$��:�:�e�j�j�)�)��:�:�d�#�#r�c�j�|xs|j}|j|�r|j|�}|Sr)rPr`r�)r�	savepointr�rPs    r�r�z#IdentifierPreparer.format_savepoint�s5���'�	����� � ��'��)�)�%�0�E��r�zsqlalchemy.sql.namingc��tjj}|jtur|j||j�}|�
y|j}|jdk(r|j||��S|j||��S)Nro)�_alembic_quote)
r&r�
sql_namingr�r+�_constraint_name_for_tabler�r�truncate_and_render_index_name�#truncate_and_render_constraint_name)rr�r��namingr�s     r�r�z$IdentifierPreparer.format_constraint�s������*�*���?�?�j�(��4�4��J�,�,��D��|���?�?�D��$�$��/��6�6��^�7��
��;�;��^�<��
r�c��|jjxs|jj}|j|||�Sr)r��max_index_name_lengthr^� _truncate_and_render_maxlen_name�rr�r��max_s    r�r�z1IdentifierPreparer.truncate_and_render_index_namesD��

�L�L�.�.�
2��|�|�1�1�	
��4�4��$��
�	
r�c��|jjxs|jj}|j|||�Sr)r��max_constraint_name_lengthr^r�r�s    r�r�z6IdentifierPreparer.truncate_and_render_constraint_name
sD��

�L�L�3�3�
2��|�|�1�1�	
��4�4��$��
�	
r�c��t|tj�r3t|�|kDr@|d|dz
dzt	j
|�ddz}n|jj|�|s|S|j|�S)NrrTr���)	r�rrDr�r&�md5_hexr��validate_identifierr�)rr�r�r�s    r�r�z3IdentifierPreparer._truncate_and_render_maxlen_namesq���d�H�5�5�6��4�y�4���A��q��)�C�/�$�,�,�t�2D�R�S�2I�I���L�L�,�,�T�2���K��:�:�d�#�#r�c�$�|j|�Sr)r�rds  r�ruzIdentifierPreparer.format_index%s���%�%�e�,�,r�c��|�|j}|j|�}|j|�}|js|r|r|j	|�dz|z}|S)z'Prepare a quoted table and schema name.r)r�r�r�r�r�)rr�r-r�r4r�s      r�r�zIdentifierPreparer.format_table(s_���<��:�:�D����D�!���1�1�%�8�����J�3C��&�&�'7�8�3�>��G�F��
r�c�$�|j|�S)zPrepare a quoted schema name.r�r9s  r�r1z IdentifierPreparer.format_schema6s���z�z�$��r�c�~�|�+t|tj�r|j|�}|j	|�S)�Prepare a quoted column name.)r�rrDr0r�)rr�r_s   r�rOz$IdentifierPreparer.format_label_name;s;����J��(�+�+�%
��>�>�(�+�D��z�z�$��r�c�n�|�|j}|�+t|tj�r|j	|�}t|dd�sF|r3|j
|j||��dz|j|�zS|j|�S|r$|j
|j||��dz|zS|S)r�r�F)r-r�r)	r�r�rrDr0r4r�r�r�)rr�r�r��
table_namer-r_s       r�r�z IdentifierPreparer.format_columnIs����<��;�;�D���J��(�+�+�%
��>�>�(�+�D��v�|�U�3���%�%�����*�&�����j�j��&�	'���z�z�$�'�'�
��%�%�����*�&�����	���r�c��|j|�}|js(|r&|r$|j|�|j|d��fS|j|d��fS)z(Format table name and schema as a tuple.Frj)r�r�r�r�)rr�r-r�s    r�r)z#IdentifierPreparer.format_table_seqvsj�� �1�1�%�8�����J�3C��!�!�"2�3��!�!�%�E�!�:��
�
�%�%�e��%�>�@�@r�c��d�|j|j|j|j�fD�\}}}tjd|||d�z�}|S)Nc3�FK�|]}tj|����y�wr)rLrMr�s  r�r,z4IdentifierPreparer._r_identifiers.<locals>.<genexpr>�s$����)
���
�I�I�a�L��s�!zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)�initial�finalr�)r�r�r�rLrN)rr�r��
escaped_final�rs     r��_r_identifiersz!IdentifierPreparer._r_identifiers�sp��)
��"�"�� � ��'�'��(8�(8�9��)
�%���
�
�J�J�
$�"�E�m�L�
M�
���r�c��|j}|j|�D��cgc]\}}|xs|��
c}}D�cgc]}|j|���c}Scc}}wcc}w)z:Unpack 'schema.table.column'-like strings into components.)r��findallr�)r�identifiersr��arlr�s      r��unformat_identifiersz'IdentifierPreparer.unformat_identifiers�sh��
����*+���;�)?�@�)?���A�a�f�1�f�)?�@�
�@��
�%�%�a�(�@�
�	
��@��
s
�A�A)r�Nr�TF)r�r�rr�)r�r�rrr)r#r�r�rrr�)rPr�r�rrr�)T)r�z
Label[Any]r�r7rr�)r�zOptional[AliasedReturnsRows]r�r7rr�)TN)FNNFN).r�r�r�r��RESERVED_WORDSr��LEGAL_CHARACTERSr��ILLEGAL_INITIAL_CHARACTERSr�r�r/�
attrgetterr�r�r�r�r�r�r�r�r�r`r8r�r�r�rrur[r�r&r�r�r�r�r�rur�r1rOr�r)r�r�r�r�r�r�r�r��s|��J�#�N�'��!;������&�&�2E�(�2E�2E�h�2O��/�O��-2�#�T�1�
���(,��"
�H�0'F�R
�F��$
�
�;�
%"�N2�h"��8<�.��.�'4�.�	�.�JN�$�1�$�9F�$�	�$���T���0�1��2��,

�

�
$�-�� �� �"�
����+�ZA�"
������"
r�r�)�r��
__future__rrw�collections.abc�abcr�r��enumrrar�r/rL�timerr<rrrr	r
rrr
rrrrrrrrrrrrrr�rrrrr r!r"r#r$r%r&r)�_typingr'r(r)r*r+r,r-r.r/r0r1r2�type_apir3�visitorsr4r5r7r8�util.typingr9r:r;�
annotationr<r=r>r�r?r*r@�dmlrArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrS�
engine.cursorrT�engine.interfacesrUrVrWrXrYrZr[r\r]r��_FromHintsTyper�rN�Ir��LEGAL_CHARACTERS_PLUS_SPACErer�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�rr�rtrr 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_oprsr�r�r�r�r�r�r�r�r�r�r�cube�rollup�
grouping_setsr�r�r��_CompoundSelectKeywordr��	UNION_ALLr��
EXCEPT_ALLr��
INTERSECT_ALLr�r�rr
rrrrrrr5rErRr`rer.rfrgrhri�
namedtuplerkr��EnsureKWArgr��BinaryElementRole�CompilerColumnElementr�rrr�r r�r|r�rr�)rs0r��<module>r!	s���"#��)������	��
�����������!��������� �������������&�����2���#�!��� �%�����!�"�#�	���+�,�"�#�)����*�'�&�'��#��.�/��&�+�'�"�'�,�4�<�:�<�=�3�=�C�+�:��l�C�'�(��_��B�2�:�:�.����5��(�b�j�j�):�B�D�D�A��.3�A�r�l�;�l��c�!�f�l�;�A�A�3�%�H���r�z�z�<�b�d�d����r�z�z�<�b�d�d����r�z�z�5�r�t�t�<���b�j�j�A�2�:�:�N���"�*�*�9�2�:�:�F��$��"�
���$�
�
��.
�
�N�N�G�.
��M�M�6�.
��M�M�5�	.
�
�M�M�5�.
��M�M�5�
.
��M�M�5�.
��M�M�3�.
��L�L�%�.
��L�L�&�.
��L�L�&�.
��L�L�%�.
��L�L�&�.
��L�L�%�.
���� 4�.
� �"�"�$<�!.
�"����#.
�$���	�%.
�&���M�'.
�(�O�O�V�).
�*����+.
�,����-.
�.�O�O�X�/.
�0�M�M�6�1.
�2�M�M�6�3.
�4���j�5.
�6���{�7.
�:���i�;.
�<���;�=.
�>�M�M�6�?.
�@���f�A.
�B���f�C.
�F���w�G.
�H���f�I.
�J���n�K.
�L���]�
���e�
���U�
���e�
���c�
����
����[.
�	�b���
�
���N�
���N�
���!4�
���N�
����
���.�
���h�
���y�
���N�
�N�N�F�
�N�N�F�
���h�
���_�-�	�)��&����������
�"�"�$�(���&�%�%�+�+�W��%�%�/�/���%�%�,�,�h��%�%�0�0�,��%�%�/�/���%�%�3�3�_�
�����>��� !��*� ������
�J�������i��$�1��$�:�J�:�zt�
�t�n�Z��2!�;�!�$
�G�
� �g��.FK��F�B�
�&��l�
?#�'��'�'��w��6H�I�?#�DH'�H'�VF�4�#�#�F�0�	���C� �(�"@�"@��2#
�	���C� �(�"@�"@�#
�LuT
�(�uT
�pil
�[�l
�^X�(�X�vj(�,�j(�Z&�,�&�B/�x�/�;�h�;�
�
��w]<s�a6

ZeroDay Forums Mini