Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/__pycache__/compiler.cpython-311.pyc

�

�܋f����l�dZddlZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZdd
lm
Z
ddlmZegd���Zejdej��Zejdej��Zd�edd��D���dg��Zejdej��Zejdej��Zejdej��Zejdej��Zejdej��Zdddddd�Ziejd�ej d �ej!d!�ej"d"�ej#d#�ej$d$�ej%d%�ej&d$�ej'd&�ej(d'�ej)d(�ej*d)�ej+d*�ej,d+�ej-d,�ej.d-�ej/d.�iej0d/�ej1d0�ej2d1�ej3d2�ej4d3�ej5d4�ej6d5�ej7d6�ej8d7�ej9d8�ej:d9�ej;d:�ej<d;�ej=d<�ej>d=�ej?d>�ej@d?��ejAd@ejBdAejCdBi�ZDejEdCejFdDejGdEejHdFejIdGejJdHejKdIejLdJejMdKejNdLejOdMejPdNejQdOejRdPiZSdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`�ZTe
jUjVdae
jUjWdbe
jUjXdce
jUjYdde
jUjZdee
jUj[dfiZ\Gdg�dhe]��Z^Gdi�djej_ej`e]����ZaGdk�dlejb��ZcGdm�dned��ZeGdo�dpe^��ZfGdq�dref��ZgGds�dte^��ZhGdu�dvea��ZiGdw�dxei��ZjGdy�dze]��ZkdS){a]Base SQL and DDL compiler implementations.

Classes provided include:

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

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

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

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

�N�)�crud)�elements)�	functions)�	operators)�schema)�
selectable)�sqltypes)�visitors�)�exc)�util)^�all�analyse�analyze�and�any�array�as�asc�
asymmetric�
authorization�between�binary�both�case�cast�check�collate�column�
constraint�create�cross�current_date�current_role�current_time�current_timestamp�current_user�default�
deferrable�desc�distinct�do�else�end�except�false�for�foreign�freeze�from�full�grant�group�having�ilike�in�	initially�inner�	intersect�into�is�isnull�join�leading�left�like�limit�	localtime�localtimestamp�natural�new�not�notnull�null�off�offset�old�on�only�or�order�outer�overlaps�placing�primary�
references�right�select�session_user�set�similar�some�	symmetric�table�then�to�trailing�true�union�unique�user�using�verbose�when�wherez
^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$c�,�h|]}t|����S�)�str)�.0�xs  �N/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/compiler.py�	<setcomp>rs�s��;�;�;��c�!�f�f�;�;�;��
�$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	:%(name)s)�pyformat�qmark�format�numeric�named� AND z OR z + 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 LAST�coalesce�CURRENT_DATE�CURRENT_TIME�CURRENT_TIMESTAMP�CURRENT_USER�	LOCALTIME�LOCALTIMESTAMP�random�sysdate�SESSION_USER�USER�CUBE�ROLLUPz
GROUPING SETS�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���eZdZdZdZdZej��Z	ddej��fd�Z	ej
dd��d���Zd�Ze
d���Zd	�Zd
�Zdd�Ze
d���Zd
�Zd�ZdS)�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.
    Nc��||_||_|jj|_||_|r|j�|��|_|�@||_|j|_|jr|j	|_
|j|jfi|��|_dSdS)a|Construct a new :class:`.Compiled` object.

        :param dialect: :class:`.Dialect` to compile against.

        :param statement: :class:`_expression.ClauseElement` to be compiled.

        :param bind: Optional Engine or Connection to compile this
          statement against.

        :param schema_translate_map: dictionary of schema names to be
         translated when forming the resultant SQL

         .. versionadded:: 1.1

         .. seealso::

            :ref:`schema_translating`

        :param compile_kwargs: additional kwargs that will be
         passed to the initial call to :meth:`.Compiled.process`.


        N)
�dialect�bind�identifier_preparer�preparer�schema_translate_map�_with_schema_translate�	statement�supports_execution�can_execute�_execution_options�execution_options�process�string)�selfr�r�r�r��compile_kwargss      rr�__init__zCompiled.__init__s���@�����	���8��
�$8��!��	� �M�@�@�$���D�M�� �&�D�N�(�;�D����
F�)2�)E��&�&�$�,�t�~�H�H��H�H�D�K�K�K�!� rtz0.7z�The :meth:`.Compiled.compile` method is deprecated and will be removed in a future release.   The :class:`.Compiled` object now runs its compilation within the constructor, and this method does nothing.c��dS)z;Produce the internal string representation of this element.Nrn�r�s rr�compilezCompiled.compileDs	��	
�rtc�p�|jr|�|||��Stj|j����N)r��_execute_compiledr
�ObjectNotExecutableErrorr�)r��
connection�multiparams�paramss    rr�_execute_on_connectionzCompiled._execute_on_connectionOs8����	?��/�/��k�6�J�J�J��.�t�~�>�>�>rtc��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 rr�sql_compilerzCompiled.sql_compilerU���"�#�#�#rtc��|j|fi|��Sr���_compiler_dispatch)r��obj�kwargss   rrr�zCompiled.process_s��%�s�%�d�5�5�f�5�5�5rtc��|jpdS)z3Return the string text of the generated SQL or DDL.�)r�r�s rr�__str__zCompiled.__str__bs���{� �b� rtc��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�r�s  rr�construct_paramszCompiled.construct_paramsgr�rtc�*�|���S)z0Return the bind params for this compiled object.�r�r�s rrr�zCompiled.paramsqs���$�$�&�&�&rtc�n�|j}|�tjdd����|�|||��S)zExecute this compiled object.Nz>This Compiled object is not bound to any Engine or Connection.�2afi��code)r�r
�UnboundExecutionErrorr�)r�r�r��es    rr�executezCompiled.executevsL��
�I���9��+�!�����
�
�"�"�4��f�=�=�=rtc�@�|j|i|�����S)zJExecute this compiled object and return the result's
        scalar value.)r��scalar)r�r�r�s   rrr�zCompiled.scalar�s'���t�|�[�3�F�3�3�:�:�<�<�<rtr�)�__name__�
__module__�__qualname__�__doc__�_cached_metadatar�r�
immutabledictr�r��
deprecatedr�r��propertyr�r�r�r�r�r�r�rnrtrrr�r��s:������
�
�����*��*�,�,����!�)�t�)�+�+�
.I�.I�.I�.I�`�T�_�
�	���
�
���
�?�?�?��$�$��X�$�6�6�6�!�!�!�
$�$�$�$��'�'��X�'�
>�
>�
>�=�=�=�=�=rtr�c�"�eZdZdZdZd�Zd�ZdS)�TypeCompilerz2Produces DDL specification for TypeEngine objects.z	visit_\w+c��||_dSr�)r�)r�r�s  rrr�zTypeCompiler.__init__�s
������rtc��|j|fi|��Sr�r��r��type_�kws   rrr�zTypeCompiler.process�s��'�u�'��3�3��3�3�3rtN)r�r�r�r��ensure_kwargr�r�rnrtrrr�r��s=������<�<��L����4�4�4�4�4rtr�c�T�eZdZdZdZdZd
d�Zed���Zed���Z	d�Z
d	S)�
_CompileLabelz;lightweight label object which acts as an expression.Label.�label)�element�namernc�8�||_||_|f|z|_dSr�)r�r��
_alt_names)r��colr��	alt_namess    rrr�z_CompileLabel.__init__�s"�������	��&�9�,����rtc��|jjSr�)r��	proxy_setr�s rrr�z_CompileLabel.proxy_set�s
���|�%�%rtc��|jjSr�)r��typer�s rrr�z_CompileLabel.type�s
���|� � rtc��|Sr�rn)r�r�s  rr�
self_groupz_CompileLabel.self_group�s���rtN)rn)r�r�r�r��__visit_name__�	__slots__r�r�r�r�r�rnrtrrr�r��s}������E�E��N�!�I�-�-�-�-�
�&�&��X�&��!�!��X�!�����rtr�c��eZdZdZd�ZdS)�prefix_anon_mapacA map that creates new keys for missing key access.
    Considers keys of the form "<ident> <name>" to produce
    new symbols "<name>_<index>", where "index" is an incrementing integer
    corresponding to <name>.
    Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
    is otherwise usually used for this type of operation.
    c��|�dd��\}}|�|d��}|dz||<|dzt|��z}|||<|S)N� r�_)�split�getro)r��key�ident�derived�anonymous_counter�values      rr�__missing__zprefix_anon_map.__missing__�sa���9�9�S�!�,�,���� �H�H�W�a�0�0��)�A�-��W�
��#�
��$5� 6� 6�6����S�	��rtN)r�r�r�r�r
rnrtrrr�r��s-������������rtr�c��eZdZdZeZeZdxZxZ	Z
	dZdZ	dZ
	dZ	dZ	dZ	dZ	dZ	dZ	dZ	dxZZ	d�d�Zed���Zed���Zejd	���Zejd
���Z d�Z!ej"d���Z#d
�Z$ed���Z%d�d�Z&ed���Z'ej(d��d���Z)d�Z*d�d�Z+	d�d�Z,	d�d�Z-				d�d�Z.d�Z/	d�d�Z0d�Z1d�Z2d�Z3d�Z4d�Z5d�Z6d �Z7	d�d!�Z8d"�Z9d#�Z:d$�Z;d%�Z<d&�Z=d'�Z>d(�Z?d)�Z@d*�ZAd+�ZBd,�ZCd-�ZDd�d.�ZEd/�ZFd0�ZGd1�ZH	d�d3�ZId4�ZJd5�ZKd6�ZLd7�ZMd8�ZNd9�ZOd:�ZPd;�ZQd<�ZR	d�d=�ZSd>�ZTd?�ZUd@�ZVdA�ZWdB�ZX	d�dC�ZYdD�ZZdE�Z[ej"dF���Z\dG�Z]dH�Z^dI�Z_dJ�Z`dK�ZadL�ZbdM�ZcdN�ZddO�ZedP�ZfdQ�ZgdR�Zh			d�dS�ZidT�ZjdU�ZkdV�ZldW�ZmdX�Zn	d�dY�Zo				d�dZ�Zp				d�d[�Zqd\�Zrd�d]�Zsd^�Ztd_�Zu			d�d`�Zvda�Zwdb�Zxdc�Zydd�Zzde�Z{df�Z|dg�Z}ej~dhe��fdie��fg��Z�d�dj�Z�							d�dk�Z�dl�Z�dm�Z�dn�Z�do�Z�dp�Z�dq�Z�dr�Z�ds�Z�dt�Z�du�Z�dv�Z�dw�Z�					d�dx�Z�d�dy�Z�dz�Z�d�d{�Z�d|�Z�d}�Z�d~�Z�d�d�Z�ej"d����Z�d��Z�d��Z�d�d��Z�d��Z�d��Z�d��Z�dS)��SQLCompilerz~Default implementation of :class:`.Compiled`.

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

    FNTrnc�L�||_|pt|dd��|_i|_t	j��|_g|_g|_|j	|_	|j	rg|_
|jdk|_t|j|_d|_|jp|j|_t%��|_i|_t+j|||fi|��|js|js|jr|jr|j|_|j	r|jr|���dSdSdS)aConstruct a new :class:`.SQLCompiler` object.

        :param dialect: :class:`.Dialect` to be used

        :param statement: :class:`_expression.ClauseElement` to be compiled

        :param column_keys:  a list of column names to be compiled into an
         INSERT or UPDATE statement.

        :param inline: whether to generate INSERT statements as "inline", e.g.
         not formatted to return any generated defaults

        :param kwargs: additional keyword arguments to be consumed by the
         superclass.

        �inlineFr{N)�column_keys�getattrr�bindsr�column_dict�
bind_names�stack�_result_columns�
positional�positiontup�
paramstyle�_numeric_binds�BIND_TEMPLATES�bindtemplate�ctes�label_length�max_identifier_lengthr��anon_map�truncated_namesr�r��isinsert�isupdate�isdelete�
_returning�	returning�_apply_numbered_params)r�r�r�rrr�s      rrr�zSQLCompiler.__init__s_��&'����C��	�8�U� C� C�����
��*�,�,�����
� "���"�,����?�	B�!�D��")�"4�	�"A�D��*�7�+=�>�����	�
� �A�G�$A�	
��(�)�)��
� "�����$���=�=�f�=�=�=�
�M�	2�!�]�	2�.2�m�	2��"�	2�'�1�D�N��?�	*�t�2�	*��'�'�)�)�)�)�)�	*�	*�	*�	*rtc��	|jddS#t$r.}tjtd��|���Yd}~dSd}~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 entry��replace_contextN)r�
IndexErrorr�raise_)r��ies  rr�current_executablezSQLCompiler.current_executableZs}��<	��:�b�>�,�/�/���	�	�	��K��A�B�B� "�
�
�
�
�
�
�
�
�
�
�����	���s��
A
�#A�A
c�:�t|j|jz��Sr�)�list�insert_prefetch�update_prefetchr�s rr�prefetchzSQLCompiler.prefetch�s���D�(�4�+?�?�@�@�@rtc�r�tj��|_i|_d|_|jr	i|_dSdS)z�Initialize collections related to CTEs only if
        a CTE is located, to save on the overhead of
        these collections otherwise.

        FN)r�OrderedDictr�ctes_by_name�ctes_recursiver�cte_positionalr�s rr�_init_cte_statezSQLCompiler._init_cte_state�sF���$�&�&��	����#����?�	%�"$�D����	%�	%rtc#�@K�|j|j}}gdc|_|_	|jr|jd}d|d<nd}|j|jfV�|r|�d��||c|_|_dS#|r|�d��||c|_|_wxYw)z;special API to support the use case of 'nested result sets'Fr(T�need_result_map_for_nestedN)r�_ordered_columnsr�pop)r��result_columns�ordered_columns�entrys    rr�_nested_resultzSQLCompiler._nested_result�s�����
� ��!�(��79�%�3���d�3�
	��z�
��
�2���6:��2�3�3����&��(=�=�=�=�=��
8��	�	�6�7�7�7���
8�D� �$�"7�"7�"7���
8��	�	�6�7�7�7���
8�D� �$�"7�
�
�
�
s�,A5�5(Bc�v��tjd���tjd�fd�|j��|_dS)Nrz
\[_POSITION\]c�F��ttj�����Sr�)ror�next)�m�poscounts �rr�<lambda>z4SQLCompiler._apply_numbered_params.<locals>.<lambda>�s����D�I�h�,?�,?�(@�(@�rt)�	itertools�count�re�subr�)r�rFs @rrr&z"SQLCompiler._apply_numbered_params�s<����?�1�%�%���f��@�@�@�@�$�+�
�
����rtc�X��td��fd��jD��D����S)Nc3�(K�|]
\}}|�||fV��dSr�rn)rprr	s   rr�	<genexpr>z/SQLCompiler._bind_processors.<locals>.<genexpr>�s@����

�

���U�� ��%�L�!� � � �

�

rtc3�p�K�|]0}�j||j��j��fV��1dSr�)rr��_cached_bind_processorr�)rp�	bindparamr�s  �rrrNz/SQLCompiler._bind_processors.<locals>.<genexpr>�sZ�������
��O�I�.��N�9�9�$�,�G�G�������rt)�dictrr�s`rr�_bind_processorszSQLCompiler._bind_processors�sX����

�

�����
"&�����

�

�

�

�

�
	
rtc�2�t|j��dkS�Nr)�lenrr�s rr�is_subqueryzSQLCompiler.is_subquery�s���4�:����"�"rtc��|Sr�rnr�s rrr�zSQLCompiler.sql_compiler�s���rtc�l�|r�i}|jD]�}|j|}|j|vr||j||<�)||vr||||<�9|rG|jr@|r tjd|j|fzd����tjd|jzd����|jr|j||<��|j||<��|Si}|jD]}}|rG|jr@|r tjd|j|fzd����tjd|jzd����|jr|j||j|<�h|j||j|<�~|S)z5return a dictionary of bind parameter keys and valuesz@A value is required for bind parameter %r, in parameter group %d�cd3xr�z)A value is required for bind parameter %r)rr�requiredr
�InvalidRequestError�callable�effective_valuer	)r�r��
_group_number�_check�pdrQr�s       rrr�zSQLCompiler.construct_params�s����3	��B�!�_�
/�
/�	���y�1���=�F�*�*�%�i�m�4�B�t�H�H��V�^�^�%�d�|�B�t�H�H��/�	� 2�/�$��!�5�4�(�}�m�<�=�"(�	����"�5�G�'�m�,�!'������'�/�(�8�B�t�H�H�(��B�t�H�H��I��B�!�_�
E�
E�	��
�i�0�
�$��!�5�4�(�}�m�<�=�"(�	����"�5�G�'�m�,�!'������%�E�5>�5N�B�t��y�1�2�2�5>�_�B�t��y�1�2�2��Irtc�.�|�d���S)zoReturn the bind param dictionary embedded into this
        compiled object, for those values that are present.F)r`r�r�s rrr�zSQLCompiler.params�s���$�$�E�$�2�2�2rtzsqlalchemy.engine.resultc�@�|j�|j��S)z(utility method used for unit tests only.)�ResultMetaData�_create_result_mapr)r��results  rrrezSQLCompiler._create_result_maps���$�7�7��8L�M�M�Mrtc��dS)z�Called when a SELECT statement has no froms, and no FROM clause is
        to be appended.

        Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output.

        r�rnr�s rr�default_fromzSQLCompiler.default_froms	���rrtc�4�d|jj|fi|��zdzS)N�(�)�r�r�)r��grouping�asfromr�s    rr�visit_groupingzSQLCompiler.visit_groupings+���8�X�%�8��H�H��H�H�H�3�N�Nrtc�(�|jrw|jjrk|jdd}|j\}}}|r|}n|}|jj}	|	�8|	j|vr/|	�||	j��r|jj|d<|j|jfd|i|��S)Nr(r	�render_label_as_label�within_columns_clause)	rr��supports_simple_order_by_label�_label_resolve_dictr��_order_by_label_elementr��shares_lineager�)
r�r�rrr�r	�	with_cols�
only_froms�	only_cols�resolve_dict�
order_by_elems
          rr�visit_label_referencez!SQLCompiler.visit_label_references����:�	<�$�,�E�	<���B���5�J�/9�/M�,�I�z�9�$�
)�)���(��$�O�C�M��)�!�&�,�6�6�!�0�0� ��!3�4���7��O�;��+���t�|��O�
�
�"7�
��
�
�	
rtc�d�|js|�|j��S|jdd}|j\}}}	|r||j}n
||j}||d<|j|fd|i|��S#t
$r2}	t
j|jtj	d|	���Yd}	~	dSd}	~	wwxYw)Nr(r	rqrrzECan't resolve label reference for ORDER BY / GROUP BY / DISTINCT etc.)�err)
rr��_text_clausertr��KeyErrorr�_no_text_coercionr
�CompileError)
r�r�rrr�r	rwrxryr��kes
          rr�visit_textual_label_referencez)SQLCompiler.visit_textual_label_reference6s���z�	6��<�<�� 4�5�5�5��Z��^�L�1�
�+5�+I�(�	�:�y�	�$�
1� ���1������0��/2�F�*�+��4�<����+@��DJ���
���	�	�	��&���� �+��
�
�
�
�
�
�
�
�
�
�����	���s�A3�3
B/�='B*�*B/c���|o|}||u}|s|rBt|jtj��r|�d|j��}	n|j}	|rn|�"||	|j||	f|jz|j��|jj|fddd�|��ttjz|j�
||	��zS|r|j�
||	��S|jj|fddi|��S)N�colidentT)rr�within_label_clauserrF)�
isinstancer�r�_truncated_label�_truncated_identifierr�r�r�r��	OPERATORSr�as_r��format_label)
r�r��add_to_result_mapr�rrrqr��render_label_with_as�render_label_only�	labelnames
          rr�visit_labelzSQLCompiler.visit_labelRsa��
"�=�*=�&=�	�2�U�:���	'� 4�	'��%�*�h�&?�@�@�
'� �6�6�z�5�:�N�N�	�	�!�J�	��	� �,�!�!���J��I�&��)9�9��J�	���1��
�0���*.�(,����	���I�M�*�
+��-�,�,�U�I�>�>�?�	
��	��=�-�-�e�Y�?�?�?�3�5�=�3����,1��57���
rtc�*�tjd���)Nz:Cannot compile Column object until its 'name' is assigned.�r
r��r�r s  rr�_fallback_column_namez!SQLCompiler._fallback_column_name�s����K�
�
�	
rtc��|jx}}|�|�|��}|j}|s0t|tj��r|�d|��}|�||||||jf|j��|r|�	|��}n|j
�|��}|j}|�	|r|j
s|S|j
�|��}	|	r|j
�|	��dz}
nd}
|j}t|tj��r|�d|��}|
|j
�|��zdz|zS)Nr��.r��alias)r�r��
is_literalr�rr�r�rr��escape_literal_columnr��quotera�named_with_column�schema_for_object�quote_schema)r�r r��
include_tabler�r��	orig_namer�ra�effective_schema�
schema_prefix�	tablenames            rr�visit_columnzSQLCompiler.visit_column�s���"�;�&��y��<��-�-�f�5�5�D��&�
��	@�j��x�/H�I�I�	@��-�-�j�$�?�?�D��(����i�&�$��
�!;�V�[�
�
�
��	-��-�-�d�3�3�D�D��=�&�&�t�,�,�D�����=�
�=�U�5L�=��K�#�}�>�>�u�E�E���
#��M�.�.�/?�@�@�3�F��
�!#�
��
�I��)�X�%>�?�?�
K� �6�6�w�	�J�J�	� �4�=�#6�#6�y�#A�#A�A�C�G�$�N�Nrtc�@�|j�|j��Sr�)r��format_collation�	collation)r�r�r�s   rr�visit_collationzSQLCompiler.visit_collation�s���}�-�-�g�.?�@�@�@rtc��|jSr��r�)r��
fromclauser�s   rr�visit_fromclausezSQLCompiler.visit_fromclause�s
����rtc��|jSr�r�)r��indexr�s   rr�visit_indexzSQLCompiler.visit_index�s
���z�rtc�F�||d<|jjj|jfi|��S)N�type_expression)r��
type_compilerr�r�)r��
typeclauser�s   rr�visit_typeclausezSQLCompiler.visit_typeclause�s/�� *����1�t�|�)�1�*�/�H�H�R�H�H�Hrtc�J�|jjr|�dd��}|S�N�%�%%�r��_double_percents�replace�r��texts  rr�post_process_textzSQLCompiler.post_process_text��'���=�)�	+��<�<��T�*�*�D��rtc�J�|jjr|�dd��}|Sr�r�r�s  rrr�z!SQLCompiler.escape_literal_column�r�rtc	���������fd�}�jsd�_t�d�t�|���j������S)Nc���|�d��}|�jvr�j�j|fi���S�j|fi���SrU)r8�_bindparamsr��bindparam_string)rEr�r�r��
textclauses  ���rr�do_bindparamz2SQLCompiler.visit_textclause.<locals>.do_bindparam�s]����7�7�1�:�:�D��z�-�-�-�#�t�|�J�$:�4�$@�G�G�B�G�G�G�,�t�,�T�8�8�R�8�8�8rtTc�,�|�d��SrU)r8)rEs rrrGz.SQLCompiler.visit_textclause.<locals>.<lambda>�s��a�g�g�a�j�j�rt)r�isplaintext�BIND_PARAMS_ESCrK�BIND_PARAMSr�r�)r�r�r�r�s``` rr�visit_textclausezSQLCompiler.visit_textclause�s������	9�	9�	9�	9�	9�	9�	9��z�	$�#�D���"�"� � ��O�O��d�4�4�Z�_�E�E�
�
�
�
�	
rtc�Z�|j}|r|jn|jd}|p1|dko|�dd��p|�dd��}|r:|jx|_|_|jD]}	|�|	d|j���� |j|j	fi|��}
|r|rd|
z}
|
S)	Nr(r�need_result_map_for_compoundFr;T�rrr��(%s))
r�_default_stack_entryrrr<�_textual_ordered_columns�column_argsr��_add_to_result_mapr�)r��taf�compound_indexrn�parensr��toplevelr@�populate_result_map�cr�s           rr�visit_text_as_fromzSQLCompiler.visit_text_as_from�s���z�>��-5�I��)�)�4�:�b�>��
�
>��!�#�E��I�I�<�e�D�D�
>�
�y�y�5�u�=�=�
	��		���
�D�!��-��_�
�
������*.�&*�&=�������t�|�C�K�.�.�2�.�.���	!�f�	!��D�=�D��rtc��dS)N�NULLrn�r��exprr�s   rr�
visit_nullzSQLCompiler.visit_null�����vrtc�"�|jjrdSdS)Nre�1�r��supports_native_booleanr�s   rr�
visit_truezSQLCompiler.visit_true�s���<�/�	��6��3rtc�"�|jjrdSdS)Nr1�0r�r�s   rr�visit_falsezSQLCompiler.visit_falses���<�/�	��7��3rtc�����|j}|�d}nt|j}|�d���fd�|jD��D����}|jr�jjrd|z}|S)Nrc3�K�|]}|�|V��	dSr�rn�rp�ss  rrrNz/SQLCompiler.visit_clauselist.<locals>.<genexpr>s>����
�
���
�
�
�
�
�
�
�
rtc3�4�K�|]}|j�fi���V��dSr�r�)rpr�r�r�s  ��rrrNz/SQLCompiler.visit_clauselist.<locals>.<genexpr>sJ�������56�$��$�T�0�0�R�0�0������rtzVALUES )�operatorr�rB�clauses�
_tuple_valuesr��tuple_in_values)r��
clauselistr��sepr�s` `  rr�visit_clauselistzSQLCompiler.visit_clauselist	s������!���;��C�C��J�/�0�C��x�x�
�
������:D�:L����
�
�
�
�
���#�	$���(D�	$��t�#�D��rtc��d}|j�||jj|fi|��dzz
}|jD].\}}|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�rq�condrfs      rr�
visit_casezSQLCompiler.visit_cases������<�#�
�0���0��@�@��@�@�3�F�F�A�"�L�	�	�L�D�&�
��)�$�)�$�9�9�&�9�9�:���,�&�+�D�;�;�F�;�;�<��	�
�A�A��<�#�
��9�&�,�9�$�I�I�&�I�I�I�C�O�
�A�	
�U�
���rtc�(�|jj|fi|��Sr�)�typed_expressionr�)r��type_coercer�s   rr�visit_type_coercezSQLCompiler.visit_type_coerce.s ��>�{�+�>�t�J�J�r�J�J�Jrtc�X�d|jj|fi|���d|jj|fi|���d�S)NzCAST(r�rk)r�r�r�)r�rr�s   rr�
visit_castzSQLCompiler.visit_cast1sN���*�D�K�*�4�:�:�6�:�:�:�:�.�D�O�.�t�>�>�v�>�>�>�>�
�	
rtc
�d�|dtjurdn�|dtjurdnj|ddkr6|jtjt|d����fi|���d�n(|jtj|d��fi|���d��d|dtjurdn�|dtjurdnj|ddkr6|jtjt|d����fi|���d�n(|jtj|d��fi|���d���S)	NrzUNBOUNDED PRECEDINGzCURRENT ROWz
 PRECEDINGz
 FOLLOWINGr}rzUNBOUNDED FOLLOWING)r�RANGE_UNBOUNDED�
RANGE_CURRENTr��literal�abs)r��range_r�s   rr�_format_frame_clausez SQLCompiler._format_frame_clause7s����a�y�H�4�4�4�
"�!��a�y�H�2�2�2����a�y�1�}�}��t�|�H�,�S����^�^�<�<�C�C��C�C�C�C�F�F��t�|�H�,�V�A�Y�7�7�>�>�2�>�>�>�>�A�
A�
A��a�y�H�4�4�4�
"�!��a�y�H�2�2�2����a�y�1�}�}��t�|�H�,�S����^�^�<�<�C�C��C�C�C�C�F�F��t�|�H�,�V�A�Y�7�7�>�>�2�>�>�>�>�A�
A�
�	
rtc�$���|jrd�j|jfi���z}n |jrd�j|jfi���z}nd}|jj�fi����dd���fd�d|jfd|jffD��|r|gngz���d�S)	NzRANGE BETWEEN %szROWS BETWEEN %sz OVER (rc	�^��g|])\}}|�t|���|�d|j�fi�������*S)Nz BY )rVr�)rp�wordr�r�r�s   ��rr�
<listcomp>z*SQLCompiler.visit_over.<locals>.<listcomp>]sc������%��f��)�c�&�k�k�)��t�t�6�V�6�t�F�F�v�F�F�F�H�*�)�)rt�	PARTITION�ORDERrk)rr	�rowsr�r�rB�partition_by�order_by)r��overr�rs` ` rr�
visit_overzSQLCompiler.visit_overNs!�����;�		�'�*C�$�*C���+�+�%�+�+��F�F��Y�	�&�)B��)B��	�*�*�#�*�*��F�F��F�
,�D�L�+�D�;�;�F�;�;�;�;��H�H������%�d�&7�8� �$�-�0�)���� &�-�F�8�8�2�	/�
�
�
�
�
�	
rtc�V�|jj|fi|���d|jj|fi|���d�S)Nz WITHIN GROUP (ORDER BY rk)r�r�r)r��withingroupr�s   rr�visit_withingroupzSQLCompiler.visit_withingroupjsN��2�K��2�4�B�B�6�B�B�B�B�3�K� �3�D�C�C�F�C�C�C�C�
�	
rtc�V�|jj|fi|���d|jj|fi|���d�S)Nz FILTER (WHERE rk)�funcr��	criterion)r��
funcfilterr�s   rr�visit_funcfilterzSQLCompiler.visit_funcfilterpsM��.�J�O�.�t�>�>�v�>�>�>�>�3�J� �3�D�C�C�F�C�C�C�C�
�	
rtc��|j�|j|j��}d|�d|jj|fi|���d�S)NzEXTRACT(r�rk)�extract_mapr�fieldr�r�)r��extractr�rs    rr�
visit_extractzSQLCompiler.visit_extractvsQ��� �$�$�W�]�G�M�B�B����E�E�+�G�L�+�D�;�;�F�;�;�;�;�
�	
rtc�>���|�||j|jd|j��t�d|j���zd��}|r	||fi|��St�|jd����r
|jr�dz
�n\|j��j�	���st�tj��r�j�
���n���dz�d���fd�|jD���gz��d�j|fi|��izS)Nrnz
visit_%s_funcz%(expr)sr�c���g|]R}�j�|��st�tj��r�j�|��n|��SSrn)r��_requires_quotes_illegal_charsr�r�quoted_namer�)rp�tokr�r�s  ��rrr
z.SQLCompiler.visit_function.<locals>.<listcomp>�so�������	 �=�G�G��L�L�!�%�d�H�,@�A�A�!��
�+�+�C�0�0�0�!���rtr�)r�r�r�lower�	FUNCTIONSr�	__class__�	_has_argsr�r$r�rr%r�rB�packagenames�function_argspec)r�rr�r��dispr�s`    @rr�visit_functionzSQLCompiler.visit_function}sv�����(���d�i���B��	�B�B�B��t�_�t�y���/@�/@�@�$�G�G���	@��4��'�'��'�'�'��=�=����6�6�D��
)��>�'��J�&�D���y���}�C�C�D�I�I��!�$��(<�=�=��D�M�'�'��-�-�-��	��j�(���8�8������ $�0�����&�	����.��.�t�>�>�v�>�>�?�@�
@rtc�6�|�|j��Sr�)�visit_sequence�sequence)r��
next_valuer�s   rr�visit_next_value_funcz!SQLCompiler.visit_next_value_func�s���"�"�:�#6�7�7�7rtc�:�td|jjz���)Nz2Dialect '%s' does not support sequence increments.�r�r�r�)r�r1r�s   rrr0zSQLCompiler.visit_sequence�s$��!�@��l��
 �
�
�	
rtc�(�|jj|fi|��Sr�)�clause_exprr�)r�rr�s   rrr,zSQLCompiler.function_argspec�s ��2�t��2�4�B�B�6�B�B�Brtrc
������j}|r�jn�jd}|p|dko|�dd��}�j�|d|d||d����j�|j��}	d|	zdz����fd	�t|j��D����}
|
�j	|fitdd
�i�����z
}
|
�j|fi���z
}
|
|jdus	|j
dur�j|fi���pdz
}
�jr|r����|
z}
�j�d���r
|rd|
zd
zS|
S)Nr(rr�F�correlate_froms�asfrom_froms)r9r:r	r�rc3�B�K�|]\}}|j�f�d|d����V��dS)F)rnr�r�Nr�)rp�ir�rnr�r�s   ���rrrNz4SQLCompiler.visit_compound_select.<locals>.<genexpr>�sl�����	
�	
��A�q�%��$���!� �#$�	��
���	
�	
�	
�	
�	
�	
rtrnr�rjrkrn)rr�r�append�compound_keywords�keywordrB�	enumerate�selects�group_by_clauserR�order_by_clause�
_limit_clause�_offset_clause�limit_clauser�_render_cte_clauser=)r��csrnr�r�r�r�r@�need_result_mapr?r�s` `  `     rr�visit_compound_selectz!SQLCompiler.visit_compound_select�s������z�>��-5�I��)�)�4�:�b�>��"�
��a��
A��	�	�8�%�@�@�	�
	
�
���#(�):�#;� %�n� 5� �0?�	
�
�	
�	
�	
��(�,�,�R�Z�8�8���g�
��#�)�)�	
�	
�	
�	
�	
�	
�&�b�j�1�1�	
�	
�	
�
�
��	
�$��$�R�I�I�4�+H�+H�v�+H��+H�+H�I�I�I���$��$�R�2�2�6�2�2�2���
�
�T�
)�
J�R�->�d�-J�
0�!��!�"�/�/��/�/�
��	
���9�	4��	4��*�*�,�,�t�3�D��
���r�����	�f�	���:��#�#��Krtc�P�d|j�d|�|rd|znd��}t||d��S)N�visit_rr�)r�r)r��	operator_�
qualifier1�
qualifier2�attrnames     rr�_get_operator_dispatchz"SQLCompiler._get_operator_dispatch�sE��������J� *�2�C�*����2�
��
�t�X�t�,�,�,rtc��|jrg|jrtjd���|�|jdd��}|r|||jfi|��S|j|t|jfi|��S|jrL|�|jdd��}|r|||jfi|��S|j|t|jfi|��Stjd���)NzFUnary expression does not support operator and modifier simultaneously�unaryr��modifierz,Unary expression has no operator or modifier)r�rTr
r�rQ� _generate_generic_unary_operatorr�� _generate_generic_unary_modifier)r�rSr�r-s    rr�visit_unaryzSQLCompiler.visit_unary�s@���>�	��~�
��&�2�����.�.�������D��
��t�E�5�>�8�8�R�8�8�8�<�t�<��9�U�^�4���8:�����^�
	��.�.�������D��
��t�E�5�>�8�8�R�8�8�8�<�t�<��9�U�^�4���8:�����"�>���
rtc�z�|js|jjr|j|jfi|��Sd|j|jfi|��zS)Nz%s = 1��_is_implicitly_booleanr�r�r�r��r�r�r�r�s    rr�visit_istrue_unary_operatorz'SQLCompiler.visit_istrue_unary_operators[���*�	B��|�3�	B� �4�<���6�6�2�6�6�6��l�d�l�7�?�A�A�b�A�A�A�Artc��|js|jjrd|j|jfi|��zSd|j|jfi|��zS)N�NOT %sz%s = 0rYr[s    rr�visit_isfalse_unary_operatorz(SQLCompiler.visit_isfalse_unary_operators`���*�	B��|�3�	B��l�d�l�7�?�A�A�b�A�A�A�A��l�d�l�7�?�A�A�b�A�A�A�Artc�J�d|�|tj���zS)Nr^)�override_operator)�visit_binaryr�match_op�r�rr�r�s    rr�visit_notmatch_op_binaryz$SQLCompiler.visit_notmatch_op_binarys.���$�+�+��i�&8�,�
�
�
�	
rtc�.�tjd��dS)Nz�The IN-predicate was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate.  Consider alternative strategies for improved performance.)r�warnr�s rr�_emit_empty_in_warningz"SQLCompiler._emit_empty_in_warnings%���	�
3�	
�	
�	
�	
�	
rtc��|jjrdS|jjr|���|�|j|jk��S)Nz1 != 1�r��_use_static_in�_warn_on_empty_inrhr�rDrds    rr�visit_empty_in_op_binaryz$SQLCompiler.visit_empty_in_op_binary%sN���<�&�	<��8��|�-�
.��+�+�-�-�-��<�<���v�{� :�;�;�;rtc��|jjrdS|jjr|���|�|j|jk��S)Nz1 = 1rjrds    rr�visit_empty_notin_op_binaryz'SQLCompiler.visit_empty_notin_op_binary-sN���<�&�	<��7��|�-�
.��+�+�-�-�-��<�<���v�{� :�;�;�;rtc�:�td|jjz���)Nz3Dialect '%s' does not support empty set expression.r5)r��
element_typess  rr�visit_empty_set_exprz SQLCompiler.visit_empty_set_expr5s$��!�A��l��
 �
�
�	
rtc��|jrCt|jtj��r$t|jtj��rd|d<|p|j}|�|dd��}|r
|||fi|��S	t|}|j	||fi|��S#t$r4}tjtj||��|���Yd}~dSd}~wwxYw)NT�
literal_bindsrr))�ansi_bind_rulesr�rDr�
BindParameterrZr�rQr��_generate_generic_binaryr�rr,r
�UnsupportedCompilationError)	r�rra�eager_groupingr�rMr-�opstringr~s	         rrrbzSQLCompiler.visit_binary;s+��
� �	'��6�;��(>�?�?�	'��6�<��)?�@�@�	'�
#'�B���%�8���	��*�*�9�h��E�E���	M��4��	�0�0�R�0�0�0�
M�$�Y�/��5�t�4�V�X�L�L��L�L�L��
�
�
�
����3�D�)�D�D�$'���������������
���s�8
B�
C�)C
�
Cc�(�|j|jfi|��Sr�)r��sql_functionr[s    rr�&visit_function_as_comparison_op_binaryz2SQLCompiler.visit_function_as_comparison_op_binaryVs���t�|�G�0�7�7�B�7�7�7rtc���|jjr*|j|jfi|��dz|j|jfi|��zS|j|jfi|��dz|j|jfi|��zS)Nz %% r~)r�r�r�rDrZrds    rr�visit_mod_binaryzSQLCompiler.visit_mod_binaryYs����=�)�	����V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3�
����V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3�
rtc�J�|j|d<|j|d|jzdzfi|��S)Nryr)ryrwrzr[s    rr�visit_custom_op_binaryz"SQLCompiler.visit_custom_op_binarygsF��'�6����,�t�,��S�8�,�,�s�2�
�
�68�
�
�	
rtc�0�|j||jdzfi|��S�Nr)rUrzr[s    rr�visit_custom_op_unary_operatorz*SQLCompiler.visit_custom_op_unary_operatorms3��4�t�4��X�&��,�
�
�02�
�
�	
rtc�0�|j|d|jzfi|��Sr�)rVrzr[s    rr�visit_custom_op_unary_modifierz*SQLCompiler.visit_custom_op_unary_modifierrs3��4�t�4��S�8�,�,�
�
�02�
�
�	
rtc��|�dd��}d|d<|jj|fd|i|��|z|jj|fd|i|��z}|r|rd|z}|S)N�
_in_binaryFTryr�)rrDr�rZ)r�rrzryr�r�r�s       rrrwz$SQLCompiler._generate_generic_binaryws����V�V�L�%�0�0�
���<��*�F�K�*��
�
�%3�
�79�
�
��
�.�f�l�-����%3��79���	
�	
��	!�.�	!��D�=�D��rtc�.�||jj|fi|��zSr�rl�r�rSrzr�s    rrrUz,SQLCompiler._generate_generic_unary_operator�s%���:�%�-�:�4�F�F�2�F�F�F�Frtc�.�|jj|fi|��|zSr�rlr�s    rrrVz,SQLCompiler._generate_generic_unary_modifier�s$��/�u�}�/��;�;��;�;�h�F�Frtc�B�tjdtj���S)Nz'%')r�)r�literal_columnr
�
STRINGTYPEr�s rr�_like_percent_literalz!SQLCompiler._like_percent_literal�s���&�u�H�4G�H�H�H�Hrtc��|���}|j}|�|j���|��|_|j||fi|��Sr���_cloner��__add__rZ�visit_like_op_binary�r�rr�r��percents     rr�visit_contains_op_binaryz$SQLCompiler.visit_contains_op_binary�sW���������,�����v�|�4�4�<�<�W�E�E���(�t�(���@�@�R�@�@�@rtc��|���}|j}|�|j���|��|_|j||fi|��Sr��r�r�r�rZ�visit_notlike_op_binaryr�s     rr�visit_notcontains_op_binaryz'SQLCompiler.visit_notcontains_op_binary�sW���������,�����v�|�4�4�<�<�W�E�E���+�t�+�F�H�C�C��C�C�Crtc��|���}|j}|�|j��|_|j||fi|��Sr�)r�r��__radd__rZr�r�s     rr�visit_startswith_op_binaryz&SQLCompiler.visit_startswith_op_binary�sK���������,���'�'���5�5���(�t�(���@�@�R�@�@�@rtc��|���}|j}|�|j��|_|j||fi|��Sr�)r�r�r�rZr�r�s     rr�visit_notstartswith_op_binaryz)SQLCompiler.visit_notstartswith_op_binary�sK���������,���'�'���5�5���+�t�+�F�H�C�C��C�C�Crtc��|���}|j}|�|j��|_|j||fi|��Sr�r�r�s     rr�visit_endswith_op_binaryz$SQLCompiler.visit_endswith_op_binary�sI���������,�����v�|�4�4���(�t�(���@�@�R�@�@�@rtc��|���}|j}|�|j��|_|j||fi|��Sr�r�r�s     rr�visit_notendswith_op_binaryz'SQLCompiler.visit_notendswith_op_binary�sI���������,�����v�|�4�4���+�t�+�F�H�C�C��C�C�Crtc���|j�dd��}|jj|fi|���d|jj|fi|����|r#d|�|tj��zndzS)N�escapez LIKE � ESCAPE r���	modifiersrrDr�rZ�render_literal_valuer
r��r�rr�r�r�s     rrr�z SQLCompiler.visit_like_op_binary�s����!�%�%�h��5�5��
+�F�K�*�4�6�6�2�6�6�6�6�+�F�L�+�D�7�7�B�7�7�7�
�
�
�J��2�2�6�8�;N�O�O�O�O��

�	
rtc���|j�dd��}|jj|fi|���d|jj|fi|����|r#d|�|tj��zndzS)Nr�z
 NOT LIKE r�r�r�r�s     rrr�z#SQLCompiler.visit_notlike_op_binary�s����!�%�%�h��5�5��*�F�K�*�4�6�6�2�6�6�6�6�+�F�L�+�D�7�7�B�7�7�7�
�
�
�J��2�2�6�8�;N�O�O�O�O��

�	
rtc���|j�dd��}d|jj|fi|���d|jj|fi|���d�|r#d|�|tj��zndzS)Nr��lower(z
) LIKE lower(rkr�r�r�r�s     rr�visit_ilike_op_binaryz!SQLCompiler.visit_ilike_op_binary�����!�%�%�h��5�5���*�F�K�*�4�6�6�2�6�6�6�6�+�F�L�+�D�7�7�B�7�7�7�7�
�
�
�J��2�2�6�8�;N�O�O�O�O��

�	
rtc���|j�dd��}d|jj|fi|���d|jj|fi|���d�|r#d|�|tj��zndzS)Nr�r�z) NOT LIKE lower(rkr�r�r�r�s     rr�visit_notilike_op_binaryz$SQLCompiler.visit_notilike_op_binary�r�rtc�^�|j�dd��}|j||rdndfi|��S)Nr`Fz BETWEEN SYMMETRIC z	 BETWEEN �r�rrw�r�rr�r�r`s     rr�visit_between_op_binaryz#SQLCompiler.visit_between_op_binary�sN���$�(�(��e�<�<�	�,�t�,��Y�G�)�)�K�
�
�KM�
�
�	
rtc�^�|j�dd��}|j||rdndfi|��S)Nr`Fz NOT BETWEEN SYMMETRIC z
 NOT BETWEEN r�r�s     rr�visit_notbetween_op_binaryz&SQLCompiler.visit_notbetween_op_binary�sQ���$�(�(��e�<�<�	�,�t�,��)2�G�%�%��
�
��
�
�	
rtc���|sM|j�|j��}|jr'|�|��}|j|fd||d�|��S|s	|rA|jr:|j�#|j�tj
d|jz���|j|fddi|��S|�
|��}||jvr�|j|}	|	|ur||	js|jr;|	j�|j��stj
d|jz���|	js|jr%tj
d|j�d|j�d����|x|j|j<|j|<|j|fd	|ji|��S)
NT)�skip_bind_expressionrrrtz@Bind parameter '%s' without a renderable value not allowed here.rrzIBind parameter '%s' conflicts with unique bind parameter of the same namezbindparam() 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').�	expanding)r��dialect_implr��_has_bind_expression�bind_expressionr�rur	r]r
r�r�render_literal_bindparam�_truncate_bindparamrrgr��intersection�_is_crudr�r�)
r�rQrrrtr�r��implr�r��existings
          rr�visit_bindparamzSQLCompiler.visit_bindparam�s ��$�
	��>�.�.�t�|�<�<�D��(�
�"&�"6�"6�y�"A�"A��#�t�|�#��)-�*?�"/�	��
�����	�2�	�t�7K�	���&�9�+=�+E��&�9�;D�=�I����1�4�0����15��9?���
��'�'�	�2�2���4�:����z�$�'�H��y�(�(��O��'0�'7��"�,�9�9�)�:M�N�N���*�A�#�-�(����
�&�	�)�*<�	��*�*�%�=�=�=�)�-�-�-�
9����8A�@��
�9�=�!�D�J�t�$4�$�t�$��
�
�%�/�
�39�
�
�	
rtc�F�|j}|�||j��Sr�)r^r�r�)r�rQr�r	s    rrr�z$SQLCompiler.render_literal_bindparam3s"���)���(�(��	��?�?�?rtc�t�|�|j��}|r||��Std|z���)aRender the value of a bind parameter as a quoted literal.

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

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

        z(Don't know how to literal-quote value %r)�_cached_literal_processorr�r�)r�r	r��	processors    rrr�z SQLCompiler.render_literal_value7sK���3�3�D�L�A�A�	��	��9�U�#�#�#�%�:�U�B���
rtc��||jvr
|j|S|j}t|tj��r|�d|��}||j|<|S)NrQ)rrr�rr�r�)r�rQ�	bind_names   rrr�zSQLCompiler._truncate_bindparamJsb�����'�'��?�9�-�-��M�	��i��!:�;�;�	K��2�2�;�	�J�J�I�&/���	�"��rtc��||f|jvr|j||fS|�|j��}t|��|jdz
krd|j�|d��}|dt
|jdz
d���dzt|��dd�z}|dz|j|<n|}||j||f<|S)N�rrrr)r �	apply_maprrVrr�max�hex)r��ident_classr��anonname�counter�	truncnames      rrr�z!SQLCompiler._truncated_identifierWs������$�"6�6�6��'��d�(;�<�<��>�>�$�-�0�0���x�=�=�4�,�q�0�0�0��*�.�.�{�A�>�>�G���S��!2�Q�!6��:�:�:�;����g�,�,�q�r�r�"�#�
�
18�!��D� ��-�-� �I�4=���k�4�0�1��rtc��||jzSr�)r�r�r�s  rr�
_anonymizezSQLCompiler._anonymizejs���d�m�#�#rtc��|jr2|�|�|��n|j�|��|rd|_d|zS|jd|izS)NTz([EXPANDING_%s])r�)rr=r�contains_expanding_parametersr)r�r��positional_namesr�r�s     rrr�zSQLCompiler.bindparam_stringmso���?�	.��+� �'�'��-�-�-�-�� �'�'��-�-�-��	6�15�D�.�%��,�,��$���~�5�5rtc	��������||d<t|jtj��r��d|j��}n|j}d}d}	|�jvrJ�j|}
||
u}	||
jvs||
urd}n)|
|jvr	�j|
=ntj
d|z���|s|rO|j�D|j}|jj}t|tj��r��d|��}n|}d}|�r�|�j|<d|jj
vr:d�jvr1�j�d|jj
di���_|�jvr�j|fi|��|�sP|�jv�rF|jrd�_�j�||��}
|jr�t|jt,j��r|j}n4t|jt,j��r|jjd}nJ�d�t5j|j��D��}|
d	d
��fd�|D����zz
}
�jrgx|d<�j|<|
d
�j ||j!fi|���d|jj"�fddi|����z
}
|j#r|
d�j ||j#fi|��zz
}
|
�j|<|r�|s|	r�j�||��S|ri�j�||��}
�j�$|��r�j�%|��}|
��&|��z
}
|
S�j�||��SdS)N�visiting_cter�TFz5Multiple, unrelated CTEs found with the same name: %r�
autocommitrc��g|]}|�|��Sr�rn�rpr�s  rrr
z)SQLCompiler.visit_cte.<locals>.<listcomp>�s%��"�"�"���=��(�=�=rtr�r�c3�L�K�|]}�j�|��V��dSr�)r��
format_column)rprr�s  �rrrNz(SQLCompiler.visit_cte.<locals>.<genexpr>�sG�����"�"� %�!�M�7�7��>�>�"�"�"�"�"�"rtr�r��
rnr)'r9r�r�rr�r�r6�	_restatesrr
r��
_cte_aliasr�r�r�rf�	visit_cte�	recursiver7r��format_alias�originalr	�Select�CompoundSelectrAr�unique_list�
inner_columnsrBrr8�_generate_prefixes�	_prefixesr��	_suffixes�_requires_quotesr��get_render_as_alias_suffix)r��ctern�ashint�	fromhintsr�r��cte_name�
is_new_cte�embedded_in_current_named_cte�existing_cte�
pre_alias_cte�cte_pre_alias_namer��
col_source�
recur_colss`               rrr�zSQLCompiler.visit_cte{s����	
������!$��~���c�h�� 9�:�:�	 ��1�1�'�3�8�D�D�H�H��x�H��
�(-�%��t�(�(�(��,�X�6�L�,8�L�,H�)��l�,�,�,��|�0C�0C�"�
�
����.�.��I�l�+�+��&�(�*2�3����
�
	*�Z�
	*��~�)� #��
�%(�^�%8�"��0�(�2K�L�L��)-�)C�)C��!3�*�*�&��!$�
�%)�"��:	&�*-�D��h�'���� >�>�>� ��(>�>�>�)-�)?�)E�)E�$�c�k�&D�(�'��*�*��&��D�I�-�-����}�7�7��7�7�7�%�'
&�#�T�Y�*>�*>��=�/�*.�D�'��}�1�1�#�x�@�@���=��!�#�,�
�0A�B�B�%�%(�\�
�
�#�C�L�*�2K�L�L�%�%(�\�%9�!�%<�
�
�$�u�"�"�!%�!1�*�2J�!K�!K�"�"�"�J��F��	�	�"�"�"�"�)3�"�"�"�����D��?�O�LN�N�F�-�.��1D�S�1I���+�D�+�C���I�I�&�I�I�I�I�3�C�L�3����%)��-3��������=���C�"9�$�"9��S�]�#�#�.4�#�#���D�"&��	�#���	A��
A�"?�
A��}�1�1�#�x�@�@�@�!�
A��}�1�1�#�7I�J�J���=�1�1�(�;�;�=�#�}�2�2�8�<�<�H���7�7��A�A�A�����}�1�1�#�x�@�@�@�	A�	Artc���|s|rBt|jtj��r|�d|j��}n|j}|r|j�||��S|rj|jj|fddi|��|�	|j�||����z}|r"||vr|�
|||||��}|S|jj|fi|��S)Nr�rnT)r�r�rr�r�r�r�r�r�r��format_from_hint_text)	r�r�rnr��iscrudr�r��
alias_name�rets	         rr�visit_aliaszSQLCompiler.visit_alias�s*���	(�V�	(��%�*�h�&?�@�@�
(�!�7�7����L�L�
�
�"�Z�
��	E��=�-�-�e�Z�@�@�@�
�	E�3�%�.�3����!��%+����/�/��
�*�*�5�*�=�=����C��
�U�i�/�/��0�0���	�%� 0�&�����J�4�5�>�4�T�D�D�V�D�D�Drtc�.�d|d<d|j|fi|��zS)NT�lateralz
LATERAL %s)r)r�rr�s   rr�
visit_lateralzSQLCompiler.visit_laterals,����9�
��.�d�.�w�=�=�"�=�=�=�=rtc��|j|fddi|���d|���j|fi|����}|j�|d|jj|fi|��zz
}|S)NrnTz
 TABLESAMPLE z REPEATABLE (%s))r�_get_methodr��seed)r��tablesamplernr�r�s     rr�visit_tablesamplezSQLCompiler.visit_tablesamples����D��[�<�<��<��<�<�<�<�8�K�#�#�%�%�8��D�D��D�D�D�
��
��'��&�3�� �3�D�?�?�B�?�?��
�D��rtc��d|zS)Nr�rn)r��alias_name_texts  rrr�z&SQLCompiler.get_render_as_alias_suffix)s
����'�'rtc�B�|j�||||f��dSr�)rr=)r��keynamer��objectsr�s     rrr�zSQLCompiler._add_to_result_map,s(����#�#�W�d�G�U�$C�D�D�D�D�Drtc	� ����j��j��}	|	jr%|s|r!|	����}
|r��fd�}nd}n�}
|r�j}nd}|s|
}�n�t
�tj��r'|
�urt|
�j
�jf���}�nL|
}�nH|�|rt|
|�jf���}�n*|rwt
�tj
��r]�jsV�j�Ot
�jt j��s0t|
tj�j
���jf���}n�t
�tj��sat
�tj��r�jr@t/�d��rt
�t0j��rt|
�j��}n6|
�ur0t|
tj�j
���jf���}n|
}|�||���|j�fi|��S)z.produce labeled columns present in a select().c�@����||�f|z|��dSr�)r�)rr�rr�r r�s    ��rrr�z;SQLCompiler._label_select_column.<locals>.add_to_result_mapEs5����+�+����y�7�':�E�����rtN)r�r�r�)r�r�r��_has_column_expression�column_expressionr�r�r�Labelr�r�r��
_key_label�ColumnClauser�rar	r��
_as_truncatedr�
TextClause�UnaryExpression�wraps_column_expression�hasattrr�Function�
anon_label�updater�)
r�r[r r�rn�column_clause_argsr�rr�need_column_expressionsr��col_exprr��result_exprs
` `          rr�_label_select_columnz SQLCompiler._label_select_column/s������{�'�'���5�5���&�	)�#�	)�':�	)��-�-�f�5�5�H�"�
)��������%)�!�!��H�"�
)�$(�$;�!�!�$(�!�$�0	#�"�K�K�
����
/�
/�.	#��v�%�%�+��f�k�f�n�5F������'���
�
�D�
�'��$�6�+<�*>����K�K�

�!	#��6�8�#8�9�9�!	#��%�!	#���(��v�|�Z�->�?�?�)�(���&�v�{�3�3�!�:�-����K�K��6�8�#6�7�7�	#��v�x�'?�@�@�	#��1�		#��F�F�+�+�	#��f�i�&8�9�9�	#�(��&�2C�D�D�K�K�
�V�
#�
#�(���&�v�{�3�3�!�:�-����K�K�#�K��!�!�"7�/�	"�	
�	
�	
�.�{�-�d�I�I�6H�I�I�Irtc�F�|�||��}|r|d|zz
}|Sr�)�get_from_hint_text)r��sqltextra�hintr��hinttexts      rrr�z!SQLCompiler.format_from_hint_text�s2���*�*�5�$�7�7���	&��s�X�~�%�G��rtc��dSr�rn)r��byfromss  rr�get_select_hint_textz SQLCompiler.get_select_hint_text�����trtc��dSr�rn�r�rar�s   rrr%zSQLCompiler.get_from_hint_text�r,rtc��dSr�rnr.s   rr�get_crud_hint_textzSQLCompiler.get_crud_hint_text�r,rtc�,�d�|��Sr��rB)r��
hint_textss  rr�get_statement_hint_textz#SQLCompiler.get_statement_hint_text�s���x�x�
�#�#�#rtc�6����i�ig����fd���|��S)z�Rewrite any "a JOIN (b JOIN c)" expression as
        "a JOIN (select * from b JOIN c) AS anon", to support
        databases that can't parse a parenthesized join correctly
        (i.e. sqlite < 3.7.16).

        c����|�dvr�d|S|�
vr�
|S|���x}�
|<|j�r�|j�r�t|jt
j���rt|����|jfi|��|_�|jfi|��}tj	|j
gd������}|jD]}|j
|_|j|_�t#t%|jj
j|j����}|||j
j<|||j
j<|||jj
j<|||jj
j<t'�d�����D]\}}||vr||�d|<��d�|��||_�|jfi|��|_n�|jrd|d<|jdd�i|��nh|jrR|jrK|�dd��dk}	|	r��i��d|d<|jdd�i|��|	r�d=n|jdd�i|��|S)	Nr(T)�
use_labels�select_container�transform_clue�clone�
inside_selectrn)r��
is_selectable�_is_joinr�rZr	�FromGrouping�_reset_exportedrDr�r�r�r�rrr��_labelrR�zipr0�itemsr�onclause�_is_from_container�_copy_internals�
_is_selectrr=)
r�r��newelemrZ�selectable_r��translate_dict�k�v�barrier_select�cloned�column_translate�visits
          ���rrrOz=SQLCompiler._transform_select_for_nested_joins.<locals>.visit�s����*�2�.�.�.�'��+�G�4�4��F�"�"��g��&�(/���(8�(8�8�G�f�W�o��%�D
;��$�D
;��w�}�j�.E�F�F�D
;��'�'�)�)�)�$�u�W�\�8�8�R�8�8�����g�m�2�2�r�2�2��(�/��]�O������%�'�'��%��&�&�A�#$�5�A�L� �v�A�H�H�!%���
�-�/���?�?�"�"��6A��u�}�1�2�6A��u�}�2�3�=H��w�}�4�9�:�>I��w�}�4�:�;�!�!1�"�!5�!;�!;�!=�!=�>�>�D�D�D�A�q��N�*�*�3A��2C�(��,�Q�/�� ��$�+�+�N�;�;�;� +��
�#(�5��)9�#@�#@�R�#@�#@�� � ��+�
;�(:��#�$�'��'�:�:�e�:�r�:�:�:�:��&�
;�7�+=�
;��F�F�+�T�2�2�6H�H��"�0�$�+�+�B�/�/�/�'6��#�$�'��'�:�:�e�:�r�:�:�:�!�-�(��,��'��'�:�:�e�:�r�:�:�:��Nrtrn)r�r[rMrNrOs  @@@rr�"_transform_select_for_nested_joinsz.SQLCompiler._transform_select_for_nested_joins�sO��������4��O	�O	�O	�O	�O	�O	�O	�b�u�V�}�}�rtc����td�|jD�����t�fd�|jD������fd�|jD��|_dS)Nc3�(K�|]
}|j|fV��dSr��rr�s  rrrNzESQLCompiler._transform_result_map_for_nested_joins.<locals>.<genexpr>�s:����
�
�"#�Q�\�1��
�
�
�
�
�
rtc3�6�K�|]}�|j|fV��dSr�rS)rpr��	inner_cols  �rrrNzESQLCompiler._transform_result_map_for_nested_joins.<locals>.<genexpr>s/�����L�L�!�)�A�L�)�1�-�L�L�L�L�L�Lrtc�X��g|]&\}}}}||t�fd�|D����|f��'S)c�<��g|]}��||����Srn�r)rpr��ds  �rrr
zQSQLCompiler._transform_result_map_for_nested_joins.<locals>.<listcomp>.<listcomp>s%���?�?�?�3�q�u�u�S�#���?�?�?rt��tuple)rprr��objs�typrYs     �rrr
zFSQLCompiler._transform_result_map_for_nested_joins.<locals>.<listcomp>sW��� 
� 
� 
�$��T�4���$��?�?�?�?�$�?�?�?�@�@�#�F� 
� 
� 
rt)rRr�r)r�r[�transformed_selectrYrUs   @@rr�&_transform_result_map_for_nested_joinsz2SQLCompiler._transform_result_map_for_nested_joins�s������
�
�'9�'G�
�
�
�
�
�	�
�L�L�L�L�v�7K�L�L�L�L�L�� 
� 
� 
� 
�(,�(<� 
� 
� 
����rtr9r:c���|j}|r|jn|jd}|d}|d}|r-|s+|�|�|��d���}n|�||���}|S)Nr(r9r:rn��explicit_correlate_froms�implicit_correlate_froms)rr��_get_display_froms�
difference)	r�r[rnrr�r@r9r:�fromss	         rr�_display_froms_for_selectz%SQLCompiler._display_froms_for_selects���
�z�>��-5�I��)�)�4�:�b�>��� 1�2���^�,���	�'�	��-�-�)8�)C�)C� �*�*�*,�	.���E�E��-�-�)8�)5�.���E��rtc		�F���������jo|o�jo�jj}
|
r)�����}�j|f�|||dd�|	��}�j}
|
r�jn�jd}|
p+|�dd��p|�dd��x��|dkrd��sd|	vr|	d=|
r�r���|��|S��	�|�|��}|	�
�����ddd	���d
}�jr#��
���\}}|r||dzz
}nd}�jr|�j��jfi|	��z
}|�j�fi|	��z
}d�������fd
��jD��D��}�rU|�St%t'd��jD��d�|jD��������fd��jD���_��|�||||	��}�jr0�fd��jD��}|r|d��|��zz
}�jr|
r����|z}�jr|d�j��jfi|	��zz
}�j�d���s|r
|rd|zdzS|S)NT)rnr�r�r��nested_join_translationr(r�Fr;rr�)r�rrzSELECT rc��g|]}|�|��Sr�rnr�s  rrr
z,SQLCompiler.visit_select.<locals>.<listcomp>us)��
�
�
���}�
��}�}rtc�N��g|]!\}}���|���|������"S))r�r �r#)	rpr�r rnrr r�r[r�s	   ������rrr
z,SQLCompiler.visit_select.<locals>.<listcomp>wsY������!�D�&��)�)���'��&��,C�*�����rtc��g|]\}}|��Srnrn�rprr�s   rrr
z,SQLCompiler.visit_select.<locals>.<listcomp>�s��H�H�H�k�s�D�T�H�H�Hrtc��g|]\}}|��Srnrnrns   rrr
z,SQLCompiler.visit_select.<locals>.<listcomp>�s,�����'�S�$����rtc�X��g|]&\}}}}||t�fd�|D����|f��'S)c3�D�K�|]}��||��V��dSr�rX)rp�o�	translates  �rrrNz6SQLCompiler.visit_select.<locals>.<listcomp>.<genexpr>�s1�����!C�!C�!�)�-�-��1�"5�"5�!C�!C�!C�!C�!C�!CrtrZ)rprr�r�r�rss     �rrr
z,SQLCompiler.visit_select.<locals>.<listcomp>�sW���$�$�$�)�C��s�E��d�E�!C�!C�!C�!C�s�!C�!C�!C�C�C�U�K�$�$�$rtc�:��g|]\}}|d�jjfv�|��S��*�r�r�)rp�dialect_name�htr�s   �rrr
z,SQLCompiler.visit_select.<locals>.<listcomp>�s<������&�\�2��C���):�#;�;�;��;�;�;rtrjrk)r7rr��supports_right_nested_joinsrP�visit_selectr�rr_�_setup_select_stack�copyr�_hints�_setup_select_hintsr�r��get_select_precolumns�_columns_plus_namesrRrAr�_compose_select_body�_statement_hintsr4rrGr�r=)r�r[rnr�r�r�ri�select_wraps_forrr��needs_nested_translationr^r�r�r@rf�	hint_text�byfromr��per_dialectrr r�rss```                 @@@@rrr{zSQLCompiler.visit_select%sb���������
��
=�+�+�
=��J��
=��L�<�<�		!�$�	�!%�!H�!H��"�"��%�4�$�"����#�-�(,�
�����D��z�>��-5�I��)�)�4�:�b�>��
�
>��y�y�7��?�?�
>��y�y�5�u�=�=�	
��5��A���"'��
#�	,�':�f�'D�'D��*�+�#�	�"�
��;�;��.�����K��(�(�����H�H��#�[�[�]�]���!�!�$)�E�J�J�	
�	
�	
����=�	� $� 8� 8�� @� @��I�v��
(��	�C��'����F���	P��+�D�+�F�F�4D�O�O��O�O�O�D��*��*�6�<�<�V�<�<�<��
�
����������%+�$>����
�
�
�
�"�	�#3�#?���H�H�V�-G�H�H�H���+;�+O��������I�$�$�$�$�-1�-A�$�$�$�D� �
�(�(��&�-����
�
���"�	H�����*0�*A����K�
�
H���d�:�:�;�G�G�G�G���9�	4��	4��*�*�,�,�t�3�D���	��C�1�$�1���(���,2����
�D�	
�
���r�����	�g�	�6�	���:��#�#��Krtc���t�fd�|j���D����}��|��}||fS)Nc	�x��g|]6\\}}}|d�jjfv�||d|��d���izf��7S)rvr�T)r��r�r�r�)rp�from_r�r(r�s    �rrr
z3SQLCompiler._setup_select_hints.<locals>.<listcomp>�sn���
�
�
�/�$�U�G�h��s�D�L�$5�6�6�6����u�7�7��T�7�J�J�K�L��7�6�6rt)rRr~rBr+)r�r[r�r�s`   rrrzSQLCompiler._setup_select_hints�sh����
�
�
�
�39�-�2E�2E�2G�2G�

�
�
�

�

���-�-�f�5�5�	��&� � rtc�R�|d}|d}|r-|s+|�|�|��d���}n|�||���}ttj|���}|�|��}	||	|d�}
|j�|
��|S)Nr9r:rnra)r:r9r	)rdrer]r	�
_from_objectsrfrr=)r�r[r@rnrr9r:rf�new_correlate_froms�all_correlate_froms�	new_entrys           rrr|zSQLCompiler._setup_select_stack�s���� 1�2���^�,���	�'�	��-�-�)8�)C�)C� �*�*�*,�	.���E�E��-�-�)8�)5�.���E�
"�*�":�E�"B�C�C��1�7�7��H�H��0�2� �
�
�	�
	
�
���)�$�$�$��rtc�����|d�|��z
}|rY|dz
}|jr'|d����fd�|D����z
}n=|d���fd�|D����z
}n|����z
}|j�|jj�fi���}|r|d|zz
}|jjr|�j|fi���z
}|j�|jj�fi���}|r|d|zz
}|j	jr|�j
|fi���z
}|j�|j�|�j
|fi���z
}|j�|�j|fi���z
}|S)Nr�z 
FROM c�2��g|]}|j�fd�d������S)T�rnr�r�)rp�fr�r�r�s  ���rrr
z4SQLCompiler._compose_select_body.<locals>.<listcomp>�sT�������-��,� ��)-����CI�����rtc�0��g|]}|j�fddi�����S)rnTr�)rpr�r�r�s  ��rrr
z4SQLCompiler._compose_select_body.<locals>.<listcomp>�sC�������-��,�T�I�I�$�I�&�I�I���rtz 
WHERE z	 
HAVING )rBr~rh�_whereclauser��_group_by_clauser�rB�_having�_order_by_clauserCrDrErF�_for_update_arg�for_update_clause)r�r�r[r�rfr�r��ts`    `` rrr�z SQLCompiler._compose_select_body�s�����	
��	�	�-�(�(�(���	(��J��D��}�
���	�	�������"'�	����������	�	������!&���������
�D�%�%�'�'�'�D���*�6��#�6�t�F�F�v�F�F�A��
(���a��'���"�*�	;��(�D�(��:�:�6�:�:�:�D��>�%�1���1�$�A�A�&�A�A�A��
)���q�(�(���"�*�	;��(�D�(��:�:�6�:�:�:�D�
� �,��$�0��%�D�%�f�7�7��7�7�7�D��!�-��*�D�*�6�<�<�V�<�<�<�D��rtc�\���d���fd�|D����}|r|dz
}|S)Nrc3�^�K�|]'\}}|�|�jjk�|j�fi���V��(dSr�r�)rp�prefixrxr�r�s   ��rrrNz1SQLCompiler._generate_prefixes.<locals>.<genexpr>	s]�����
�
�$����#�|�t�|�7H�'H�'H�
&�F�%�d�1�1�b�1�1�'H�'H�'H�'H�
�
rtr2)r��stmt�prefixesr�r�s`  ` rrr�zSQLCompiler._generate_prefixes	sZ�������
�
�
�
�
�(0�
�
�
�
�
��
�	��c�M�F��
rtc�(���jr.t�fd��jD��g���jz�_���j��dz}|d�d��j���D����z
}|dz
}|S)Nc�*��g|]}�j|��Srn)r8)rpr�r�s  �rrr
z2SQLCompiler._render_cte_clause.<locals>.<listcomp>$	s!���C�C�C�#�T�(��-�C�C�Crtr�, 
c��g|]}|��Srnrn)rp�txts  rrr
z2SQLCompiler._render_cte_clause.<locals>.<listcomp>(	s�� C� C� C��� C� C� Crtz
 )r�sumrr�get_cte_preambler7rB�values)r��cte_texts` rrrGzSQLCompiler._render_cte_clause!	s�����?�	��C�C�C�C���C�C�C�R�H�H��"�#�
���(�(��)<�=�=��C���F�K�K� C� C��	�0@�0@�0B�0B� C� C� C�D�D�D���E����rtc��|rdSdS)NzWITH RECURSIVE�WITHrn)r�r�s  rrr�zSQLCompiler.get_cte_preamble,	s���	�#�#��6rtc��|jrdpdS)zcCalled when building a ``SELECT`` statement, position is just
        before column list.

        r�r�)�	_distinct�r�r[r�s   rrr�z!SQLCompiler.get_select_precolumns2	s��
��/�K�5�2�5rtc�:�|jj|fi|��}|rd|zSdS)z5allow dialects to customize how GROUP BY is rendered.z
 GROUP BY r�)r�r�)r�r[r��group_bys    rrrBzSQLCompiler.group_by_clause9	�9��>�6�*�=�d�I�I�b�I�I���	��(�*�*��2rtc�:�|jj|fi|��}|rd|zSdS)z5allow dialects to customize how ORDER BY is rendered.z
 ORDER BY r�)r�r�)r�r[r�rs    rrrCzSQLCompiler.order_by_clauseB	r�rtc��dS)Nz FOR UPDATErnr�s   rrr�zSQLCompiler.for_update_clauseK	s���}rtc�*�tjd���)Nz@RETURNING is not supported by this dialect's statement compiler.r�)r�r��returning_colss   rr�returning_clausezSQLCompiler.returning_clauseN	s����
,�
�
�	
rtc��d}|j�|d|j|jfi|��zz
}|j�%|j�|dz
}|d|j|jfi|��zz
}|S)Nr�z
 LIMIT z

 LIMIT -1z OFFSET )rDr�rE)r�r[r�r�s    rrrFzSQLCompiler.limit_clauseT	s}������+��K�,�$�,�v�/C�"J�"J�r�"J�"J�J�J�D�� �,��#�+��
�%���J����f�.C�!J�!J�r�!J�!J�J�J�D��rtc�P�|s|r�|j�|��}|r@|r>|j�|��dz|j�|j��z}	n|j�|j��}	|r"||vr|�|	||||��}	|	SdS)Nr�r�)r�r�r�r�r�r�)
r�rarnr�r�r��
use_schemar�r�rs
          rr�visit_tablezSQLCompiler.visit_table^	s����	�V�	�#�}�>�>�u�E�E���
6�.�
6��M�.�.�/?�@�@����m�)�)�%�*�5�5�6����m�)�)�%�*�5�5���
�U�i�/�/��0�0���	�%� 0�&�����J��2rtc��|jrd}n|jrd}nd}|jj|fddi|��|z|jj|fddi|��zdz|jj|fi|��zS)Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN rnT� ON )r6�isouterrDr�rZrC)r�rBrnr��	join_types     rr�
visit_joinzSQLCompiler.visit_join{	s����9�	!�+�I�I�
�\�	!�+�I�I� �I�(�D�I�(��E�E�d�E�f�E�E��
�+�d�j�+�D�H�H��H��H�H�
I��
�/�d�m�.�t�>�>�v�>�>�	
?�	
rtc����t�fd�|j���D����}|j|vr(��||j||jd��}||fS)Nc�D��g|]\\}}}|d�jjfv�||f��Srurw)rprar�r�r�s    �rrr
z1SQLCompiler._setup_crud_hints.<locals>.<listcomp>�	sF���
�
�
�/�$�U�G�i��s�D�L�$5�6�6�6��	�"�6�6�6rtT)rRr~rBrar�)r�r��
table_text�
dialect_hintss`   rr�_setup_crud_hintszSQLCompiler._setup_crud_hints�	s�����
�
�
�
�37�;�3D�3D�3F�3F�
�
�
�
�
�
��:��&�&��3�3��D�J�
�d�j�(A�4���J��j�(�(rtc���|j}|j�t��t��|d���tj||tjfi|��}|s9|jjs-|jjs!tj
d|jjz���|jr6|jj
s!tj
d|jjz���|d}n|}|j�|jj}d}|jr||j||jfi|��z
}|dz
}��|j��}	|jr|�||	��\}
}	||	z
}|s|s'|dd��fd	�|D����zz
}|js|jr2|�||jp|j��}|jr|d
|zz
}nd}|j�N|j|jfi|��}|jr+|r)|jjr|d
|����|��z
}np|d|zz
}ng|s|r|dz
}n]|jr&|d
d�d�|D����zz
}n0d�d�|D����}
|d|
zz
}|r|
|_ |j!�|j|j!fi|��}|r|d
|zz
}|r|js|d
|zz
}|jr%|r#|jjs|���|z}|j�"d��|rd|zdzS|S)N�r9r:r	zWThe '%s' dialect with current database version settings does not support empty inserts.zcThe '%s' dialect with current database version settings does not support in-place multirow inserts.rzINSERT zINTO z (%s)r�c�F��g|]}��|d����S)r)r�)rpr�r�s  �rrr
z,SQLCompiler.visit_insert.<locals>.<listcomp>�	s+���J�J�J�!��'�'��!��-�-�J�J�Jrtrz %sz DEFAULT VALUESz
 VALUES %sc3�ZK�|]&}dd�d�|D����zV��'dS)r�r�c3�&K�|]}|dV��
dS)rNrnr�s  rrrNz5SQLCompiler.visit_insert.<locals>.<genexpr>.<genexpr>�	s&����'E�'E���!��'E�'E�'E�'E�'E�'ErtNr2)rp�crud_param_sets  rrrNz+SQLCompiler.visit_insert.<locals>.<genexpr>�	sV������&��d�i�i�'E�'E�n�'E�'E�'E�E�E�F������rtc��g|]
}|d��S)rrnr�s  rrr
z,SQLCompiler.visit_insert.<locals>.<listcomp>�	s��2M�2M�2M�A�1�Q�4�2M�2M�2Mrtz VALUES (%s)r(rjrk)#rr=r]r�_setup_crud_params�ISINSERTr��supports_default_values�supports_empty_insertr
r�r��_has_multi_parameters�supports_multivalues_insertr�r�r��format_tablerar~r�rBr%r$r��returning_precedes_valuesr[r��_insert_from_selectr�cte_follows_insertrG�insert_single_values_expr�_post_values_clauser=)r��insert_stmtrnr�r��crud_params�crud_params_singler�r�r�rr��select_textr��post_values_clauser�s               @rr�visit_insertzSQLCompiler.visit_insert�	sQ����z�>���
���#&�5�5� #���)�
�
�	
�	
�	
��-��+�t�}�
�
�02�
�
��
�		��L�8�		��L�6�		�
�"��!�\�.�/���
��,�		-��<�;�
��&�1�37�<�3D�E����
"-�Q����!,���=��"&�,�"F����� �	��+�D�+��[�2���68���
�D�	
�����*�*�;�+<�=�=�
���	L� �2�2�;�
�K�K�M�A�z��
����	�%<�	��G�d�i�i�J�J�J�J�7I�J�J�J����
�D��>�	$�[�3�	$�#�4�4��T�^�E�{�/E� � ���-�
/���.�.�.���#����)�&�$�,�t�'?�F�F�2�F�F�K��y�
,�X�
,�$�,�*I�
,���4�#:�#:�#<�#<�#<�k�k�J�J������+�+����
	K�!8�
	K��%�%�D�D�
�
.�	K��L��	�	���*5�������
�D�D�)-�	�	�2M�2M��2M�2M�2M�(N�(N�%��N�%>�>�>�D��
K�1J��.��*�6�!-����/�"�"�35�"�"��"�
1���0�0�0���	+�D�$B�	+��C�*�*�*�D��9�	4��	4�$�,�*I�	4��*�*�,�,�t�3�D��
���r�����	���:��#�#��Krtc��dS)z3Provide a hook for MySQL to add LIMIT to the UPDATENrn)r��update_stmts  rr�update_limit_clausezSQLCompiler.update_limit_clause
s���trtc�,�d|d<|j|fddi|��S)z|Provide a hook to override the initial table clause
        in an UPDATE statement.

        MySQL overrides this.

        Trnr�r�)r�r��
from_table�extra_fromsr�s     rr�update_tables_clausez SQLCompiler.update_tables_clause
s-����8��,�z�,�T�E�E�$�E�"�E�E�Ertc� �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��r�r�r�r��
from_hintsr�s      rr�update_from_clausezSQLCompiler.update_from_clause
s��"�
%�
�
�	
rtc�������j}|j}t|��}|rJtt	j|j������fd�|D��}��|��}n
g}|jh}�j�|||d���d}	|j	r|	�j
||j	fi|��z
}	�j||j|fi|��}
tj
�|tjfi|��}|jr��||
��\}}
nd}|	|
z
}	|	dz
}	|o�j�|	d���fd�|D����z
}	�js|jr/�jr(|	d��|�jp|j��zz
}	|r �j||j||fi|��}
|
r|	d|
zz
}	|j��j|jfi|��}|r|	d|zz
}	��|��}|r|	d|zz
}	�js|jr/�js(|	d��|�jp|j��zz
}	�jr|r����|	z}	�j�d	��|rd
|	zdzS|	S)Nc���g|]}|�v�|��	Srnrn)rpr��
main_fromss  �rrr
z,SQLCompiler.visit_update.<locals>.<listcomp>-
s*���"�"�"��!�:�*=�*=��*=�*=�*=rtr�zUPDATE z SET r�c3�j�K�|]-}|d������dz|dzV��.dS)r)r��=rNr�)rpr�r�r�s  ��rrrNz+SQLCompiler.visit_update.<locals>.<genexpr>X
sd�����
�
��
�a�D�#�#�D�
�#�F�F��
���d�
�
�
�
�
�
�
rtr� WHERE r(rjrk)r�_extra_froms�boolr]r	r�rarfr=r�r�r�rr��ISUPDATEr~r��'render_table_with_column_in_update_fromrBr%r$r�r�r�r�r�r�rrGr=)r�r�rnr�r�r��
is_multitable�render_extra_fromsr9r�r�r�r��extra_from_textr�rFr�r�s`               @@rr�visit_updatezSQLCompiler.visit_update$
s�������z�>��!�.���[�)�)�
��		2��Z�5�k�6G�H�H�I�I�J�"�"�"�"�&�"�"�"��)�.�.�{�;�;�O�O�!#��*�0�1�O��
���#2� /�)�
�
�	
�	
�	
���� �	��+�D�+��[�2���68���
�D�/�T�.���*�,>�
�
�BD�
�
�
��-��+�t�}�
�
�02�
�
����	!�(,�(>�(>��Z�)�)�%�M�:�:�!�M��
��������J�d�J�	�	
��	�	�
�
�
�
�
�!�	
�
�
�
�
�	
���>�	�[�3�	��-�
���d�3�3����!I�;�3I�������		.�5�d�5���!�"��	��
���O��
.���o�-�-���#�/����[�5�<�<��<�<�A��
&��	�A�
�%���/�/��<�<���	'��C�,�&�&�D�
�N�	�)�4�	��0�	�
�C�$�/�/��T�^�E�{�/E����
�D��9�	4��	4��*�*�,�,�t�3�D��
���r�����	���:��#�#��Krtc�6�tj||j��Sr�)r�_key_getters_for_crud_columnr�r�s rrr�z(SQLCompiler._key_getters_for_crud_column�
s���0��t�~�F�F�Frtc� �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      rr�delete_extra_from_clausez$SQLCompiler.delete_extra_from_clause�
s��"�
%�
�
�	
rtc�2�|�|dd���S)NT)rnr�r�)r��delete_stmtr�r�s    rr�delete_table_clausezSQLCompiler.delete_table_clause�
s���,�,�T�$�t�,�L�L�Lrtc�t�|j}tj||tjfi|��|j}|jh�|��}|j�|||d���d}|jr||j	||jfi|��z
}|dz
}|�
||j|��}|jr|�||��\}	}nd}	||z
}|j
r(|jr!|d|�||j
��zz
}|r |j||j||	fi|��}
|
r|d|
zz
}|j�|jj|fi|��}|r|d|zz
}|j
r(|js!|d|�||j
��zz
}|jr|r|���|z}|j�d��|rd|zdzS|S)	Nr�zDELETE �FROM rr�r(rjrk)rrr��ISDELETEr�rarfr=r�r�r�r~r�r$r�r�r�r�r�rrGr=)r�r�rnr�r�r�r9r�r�r�r�r�s            rr�visit_deletezSQLCompiler.visit_delete�
s����z�>�����k�4�=�G�G�B�G�G�G�!�.��&�,�-�3�3�K�@�@���
���#2� /�)�
�
�	
�	
�	
���� �	��+�D�+��[�2���68���
�D�	
�����-�-���*�K�
�
�
���	!�(,�(>�(>��Z�)�)�%�M�:�:�!�M��
����!�	��-�
���d�3�3���!7�������		.�;�d�;���!���	��
���O��
.���o�-�-���#�/�;��(�;�D�G�G�B�G�G�A��
&��	�A�
�%���!�	�$�*H�	��C�$�/�/��[�3����
�D��9�	4��	4��*�*�,�,�t�3�D��
���r�����	���:��#�#��Krtc�<�d|j�|��zS)NzSAVEPOINT %s�r��format_savepoint�r��savepoint_stmts  rr�visit_savepointzSQLCompiler.visit_savepoint�
s����
� >� >�~� N� N�N�Nrtc�<�d|j�|��zS)NzROLLBACK TO SAVEPOINT %srrs  rr�visit_rollback_to_savepointz'SQLCompiler.visit_rollback_to_savepoint�
s&��)�D�M�,J�,J��-
�-
�
�	
rtc�<�d|j�|��zS)NzRELEASE SAVEPOINT %srrs  rr�visit_release_savepointz#SQLCompiler.visit_release_savepoint�
s&��%��
�(F�(F��)
�)
�
�	
rt)NF)NNT�F)NFFN)NT)NFTr�)FTr)FFF)FFNN)FFFN�NTF)FTNrFNF)FFFNT)�r�r�r�r��EXTRACT_MAPr�COMPOUND_KEYWORDSr>r#r!r"r�r%r�r�r�rur�r<rr�r1r2r�r�r.r3r�memoized_instancemethodr9�
contextlib�contextmanagerrAr&�memoized_propertyrSrWr�r�r��dependenciesrerhror|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rrrr!r.r3r0r,rJrQrWr\r_rerhrmrorrrbr}rr�r�r�rwrUrVr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
r�r�r#r�r+r%r0r4rPr_r��	frozensetr�rgr{rr|r�r�rGr�r�rBrCr�r�rFr�r�r�r�r�r�r�r�r�r�r�rr	rr
rnrtrrrr�s�
���������K�)��%*�*�H�*�x�(��
�K��I��
!&���/4�+��
%*�!���O�� %�������N��!%���)+�*�O�o�<A�G*�G*�G*�G*�R�#�#��X�#�J�A�A��X�A�
�!�%�%�"�!�%��������.
�
�
�
��
�
���
�#�#�#�����X��6�6�6�6�p�3�3��X�3�
�T��1�2�2�N�N�3�2�N����O�O�O�O�.3� 
� 
� 
� 
�F.3�����>�!�#�"�
/�/�/�/�b
�
�
�=A�&O�&O�&O�&O�PA�A�A�������I�I�I����
���

�
�
�(>B�����@������������$���&K�K�K�
�
�
�
�
�
�.
�
�
�8
�
�
�
�
�
�
�
�
� @� @� @� @�D8�8�8�
�
�
�C�C�C�=>�1�1�1�1�f-�-�-����>B�B�B�B�B�B�
�
�
�

�
�
�<�<�<�<�<�<�
�
�
�>C�M�M�M�M�68�8�8����
�
�
�
�
�
�

�
�
�05�����*G�G�G�G�G�G�
��I�I���I�A�A�A�D�D�D�A�A�A�D�D�D�A�A�A�D�D�D�
�
�
�	
�	
�	
�	
�	
�	
�	
�	
�	
�
�
�
�
�
�
�$��"�;
�;
�;
�;
�z@�@�@����&������&$�$�$�6;�6�6�6�6�"����
zA�zA�zA�zA�~����
E�E�E�E�B>�>�>�����(�(�(�E�E�E��"� %�ZJ�ZJ�ZJ�ZJ�x������������$�$�$�[�[�[�z
�
�
�.�4�-�
�Y�Y�[�[�	)�N�I�I�K�K�+H�I��������8���� %���N�N�N�N�`
!�
!�
!����:4�4�4�l���	�	�	����6�6�6����������
�
�
�������������:

�

�

�

�)�)�)�n�n�n�n�`���F�F�F�
�
�
�d�d�d�d�L
��G�G���G�
�
�
� M�M�M�H�H�H�H�TO�O�O�
�
�
�

�
�
�
�
rtrc�H�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZdS)�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��dS)Nz<name unknown>rnr�s  rrr�z$StrSQLCompiler._fallback_column_name
s���rtc�V�|j|jfi|���d|j|jfi|���d�S)N�[�])r�rDrZrds    rr�visit_getitem_binaryz#StrSQLCompiler.visit_getitem_binarysJ���D�L���+�+��+�+�+�+��D�L���,�,��,�,�,�,�
�	
rtc� �|j||fi|��Sr��rrds    rr�visit_json_getitem_op_binaryz+StrSQLCompiler.visit_json_getitem_op_binary���(�t�(���@�@�R�@�@�@rtc� �|j||fi|��Sr�r rds    rr�!visit_json_path_getitem_op_binaryz0StrSQLCompiler.visit_json_path_getitem_op_binaryr"rtc�<�d|j�|��zS)Nz<next sequence value: %s>)r��format_sequence)r��seqr�s   rrr0zStrSQLCompiler.visit_sequences��*�T�]�-J�-J�3�-O�-O�O�Ortc�t���fd�tj|��D��}dd�|��zS)Nc	�B��g|]}��d|ddi����Srrl�rpr�r�s  �rrr
z3StrSQLCompiler.returning_clause.<locals>.<listcomp> s?���
�
�
��
�%�%�d�A�t�U�B�?�?�
�
�
rtz
RETURNING r�)r�_select_iterablesrB)r�r�r��columnss`   rrr�zStrSQLCompiler.returning_clausesO���
�
�
�
��/��?�?�
�
�
��
�d�i�i��0�0�0�0rtc�T����dd����fd�|D����zS)Nrr�c3�:�K�|]}|j�fd�d����V��dS�Tr�Nr��rpr�r�r�r�s  ���rrrNz4StrSQLCompiler.update_from_clause.<locals>.<genexpr>*sS�����#
�#
��
!�A� ��O�d�j�O�O�B�O�O�#
�#
�#
�#
�#
�#
rtr2r�s`   ``rrr�z!StrSQLCompiler.update_from_clause'sT���������#
�#
�#
�#
�#
�#
� �#
�#
�#
�
�
�
�	
rtc�T����dd����fd�|D����zS)Nr�c3�:�K�|]}|j�fd�d����V��dSr/r�r0s  ���rrrNz:StrSQLCompiler.delete_extra_from_clause.<locals>.<genexpr>2sS����� 
� 
��
!�A� ��O�d�j�O�O�B�O�O� 
� 
� 
� 
� 
� 
rtr2r�s`   ``rrr�z'StrSQLCompiler.delete_extra_from_clause/sT������d�i�i� 
� 
� 
� 
� 
� 
� � 
� 
� 
�
�
�
�	
rtc��d|zS)Nz[%s]rnr.s   rrr%z!StrSQLCompiler.get_from_hint_text7s����}�rtN)
r�r�r�r�r�rr!r$r0r�r�r�r%rnrtrrrr�
s���������& � � �
�
�
�A�A�A�A�A�A�P�P�P�1�1�1�
�
�
�
�
�
�����rtrc�.�eZdZejd���Zejd���Zd)d�Zd�Zd�Z	d�Z
d�Zd*d
�Z	d)d�Z
d�Zd
�Zd�Z	d+d�Zd�Zd*d�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)dS),�DDLCompilerc�P�|j�|jd|j���S)N)r�)r��statement_compilerr�r�s rrr�zDDLCompiler.sql_compiler<s-���|�.�.��L�$�T�5N�/�
�
�	
rtc��|jjSr�)r�r�r�s rrr�zDDLCompiler.type_compilerBs
���|�)�)rtNc��dSr�rnr�s  rrr�zDDLCompiler.construct_paramsFr,rtc��|j}t|jtj��r�|���}|j}|�|j��}t|��dkr|dd}}n|d|d}}|�	d|��|�	d|��|�	d|�
|j����|j�|j
|z��S)Nrrr�r(rar�fullname)�contextr��targetr�Tabler}r��format_table_seqrV�
setdefaultr�r�r�r�)r��ddlr�r<r��pathra�schs        rr�	visit_ddlzDDLCompiler.visit_ddlIs����+���c�j�&�,�/�/�	N��l�l�n�n�G��}�H��,�,�S�Z�8�8�D��4�y�y�A�~�~�!�!�W�b�s���!�"�X�t�A�w�s�����w��.�.�.����x��-�-�-����z�8�+@�+@���+L�+L�M�M�M�� �2�2�3�=�7�3J�K�K�Krtc�J�|j�|j��}d|zS)NzCREATE SCHEMA )r��
format_schemar�)r�r"rs   rr�visit_create_schemazDDLCompiler.visit_create_schema\s$����,�,�V�^�<�<���&�(�(rtc�f�|j�|j��}d|z}|jr|dz
}|S)NzDROP SCHEMA � CASCADE)r�rFr��cascade)r��droprr�s    rr�visit_drop_schemazDDLCompiler.visit_drop_schema`s<����,�,�T�\�:�:����&���<�	��J��D��rtc��|j}|j}d}|jr |d�|j��dzz
}|d|�|��zdzz
}|�|��}|r||dzz
}|dz
}d}d}|jD]�}|j}		|�||	jo|���}
|
�||z
}d}|d	|
zz
}|	jrd
}�D#tj
$r_}tjtj
tj
d��|j|	j|jdfz��|�
��Yd}~��d}~wwxYw|�||j���}|r||d	z|zz
}|d|�|��zz
}|S)Nz
CREATE rzTABLE rjr�F��first_pkr��	Tz (in table '%s', column '%s'): %sr)r�)� _include_foreign_key_constraintsz
)%s

)r�r�r�rBr��create_table_suffixr,r��primary_keyr
r�rr,�u�descriptionr��args�create_table_constraints�include_foreign_key_constraints�post_create_table)
r�r"rar�r�rR�	separatorrO�
create_columnr �	processed�ce�consts
             rr�visit_create_tablezDDLCompiler.visit_create_tablegs������=�����?�	4��C�H�H�U�_�-�-��3�3�D���8�0�0��7�7�7�#�=�=��"�6�6�u�=�=���	.��'�#�-�-�D������	���#�^�	�	�M�"�*�F�
� �L�L�!�F�,>�,O�x�<�)���	��(��I�%�D� &�I��D�9�,�,�D��%�$�#�H����#�
�
�
����$���A�B�B� �,�f�k�2�7�1�:�F�G�����������������
�����-�-��-3�-S�.�
�
���	-��I��$�u�,�,�D���d�4�4�U�;�;�;�;���s�9C	�	D7�AD2�2D7Fc���|j}|jrdS��||���}d��fd�|jD����}|r|d|zz
}|S)NrNrc3�B�K�|]}��|��V��dSr�)r��rpr!r�s  �rrrNz2DDLCompiler.visit_create_column.<locals>.<genexpr>�s@�����
�
�)3�D�L�L��$�$�
�
�
�
�
�
rt)r��system�get_column_specificationrB�constraints)r�r"rOr r�r^s`     rr�visit_create_columnzDDLCompiler.visit_create_column�s��������=�	��4��,�,�V�h�,�G�G�����
�
�
�
�7=�7I�
�
�
�
�
���	 ��C�%�K��D��rtc�L����g}�jr|��j���j}|�|�|���nt	���|���fd��jD����d�d��fd�|D��D����S)Nc�.��g|]}|�ju�|�v�|��Srn)rS)rpr��	omit_fkcsras  ��rrr
z8DDLCompiler.create_table_constraints.<locals>.<listcomp>�s;���
�
�
���E�-�-�-�!�9�2D�2D��2D�2D�2Drtz, 
	c3�K�|]}|�|V��	dSr�rn)rp�ps  rrrNz7DDLCompiler.create_table_constraints.<locals>.<genexpr>�s4����
�
���}�
��}�}�}�
�
rtc3��K�|]R}|j�|������jjrt|dd���;��|��V��SdS)N�	use_alterF)�_create_ruler��supports_alterrr�rbs  �rrrNz7DDLCompiler.create_table_constraints.<locals>.<genexpr>�s����������+�3�!�.�.�t�4�4�4���3�	4�
#�:�{�E�B�B�4����Z�(�(�4�3�3�3�	�rt)rSr=�foreign_key_constraintsrer]�extend�_sorted_constraintsrB)r�rarQre�all_fkcsris``   @rrrWz$DDLCompiler.create_table_constraints�s����������	2����u�0�1�1�1��0��+�7� �+�+�,L�M�M�I�I����I����
�
�
�
�
��2�
�
�
�	
�	
�	
��}�}�
�
�����"-����
�
�
�
�
�	
rtc�F�d|j�|j��zS)Nz
DROP TABLE �r�r�r��r�rKs  rr�visit_drop_tablezDDLCompiler.visit_drop_table�s�����!;�!;�D�L�!I�!I�I�Irtc�F�d|j�|j��zS)Nz
DROP VIEW rurvs  rr�visit_drop_viewzDDLCompiler.visit_drop_view�s����
� :� :�4�<� H� H�H�Hrtc�L�|j�tjd|jz���dS)Nz,Index '%s' is not associated with any table.)rar
r�r��r�r�s  rr�_verify_index_tablezDDLCompiler._verify_index_table�s1���;���"�A�E�J�N���
��rtTc
�d��|j}��|���j}d}|jr|dz
}|j�tjd���|d��||����d|�|j	|����dd	�
�fd
�|jD�����d�z
}|S)NzCREATE zUNIQUE z0CREATE INDEX requires that the index have a namezINDEX ��include_schemar��r�� (r�c3�R�K�|]!}�j�|dd���V��"dS)FT�r�rtN)r�r�)rpr�r�s  �rrrNz1DDLCompiler.visit_create_index.<locals>.<genexpr>�sX���������!�)�)���T�*��������rtrk)r�r|r�rgr�r
r��_prepared_index_namer�rarB�expressions)r�r"r�include_table_schemar�r�r�s`      rr�visit_create_indexzDDLCompiler.visit_create_index�s������� � ��'�'�'��=�����<�	��I��D��:���"�B���
�	
���%�%�e�N�%�K�K�K�K��!�!���(<�
"�
�
�
�
�
�I�I�����"�-�	���
�
�
�
�
�	
���rtc�z�|j}|j�tjd���d|�|d���zS)Nz.DROP INDEX requires that the index have a namez
DROP INDEX Tr~)r�r�r
r�r�)r�rKr�s   rr�visit_drop_indexzDDLCompiler.visit_drop_index�sT������:���"�@���
���!:�!:��$�";�"
�"
�
�	
rtc���|j� |j�|j��}nd}|r|r|j�|��}nd}|j�|��}|r|dz|z}|S�Nr�)rar�r�r��format_index)r�r�rr��schema_name�
index_names      rrr�z DDLCompiler._prepared_index_names����;�"�#�}�>�>�u�{�K�K���#���	�.�	��-�4�4�5E�F�F�K�K��K��]�/�/��6�6�
��	8�$�s�*�Z�7�J��rtc��d|j�|jj���d|�|j����S)N�ALTER TABLE z ADD )r�r�r�rar��r�r"s  rr�visit_add_constraintz DDLCompiler.visit_add_constraints@����M�&�&�v�~�';�<�<�<�<��L�L���(�(�(�
�	
rtc��d|j�|j���d|j�|jjt
j������S)NzCOMMENT ON TABLE r�)r�r�r�r�r��commentr
�Stringr�s  rr�visit_set_table_commentz#DDLCompiler.visit_set_table_commentsV����M�&�&�v�~�6�6�6�6���2�2���&���(9�(9�
�
�
�
�	
rtc�F�d|j�|j��zS)NzCOMMENT ON TABLE %s IS NULLrurvs  rr�visit_drop_table_commentz$DDLCompiler.visit_drop_table_comment!s(��,�t�}�/I�/I��L�0
�0
�
�	
rtc��d|j�|jdd����d|j�|jjt
j������S)NzCOMMENT ON COLUMN T)�	use_tabler�r�)r�r�r�r�r�r�r
r�r�s  rr�visit_set_column_commentz$DDLCompiler.visit_set_column_comment&sj����M�'�'���$�4�
(�
�
�
�
�
��2�2���&���(9�(9�
�
�
�	
�	
rtc�J�d|j�|jd���zS)NzCOMMENT ON COLUMN %s IS NULLT)r�)r�r�r�rvs  rr�visit_drop_column_commentz%DDLCompiler.visit_drop_column_comment0s0��-��
�0K�0K��L�D�1L�1
�1
�
�	
rtc��d|j�|j��z}|jj�|d|jjzz
}|jj�|d|jjzz
}|jj�|d|jjzz
}|jj�|d|jjzz
}|jj�|dz
}|jj�|dz
}|jj	�|d|jj	zz
}|jj
d	ur|d
z
}|jj�|dz
}|S)NzCREATE SEQUENCE %sz INCREMENT BY %dz START WITH %dz MINVALUE %dz MAXVALUE %dz NO MINVALUEz NO MAXVALUEz	 CACHE %dTz ORDERz CYCLE)r�r&r��	increment�start�minvalue�maxvalue�
nominvalue�
nomaxvalue�cacherT�cycle)r�r"r�s   rr�visit_create_sequencez!DDLCompiler.visit_create_sequence5s"��#�d�m�&C�&C��N�'
�'
�
���>�#�/��&���)A�A�A�D��>��+��$�v�~�';�;�;�D��>�"�.��N�V�^�%<�<�<�D��>�"�.��N�V�^�%<�<�<�D��>�$�0��N�"�D��>�$�0��N�"�D��>��+��K�&�.�"6�6�6�D��>��4�'�'��H��D��>��+��H��D��rtc�F�d|j�|j��zS)NzDROP SEQUENCE %s)r�r&r�rvs  rr�visit_drop_sequencezDDLCompiler.visit_drop_sequenceMs��!�D�M�$A�$A�$�,�$O�$O�O�Ortc��|j}|j�|j�|��}nd}|�t	jd|jz���d|j�|jj���d|�|jrdpd��S)Nz<Can't emit DROP CONSTRAINT for constraint %r; it has no namer�z DROP CONSTRAINT rIr�)	r�r�r��format_constraintr
r�r�rarJ)r�rKr!�formatted_names    rr�visit_drop_constraintz!DDLCompiler.visit_drop_constraintPs����\�
��?�&�!�]�<�<�Z�H�H�N�N�!�N��!��"�!�#'�<�0���
�"�
�M�&�&�t�|�'9�:�:�:�:��N��L�'�Z�-�2�-�
�	
rtc�2�|j�|��dz|jj�|j|���z}|�|��}|�|d|zz
}|j� |d|�|j��zz
}|js|dz
}|S)Nr)r�z	 DEFAULT z	 NOT NULL)	r�r�r�r�r�r��get_column_default_string�computed�nullable)r�r r��colspecr)s     rrrdz$DDLCompiler.get_column_specificationbs����M�'�'��/�/��
��l�(�0�0���V�1���
�	��0�0��8�8�����{�W�,�,�G��?�&��s�T�\�\�&�/�:�:�:�:�G���	#��{�"�G��rtc��dS�Nr�rn�r�ras  rrrRzDDLCompiler.create_table_suffixu����rrtc��dSr�rnr�s  rrrYzDDLCompiler.post_create_tablexr�rtc�6�t|jtj��ryt|jjt
j��r/|j�|jjtj
��S|j�|jjd���SdS)NT)rt)r��server_defaultr�
DefaultClause�argr�string_typesr�r�r
r�r�r�s  rrr�z%DDLCompiler.get_column_default_string{s����f�+�V�-A�B�B�
	��&�/�3�T�5F�G�G�
��(�=�=��)�-�x�/B�����(�0�0��)�-�T�1�����4rtc���d}|j�$|j�|��}|�|d|zz
}|d|j�|jdd���zz
}||�|��z
}|S�Nr��CONSTRAINT %s z
CHECK (%s)FTr��r�r�r�r�r�r&�define_constraint_deferrability�r�r!r�r�s    rr�visit_check_constraintz"DDLCompiler.visit_check_constraint�������?�&�!�]�<�<�Z�H�H�N��)��(�>�9�9����t�0�8�8���e�4� 9� 
� 
�
�	
��	
��4�4�Z�@�@�@���rtc���d}|j�$|j�|��}|�|d|zz
}|d|j�|jdd���zz
}||�|��z
}|Sr�r�r�s    rr�visit_column_check_constraintz)DDLCompiler.visit_column_check_constraint�r�rtc�:��t|��dkrdSd}|j�$�j�|��}|�|d|zz
}|dz
}|dd��fd�|jr|jn|jD����zz
}|��|��z
}|S)Nrr�r�zPRIMARY KEY r�r�c3�V�K�|]#}�j�|j��V��$dSr��r�r�r�r*s  �rrrNz;DDLCompiler.visit_primary_key_constraint.<locals>.<genexpr>�sI�����#
�#
��
�M�����'�'�#
�#
�#
�#
�#
�#
rt)	rVr�r�r�rB�_implicit_generated�columns_autoinc_firstr,r�r�s`   rr�visit_primary_key_constraintz(DDLCompiler.visit_primary_key_constraint�s�����z�?�?�a����2����?�&�!�]�<�<�Z�H�H�N��)��(�>�9�9�����������#
�#
�#
�#
��1�(�
�0�0��'�#
�#
�#
�
�
�
�	
��	
��4�4�Z�@�@�@���rtc
� ��|j�d}|j�$|j�|��}|�|d|zz
}t|j��djj}|dd��fd�|jD�����d|�||����dd��fd	�|jD�����d
�z
}||�	|��z
}||�
|��z
}||�|��z
}|S)Nr�r�rzFOREIGN KEY(r�c3�V�K�|]#}��|jj��V��$dSr�)r��parentr��rpr�r�s  �rrrNz;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>��D�������23����q�x�}�-�-������rtz
) REFERENCES r�c3�V�K�|]#}��|jj��V��$dSr�)r�r r�r�s  �rrrNz;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>�r�rtrk)r�r�r�r0rr rarB�define_constraint_remote_table�define_constraint_match�define_constraint_cascadesr�)r�r!r�r��remote_tabler�s     @rr�visit_foreign_key_constraintz(DDLCompiler.visit_foreign_key_constraint�sm����=�����?�&�!�]�<�<�Z�H�H�N��)��(�>�9�9���J�/�0�0��3�:�@�����I�I�����7A�7J����
�
�
�
�
�/�/��L�(�
�
�
�
�
�I�I�����7A�7J����
�
�
�
�

�
	
��	
��,�,�Z�8�8�8����/�/�
�;�;�;����4�4�Z�@�@�@���rtc�,�|�|��S)z=Format the remote table clause of a CREATE CONSTRAINT clause.)r�)r�r!rar�s    rrr�z*DDLCompiler.define_constraint_remote_table�s���$�$�U�+�+�+rtc�
��t|��dkrdSd}|j�$�j�|��}|�|d|zz
}|dd��fd�|D����zz
}|��|��z
}|S)Nrr�r�zUNIQUE (%s)r�c3�V�K�|]#}�j�|j��V��$dSr�r�r*s  �rrrNz6DDLCompiler.visit_unique_constraint.<locals>.<genexpr>�s5�����F�F�a�d�m�)�)�!�&�1�1�F�F�F�F�F�Frt)rVr�r�r�rBr�r�s`   rr�visit_unique_constraintz#DDLCompiler.visit_unique_constraint�s�����z�?�?�a����2����?�&�!�]�<�<�Z�H�H�N��)��(�>�9�9���
��I�I�F�F�F�F�:�F�F�F�F�F�
�	
��	
��4�4�Z�@�@�@���rtc���d}|j�+|d|j�|jt��zz
}|j�+|d|j�|jt
��zz
}|S)Nr�z
 ON DELETE %sz
 ON UPDATE %s)�ondeleter��validate_sql_phrase�FK_ON_DELETE�onupdate�FK_ON_UPDATE�r�r!r�s   rrr�z&DDLCompiler.define_constraint_cascades�s|������*��O�d�m�&G�&G��#�\�'�'��
�D���*��O�d�m�&G�&G��#�\�'�'��
�D��rtc��d}|j�|jr|dz
}n|dz
}|j�+|d|j�|jt��zz
}|S)Nr�z DEFERRABLEz NOT DEFERRABLEz
 INITIALLY %s)r*r<r�r��FK_INITIALLYr�s   rrr�z+DDLCompiler.define_constraint_deferrability�so����� �,��$�
*��
�%����)�)����+��O�d�m�&G�&G��$�l�'�'��
�D��rtc�2�d}|j�
|d|jzz
}|S)Nr�z	 MATCH %s)�matchr�s   rrr�z#DDLCompiler.define_constraint_match�s'������'��K�*�"2�2�2�D��rtc��d|j�|jdd���z}|jdur|dz
}n|jdur|dz
}|S)NzGENERATED ALWAYS AS (%s)FTr�z STOREDz VIRTUAL)r�r�r&�	persisted)r��	generatedr�s   rr�visit_computed_columnz!DDLCompiler.visit_computed_column�sj��)�D�,=�,E�,E���U�$�-F�-
�-
�
����$�&�&��I��D�D�
�
 �E�
)�
)��J��D��rtr�r)FT)*r�r�r�rrr�r�r�rDrGrLr_rfrWrwryr|r�r�r�r�r�r�r�r�r�r�r�rdrRrYr�r�r�r�r�r�r�r�r�r�r�rnrtrrr5r5;s�������	��
�
���
�

��*�*���*�����L�L�L�&)�)�)����0�0�0�d
�
�
�
� 7;�'
�'
�'
�'
�RJ�J�J�I�I�I����BF�����6	
�	
�	
����� 
�
�
�
�
�
�
�
�
�

�
�
�
�
�
�
���0P�P�P�
�
�
�$���&���������
�
�
�
�
�
����(���0,�,�,�
���
�
�
�����������rtr5c�
�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�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+S),�GenericTypeCompilerc��dS)N�FLOATrnr�s   rr�visit_FLOATzGenericTypeCompiler.visit_FLOAT

����wrtc��dS)N�REALrnr�s   rr�
visit_REALzGenericTypeCompiler.visit_REAL

r�rtc�^�|j�dS|j�dd|jizSd|j|jd�zS)N�NUMERICzNUMERIC(%(precision)s)�	precisionz!NUMERIC(%(precision)s, %(scale)s)�r��scaler�r�s   rr�
visit_NUMERICz!GenericTypeCompiler.visit_NUMERIC
�J���?�"��9�
�[�
 �+�{�E�O�.L�L�L�6�"�_���:�:��
rtc�^�|j�dS|j�dd|jizSd|j|jd�zS)N�DECIMALzDECIMAL(%(precision)s)r�z!DECIMAL(%(precision)s, %(scale)s)r�r�r�s   rr�
visit_DECIMALz!GenericTypeCompiler.visit_DECIMAL
r�rtc��dS)N�INTEGERrnr�s   rr�
visit_INTEGERz!GenericTypeCompiler.visit_INTEGER&
����yrtc��dS)N�SMALLINTrnr�s   rr�visit_SMALLINTz"GenericTypeCompiler.visit_SMALLINT)
����zrtc��dS)N�BIGINTrnr�s   rr�visit_BIGINTz GenericTypeCompiler.visit_BIGINT,
s���xrtc��dS)N�	TIMESTAMPrnr�s   rr�visit_TIMESTAMPz#GenericTypeCompiler.visit_TIMESTAMP/
s���{rtc��dS)N�DATETIMErnr�s   rr�visit_DATETIMEz"GenericTypeCompiler.visit_DATETIME2
rrtc��dS)N�DATErnr�s   rr�
visit_DATEzGenericTypeCompiler.visit_DATE5
r�rtc��dS)N�TIMErnr�s   rr�
visit_TIMEzGenericTypeCompiler.visit_TIME8
r�rtc��dS)N�CLOBrnr�s   rr�
visit_CLOBzGenericTypeCompiler.visit_CLOB;
r�rtc��dS)N�NCLOBrnr�s   rr�visit_NCLOBzGenericTypeCompiler.visit_NCLOB>
r�rtc�Z�|}|jr
|d|jzz
}|jr
|d|jzz
}|S)N�(%d)z
 COLLATE "%s")�lengthr�)r�r�r�r�s    rr�_render_string_typez'GenericTypeCompiler._render_string_typeA
sB�����<�	*��F�U�\�)�)�D��?�	6��O�e�o�5�5�D��rtc�.�|�|d��S)N�CHAR�rr�s   rr�
visit_CHARzGenericTypeCompiler.visit_CHARJ
����'�'��v�6�6�6rtc�.�|�|d��S)N�NCHARr!r�s   rr�visit_NCHARzGenericTypeCompiler.visit_NCHARM
s���'�'��w�7�7�7rtc�.�|�|d��S)N�VARCHARr!r�s   rr�
visit_VARCHARz!GenericTypeCompiler.visit_VARCHARP
s���'�'��y�9�9�9rtc�.�|�|d��S)N�NVARCHARr!r�s   rr�visit_NVARCHARz"GenericTypeCompiler.visit_NVARCHARS
s���'�'��z�:�:�:rtc�.�|�|d��S)N�TEXTr!r�s   rr�
visit_TEXTzGenericTypeCompiler.visit_TEXTV
r#rtc��dS)N�BLOBrnr�s   rr�
visit_BLOBzGenericTypeCompiler.visit_BLOBY
r�rtc�.�d|jr
d|jzpdzS)N�BINARYrr��rr�s   rr�visit_BINARYz GenericTypeCompiler.visit_BINARY\
s ���5�<�A�F�U�\�,A�G�R�H�Hrtc�.�d|jr
d|jzpdzS)N�	VARBINARYrr�r5r�s   rr�visit_VARBINARYz#GenericTypeCompiler.visit_VARBINARY_
s ���e�l�D�v���/D�J��K�Krtc��dS)N�BOOLEANrnr�s   rr�
visit_BOOLEANz!GenericTypeCompiler.visit_BOOLEANb
rrtc��|j|fi|��Sr�)r2r�s   rr�visit_large_binaryz&GenericTypeCompiler.visit_large_binarye
����t��u�+�+��+�+�+rtc��|j|fi|��Sr�)r<r�s   rr�
visit_booleanz!GenericTypeCompiler.visit_booleanh
���!�t�!�%�.�.�2�.�.�.rtc��|j|fi|��Sr�)rr�s   rr�
visit_timezGenericTypeCompiler.visit_timek
r?rtc��|j|fi|��Sr�)rr�s   rr�visit_datetimez"GenericTypeCompiler.visit_datetimen
���"�t�"�5�/�/�B�/�/�/rtc��|j|fi|��Sr�)rr�s   rr�
visit_datezGenericTypeCompiler.visit_dateq
r?rtc��|j|fi|��Sr�)rr�s   rr�visit_big_integerz%GenericTypeCompiler.visit_big_integert
s�� �t� ��-�-�"�-�-�-rtc��|j|fi|��Sr�)rr�s   rr�visit_small_integerz'GenericTypeCompiler.visit_small_integerw
rGrtc��|j|fi|��Sr�)rr�s   rr�
visit_integerz!GenericTypeCompiler.visit_integerz
rBrtc��|j|fi|��Sr�)r�r�s   rr�
visit_realzGenericTypeCompiler.visit_real}
r?rtc��|j|fi|��Sr�)r�r�s   rr�visit_floatzGenericTypeCompiler.visit_float�
s���t���,�,��,�,�,rtc��|j|fi|��Sr�)r�r�s   rr�
visit_numericz!GenericTypeCompiler.visit_numeric�
rBrtc��|j|fi|��Sr��r)r�s   rr�visit_stringz GenericTypeCompiler.visit_string�
rBrtc��|j|fi|��Sr�rWr�s   rr�
visit_unicodez!GenericTypeCompiler.visit_unicode�
rBrtc��|j|fi|��Sr��r/r�s   rr�
visit_textzGenericTypeCompiler.visit_text�
r?rtc��|j|fi|��Sr�r\r�s   rr�visit_unicode_textz&GenericTypeCompiler.visit_unicode_text�
r?rtc��|j|fi|��Sr�rWr�s   rr�
visit_enumzGenericTypeCompiler.visit_enum�
rBrtc�0�tjd|z���)NzKCan't generate DDL for %r; did you forget to specify a type on this Column?r�r�s   rrr�zGenericTypeCompiler.visit_null�
s$����
#�%*�
+�
�
�	
rtc�N�|j|�|j��fi|��Sr�)r��type_enginer�r�s   rr�visit_type_decoratorz(GenericTypeCompiler.visit_type_decorator�
s,���t�|�E�-�-�d�l�;�;�B�B�r�B�B�Brtc��|jdi|��S)Nrn)�get_col_specr�s   rr�visit_user_definedz&GenericTypeCompiler.visit_user_defined�
s��!�u�!�'�'�B�'�'�'rtN)-r�r�r�r�r�r�r�rrrrrrrrrrr"r&r)r,r/r2r6r9r<r>rArDrFrIrKrMrOrQrSrUrXrZr]r_rar�rerhrnrtrrr�r�	
s�������������	�	�	�	�	�	�������������������������������7�7�7�8�8�8�:�:�:�;�;�;�7�7�7����I�I�I�L�L�L����,�,�,�/�/�/�,�,�,�0�0�0�,�,�,�.�.�.�0�0�0�/�/�/�,�,�,�-�-�-�/�/�/�/�/�/�/�/�/�,�,�,�,�,�,�/�/�/�
�
�
�C�C�C�(�(�(�(�(rtr�c��eZdZd�Zd�ZdS)�StrSQLTypeCompilerc�X�|�d��r|jSt|���)NrL)�
startswith�_visit_unknown�AttributeError)r�rs  rr�__getattr__zStrSQLTypeCompiler.__getattr__�
s-���>�>�(�#�#�	&��&�&� ��%�%�%rtc� �d|jjzS)Nz%s)r)r�r�s   rrrmz!StrSQLTypeCompiler._visit_unknown�
s���e�o�.�.�.rtN)r�r�r�rormrnrtrrrjrj�
s2������&�&�&�/�/�/�/�/rtrjc�4�eZdZdZeZeZeZ	e
jd��Z					dd�Z
d�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zdd�Zdd�Zd�Zd d�Zdd�Zdd�Zdd�Zejd��d���Zd�Zd!d�Z d�Z!				d"d�Z"d d�Z#ej$d���Z%d�Z&dS)#�IdentifierPreparerz@Handle quoting and case-folding of identifiers based on options.N�"TFc��||_||_|p|j|_||_|jdz|_||_||_i|_|jjdv|_	dS)asConstruct a new ``IdentifierPreparer`` object.

        initial_quote
          Character that begins a delimited identifier.

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

        omit_schema
          Prevent prepending schema name. Useful for databases that do
          not support schemae.
        r)rzrxN)
r��
initial_quote�final_quote�escape_quote�escape_to_quote�omit_schema�quote_case_sensitive_collations�_stringsrr�)r�r�rurvrwrzrys       rrr�zIdentifierPreparer.__init__�
so��.���*���&�<�$�*<���(���#�0�1�4���&���/N��,���
� $�� 7�<
�!
����rtc��|j�|j��}|j�|j��t	j|��|_|Sr�)r)�__new__�__dict__rr�_schema_getterr�)r�r��preps   rrr�z)IdentifierPreparer._with_schema_translate�
sJ���~�%�%�d�n�5�5���
���T�]�+�+�+�!'�!6�7K�!L�!L����rtc��|�|j|j��}|jr|�dd��}|S)z�Escape an identifier.

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

        Subclasses should override this to provide database-dependent
        unescaping behavior that reverses _escape_identifier.
        )r�rxrwr�s  rr�_unescape_identifierz'IdentifierPreparer._unescape_identifier�
s���}�}�T�1�4�3D�E�E�Ertc�t�|�5|�|��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

        NzUnexpected SQL phrase: z (matching against rk)r�r
r��pattern)r�r��regs   rrr�z&IdentifierPreparer.validate_sql_phrase�
sN����s�y�y��'9�'9���"�"��7�7�C�K�K�K�)���
��rtc�L�|j|�|��z|jzS)z~Quote an identifier.

        Subclasses should override this to provide database-dependent
        quoting behavior.
        )rur�rvr�s  rr�quote_identifierz#IdentifierPreparer.quote_identifiers0��
���%�%�e�,�,�
-���
�	
rtc��|���}||jvpA|d|jvp2|j�tj|����p||kS)z5Return True if the given identifier requires quoting.r)r'�reserved_words�illegal_initial_characters�legal_charactersr�r�	text_type)r�r	�lc_values   rrr�z#IdentifierPreparer._requires_quotessh���;�;�=�=����+�+�
#��Q�x�4�:�:�
#��(�.�.�t�~�e�/D�/D�E�E�E�
#��E�!�		
rtc�\�|j�tj|����S)zjReturn True if the given identifier requires quoting, but
        not taking case convention into account.)r�r�rr�r�s  rrr$z1IdentifierPreparer._requires_quotes_illegal_chars"s(���(�.�.�t�~�e�/D�/D�E�E�E�Ertc�X�|�tjd��|�|��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`.

        Nz�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().)r�warn_deprecatedr�)r�r�forces   rrr�zIdentifierPreparer.quote_schema's:��.��
� �!�
�
�
��z�z�&�!�!�!rtc�F�|�tjd��t|dd��}|�`||jvr
|j|S|�|��r|�|��|j|<n
||j|<|j|S|r|�|��S|S)aConditionally quote an identfier.

        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�)rr�rr{r�r�)r�rr�s   rrr�zIdentifierPreparer.quoteLs���,��
� �!�
�
�
���w��-�-���=���
�%�%��}�U�+�+��(�(��/�/�1�+/�+@�+@��+G�+G�D�M�%�(�(�+0�D�M�%�(��}�U�+�+�
�	��(�(��/�/�/��Lrtc�>�|jr|�|��S|Sr�)rzr�)r��collation_names  rrr�z#IdentifierPreparer.format_collation~s%���/�	"��:�:�n�-�-�-�!�!rtc��|�|j��}|�|��}|js|r|�|�|��dz|z}|Sr�)r�r�r�ryr�)r�r1r�r�r�s     rrr&z"IdentifierPreparer.format_sequence�sk���z�z�(�-�(�(���1�1�(�;�;��� �	D��	D�!�,��$�$�%5�6�6��<�t�C�D��rtc�:�|�|p|j��Sr��r�r�)r�r�r�s   rrr�zIdentifierPreparer.format_label�����z�z�$�,�%�*�-�-�-rtc�:�|�|p|j��Sr�r�)r�r�r�s   rrr�zIdentifierPreparer.format_alias�r�rtc�l�|p|j}|�|��r|�|��}|Sr�)rr�r�)r��	savepointr�rs    rrrz#IdentifierPreparer.format_savepoint�s>���'�	���� � ��'�'�	1��)�)�%�0�0�E��rtzsqlalchemy.sql.namingc��|jtjur |�||j��}|�dSn|j}t|tj��r}|jdkr|jj	p|jj
}n|jjp|jj
}t|��|kr-|d|dz
�dztj|��dd�z}n|j�|��|�|��S)Nr�r�r���)r�r�
_NONE_NAME�_constraint_name_for_tablerar�r�r�r��max_index_name_lengthr�max_constraint_name_lengthrVr�md5_hex�validate_identifierr�)r��namingr!r��max_s     rrr�z$IdentifierPreparer.format_constraint�s���?�h�1�1�1��4�4��J�,���D��|��t���?�D��d�H�5�6�6�	3��(�G�3�3��L�6�:��|�9����L�;�:��|�9���4�y�y�4����A��q��L�)�C�/�$�,�t�2D�2D�R�S�S�2I�I����L�,�,�T�2�2�2��z�z�$���rtc�,�|�|��Sr�)r�r{s  rrr�zIdentifierPreparer.format_index�s���%�%�e�,�,�,rtc��|�|j}|�|��}|�|��}|js|r|r|�|��dz|z}|S)z'Prepare a quoted table and schema name.Nr�)r�r�r�ryr�)r�rar�r�rfr�s      rrr�zIdentifierPreparer.format_table�su���<��:�D����D�!�!���1�1�%�8�8����	H�J�	H�3C�	H��&�&�'7�8�8�3�>��G�F��
rtc�,�|�|��S)zPrepare a quoted schema name.)r�r�s  rrrFz IdentifierPreparer.format_schema�s���z�z�$���rtc��|�|j}t|dd��sM|r6|�|j||���dz|�|��zS|�|��S|r#|�|j||���dz|zS|S)zPrepare a quoted column name.Nr�F)r�r�r�)r�rr�rar�)r�r r�r��
table_namer�s      rrr�z IdentifierPreparer.format_column�s����<��;�D��v�|�U�3�3�	��	
(��%�%����*�&������j�j��&�&�	'���z�z�$�'�'�'�
�	
��%�%����*�&������	���rtc���|�|��}|js0|r.|r,|�|��|�|d���fS|�|d���fS)z(Format table name and schema as a tuple.Fr�)r�ryr�r�)r�rar�r�s    rrr?z#IdentifierPreparer.format_table_seq�s��� �1�1�%�8�8����	A�J�	A�3C�	A��!�!�"2�3�3��!�!�%�E�!�:�:��
�
�%�%�e��%�>�>�@�@rtc��d�|j|j|�|j��fD��\}}}tjd|||d�z��}|S)Nc�6�g|]}tj|����Srn)rJr�r�s  rrr
z5IdentifierPreparer._r_identifiers.<locals>.<listcomp>s0��)
�)
�)
��
�I�a�L�L�)
�)
�)
rtzM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)�initial�final�escaped)rurvr�rJr�)r�r�r��
escaped_final�rs     rr�_r_identifiersz!IdentifierPreparer._r_identifiers
s��)
�)
��"�� ��'�'��(8�9�9��)
�)
�)
�%���
�
�J�
$�"�E�m�L�L�
M�
�
���rtc�h���j}�fd�d�|�|��D��D��S)z:Unpack 'schema.table.column'-like strings into components.c�:��g|]}��|����Srn)r�)rpr<r�s  �rrr
z;IdentifierPreparer.unformat_identifiers.<locals>.<listcomp>#s7���
�
�
��
�%�%�a�(�(�
�
�
rtc��g|]	\}}|p|��
Srnrn)rp�a�bs   rrr
z;IdentifierPreparer.unformat_identifiers.<locals>.<listcomp>%s ��@�@�@���A�a�f�1�@�@�@rt)r��findall)r��identifiersr�s`  rr�unformat_identifiersz'IdentifierPreparer.unformat_identifierssR���
���
�
�
�
�@�@����;�)?�)?�@�@�@�
�
�
�	
rt)rsNrsTFr�)T)TN)FNNF)'r�r�r�r��RESERVED_WORDSr��LEGAL_CHARACTERSr��ILLEGAL_INITIAL_CHARACTERSr�rrr�r�r�r�r�r�r�r�r$r�r�r�r&r�r�rrrr�r�r�rFr�r?rr�r�rnrtrrrrrr�
s"������J�J�#�N�'��!;��-��-�d�3�3��
���(,��"
�"
�"
�"
�H���
�
�
�F�F�F����$
�
�
�
�
�
�F�F�F�
#"�#"�#"�#"�J0�0�0�0�d"�"�"�����.�.�.�.�.�.�.�.������T��.�/�/� � �0�/� �@-�-�-����� � � ��
���
$�$�$�$�LA�A�A�A�"
�������"
�
�
�
�
rtrr)lr�rrHrJr�rrrrrr	r
rr
rr]r�r��Ir��LEGAL_CHARACTERS_PLUS_SPACE�rangerfr�r�r�r��UNICODEr�r�r�and_�or_�add�mulrK�div�mod�truediv�neg�lt�le�ne�gt�ge�eq�is_distinct_from�isnot_distinct_from�	concat_oprc�notmatch_op�in_op�notin_op�comma_opr�r��is_�isnotr�exists�distinct_op�inv�any_op�all_op�desc_op�asc_op�
nullsfirst_op�nullslast_opr�r�r$r&r'r(rGrHr�r�r\rh�cube�rollup�
grouping_setsr(rr�r��	UNION_ALLr��
EXCEPT_ALLr��
INTERSECT_ALLr�objectr��with_metaclass�EnsureKWArgTyper��	Visitabler�rRr�rrr5r�rjrrrnrtrr�<module>r�s$����$��������	�	�	�	���������������������������������������������������������������_�_�_�a�a��F�2�:�.���5�5��(�b�j�):�B�D�A�A��;�;�e�e�A�r�l�l�;�;�;�A�A�3�%�H�H���r�z�<�b�d�����r�z�<�b�d�����r�z�5�r�t�<�<���b�j�A�2�:�N�N���"�*�9�2�:�F�F�� �
���
����)
�
�N�G�)
��M�6�)
��M�5�	)
�
�M�5�)
��M�5�
)
��M�5�)
��M�5�)
���u�)
��M�3�)
��L�%�)
��L�&�)
��L�&�)
��L�%�)
��L�&�)
� �L�%�!)
�"�� 4�#)
�$�!�#;�%)
�)
�&���')
�(��	�))
�*��=�+)
�,�O�V�-)
�.��
�/)
�0���1)
�2�O�X�3)
�4�M�6�5)
�6�M�6�7)
�8�O�Z�9)
�:��{�;)
�>��i�?)
�@��;�A)
�B�M�6�C)
�D��f�E)
�F��f�G)
�J��w�K)
�)
�L��f�
��^�
��M�Q)
�)
�	�X��
�
��N�
��N�
��!4�
��N�
���
��.�
��h�
��y�
��N�
�N�F�
�N�F�
��h�
��_�
�	�$����������
�"�"�$�(����&��#�W���'����$�h���(�,���'����+�_�
��J=�J=�J=�J=�J=�v�J=�J=�J=�Z	4�	4�	4�	4�	4�&�4�&�t�';�V�D�D�	4�	4�	4������H�&����0�����d����$w$
�w$
�w$
�w$
�w$
�(�w$
�w$
�w$
�tI?�?�?�?�?�[�?�?�?�DK�K�K�K�K�(�K�K�K�\W(�W(�W(�W(�W(�,�W(�W(�W(�t/�/�/�/�/�,�/�/�/�x
�x
�x
�x
�x
��x
�x
�x
�x
�x
rt

Hacked By AnonymousFox1.0, Coded By AnonymousFox