� k\�g2�� �UdZddlmZddlZddlmZddlZddlm Z ddl Z ddl Z ddl Z ddl Z ddlmZddlZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd 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;lGmJZJej$r�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 jvd`e jw��Zxe jvdae jw��Zydb�ezddc��D���{ddg��Z|e jvdee jw��Z}e jvdee jw��Z~e jvdfe jw��Ze jvdge j���Z�e jvdhe j���Z�diZ�e�djdkdldmdndo�Z�ie,j�dp�e,j�dq�e,j�dr�e,j�ds�e,j�dt�e,j�du�e,j�dv�e,j�dw�e,j�dx�e,j�dy�e,j�dz�e,j�d{�e,j�d|�e,j�d}�e,j�d~�e,j�d�e,j�d��ie,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d��e,j�d���e,j�d�e,j�d�e,j�d�e,j�d�e,j�d�e,j�d�e,j�d�i�Z�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�e+j�d�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�ej�d�d�d�g����Z�Gd�d��Z�Gd�d�e1j���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�dS)�a]Base SQL and DDL compiler implementations. Classes provided include: :class:`.compiler.SQLCompiler` - renders SQL strings :class:`.compiler.DDLCompiler` - renders DDL (data definition language) strings :class:`.compiler.GenericTypeCompiler` - renders type specification strings. To generate user-defined SQL strings, see :doc:`/ext/compiler`. �)� 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)�SchemaTranslateMapTyperO>^�as�do�in�is�on�or�to�all�and�any�asc�end�for�new�not�off�old�set�both�caser�desc�else�from�full�into�join�left�like�null�only�some�then�true�user�when�array�check�cross�false�grant�group�ilike�inner�limit�order�outer�right�table�union�using�where�binary�column�create�except�freeze�having�isnull�offset�select�unique�analyse�analyze�between�collate�default�foreign�leading�natural�notnull�placing�primary�similar�verbose�distinct�overlaps�trailing� initially� intersect� localtime� symmetric� asymmetric� constraint� deferrable� references� current_date� current_role� current_time� current_user� session_user� authorization�localtimestamp�current_timestampz ^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$c�,�h|]}t|����S�)�str)�.0�xs �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sqlalchemy/sql/compiler.py� <setcomp>r��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 $[_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�B�eZdZUdZded< ded< ded< ded<d S) �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. r��keyname�name�Tuple[Any, ...]�objects�TypeEngine[Any]�typeN��__name__� __module__� __qualname__�__doc__�__annotations__r�r�r�r�r�[sY����������L�L�L�;� �I�I�I�%������ �����r�r�c��eZdZd d �Zd S) �_ResultMapAppenderr�r�r�r�� Sequence[Any]�type_r��return�Nonec��dS�Nr���selfr�r�r�rs r��__call__z_ResultMapAppender.__call__{s �� �sr�N) r�r�r�r�r�rrr�rr �r�rrrr�r�r�rrzs(�����������r�rz Literal[0]�RM_RENDERED_NAMEz Literal[1]�RM_NAMEz Literal[2]� RM_OBJECTS�z Literal[3]�RM_TYPEc�.�eZdZUded<ded<ded<dS)�_BaseCompilerStackEntryzSet[FromClause]� asfrom_froms�correlate_fromsrQr$N�r�rrrr�r�r�rr�s6�������!�!�!�!�$�$�$�$������r�rc�B�eZdZUded<ded<ded<ded<ded <d S) �_CompilerStackEntryr?� compile_state�bool�need_result_map_for_nested�need_result_map_for_compoundrQ�select_0� Select[Any]�insert_from_selectNrr�r�r�rr�sN�����������$�$�$�$�&�&�&�&�����#�#�#�#�#�#r�rF)�totalc��eZdZUdZded< ded< ded< ded < d ed < edd���Zedd���ZdS)� 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�� statementrV� parameters�%Mapping[str, _BindProcessorType[Any]]� processors�Optional[Sequence[str]]� positiontupzMapping[str, List[str]]�parameter_expansionrr�c�z���j�tjd���t�fd��jD����S)zrTuple of positional parameters, for statements that were compiled using a positional paramstyle. Nz.statement does not use a positional paramstylec3�2�K�|]}�j|V��dSr �r')r��keyr s �r�� <genexpr>z6ExpandedState.positional_parameters.<locals>.<genexpr>�s*�����F�F�c�T�_�S�)�F�F�F�F�F�Fr�)r+r8�InvalidRequestError�tuple�r s`r��positional_parametersz#ExpandedState.positional_parameters�sN��� � � #��)�@��� ��F�F�F�F�T�5E�F�F�F�F�F�Fr�c��|jS)z.synonym for :attr:`.ExpandedState.parameters`.r/r4s r��additional_parametersz#ExpandedState.additional_parameters�s ����r�N)rr�)rrV)r�rrrr�propertyr5r7r�r�r�r%r%�s����������"�N�N�N�=�(�(�(�(��6�5�5�5�+�(�(�(�(��1�0�0�0��� G� G� G��X� G������X���r�r%c��eZdZUdZded< ded< ded< ded < d Zded < d Zded < d Zded< dZded< d Z ded< d Z ded< d Z ded<d S)�_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�rrrrrArBrDrErFrGrHr�r�r�r:r:�s�������������� �����8�7�7�7�M�&�&�&�&� �%*��)�)�)�)��',��+�+�+�+��9=��<�<�<�<��!"��!�!�!�!��48��7�7�7�7�� $��#�#�#�#� �"'��&�&�&�&� � r�r:c�x�eZdZUdZded<ded<ded<ded <d ed <d ed <d ed<d ed<ded<ded<dS)�_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_statementrW�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�rJrJNs�������� � �����/�/�/�/�@�@�@�@�.�.�.�.�.�.�.�.������M�M�M��������������r�rJc�D�eZdZdZdZdZdZdZeezezZeezZ dZ dZ dS) �InsertmanyvaluesSentinelOptszcbitflag enum indicating styles of PK defaults which can work as implicit sentinel columns rr7����@N) r�rrr� NOT_SUPPORTED� AUTOINCREMENT�IDENTITY�SEQUENCE�ANY_AUTOINCREMENT�_SUPPORTED_OR_NOT�USE_INSERT_FROM_SELECT�RENDER_SELECT_COL_CASTSr�r�r�rWrWgsX�������� �M��M��H��H�%��0�8�;��%�(9�9���� ���r�rWc��eZdZdZ dZ dZdS)� CompilerStaterrr7N)r�rr� COMPILING�STRING_APPLIED� NO_STATEMENTr�r�r�rereys-�������I�=��N�� �L��r�rec�.�eZdZdZdZ dZ dZ eezZdS)�Lintingz�represent preferences for the 'SQL linting' feature. this feature currently includes support for flagging cartesian products in SQL statements. rrr7N)r�rrr� NO_LINTING�COLLECT_CARTESIAN_PRODUCTS� WARN_LINTING� FROM_LINTINGr�r�r�rjrj�sG���������J��!"����L�2�-� �<�L��r�rjc�"�eZdZdZdd�Zdd�ZdS)� FromLinterzKrepresents current state for the "cartesian product" detection feature.Nc����|j}|sdSt|j��}t|��}|�|}|�|��n|���}t j|g��}|rs|rq|����|�����fd�|D��}|� �fd�|D����|� |��|r|�q|r||fSdS)N�NNc���h|]}�|v�|�� Sr�r��r��edge�nodes �r�r�z"FromLinter.lint.<locals>.<setcomp>�s���@�@�@�$�4�4�<�<��<�<�<r�c3�P�K�|] }||���� V��!dSr )�indexrts �r�r1z"FromLinter.lint.<locals>.<genexpr>�s7�����N�N�D�T�d�j�j��&6�&6�"6�7�N�N�N�N�N�Nr�) �fromsrp�edges�remove�pop� collections�deque�popleft�discard� extendleft�difference_update) r �startryrz�the_rest� start_with�stack� to_removervs @r��lintzFromLinter.lint�s$���� ��� ��:��D�J�����u�:�:�� � ��J� �O�O�J� '� '� '� '�!�����J��!�:�,�/�/��� /�� /��=�=�?�?�D� � � �T� "� "� "� A�@�@�@�%�@�@�@�I� � � �N�N�N�N�I�N�N�N� N� N� N� � #� #�I� .� .� .�� /�� /� � ��Z�'� '��:r��SELECTc��������\}}|r`|}|r^d}d��fd�|D����}|�||�j|���}t j|��dSdSdS)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�:�K�|]}d�j|�d�V��dS)�"N)ry)r��from_r s �r�r1z"FromLinter.warn.<locals>.<genexpr>�sG�����&�&�16�,�� �5�)�,�,�,�&�&�&�&�&�&r�)� stmt_typeryr�)r�rxr�ryr&�warn)r r�r�r�ry�template� froms_str�messages` r�r�zFromLinter.warn�s����#�y�y�{�{���*� � #��E�� #�7�� !�I�I�&�&�&�&�:?�&�&�&��� �#�/�/�'�#��*�Z�0�*���� � �'�"�"�"�"�"�% #� #� #� #r�r )r�)r�rrrr�r�r�r�r�rprp�sG��������#�#�#�#�J#�#�#�#�#�#r�rpryrzc���eZdZUdZdZded< dZded< ded < d Zd ZdZ d ed <dZ d ed<dZ ded<e j Zded< ded<e j Zded<dZded< dZded< dZded< ded< dd e j��fd;d$�Zd<�fd'� Zed(���Zd)�Zd*�Zed+���Zd=d0�Zd>d1�Z d?d@d9�Zed:���Z�xZ S)A�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��stringre�stateFzOptional[CursorResultMetaData]�_cached_metadataz"Optional[List[ResultColumnsEntry]]�_result_columns� Optional[SchemaTranslateMapType]�schema_translate_maprZ�execution_options�IdentifierPreparer�preparerr=� _annotationszOptional[CompileState]r�dml_compile_state�Optional[CacheKey]� cache_key�float� _gen_time�dialectr]�render_schema_translater�compile_kwargs�Mapping[str, Any]c�6�||_|jj|_|r&||_|j�|��|_|��t j|_||_|j |_ |j |_ |j r*trt|t��sJ�|j|_|j|jfi|��|_|r%|j�|j|��|_t j|_nt j|_t-��|_dS)a�Construct a new :class:`.Compiled` object. :param dialect: :class:`.Dialect` to compile against. :param statement: :class:`_expression.ClauseElement` to be compiled. :param schema_translate_map: dictionary of schema names to be translated when forming the resultant SQL .. seealso:: :ref:`schema_translating` :param compile_kwargs: additional kwargs that will be passed to the initial call to :meth:`.Compiled.process`. N)r��identifier_preparerr�r��_with_schema_translatererfr�r&�supports_execution� can_executer�r� isinstancer.�_execution_optionsr��processr��_render_schema_translatesrgrhrr��r r�r&r�r�r�s r��__init__zCompiled.__init__;s��4�� �� �8�� � � �(<�D� %� �M�@�@�$���D�M� � �&�0�D�J�&�D�N�(�;�D� � )� 6�D� ��� F� �=�%�i��<�<�<�<�<�)2�)E��&�&�$�,�t�~�H�H��H�H�D�K�&� �"�m�E�E��K�!5���� �'�5�D�J�J�&�3�D�J�%������r�rr c�l��|���t�����Sr )�_init_compiler_cls�super�__init_subclass__)�cls� __class__s �r�r�zCompiled.__init_subclass__ss+��� ��� � � ��w�w�(�(�*�*�*r�c��dSr r��r�s r�r�zCompiled._init_compiler_clsws�� �r�c�p�|jr|�|||��Stj|j���r )r��_execute_compiledr8�ObjectNotExecutableErrorr&)r � connection�distilled_paramsr�s r��_execute_on_connectionzCompiled._execute_on_connection{sE�� � � ?��/�/��&�(9��� ��.�t�~�>�>� >r�c �H�tj|t|����|�r �r8�UnsupportedCompilationErrorr��r �element�err�kws r��visit_unsupported_compilationz&Compiled.visit_unsupported_compilation�s���-�d�D��M�M�B�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'. ��NotImplementedErrorr4s r�� sql_compilerzCompiled.sql_compiler�s��"�#�#�#r��objr6�kwargsrc ��|j|fi|��Sr ��_compiler_dispatch)r r�r�s r�r�zCompiled.process�s��%�s�%�d�5�5�f�5�5�5r�c�:�|jtjur|jSdS)z3Return the string text of the generated SQL or DDL.r�)r�rergr�r4s r��__str__zCompiled.__str__�s!�� �:��5� 5� 5��;� ��2r�T�params�"Optional[_CoreSingleExecuteParams]�extracted_parameters�&Optional[Sequence[BindParameter[Any]]]� escape_names�)Optional[_MutableCoreSingleExecuteParams]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 r�r�r�s r��construct_paramszCompiled.construct_params�s��"�#�#�#r�c�*�|���S)z0Return the bind params for this compiled object.�r�r4s r�r�zCompiled.params�s���$�$�&�&�&r�) r�r]r&r�r�r�r�rr�r�)rr )r�r6r�rrr�)rr��NNT�r�r�r�r�r�rrr�)!r�rrrr&rr��is_sql�is_ddlr�r�r�r&� EMPTY_DICTr�r�rr�r�� immutabledictr�r�� classmethodr�r�r�r8r�r�r�r�r�� __classcell__�r�s@r�r�r��sE�������� � �*.�I�-�-�-�-���F�����4�����-� �F� �F�7;��;�;�;�;�:>�O�>�>�>�>�=A��A�A�A�A�)-���8�8�8�8�� !� � � �$(�O�L�3�3�3�3�,0�M�0�0�0�0� �15��4�4�4�4� �%)�I�(�(�(�(� ������BF�(-�,>�D�,>�,@�,@� 6(�6(�6(�6(�6(�p+�+�+�+�+�+�� � ��[� �?�?�?�L�L�L��$�$��X�$�6�6�6�6�����6:�GK�!� $� $� $� $� $��'�'��X�'�'�'�'�'r�r�c�.�eZdZdZdZdd�Zdd �Zdd�ZdS)� TypeCompilerz2Produces DDL specification for TypeEngine objects.z visit_\w+r�r]c��||_dSr )r�)r r�s r�r�zTypeCompiler.__init__�s ���� � � r�rr�r�rrr�c ��|jr*|jj|jvr|j|jj}|j|fi|��Sr )�_variant_mappingr�r�r��r rr�s r�r�zTypeCompiler.process�sM�� � "� >�� �!�U�%;�;�;��*�4�<�+<�=�E�'�u�'��3�3��3�3�3r�r�r�� Exceptionrc �.�tj||��|�r )r8r�r�s r�r�z*TypeCompiler.visit_unsupported_compilation�s���-�d�G�<�<�#�Er�N)r�r])rr�r�rrr�)r�rr�r�r�rrr)r�rrr� ensure_kwargr�r�r�r�r�r�r�r��sa������<�<��L�����4�4�4�4�F�F�F�F�F�Fr�r�c�T�eZdZdZdZdZd d�Zed���Zed���Z d�Z d S) � _CompileLabelz;lightweight label object which acts as an expression.Label.�label�r�r�� _alt_namesr�c�8�||_||_|f|z|_dSr r�)r �colr�� alt_namess r�r�z_CompileLabel.__init__�s"���� ��� ��&�9�,����r�c��|jjSr �r�� proxy_setr4s r�r�z_CompileLabel.proxy_set�� ���|�%�%r�c��|jjSr �r�r�r4s r�r�z_CompileLabel.type�� ���|� � r�c ��|Sr r��r r�s r�� self_groupz_CompileLabel.self_group����� r�N)r�) r�rrr�__visit_name__� __slots__r�r8r�r�rr�r�r�r�r��s�������F�E��N�/�I�-�-�-�-� �&�&��X�&��!�!��X�!�����r�r�c�X�eZdZdZdZdZd�Zed���Zed���Z d�Z d�Z d S) �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�,�||_|j|_dSr r )r r�s r�r�zilike_case_insensitive.__init__�s���� �!�,����r�c��|jjSr r�r4s r�r�z ilike_case_insensitive.proxy_set�r�r�c��|jjSr rr4s r�r�zilike_case_insensitive.type�rr�c ��|Sr r�rs r�rz!ilike_case_insensitive.self_grouprr�c�P�t|j�|����Sr )r r��_with_binary_element_type)r rs r�rz0ilike_case_insensitive._with_binary_element_types'��%� �L� 2� 2�5� 9� 9� � � r�N) r�rrrrrr�r8r�r�rrr�r�r�r r �s������� � �6�N�'�I�-�-�-��&�&��X�&��!�!��X�!���� � � � � r�r c �� �eZdZUdZeZejddddddddd���Zde d < d e d <de d <d Z e Z 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>< ej%Z&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/e1j2�dPe0j2����Z3e4dQ���Z5e4dR���Z6ddde7df�dcdb�Z8e9�dddd���Z:ej;�dede���Z<e9df���Z=e9dg���Z>e9dh���Z?ej@�dfdj���ZAejB�dgdl���ZCeDjEdm���ZFdn�ZGdo�ZHej@�dhdq���ZIdr�ZJe9ds���ZK �di�djdx�ZL �dk�dld��ZMejBd����ZNe9d����ZO �dm�dnd��ZPejQd���d����ZRd�e d�<ej@�dod����ZSej@ejQd���d������ZTej@ejQd���d������ZUd��ZVd��ZW�dmd��ZXd��ZY �dmd��ZZ �dmd��Z[ �dpd��Z\d��Z]d��Z^ �dq�drd��Z_d��Z`d��Zad��Zbd��Zcd��Zdd��Ze�dsd��Zf �dtd��Zgd��Zhd��Zid��Zjd��Zkd��Zld��Zmd��Znd��Zod��Zpd��Zqd��Zrd��Zsd��Ztd��Zud��Zvd��Zwd��Zx �ds�dud��Zyd��Zzd��Z{d��Z| �dvd��Z}d„Z~dÄZ �dwdĄZ�dńZ�dƄZ�dDŽZ�dȄZ�dɄZ�dʄZ�d˄Z�d̄Z� �dsd̈́Z�d΄Z� �dxdτZ�dЄZ�dфZ�d҄Z�dӄZ�dԄZ� �dmdՄ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� �dyd�Z�d��Z�e�dfd�Z�d�Z�d�Z��dzd��Z��d{d��Z� �d|�d}�d�Z��d�Z�ddddde�j�d��f�d~�d�Z��d�Z��d�Z� �d�d�Z��d�Z��d�Z��dm�d�Z��d�Z��dv�d�Z��d�Z��d�Z��d��d �Z� �ds�d!�Z� �d��d"�ZĐd#�ZŐd$�ZƐd%�Zǐd&�ZȐd'�Zɐd(e �d)<e�j�s(ej�d*e"��f�d+e"��fg��Z� �dm�d,�Z�dZ�dae �d-< �d��d.�Zϐd��d2�ZАd3�Zѐd4�ZҐd5�Z� �dt�d6�ZԐd7�ZՐd8�Z֐d9�Zאd:�Zؐd;�Zِd��dA�ZڐdB�Z� �d��dC�Z� �d��dD�Zݐdv�dE�ZސdF�Z�eje�j�e�j�e�j�e�j�e�j�e�j�e�j�e�j�e�j�e�j�i��Z�e��e�j�e�j�i��Z�d��dJ�Z�d��dV�Z� �d��dW�Z�dX�Z�dY�Z�dZ�Z�d[�Z�ds�d\�Z�d]�Z��d^�Z��ds�d_�Z��d`�Z��da�Z��db�Z�dS(�� 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�.�|���dSr )�_init_bind_translater�s r�r�zSQLCompiler._init_compiler_cls2s�� � � �"�"�"�"�"r�c��tjd�|j����}tjd|�d���|_|j|_dS)Nr�rr )�re�escaperxr"�compiler#r$)r��regs r�rPz SQLCompiler._init_bind_translate6sK���i����� >�?�?�@�@��!#��J��J�J�J�!7�!7���$'�$B��!�!�!r�r�r]r&r�r�r�� column_keysr*�for_executemany�lintingrj�_supporting_against�Optional[SQLCompiler]r�rc �J�||_||_|r-d�|dD��} d�|dD��} | | f|_||_||_i|_t j��|_g|_ g|_ |j |_ |j rD|j � d��x|_} | r|j dkrdnd|_t |_nt$|j |_d|_|jp|j|_t-��|_i|_i|_t5j|||fi|��|js|js|jr�t>rtA|tB��sJ�|js|jrUt>rtA|tD��sJ�|j#rd |_$n(|jr!|jr|j%j&r|j'rd |_$t$|j |_(|r;|j)�*d �|j)�+��D����|j,tZj.urn|j r0|jr|�/��n|�0��|j1r2|�2d d � ��} |�3| d � ��dSdSdS)a�Construct a new :class:`.SQLCompiler` object. :param dialect: :class:`.Dialect` to be used :param statement: :class:`_expression.ClauseElement` to be compiled :param column_keys: a list of column names to be compiled into an INSERT or UPDATE statement. :param for_executemany: whether INSERT / UPDATE statements should expect that they are to be invoked in an "executemany" style, which may impact how the statement will be expected to return the values of defaults and autoincrement / sequences and similar. Depending on the backend and driver in use, support for retrieving these values may be disabled which means SQL expressions may be rendered inline, RETURNING may not be rendered, etc. :param kwargs: additional keyword arguments to be consumed by the superclass. c��i|] }|j|�� Sr��r0�r��bs r�� <dictcomp>z(SQLCompiler.__init__.<locals>.<dictcomp>as��3�3�3��A�E�1�3�3�3r�rc��i|]}||g��Sr�r�r^s r�r`z(SQLCompiler.__init__.<locals>.<dictcomp>bs��1�1�1�q�A��s�1�1�1r�r�r�r�rNTc�"�i|] \}}|dv� ||�� S)>r�r�r�� positionalr3r:r4r��r��k�vs r�r`z(SQLCompiler.__init__.<locals>.<dictcomp>�s@�� � � ���1��� � ��q� � � r�F�r��_no_postcompile)�_populate_self)4rVr�rFrWrXr.r&� column_dictr/r�r�rc� paramstyle� startswithr:r5�_pyformat_templater4�BIND_TEMPLATESrJ� label_length�max_identifier_lengthr5�anon_map�truncated_names�_truncated_countersr�r�r&r'r%rr�rCrD�_inlinerIr��insert_executemany_returning�_return_defaultsr3�__dict__�update�itemsr�rerg�_process_numeric�_process_positionalr;r��#_process_parameters_for_postcompile) r r�r&r�rVrWrXrYr��cksm�ckbm�nbr's r�r�zSQLCompiler.__init__<s6��@'���"��� � 6�3�3�i��l�3�3�3�D�1�1�I�a�L�1�1�1�D�*.���D� &� /����� ��� ��*�,�,����� �!���"�,��� �?� O�'.�'9�'D�'D�Y�'O�'O� O�D� �"�� �"�-�1A�A�A�C�C�s��3�-?�D� )� )�,:�7�;M�,N�D� )��� � � � A�G�$A� �� (�)�)�� �<>���35�� ���$���=�=�f�=�=�=� �=� '�D�M� '�T�]� '�� 9�!�)�Z�8�8�8�8�8��}� '�� � '� �=�%�i��<�<�<�<�<��$� '�"&�D�K�K��)�'�� �'�� �A�'�&�6� '�#'�D�K�*�7�+=�>��� � � �M� � � � � 3� <� B� B� D� D� � � � � � �" �:��5� 5� 5��� /��&�/��)�)�+�+�+�+��,�,�.�.�.��'� �!�2�2�!&�$(�3��� � �8�8��t�9������ 6� 5� � r�rc�,�|j�dS|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)rAr<r4s r��insert_single_values_exprz%SQLCompiler.insert_single_values_expr�s�� � !� )��4��)�<� <r�c��|jr|jS|j�*t|j��rd�|jjD��SdS)a�The effective "returning" columns for INSERT, UPDATE or DELETE. This is either the so-called "implicit returning" columns which are calculated by the compiler on the fly, or those present based on what's present in ``self.statement._returning`` (expanded into individual columns using the ``._all_selected_columns`` attribute) i.e. those set explicitly using the :meth:`.UpdateBase.returning` method. .. versionadded:: 2.0 Nc�0�g|]}t|���|��Sr�r'�r��cs r�� <listcomp>z3SQLCompiler.effective_returning.<locals>.<listcomp>�s6������$�Q�'�'�����r�)r,r&r)�_all_selected_columnsr4s r��effective_returningzSQLCompiler.effective_returning�s\�� � "� ��*� *� �^� '�F�4�>�,B�,B� '�����=���� ��4r�c��|jS)zVbackwards compatibility; returns the effective_returning collection. )r�r4s r�� returningzSQLCompiler.returning�s �� �'�'r�c�n� |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_executablesM��< M��:�b�>�,�/� /��� M� M� M��C�D�D�"� L����� M���s�� 4�/�4c�T�t|j��t|j��zSr )�listr)r*r4s r��prefetchzSQLCompiler.prefetch%s#���D�(�)�)�D��1E�,F�,F�F�Fr��Dict[Any, Any]c��iSr r�r4s r��_global_attributeszSQLCompiler._global_attributes)s��� r��MutableMapping[CTE, str]c�d�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&� OrderedDictrJrKrLrM)r rJs r��_init_cte_statezSQLCompiler._init_cte_state-s:��*.�)9�);�);���� �#%���"$���#���� r�c#�@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�TrN)r�r8r�r|)r �result_columns�ordered_columns�entrys r��_nested_resultzSQLCompiler._nested_resultEs����� � � � !�(��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��������jrJ��jtjusJ��jrJ��jjdkrd�n�jjdksJ�d�g�d��fd � �tj�j ��j ���_ �j r^d ��j � ��D���t�j ��t���ksJ��fd ��D���_n��_�jrcg�tj�j ��jj��}��fd ��jjD��}�j�||� ���_dSdS)Nr��%sr�r��m� re.Match[str]rr�c����|�d��}|r��|���S��|�d����|�d��S)Nrr7r)r��append)r�� normal_bind� placeholder� positionss ��r�� find_positionz6SQLCompiler._process_positional.<locals>.find_positionjsd����'�'�!�*�*�K�� "�� � ��-�-�-�"�"�� � �������,�,�,��w�w�q�z�z�!r�c��i|]\}}||�� Sr�r�rds r�r`z3SQLCompiler._process_positional.<locals>.<dictcomp>ys��O�O�O�t�q�!�a��O�O�Or�c�<��g|]}��||����Sr���get)r�r��reverse_escapes �r�r�z3SQLCompiler._process_positional.<locals>.<listcomp>{s6��� � � �37��"�"�4��.�.� � � r�c �~��g|]9}|d|dtj�j�|d��|df��:S)rrr7r)rR�sub�_positional_pattern)r�rfr�r s ��r�r�z3SQLCompiler._process_positional.<locals>.<listcomp>�sZ���"�"�"�� �a�D��a�D��F�4�3�]�A�a�D�I�I��a�D� �"�"�"r��r<r>)r�r�rr�)r+r�rergr:r�rkrRr�r�r�rEry�lenrAr<r>�_replace)r r<r>r�r�r�r�s` @@@@r�r{zSQLCompiler._process_positional]s���������#�#�#�#��z�]�9�9�9�9�9��&�&�&�&� �<� "�h� .� .��K�K��<�*�g�5�5�5�5��K�� � "� "� "� "� "� "� "��f� � $�m�T�[� � �� � � "� )�O�O�t�/F�/L�/L�/N�/N�O�O�O�N��t�.�/�/�3�~�3F�3F�F�F�F�F� � � � �;D� � � �D� � � )�D� � � !� ��I�!#���(���&�9�"�"� � "�"�"�"�"��/�B�"�"�"� �&*�%;�%D�%D�#5�#5�&E�&�&�D� "� "� "�% � r�c�~�� ��jsJ��jtjusJ�d}i� �jrW�j�Pt j�fd��j� ��D���j� ����}n�j� ��}|D]A}|� vr��j |}|�j vs |�j vrd� |<�,�j �|��}|dz }|� |<�B|�_t� ���_�jrDt%� ��}�fd�� ���D��� t%� ��|ksJ��j�� fd��j���_�jrH�jj� z}d��jjD��}�j�||����_dSdS)Nrc3�.�K�|]}|�jv� |V��dSr )rG)r�r�r s �r�r1z/SQLCompiler._process_numeric.<locals>.<genexpr>�s=���������4�#9�9�9��9�9�9�9��r�c�N��i|]!\}}�j�||��|��"Sr�)rEr�)r�r��posr s �r�r`z0SQLCompiler._process_numeric.<locals>.<dictcomp>�sB�������D�#��'�+�+�D�$�7�7����r�c�:���|�d��S�Nr�r��r�� param_poss �r��<lambda>z.SQLCompiler._process_numeric.<locals>.<lambda>�s���i����� � �+�r�c�>�g|]}|d|dd|df��S)rrr�rr�)r�rfs r�r�z0SQLCompiler._process_numeric.<locals>.<listcomp>�s=��"�"�"���1��q��t�T�1�Q�4�(�"�"�"r�r�)r:r�rergrArG� itertools�chainr/�valuesr.rDrCr5�next_numeric_posr�r+rEr�ry�_pyformat_patternr�r�r<r>r�) r �numr�� bind_name�bind�ph� len_beforer<r>r�s ` @r�rzzSQLCompiler._process_numeric�sZ�����"�"�"�"��z�]�9�9�9�9�9���$&� � � !� -�d�&<�&H��O����� $�� 6� 6� 8� 8���� ��&�&�(�(� ��E�E��O�*�*�,�,�E�� *� *�I��I�%�%���:�i�(�D���0�0�0��4�6�6�6�(,� �)�$�$��;�B�S�B�B���q���')� �)�$�$� #���� �?�?��� � "� 0��Y���J�����!*���!2�!2����I��y�>�>�Z�/�/�/�/��,�0�0� +� +� +� +�T�[� � �� � � !� ��&�9��� � "�"��/�B�"�"�"� � &*�%;�%D�%D�#5�#5� &E�&�&�D� "� "� "� � r��VMutableMapping[str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]]]c�>��d��fd��jD��D��S)Nc��i|] \}}|�||�� Sr r�)r�r0�values r�r`z0SQLCompiler._bind_processors.<locals>.<dictcomp>�s2�� � � ���U� � �# ��"!� � r�c 3���K�|]t}�j||jjs|j��j��n7t �fd�t t|j��jD����fV��udS)c3�L�K�|]}|��j��V��dSr )�_cached_bind_processorr�)r�� elem_typer s �r�r1z9SQLCompiler._bind_processors.<locals>.<genexpr>.<genexpr>�sG�����#�#� )�&�<�<�T�\�J�J�#�#�#�#�#�#r�N) r/r��_is_tuple_typer�r�r3rr3�types)r�� bindparamr s �r�r1z/SQLCompiler._bind_processors.<locals>.<genexpr>�s����������O�I�.� )�~�<�� ��=�=�d�l�K�K�K�"�#�#�#�#�-1� )�9�>�.�.�#� #�#�#��� ������r�)r/r4s`r��_bind_processorszSQLCompiler._bind_processors�sK��� � �����"&����� � � � r�c�2�t|j��dkSr�)r�r�r4s r�� is_subqueryzSQLCompiler.is_subquery�s���4�:����"�"r�c��|Sr r�r4s r�r�zSQLCompiler.sql_compilers��� r�r�r�r�r%c�\�|�||d���}|�|��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 Trg)r�r|)r r�r�r's r��construct_expanded_statez$SQLCompiler.construct_expanded_statesD���*�*� �%� �+� � � � �7�7� � � � r�r�r�� _group_number� Optional[int]�_checkrhr\c����|jr:|s8|j�J�|st|jj��St jd���|ot |j��}|rU|j�t j d���|jd}|j } | �J�| \�} �fd�t||��D��} nd} |r�i} |j � ��D]�\} }|r|j�||��n|}| j|vr|| j| |<�>||vr ||| |<�N|rG| jr@|r t jd| j|fzd����t jd | jzd����| r| �| | ��}n| }| jr |j| |<��|j| |<��| Si} |j � ��D]�\} }|r|j�||��n|}|rG| jr@|r t jd| j|fzd����t jd | jzd����| r| �| | ��}n| }| jr |j| |<��|j| |<��| S) 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_paramsrc�2��i|]\}}�|D]}||���Sr�r�)r�r_� extractedr�r~s �r�r`z0SQLCompiler.construct_params.<locals>.<dictcomp>GsJ���"�"�"� �A�y� ��G�"�"���i�"�"�"�"r�z@A value is required for bind parameter %r, in parameter group %d�cd3x)�codez)A value is required for bind parameter %r)r;r<�dictr'r8r2rrEr�� CompileErrorrF�zipr/ryr�r0�required�callable�effective_valuer�)r r�r�r�r�r�rh�has_escaped_names�orig_extracted� ckbm_tupler�resolved_extracted�pdr�r�� escaped_name� value_paramr~s @r�r�zSQLCompiler.construct_paramss���� � #� �O� ��4�@�@�@�� ��D�=�H�I�I�I��-�4����)�J�T�$�2I�-J�-J�� � &��~�%��&�J���� "&���!2���3�J��)�)�)� �G�D�!�"�"�"�"�$'��8L�$M�$M�"�"�"� � � "&� � �K ��B�#'�?�#8�#8�#:�#:�% =�% =�� �4�)��D�+�/�/��d�;�;�;��� �=�F�*�*�'-�i�m�'<�B�|�$�$��V�^�^�'-�d�|�B�|�$�$��=� � 2�=�$� �!�5�4�(�}�m�<�=�"(� ����"�5�G�'�m�,�!'����� *�0�&8�&<�&<�%�y�'�'� � �'0� � �)�=�+6�+F��<�(�(�+6�+<��<�(�(��I��B�#'�?�#8�#8�#:�#:� 9� 9�� �4�)��D�+�/�/��d�;�;�;��� � �i�0� �$� �!�5�4�(�}�m�<�=�"(� ����"�5�G�'�m�,�!'����� &�,�"4�"8�"8��I�"N�"N�K�K�"+�K��%�9�'2�'B�B�|�$�$�'2�'8�B�|�$�$��Ir�c�$������|j��j��j��j�����fd��i}|j}|jD]U}||vr�|jjr/�fd�tt|j��j D��||<�B�|j��||<�V|S)Nc�x��|��������}|���|�vr��|�vr|SdSr )�_unwrapped_dialect_impl�get_dbapi_type)�typ�dbtype�dbapir�� exclude_types� include_typess ����r�� lookup_typez<SQLCompiler._get_set_input_sizes_lookup.<locals>.lookup_type�sV����0�0��9�9�H�H��O�O�F��"�"�*�f�M�.I�.I�"�*�f� �.E�.E�� ��tr�c�&��g|] }�|����Sr�r�)r�r�r�s �r�r�z;SQLCompiler._get_set_input_sizes_lookup.<locals>.<listcomp>�s3���)�)�)�� �K��$�$�)�)�)r�) r��include_set_input_sizes�exclude_set_input_sizesr�rCr/r�r�rr3r�) r � inputsizesrCr�r�r�r�r�r�s @@@@@r��_get_set_input_sizes_lookupz'SQLCompiler._get_set_input_sizes_lookup�s���������,���7� ��7� �� �� � � � � � � � �� �!%�!<���� D� D�I��2�2�2���~�,� D�)�)�)�)�#�I�y�~�>�>�D�)�)�)� �9�%�%� )4� �I�N�(C�(C� �9�%�%��r�c�.�|�d���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�r4s r�r�zSQLCompiler.params�s���$�$�E�$�2�2�2r�r'ric�0�������i}�j}|��j}�jrg}�j}|��j}ndx}}�j}t d|���t d|���i}i�i} d} �jr|� |} �jrg} n�j� ��} �j } | D�]��| r| � ����n�} �j �}|�j vr2| �vr-��||�| ������| <�e|�jv�r| �vr | | }d}n;|����}��| ||��}|\}}|| | <|�| <|js�|�|��|jjr5|�J�|���fd�t-|d��D����n"|���fd�|D����| � | �d�|D����n!|�|�d �|D����d �|D��|�<���|�|��������fd �}t3j�j||��}| �X|�J��fd �t-| �j��D����j��fd �|��}|�| ��t=|||||��}|rE|�_|�_|j�_�jrtA|jpd��nd�_|�_!|S)a�handle special post compile parameters. These include: * "expanding" parameters -typically IN tuples that are rendered on a per-parameter basis for an otherwise fixed SQL statement string. * literal_binds compiled with the literal_execute flag. Used for things like SQL Server "TOP N" where the driver does not accommodate N as a bound parameter. Nr(z/Mapping[str, Sequence[_BindProcessorType[Any]]]��render_literal_valuec3��K�|]M\}}t|d��D]7\}}��vr.��|dz ���d|�d|����|dz fV��8�NdS)rNr�� enumerate)r��i� tuple_element�jrr��tuple_processorss ��r�r1zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>=s������ .� .� !1��=�(1�-��(C�(C� .� .� !%��1�#�'7�7�7� 0�� 6�q�1�u� =� I� /3�d�d�A�A�A�q�q� 9� 0�� 6�q�1�u� =��!J� I� I� I� I� .� .r�rc3�:�K�|]\}}��v� |��fV��dSr r�)r�r0rr��single_processorss ��r�r1zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>HsJ�����.�.� &��Q�#�'8�8�8�!�"3�D�"9�:�8�8�8�8�.�.r�c3� K�|] \}}|V�� dSr r��r�r�rs r�r1zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>Ns7����3�3�%,�T�1�D�3�3�3�3�3�3r�c3� K�|] \}}|V�� dSr r�r s r�r1zBSQLCompiler._process_parameters_for_postcompile.<locals>.<genexpr>Us&����.M�.M���a�t�.M�.M�.M�.M�.M�.Mr�c��g|]\}}|��Sr�r�)r�� expand_keyrs r�r�zCSQLCompiler._process_parameters_for_postcompile.<locals>.<listcomp>Vs)��1�1�1�'4�z�1� �1�1�1r�c�L����|�d��}�|}|�d��rn|�d���d��}|d|dc��d���fd�|�d��D����}|S)Nrr7�~~rr�c3�(�K�|] }��|����V�� dSr r�)r��exp�be_left�be_rights ��r�r1z]SQLCompiler._process_parameters_for_postcompile.<locals>.process_expanding.<locals>.<genexpr>esD�����!�!��!(����h�h�7�!�!�!�!�!�!r�)r��splitrx)r�r0�expr�tokrr�replacement_expressionss @@�r��process_expandingzJSQLCompiler._process_parameters_for_postcompile.<locals>.process_expanding\s�������'�'�!�*�*�C�*�3�/�D��w�w�q�z�z� ��g�g�a�j�j�&�&�t�,�,��$'��F�C��F�!����y�y�!�!�!�!�!�#�z�z�$�/�/�!�!�!�����Kr�c�.��i|]\}}|�j�|����Sr��r5)r�r�r0r s �r�r`zCSQLCompiler._process_parameters_for_postcompile.<locals>.<dictcomp>qs=�������C����;�B�S�B�B���r�c�:���|�d��Sr�r�r�s �r�r�zASQLCompiler._process_parameters_for_postcompile.<locals>.<lambda>ys���)�A�G�G�A�J�J�/�r�r�)"r>r�rcr@r+r�rr:r/r�rEr�r.rC�render_literal_bindparamr|rD�$_literal_execute_expanding_parameter�literal_executerxr�r�r�extendr�rRr��_post_compile_patternr�r�r%r&r�r<)r r'ri�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_exprrr&�expanded_stater�r�rr rs` @@@@@r�r|z/SQLCompiler._process_parameters_for_postcompile�s���������$!��#�7�� � &�"&�+� � �?� >� �O�'+�'E� $�'�/�+/�+;�(��:>� =�O�6��*� � � 3�Z� � �� � =�z� � ��>@��24��)+��48�� �?� -�7�C�#;�E��"� )�&(�#���O�*�*�,�,�E��%���I -�I -�D�25�?�3�7�7�4��.�.�.�4�L�� �4�(�I��D�7�7�7��'>�>�>��5�5�%�1;��� �1M�1M�6���,�L�9� ��D�4�4�4��#:�:�:� .�|� <�I�!�F�F�(�^�^�D�1�1�F�#�H�H�$�i�� � �H�5=�1�Y� 0�3<�N�<�0�<L�+�L�9� �0���%�%�i�0�0�0� �~�4��%�1�1�1�&�-�-� .� .� .� .� .� 5>�f�a�4H�4H� .� .� .� � � � �'�-�-�.�.�.�.�.�*3�.�.�.���� +�6�+�2�2�3�3�09�3�3�3�����)�4�(�.�.�.M�.M�9�.M�.M�.M�M�M�M�1�1�8A�1�1�1�'��-��!�,��&�&�t�,�,�,�� � � � � ��F� � &�(9�;N� � � � � *�"�.�.�.����� )�'��)>�!�!����I��.�2�2�/�/�/�/����I� � "� "�#6� 7� 7� 7�&� � � � � �  � �� � ?�)<�D� %�-E�D� *�(�2�D�K��?���^�/�5�2�6�6�6�� � � 1?�D� -��r�zsqlalchemy.engine.cursorc�b�tjj}|j�|j��S)z(utility method used for unit tests only.)r&� preloaded� engine_cursorrU�_create_description_match_mapr�)r �cursors r��_create_result_mapzSQLCompiler._create_result_map�s/����-���*�H�H� � � � � r��_BindNameForColProtocol�_get_bind_name_for_col�Callable[[Any], str]c��|j}|Sr )r8)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 }� fd�|j D��� d�|j ���<�j � |jd��� � �����|jvr�fd�}|�nd� |�d�|j D����� ��� � � fd�}|S)Nc�R��g|]#}tjd�|��d��|f��$S)r�N)�operator� methodcaller)r�r��param_key_getters �r�r�zKSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.<listcomp>�sI��� � � ��� "�5�*:�*:�3�*?�*?�� F� F�� L� � � r�c�<��|��|��}|�|S|Sr r�)� lastrowidr'� param_value� autoinc_keys �r��_autoinc_getterzPSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>._autoinc_getter�s,���",�.�.��i�"H�"H�K�"�.� +�*� )�(r�c��g|] }|j�� Sr�r]�r�r�s r�r�zKSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.<listcomp>����%K�%K�%K�#�c�g�%K�%K�%Kr�c������� ���������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. Nc3�4�K�|]\}}|���V��dSr r�)r�r;r�r's �r�r1zWSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>�s1�����L�L�[�V�S�f�f�Z�0�0�L�L�L�L�L�Lr�c3�\�K�|]&\}}|�ur�� �����n �n |���V��'dSr r�)r�r;r�� autoinc_col�autoinc_getterrCr's ����r�r1zWSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get.<locals>.<genexpr>�su����� � �$����+�-�-� .�9�+�N�9�j�A�A�A�!*��$�V�J�/�/� � � � � � r�r�)rCr'rMrN�getters�lastrowid_processor�row_fns``�����r�r�zDSQLCompiler._inserted_primary_key_from_lastrowid_getter.<locals>.get�s������#�.�/�/� �:�:� �� ��v�L�L�L�L�G�L�L�L�L�L�L��v� � � � � � � �(/� � � � � � r�)r&r2� engine_resultr<rr&rr�rBr�� primary_key�_autoincrement_columnr��_cached_result_processorr�r.� result_tuple) r �resultr&r�rFr�rMrNrErOrPrArQs @@@@@@@r��+_inserted_primary_key_from_lastrowid_getterz7SQLCompiler._inserted_primary_key_from_lastrowid_getter�s`�����������-���=���!�-�-�-��&�0� � � 1��i��0�0� 0� 0�0���� � � � ��(� � � �� ���1� � � "�"-�"2�"K�"K�� �d�#�#� �+�*�;�7�7�K��d�j�(�(� )� )� )� )� )�"1���#'� ��$�$�%K�%K��9J�%K�%K�%K�L�L�� � � � � � � � � �4� r�c����� �tjrddlm}ntjj}|j�J�|jj}trt|t��sJ�|j �|j }|j }|�J�d�t|��D���td��fd�|jD�����|�d�|jD����� �� fd�}|S)Nr7)rWc��i|]\}}||�� Sr�r�)r��idxr�s r�r`zKSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.<dictcomp> s��=�=�=�H�C��s�C�=�=�=r�z'List[Tuple[Callable[[Any], Any], bool]]c���g|]C}|�vrtj�|��dfn tjd�|��d��df��DS)Tr�NF)r?� itemgetterr@)r�r�rA�rets ��r�r�zKSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.<listcomp> s|��� � � ���c�z�z��(��S��2�2�D�9�9�!�-�!�#3�#3�C�#8�#8�$���� � � � r�c��g|] }|j�� Sr�r]rHs r�r�zKSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.<listcomp> rIr�c�8�������fd��D����S)Nc3�N�K�|]\}}|r |���n |���V�� dSr r�)r�r;�use_rowr'�rows ��r�r1zWSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get.<locals>.<genexpr>" sV�������#�F�G� '�>���s� � � �F�F�:�,>�,>������r�r�)rcr'rOrQs``��r�r�zDSQLCompiler._inserted_primary_key_from_returning_getter.<locals>.get! sD������6������'.������ r�)�typingr�enginerWr&r2rRrr&r�rBr<r�r,rrrSrV) r rWr&r�r�r�rOrAr^rQs @@@@r��+_inserted_primary_key_from_returning_getterz7SQLCompiler._inserted_primary_key_from_returning_getter�s7������ � � 2� '� '� '� '� '� '� '��^�1�F��!�-�-�-��&�0� � � 1��i��0�0� 0� 0�0��=������+� ��$�$�$�=�=� �)�(<�(<�=�=�=��� 5� � � � � �!�,� � � � � ��"�$�$�%K�%K��9J�%K�%K�%K�L�L�� � � � � � � � r�c��dS)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�r4s r�� default_fromzSQLCompiler.default_from) s ���rr�c �H�|jj|fi|��}|jD�]}||jvr� |j|}|�|j|jdd���}|j|}|x|j|<|j|<||j|<|j�|d��||jvr|xj|hzc_||j vr|xj |hzc_ |j }|r@|\} } |j D]3}|j| vr(| |j} | | � |���4��|S)a�SQL compile the nested element of an _OverrideBinds with bindparams swapped out. The _OverrideBinds is not normally expected to be compiled; it is meant to be used when an already cached statement is to be used, the compilation was already performed, and only the bound params should be swapped in at execution time. However, there are test cases that exericise this object, and additionally the ORM subquery loader is known to feed in expressions which include this construct into new queries (discovered in #11173), so it has to do the right thing at compile time as well. TF)� maintain_keyr�N) r�r�� translater.� _with_valuer0r/r|rDrCrF� _cloned_setr�) r �override_bindsr��sqltextre�bp�new_bpr�r�r~r}�cbs r��visit_override_bindsz SQLCompiler.visit_override_binds3 sk��"<�.�(�;�D�G�G�B�G�G�� �)�" 0�" 0�A��� �"�"����A��B��^�^��(���0�!��$���F� �?�2�&�D�/5� 5�D�J�q�M�D�J�t�,�&*�D�O�F� #� �O� � ��D� )� )� )��T�-�-�-��(�(�V�H�4�(�(��T�0�0�0��+�+��x�7�+�+��3�J�� 0�'� ��d��.�0�0�B��v��~�~�!�"�&�\���R�����/�/�/����r�c �4�d|jj|fi|��zdzS�Nrr�r�r�)r �grouping�asfromr�s r��visit_groupingzSQLCompiler.visit_groupings �+���8�X�%�8��H�H��H�H�H�3�N�Nr�c �4�d|jj|fi|��zdzSrurv)r rwr�s r��visit_select_statement_groupingz+SQLCompiler.visit_select_statement_groupingv rzr�c ��|jr�|jjr� td|jdd��}n'#t$r}t jd��|�d}~wwxYw|j\}}}|r|} n|} |jj } | �8| j | vr/| � | | j ��r|jj |d<|j |jfd|i|��S)N�'Union[SelectState, CompoundSelectState]r�r�ECan't resolve label reference for ORDER BY / GROUP BY / DISTINCT etc.�render_label_as_label�within_columns_clause) r�r��supports_simple_order_by_labelr�KeyErrorr8r��_label_resolve_dictr��_order_by_label_elementr��shares_lineager�) r r�r�r�r�ke� with_cols� only_froms� only_cols� resolve_dict� order_by_elems r��visit_label_referencez!SQLCompiler.visit_label_referencey s9�� �:�% �$�,�E�% � � $�=��J�r�N�?�3�!�!� � ��� � � ��&�/��������� �����1�  ����$� )�)� � �(� � $�O�C�M��)�!�&�,�6�6�!�0�0� ��!3�4���7� �O�;��.�/��t�|� �O� � �"7� �� � � s�!7� A�A�Ac ��|js|�|j��S td|jdd��}n>#t$r1}t j|jdtj |���Yd}~nd}~wwxYw|j \}}} |r||j} n ||j} | |d<|j| fd|i|��S#t$r2} t j|jdtj | ���Yd} ~ dSd} ~ wwxYw)Nr~r�rr)�extra�exc_clsr�r�r�) r�r�� _text_clauserr�r�_no_text_coercionr�r8r�r�) r r�r�r�rr�r�r�r�r�r�s r��visit_textual_label_referencez)SQLCompiler.visit_textual_label_reference� s����z� 6��<�<�� 4�5�5� 5� � �9�� �2���/���M�M��� � � � � '���/��(�� � � � � � � � � ����� ����,9�+L�(� �:�y� �$� 1� ���1������0��/2�F�*� +��4�<����+@��DJ��� ��� � � � � '���/��(�� � � � � � � � � � ����� ���s/�!A� B�'A;�;B�C� C=� 'C8�8C=c ���|o| }||u} | s|rBt|jtj��r|�d|j��} n|j} |rq|�%|| |j|| f|jz|z|j��|jj|fddd�|��ttj z|j � || ��zS| r|j � || ��S|jj|fddi|��S)N�colidentT)r��within_label_clauser�F)r�r�rrE�_truncated_identifierr�r�r�r�� OPERATORSr!�as_r�� format_label) r r��add_to_result_mapr�r�r��result_map_targetsr��render_label_with_as�render_label_only� labelnames r�� visit_labelzSQLCompiler.visit_label� sg�� "� =�*=�&=� �2�U�:�� � '� 4� '��%�*�h�&?�@�@� '� �6�6�z�5�:�N�N� � �!�J� � � � �,�!�!���J��I�&��)9�9�<N�N��J� ���1�� �0���*.�(,���� �� �I�M�*� +��-�,�,�U�I�>�>�?� �� ��=�-�-�e�Y�?�?� ?�3�5�=�3����,1��57��� r�c�*�tjd���)Nz:Cannot compile Column object until its 'name' is assigned.�r8r��r r�s r��_fallback_column_namez!SQLCompiler._fallback_column_name s���� H� � � r�c �,�|j}|j|fi|��Sr )� _resolvedr�)r r�r�� sql_elements r��visit_lambda_elementz SQLCompiler.visit_lambda_element s$���'� ��t�|�K�.�.�2�.�.�.r�r��ColumnClause[Any]r��Optional[_ResultMapAppender]� include_tabler�r��ambiguous_table_name_map� Optional[_AmbiguousTableNameMap]c �0�|jx}}|�|�|��}|j} | s0t|tj��r|�d|��}|�2|||jf|z} |jr | |jfz } |||| |j ��| r|� |��}n|j � |��}|j } | � |r| js|S|j �| ��} | r|j �| ��dz} nd} t"rt| t$��sJ�| j}| s|r ||vr||}t|tj��r|�d|��}| |j � |��zdz|zS)Nr�rr��alias)r�r�� is_literalr�rrEr�r0� _tq_labelr��escape_literal_columnr��quoter��named_with_column�schema_for_object� quote_schemarrP)r r�r�r�r�r�r�r�� orig_namer��targetsr��effective_schema� schema_prefix� tablenames r�� visit_columnzSQLCompiler.visit_column s���"�;�&��y� �<��-�-�f�5�5�D��&� �� @�j��x�/H�I�I� @��-�-�j�$�?�?�D� � (��t�V�Z�0�3E�E�G��� /��F�,�.�.�� � �d�I�w�� � D� D� D� � -��-�-�d�3�3�D�D��=�&�&�t�,�,�D�� �� �=� �=�U�5L�=��K�#�}�>�>�u�E�E� �� #��M�.�.�/?�@�@�3�F�� �!#� �� :�!�%��9�9�9�9�9�� �I�%� @�,� @��!9�9�9�4�Y�?� ��)�X�%>�?�?� K� �6�6�w� �J�J� � �4�=�#6�#6�y�#A�#A�A�C�G�$�N� Nr�c �@�|j�|j��Sr )r��format_collation� collation�r r�r�s r��visit_collationzSQLCompiler.visit_collationJ s���}�-�-�g�.?�@�@�@r�c ��|jSr �r�)r � fromclauser�s r��visit_fromclausezSQLCompiler.visit_fromclauseM s ����r�c ��|jSr r�)r rxr�s r�� visit_indexzSQLCompiler.visit_indexP s ���z�r�c �Z�||d<|j|d<|jjj|jfi|��S)N�type_expressionr�)r�r��type_compiler_instancer�r�)r � typeclauser�s r��visit_typeclausezSQLCompiler.visit_typeclauseS sH�� *�� ��$(�M�� �!�:�t�|�2�:� �O� � �!� � � r�c�J�|jjr|�dd��}|S�Nr�%%�r��_double_percents�replace�r �texts r��post_process_textzSQLCompiler.post_process_textZ �'�� �=� )� +��<�<��T�*�*�D�� r�c�J�|jjr|�dd��}|Sr�r�r�s r�r�z!SQLCompiler.escape_literal_column_ r�r�c ��������fd�}�jsd�_|r|dd�ftj��t�d�t �|���j������S)Nc���|�d��}|�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 s]����7�7�1�:�:�D��z�-�-�-�#�t�|�J�$:�4�$@�G�G�B�G�G�G�,�t�,�T�8�8�R�8�8�8r�Tc�,�|�d��Sr�r�)r�s r�r�z.SQLCompiler.visit_textclause.<locals>.<lambda>w s��a�g�g�a�j�j�r�) r�r-r%�NULLTYPE�BIND_PARAMS_ESCr�� BIND_PARAMSr�r�)r r�r�r�r�s`` ` r��visit_textclausezSQLCompiler.visit_textclaused s������ 9� 9� 9� 9� 9� 9� 9��z� $�#�D� � � L� � �d�D�:�-��9J� K� K� K��"�"� � � �O�O��d�4�4�Z�_�E�E� � � � � r�c ���|j }|r|jn |jd}t��t��|d�}|j�|��|jr|�||��|p1|dko|�dd��p|�dd��}|r[|jx|_|_ |j ot|j ��|_ |j D]} |� | d|j���� |j |jfi|��} |jr1|st#|j��nd} |�| � ��| z} |j�d��| S) Nr��rrr$rrFrT)r�r��� nesting_level)r��_default_stack_entryrpr��_independent_ctes�_dispatch_independent_ctesr�rcr8r6r� column_argsr9r��_add_to_result_mapr�rJr��_render_cte_clauser|) r �taf�compound_indexrxr��toplevelr�� new_entry�populate_result_mapr�r�r�s r��visit_textual_selectz SQLCompiler.visit_textual_select} s����z�>��-5�I��)�)�4�:�b�>�� #�u�u��E�E��* �* � � � ���)�$�$�$� � � 5� � +� +�C�� 4� 4� 4� � >��!�#�E��I�I�<�e�D�D� >� �y�y�5�u�=�=� � � ��� �D� !�D�$A� 47�>�/A�0�d���G�G�D� ,��_� � ��� � ��*.�&*�&=������ �t�|�C�K�.�.�2�.�.�� �9� O�3;�E�C�� �O�O�O��M��*�*��*�G�G�$�N�D� � ���r����� r�c ��dS�N�NULLr��r rr�s r�� visit_nullzSQLCompiler.visit_null� ����vr�c �"�|jjrdSdS)Nr�1�r��supports_native_booleanr�s r�� visit_truezSQLCompiler.visit_true� s�� �<� /� ��6��3r�c �"�|jjrdSdS)Nr��0r�r�s r�� visit_falsezSQLCompiler.visit_false� s�� �<� /� ��7��3r�c �^���|�d���fd�|D��D����S)Nc3�K�|]}|�|V�� dSr r��r��ss r�r1z7SQLCompiler._generate_delimited_list.<locals>.<genexpr>� s<���� � ��� � � � � � � � r�c3�4�K�|]}|j�fi���V��dSr r��r�r�r�r s ��r�r1z7SQLCompiler._generate_delimited_list.<locals>.<genexpr>� s9�����I�I�1�*�a�*�4�6�6�2�6�6�I�I�I�I�I�Ir��rx)r r� separatorr�s` `r��_generate_delimited_listz$SQLCompiler._generate_delimited_list� sM�����~�~� � �I�I�I�I�I��I�I�I� � � � � � r�c �Z���tj�tjtjjtjj|��\}}|dkr|dj�fi���Sttj}|� d���fd�|D��D����S)Nrrc3�K�|]}|�|V�� dSr r�rs r�r1z;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>� s<����"�"���"��"�"�"�"�"�"r�c3�4�K�|]}|j�fi���V��dSr r�rs ��r�r1z;SQLCompiler._generate_delimited_and_list.<locals>.<genexpr>� s9�����L�L�q�.�!�.�t�:�:�r�:�:�L�L�L�L�L�Lr�) r�BooleanClauseList�_process_clauses_for_booleanr!�and_�True_� _singleton�False_r�r�rx)r �clausesr��lccrs` ` r��_generate_delimited_and_listz(SQLCompiler._generate_delimited_and_list� s������1�N�N� �N� �N� %� �O� &� �  � � ��W� �!�8�8�0�7�1�:�0��<�<��<�<� <�!�)�.�1�I��>�>�"�"�L�L�L�L�L�G�L�L�L�"�"�"��� r�c �$�d|j|fi|��zS�N�(%s))�visit_clauselist)r � clauselistr�s r�� visit_tuplezSQLCompiler.visit_tuple� s#���-��-�j�?�?�B�?�?�?�?r�c �f�|j}|�d}nt|j}|j|j|fi|��S�Nr!)r?r�r r)r rr��seps r�rzSQLCompiler.visit_clauselist� sC���!�� �;��C�C��J�/�0�C�,�t�,�Z�-?��K�K��K�K�Kr�c ���|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_dispatchr�r rr�r8r�)r rr�� operator_�disp�opstringr�s r��visit_expression_clauselistz'SQLCompiler.visit_expression_clauselist� s����'� ��*�*� �.�� � �� � 5��4� �I�4�4��4�4� 4� � ��+�H�-1�B�(� )�0�4�0��"�H���02��� �� � L� L� L��1�$� �B�B�� K����� L���s� A� A7�A2�2A7c ��d}|j�||jj|fi|��dzz }|jD].\}}|d|j|fi|��zdz|j|fi|��zdzz }�/|j�|d|jj|fi|��zdzz }|dz }|S)NzCASE r!zWHEN z THEN zELSE �END)r�r��whens�else_)r �clauser�r��condrWs r�� visit_casezSQLCompiler.visit_case� s��� �� �<� #� �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� ���r�c �(�|jj|fi|��Sr )�typed_expressionr�)r � type_coercer�s r��visit_type_coercezSQLCompiler.visit_type_coerce s ��>�{�+�>�t�J�J�r�J�J�Jr�c ���|jj|fi|��}tjd|��}d|jj|fi|���d|r|�d��n|�d|r|�d��nd��S)Nz(.*)( COLLATE .*)zCAST(r�rrr7r�)r�r�rR�matchr+r�)r rr�� type_clauser3s r�� visit_castzSQLCompiler.visit_cast s���8�d�o�8��H�H��H�H� ���,�k�:�:��� *�D�K� *�4� :� :�6� :� :� :� :�#� 4�E�K�K��N�N�N�� 4� 4�#� +�E�K�K��N�N�N�� +� � r�c �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 PRECEDINGz CURRENT ROWz PRECEDINGz FOLLOWINGr�rzUNBOUNDED FOLLOWING)r�RANGE_UNBOUNDED� RANGE_CURRENTr��literal�abs)r �range_r�s r��_format_frame_clausez SQLCompiler._format_frame_clause s����!�9�� 8�8�8�&�%��a�y�H�$:�:�:�"�M�"�!�9�q�=�=� )�D�L� (� 0��V�A�Y��� @� @���DF�������(�4�<��(8����(C�(C�J�J�r�J�J�J�J�M���(�!�9�� 8�8�8�&�%��a�y�H�$:�:�:�"�M�"�!�9�q�=�=� )�D�L� (� 0��V�A�Y��� @� @���DF�������(�4�<��(8����(C�(C�J�J�r�J�J�J�J�M��+' �' r�c �(���|jj�fi���}|jrd�j|jfi���z}n |jrd�j|jfi���z}nd}|�dd���fd�d|jfd|jffD��|r|gngz���d�S) NzRANGE BETWEEN %szROWS BETWEEN %sz OVER (r!c �^��g|])\}}|�t|���|�d|j�fi�������*S)Nz BY )r�r�)r��wordr+r�r s ��r�r�z*SQLCompiler.visit_over.<locals>.<listcomp>P sc������%��f��)�c�&�k�k�)� �t�t�6�V�6�t�F�F�v�F�F�F�H� *�)�)r�� PARTITION�ORDERr)r�r�r;r<�rowsrx� partition_by�order_by)r �overr�r�r;s` ` r�� visit_overzSQLCompiler.visit_over@ s$����.�t�|�.�t�>�>�v�>�>�� �;� �'�*C�$�*C�� �+�+�%�+�+��F�F��Y� �&�)B��)B�� �*�*�#�*�*��F�F��F� �D�D� �H�H������%�d�&7�8� �$�-�0�)���� &�-�F�8�8�2� /� � � � � � r�c �V�|jj|fi|���d|jj|fi|���d�S)Nz WITHIN GROUP (ORDER BY r)r�r�rD)r � withingroupr�s r��visit_withingroupzSQLCompiler.visit_withingroup] sN�� 2�K� � 2�4� B� B�6� B� B� B� B� 3�K� � 3�D� C� C�F� C� C� C� C� � r�c �V�|jj|fi|���d|jj|fi|���d�S)Nz FILTER (WHERE r)�funcr�� criterion)r � funcfilterr�s r��visit_funcfilterzSQLCompiler.visit_funcfilterc sM�� .�J�O� .�t� >� >�v� >� >� >� >� 3�J� � 3�D� C� C�F� C� C� C� C� � r�c ��|j�|j|j��}d|�d|jj|fi|���d�S)NzEXTRACT(r�r)� extract_mapr��fieldrr�)r �extractr�rQs r�� visit_extractzSQLCompiler.visit_extracti sQ��� �$�$�W�]�G�M�B�B��� �E�E� +�G�L� +�D� ;� ;�F� ;� ;� ;� ;� � r�c �T�|j|jfi|��}|j|fi|��}d|�d|��S)Nrz).)�visit_function�fnr�)r r�r�� compiled_fn� compiled_cols r��visit_scalar_function_columnz(SQLCompiler.visit_scalar_function_columnp sK��)�d�)�'�*�;�;��;�;� �(�t�(��7�7�B�7�7� � �'�K�K���6�6r�rK� Function[Any]c ����|�#||j|j|jf|j��t�d|j���zd��}|r ||fi|��}n�t�|���jd����r |jr�dz �n\|j��j � ���st�tj ��r�j ����n���dz�d���fd�|jD���gz��d�j|fi|��iz}|jr|dz }|S)Nz visit_%s_funcz%(expr)src���g|]R}�j�|��st�tj��r�j�|��n|��SSr�)r��_requires_quotes_illegal_charsr�rr1r�)r�rr�r s ��r�r�z.SQLCompiler.visit_function.<locals>.<listcomp>� so�������  �=�G�G��L�L�!�%�d�H�,@�A�A�!�� �+�+�C�0�0�0�!� ��r�rz WITH ORDINALITY)r�r��getattr�lowerr�r�� _deannotater�� _has_argsr�r]r�rr1r�rx� packagenames�function_argspec�_with_ordinality)r rKr�r�r$r�r�s` @r�rUzSQLCompiler.visit_functionu s����� � (� � �d�i���T�Y�L�$�)� L� L� L��t�_�t�y���/@�/@�@�$�G�G�� � @��4��'�'��'�'�D�D��=�=��!1�!1�!3�!3�!=�t�D�D�D�� )��>�'��J�&�D���y���}�C�C�D�I�I��!�$��(<�=�=��D�M�'�'��-�-�-�� � �j�(���8�8������ $�0�����&� � � ��.��.�t�>�>�v�>�>�?� @�D� � � '� �&� &�D�� r�c �6�|�|j��Sr )�visit_sequence�sequence)r � next_valuer�s r��visit_next_value_funcz!SQLCompiler.visit_next_value_func� s���"�"�:�#6�7�7�7r�c �:�td|jjz���)Nz2Dialect '%s' does not support sequence increments.�r�r�r��r rgr�s r�rfzSQLCompiler.visit_sequence� s$��!� @��l�� � � � r�c �(�|jj|fi|��Sr )� clause_exprr�)r rKr�s r�rczSQLCompiler.function_argspec� s ��2�t��2�4�B�B�6�B�B�Br�c �H�����j }|j|�fi���}|r�js|�_|j}|r�jn �jd}|p| o|�dd��} |dkr||d<�j�|d|d||| d���|jr��|����j |j } d | zd z� ���fd �t|j ��D����} d�d <| �j|fitdd �i�����z } | �j|fi���z } |jr| �j|fi���z } �jr2|st)�j��nd} ��| d ���| z} �j�d��| S)Nr�rFrr rr)rrr$rrr!c3�@�K�|]\}}|j�f�|d����V��dS))rxr�Nr�)r�rr�rxr�r s ���r�r1z4SQLCompiler.visit_compound_select.<locals>.<genexpr>� sf����� � ��A�q�%��$���!'����=C��� � � � � � r�r�rxT�r��include_following_stackr�)r��_compile_state_factoryrr&r�r�r�r�r��compound_keywords�keywordrxr�selects�group_by_clauser��order_by_clause�_has_row_limiting_clause�_row_limit_clauserJr�r�r|) r �csrxr�r�r�r� compound_stmtr��need_result_maprur�r�s ` ` ` r��visit_compound_selectz!SQLCompiler.visit_compound_select� se������z�>��1��1�"�d�E�E�f�E�E� � � /�D�.� /�!.�D� �%�/� �-5�I��)�)�4�:�b�>��"� �� � A�� � �8�%�@�@� � �Q� � � "�E�*� � � ���#(�):�#;� %�n� 5� �!.�0?�  � � � � � � *� C� � +� +�M�6� B� B� B��(���4���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�� � &� 9� �*�D�*�2�8�8��8�8� 8�D� �9� �3;�E�C�� �O�O�O��M��'�'�"/�,0�(���� � � � ���r����� r�c �H�|j�|j|fi|��S|j|fi|��Sr )� _fetch_clause� fetch_clause� limit_clause)r r{r�s r�rzzSQLCompiler._row_limit_clause� sA�� � � '�$�4�$�R�2�2�6�2�2� 2�$�4�$�R�2�2�6�2�2� 2r�c�P�d|j�d|�|rd|znd��}t||d��S)N�visit_rr�)r�r^)r r#� qualifier1� qualifier2�attrnames r�r"z"SQLCompiler._get_operator_dispatch� sE��� � � � � �J� *� 2�C�*� � �� 2� �� �t�X�t�,�,�,r�c ���|�||fz }||d<||d<|jrg|jrtjd���|�|jdd��}|r|||jfi|��S|j|t |jfi|��S|jrL|�|jdd��}|r|||jfi|��S|j|t |jfi|��Stjd���)Nr�r�zFUnary expression does not support operator and modifier simultaneously�unaryr?�modifierz,Unary expression has no operator or modifier)r?r�r8r�r"� _generate_generic_unary_operatorr�� _generate_generic_unary_modifier)r r�r�r�r�r$s r�� visit_unaryzSQLCompiler.visit_unary� sk�� � (� �5�(� *� �&7�B�"� #�'9�B�#� $� �>� ��~� ��&�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:�����"�>��� r�c �\�|jjrw|j|jfi|��dz|jt j|j|jjjtj ur |jjntj ����fi|��zS|j|jfi|��dz|j|jfi|��zS)N� / ) r��div_is_floordivr�ryr�Castr�r��_type_affinityr%�Numeric�r r�r?r�s r��visit_truediv_binaryz SQLCompiler.visit_truediv_binary$ s��� �<� '� ��� �V�[�/�/�B�/�/����$�,��M�� � &�|�0�?�'�/� 0� 0�#�L�-�-�"*�!1�!3�!3� �� � �� � � � �(�� �V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3� r�c ��|jjrG|jjjt jur*|j|jfi|��dz|j|jfi|��zSd|j|jfi|��dz|j|jfi|��zzS)Nr�z FLOOR(%s)) r�r�r�r�r�r%�Integerr�ryr�s r��visit_floordiv_binaryz!SQLCompiler.visit_floordiv_binary? s��� �L� (� �� �!�0�H�4D�D�D��� �V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3� � ��� �V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3�� r�c �z�|js |jjr|j|jfi|��Sd|j|jfi|��zS)Nz%s = 1��_is_implicitly_booleanr�r�r�r��r r�r?r�s r��visit_is_true_unary_operatorz(SQLCompiler.visit_is_true_unary_operatorP s[�� � *� B��|�3� B� �4�<���6�6�2�6�6� 6��l�d�l�7�?�A�A�b�A�A�A� Ar�c ��|js |jjrd|j|jfi|��zSd|j|jfi|��zS)N�NOT %sz%s = 0r�r�s r��visit_is_false_unary_operatorz)SQLCompiler.visit_is_false_unary_operatorY s`�� � *� B��|�3� B��l�d�l�7�?�A�A�b�A�A�A� A��l�d�l�7�?�A�A�b�A�A�A� Ar�c �J�d|�|tj���zS)Nr�)�override_operator)� visit_binaryr!�match_opr�s r��visit_not_match_op_binaryz%SQLCompiler.visit_not_match_op_binaryb s.���$�+�+� �i�&8�,� � � � r�c �<�d|j|t|fi|��zSr)�_generate_generic_binaryr�r�s r��visit_not_in_op_binaryz"SQLCompiler.visit_not_in_op_binaryg s:���5��5� �I�h�'� � �+-� � � � r�c �@�|tjur7t|��dkr"dd�d�|D����zSdS|tjur7t|��dkr"dd�d�|D����zSdS|�|��S) Nrz(%s)) OR (1 = 1r�c3�K�|]}dV��dS�r�Nr��r�r�s r�r1z6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>s �"����:�:��f�:�:�:�:�:�:r�zNULL) OR (1 = 1z(%s)) AND (1 != 1c3�K�|]}dV��dSr�r�r�s r�r1z6SQLCompiler.visit_empty_set_op_expr.<locals>.<genexpr>z r�r�zNULL) AND (1 != 1)r!� not_in_opr�rx�in_op�visit_empty_set_expr)r r� expand_opr�s r��visit_empty_set_op_exprz#SQLCompiler.visit_empty_set_op_expro s��� � �+� +� +��5�z�z�A�~�~�(��I�I�:�:�E�:�:�:�:�:���)�(� �)�/� )� )��5�z�z�A�~�~�*��I�I�:�:�E�:�:�:�:�:���+�*��,�,�U�3�3� 3r�c �:�td|jjz���)Nz3Dialect '%s' does not support empty set expression.rk�r � element_typesr�s r�r�z SQLCompiler.visit_empty_set_expr� s$��!� A��l�� � � � r�c����� � ��j��j��}|sb|jr8�jjrdnd���jj�j��z}�n����jg�j��}�nf|jsI|jr�t|dtj ��ryt|dttf��sW|jrtd����jjrdndd���fd�t#|��D����z}n�|r��j}|�|��}|r|�d��s Jd���|�d���d ��}|d |d c� � d�� � ��fd �|D����}n"d���fd �|D����}d|fS)N�VALUES r�rz?bind_expression() on TupleType not supported with literal_bindsr�c 3��K�|]C\}}dd��fd�t|�jj��D����zV��DdS)rr�c3�J�K�|]\}}��||��V��dSr r)r�r�� param_typer s �r�r1z[SQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>.<genexpr>� sK�������-�E�:��1�1�%��D�D������r�N)rxr�r�r�)r�rrr,r s ��r�r1zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>� s������ � �%�A�}���I�I�����14�)�9�>�+?�2�2������� � � � � � r�r7�)unexpected format for expanding parameterrrrc3�Z�K�|]%}����|�j������V��&dSr �rr�)r�r�rrr,r s ����r�r1zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>� s]�����3�3��  ���1�1�%���H�H�H� �� �3�3�3�3�3�3r�c3�N�K�|]}��|�j��V�� dSr r�)r�r�r,r s ��r�r1zQSQLCompiler._literal_execute_expanding_parameter_literal_binds.<locals>.<genexpr>� sI�����3�3���-�-�e�Y�^�D�D�3�3�3�3�3�3r�r�)r�r�r�r��tuple_in_valuesr�r�r��_isnullr��collections_abcrr��bytes�_has_bind_expressionr�rxrr"�searchr�r) r r,r��bind_expression_template�typ_dialect_impl�replacement_expression�post_compile_patternr�rrrs `` @@r��2_literal_execute_expanding_parameter_literal_bindsz>SQLCompiler._literal_execute_expanding_parameter_literal_binds� s�������%�>�A�A�$�,�O�O���A �  �.� �!%��!=�E�I�I�2��0�0��N�(�)�*=���*�&�&�*.�)E�)E��^�$�i�&9�*�*�&�&�� ,�0 � � $�0 ��6�!�9�o�&>�?�?�0 ��v�a�y�3��,�7�7�0 �  �4� �)�$���� "�\�9�A� � �r�� � � � � � � �)2�&�(9�(9� � � � � � &� "� "�(� �'+�'A�$�(�/�/�0H�I�I���?�Q�W�W����?�?�>�?�?���g�g�a�j�j�&�&�t�,�,��$'��F�C��F�!���)-���3�3�3�3�3�3�3�"(�3�3�3�*�*�&�&�*.���3�3�3�3�3�!'�3�3�3�*�*�&� �)�)�)r�c�������� ��jr���|��S�j}�j�|��� �jr�j�n�j��jjr� j r ���� fd��n�fd��|sRg�� j r'�� �jj �j ��}�n�� �jg�j ��}n� j sI� jr�t|dt j��r�t|dt$t&f��sa� jrJ��fd�t+|d��D���|jrdndd���fd �t+|��D����z}n=�fd �t+|d��D���d��fd ��D����}�|fS) Nc�F�����j��d|iz��S�Nr�)�render_bind_castr�)r�� bind_templater,r r�s ����r��_render_bindtemplatezNSQLCompiler._literal_execute_expanding_parameter.<locals>._render_bindtemplate� s/����,�,��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�rc�Z��g|]'\}}t|d��D]\}}��d|�d|��|f���(S)rrr)r�rrrr�r�s �r�r�zDSQLCompiler._literal_execute_expanding_parameter.<locals>.<listcomp> sh������$�A�}� )�-�� ;� ;����A�u� $�t�t�Q�Q�Q���*�E�2����r�rr�r�r�c3����K�|];\��dd�����fd�t���D����zV��<dS)rr�c3�r�K�|]1\}}���t���z|zd��V��2dS)rN)r�)r�rr�r�rr-rs ����r�r1zMSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr>.<genexpr> si�������%�A�u�-�,�%�a�#�m�*<�*<�&<�q�&@�A�!�D��������r�N)rxr)r�rrr�r-s @@��r�r1zCSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr> s�������� � �%�A�}���I�I��������)2�-�(@�(@� ������ � � � � � r�c�(��g|]\}}��d|��|f��S)rr�)r�rr�r�s �r�r�zDSQLCompiler._literal_execute_expanding_parameter.<locals>.<listcomp> s=�������A�u�!�D�D�!�!�$�e�,���r�c3�4�K�|]\}}�|��V��dSr r�)r�r0r�r�s �r�r1zCSQLCompiler._literal_execute_expanding_parameter.<locals>.<genexpr> sD�����/�/�.8�c�5�$�$�S�)�)�/�/�/�/�/�/r�)r r�r�r�r�r:r4r3�_bind_typing_render_castsr�r�r�r�r�r�r�r�rr�r�� _is_arrayrr�rx) r r�r,r�r�r�r�r�r-r�s ``` @@@@r�rz0SQLCompiler._literal_execute_expanding_parameter� s���������� � $� ��J�J��6��� ��,��$�>�A�A�'�J�J�� � � .� �9�M�M� �-�M� �L� 2� 6� �1� 6�  � � � � � � � � � 6� 6� 6� 6� 6��, ��I��.� �)-�)E�)E��N�(�)�*=�*�*�&�&�*.�)E�)E��^�$�i�&9�*�*�&�&�� ,�! � � $�! ��6�!�9�o�&>�?�?�! ��v�a�y�3��,�7�7�! � (�1� 1� 1�1�����(1�&�!�(<�(<����I�%�4�<� � �"�� � � � � � � �)2�&�(9�(9� � � � � � &� "� "����� )�&�!� 4� 4����I�&*�Y�Y�/�/�/�/�<E�/�/�/�&�&� "��0�0�0r�c �F�|r�tj|j��r�|�l|d}|j�t jt|jj |gz��t|j j |gz������n[|j�t jt|jj ��t|j j ������|j rCt|jtj��r$t|j tj��rd|d<|p|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?rzrxr��productr*ryr+r�r2r�rrFr"r�r�r�r8r�) r r�r��eager_groupingr�r�r�r�r#r$r%r�s r�r�zSQLCompiler.visit_binary s�� � �9�2�6�?�C�C� �"�.�$&�':�$;�!�#�)�0�0��%�!�"�K�5�9J�8K�K���"�"�L�6�:K�9L�L��� �� � � � ��!�(�(��%�!�&�+�";�<�<�!�&�,�"<�=�=������ � � )��6�;��(>�?�?� )��6�<��)?�@�@� )� %)�B� � !�%�8��� ��*�*�9�h��E�E�� � ��4�� �0�0�R�0�0� 0� �$�Y�/��5�t�4����!,�(;� �� � ����� P� P� P��5�d�I�F�F�C�O����� P���s� E;�; F �F�F c �(�|j|jfi|��Sr )r�� sql_functionr�s r��&visit_function_as_comparison_op_binaryz2SQLCompiler.visit_function_as_comparison_op_binaryX s���t�|�G�0�7�7�B�7�7�7r�c ���|jjr*|j|jfi|��dz|j|jfi|��zS|j|jfi|��dz|j|jfi|��zS)Nz %% r�)r�r�r�ryr�r�s r��visit_mod_binaryzSQLCompiler.visit_mod_binary[ s��� �=� )� ��� �V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3� ��� �V�[�/�/�B�/�/����$�,�v�|�2�2�r�2�2�3� r�c �p�|j|d<|j|d|�|j��zdzfi|��S)Nr�r!)r�r�r�r%r�s r��visit_custom_op_binaryz"SQLCompiler.visit_custom_op_binaryi sW��'�6�� ��,�t�,� � �$�,�,�X�->�?�?� ?�#� E� � �� � � r�c �V�|j||�|j��dzfi|��Sr)r�r�r%r�s r��visit_custom_op_unary_operatorz*SQLCompiler.visit_custom_op_unary_operatorq sA��4�t�4� �T�/�/��0A�B�B�S�H� � �LN� � � r�c �V�|j|d|�|j��zfi|��Sr)r�r�r%r�s r��visit_custom_op_unary_modifierz*SQLCompiler.visit_custom_op_unary_modifierv sA��4�t�4� �S�4�5�5�h�6G�H�H�H� � �LN� � � r�c ��|�dd��}d|d<|j|d<|jj|fd|i|��|z|jj|fd|i|��z}|r|rd|z}|S)Nr!FT� _binary_opr�r)r�r?ryr�r�)r r�r%r�r�r!r�s r�r�z$SQLCompiler._generate_generic_binary{ s���#%�&�&�)B�E�"J�"J��(,�� $�%�!�?��<�� *�F�K� *�� � �%3� �79� � �� �.�f�l�-����%3��79���  � � #� !�~� !��D�=�D�� r�c �.�||jj|fi|��zSr rv�r r�r%r�s r�r�z,SQLCompiler._generate_generic_unary_operator� s%���:�%�-�:�4�F�F�2�F�F�F�Fr�c �.�|jj|fi|��|zSr rvr�s r�r�z,SQLCompiler._generate_generic_unary_modifier� s$��/�u�}�/��;�;��;�;�h�F�Fr�c�B�tjdtj���S)Nz'%')r)r�literal_columnr%� STRINGTYPEr4s r��_like_percent_literalz!SQLCompiler._like_percent_literal� s���&�u�H�4G�H�H�H�Hr�c �0�d|jj|fi|���d�S)Nzlower(rrvr�s r��$visit_ilike_case_insensitive_operandz0SQLCompiler.visit_ilike_case_insensitive_operand� s+��I�:���:�4�F�F�2�F�F�I�I�I�Ir�c ��|���}|j}|�|j���|��|_|j||fi|��Sr ��_cloner��concatr��visit_like_op_binary�r r�r?r��percents r��visit_contains_op_binaryz$SQLCompiler.visit_contains_op_binary� sW���������,���~�~�f�l�3�3�:�:�7�C�C�� �(�t�(���@�@�R�@�@�@r�c ��|���}|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� sW���������,���~�~�f�l�3�3�:�:�7�C�C�� �,�t�,�V�X�D�D��D�D�Dr�c ��|���}|j}t|j��|_|�t|j�����|��|_|j||fi|��Sr �r�r�r ryr�r��visit_ilike_op_binaryr�s r��visit_icontains_op_binaryz%SQLCompiler.visit_icontains_op_binary� sw���������,��,�V�[�9�9�� ��~�~� "�6�<� 0� 0� � � �&��/�/� � �*�t�)�&�(�A�A�b�A�A�Ar�c ��|���}|j}t|j��|_|�t|j�����|��|_|j||fi|��Sr �r�r�r ryr�r��visit_not_ilike_op_binaryr�s r��visit_not_icontains_op_binaryz)SQLCompiler.visit_not_icontains_op_binary� sw���������,��,�V�[�9�9�� ��~�~� "�6�<� 0� 0� � � �&��/�/� � �.�t�-�f�h�E�E�"�E�E�Er�c ��|���}|j}|�|j��|_|j||fi|��Sr )r�r��_rconcatr�r�r�s r��visit_startswith_op_binaryz&SQLCompiler.visit_startswith_op_binary� sK���������,���'�'�� �5�5�� �(�t�(���@�@�R�@�@�@r�c ��|���}|j}|�|j��|_|j||fi|��Sr )r�r�r r�rr�s r��visit_not_startswith_op_binaryz*SQLCompiler.visit_not_startswith_op_binary� sK���������,���'�'�� �5�5�� �,�t�,�V�X�D�D��D�D�Dr�c ���|���}|j}t|j��|_|�t|j����|_|j||fi|��Sr )r�r�r ryr r�rr�s r��visit_istartswith_op_binaryz'SQLCompiler.visit_istartswith_op_binary� se���������,��,�V�[�9�9�� ��'�'�(>�v�|�(L�(L�M�M�� �)�t�)�&�(�A�A�b�A�A�Ar�c ���|���}|j}t|j��|_|�t|j����|_|j||fi|��Sr )r�r�r ryr r�rr�s r��visit_not_istartswith_op_binaryz+SQLCompiler.visit_not_istartswith_op_binary� se���������,��,�V�[�9�9�� ��'�'�(>�v�|�(L�(L�M�M�� �-�t�-�f�h�E�E�"�E�E�Er�c ��|���}|j}|�|j��|_|j||fi|��Sr r�r�s r��visit_endswith_op_binaryz$SQLCompiler.visit_endswith_op_binary� sI���������,���~�~�f�l�3�3�� �(�t�(���@�@�R�@�@�@r�c ��|���}|j}|�|j��|_|j||fi|��Sr r�r�s r��visit_not_endswith_op_binaryz(SQLCompiler.visit_not_endswith_op_binary� sI���������,���~�~�f�l�3�3�� �,�t�,�V�X�D�D��D�D�Dr�c ���|���}|j}t|j��|_|�t|j����|_|j||fi|��Sr rr�s r��visit_iendswith_op_binaryz%SQLCompiler.visit_iendswith_op_binary� sc���������,��,�V�[�9�9�� ��~�~�&<�V�\�&J�&J�K�K�� �)�t�)�&�(�A�A�b�A�A�Ar�c ���|���}|j}t|j��|_|�t|j����|_|j||fi|��Sr rr�s r��visit_not_iendswith_op_binaryz)SQLCompiler.visit_not_iendswith_op_binary� sc���������,��,�V�[�9�9�� ��~�~�&<�V�\�&J�&J�K�K�� �-�t�-�f�h�E�E�"�E�E�Er�c ���|j�dd��}|jj|fi|���d|jj|fi|����|�#d|�|t j��zndzS)NrSz LIKE � ESCAPE r��� modifiersr�ryr�r�rr%r��r r�r?r�rSs r�r�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� � �!� ��2�2�6�8�;N�O�O� O� O��  � r�c ���|j�dd��}|jj|fi|���d|jj|fi|����|�#d|�|t j��zndzS)NrSz NOT LIKE rr�rrs r�rz$SQLCompiler.visit_not_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� � �!� ��2�2�6�8�;N�O�O� O� O��  � r�c ���|tjurF|���}t|j��|_t|j��|_|j||fi|��Sr )r!�ilike_opr�r ryr�r�r�s r�rz!SQLCompiler.visit_ilike_op_binarys^�� �y�)� )� )��]�]�_�_�F�0���=�=�F�K�1�&�,�?�?�F�L�)�t�(���@�@�R�@�@�@r�c ���|tjurF|���}t|j��|_t|j��|_|j||fi|��Sr )r!� not_ilike_opr�r ryr�rr�s r�rz%SQLCompiler.visit_not_ilike_op_binarys^�� �y�-� -� -��]�]�_�_�F�0���=�=�F�K�1�&�,�?�?�F�L�-�t�,�V�X�D�D��D�D�Dr�c �^�|j�dd��}|j||rdndfi|��S)Nr�Fz BETWEEN SYMMETRIC z BETWEEN �rr�r��r r�r?r�r�s r��visit_between_op_binaryz#SQLCompiler.visit_between_op_binarysN���$�(�(��e�<�<� �,�t�,� �Y�G�)�)�K� � �KM� � � r�c �^�|j�dd��}|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_binarysQ���$�(�(��e�<�<� �,�t�,� �)2� G� %� %�� � �� � � r�c �D�tjd|jjz����Nz/%s dialect does not support regular expressions�r8r�r�r�r�s r��visit_regexp_match_op_binaryz(SQLCompiler.visit_regexp_match_op_binary&�'���� =��l�� � � � r�c �D�tjd|jjz���r,r-r�s r�� visit_not_regexp_match_op_binaryz,SQLCompiler.visit_not_regexp_match_op_binary,r/r�c �D�tjd|jjz���)Nz;%s dialect does not support regular expression replacementsr-r�s r��visit_regexp_replace_op_binaryz*SQLCompiler.visit_regexp_replace_op_binary2s'���� I��l�� � � � r�c ���|s�|j�|j��}|jr�|�|��} |j| fd||o|j ||d�|��} |jr~tjd| ��} | s Jd���d| � d���d| � d���d | � d ���d �} |r|j |fd| d �|��} d | zS| S|s|p|j p|o|j }|p|j} nd} |r|j |fddi|��} |jrd | z} | S|� |��}||jvr�|j|}||ur�|js|jrU|j�|j��s6|j�|j��st'jd|z���|j|jkrt'jd|�d����|js|jrG|jr|jrt'jd���t'jd|j�d|j�d����|x|j|j<|j|<|j}|r@|\}}|jD]3}|j|vr(||j}||�|���4|jrd|_| r.|rd|_|r|xj|hzc_n|xj|hzc_|j|f| |j|jd�|��} |jrd | z} | S)NT)�skip_bind_expressionr�� literal_bindsr �render_postcompilez&^(.*)\(__\[POSTCOMPILE_(\S+?)\]\)(.*)$r�z(__[POSTCOMPILE_r7rrz~~REPL~~rz~~]))r�r�rFr�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�r9rRr3r�rr r2�_truncate_bindparamr.r�r�� intersectionrmr8r��_is_crudr0rFr�� isoutparam�has_out_parametersr;rCrDr�)r r�r�r6r5r r7r��implr<�wrappedr�r^r8r��existingr�r~r}rprrs r��visit_bindparamzSQLCompiler.visit_bindparam8s���$�$ ��>�.�.�t�|�<�<�D��(�" �"&�"6�"6�y�"A�"A��&�$�,�#��)-�*?�"/�"K� �8K�4K�$3�'9� �������&�,���A�7���A��I�I�I�I�I�1�I����� � � � ����� � � � ����� � � � ��G� %�,�;�d�;�%��26�5<���%� ��� &��|�+���� !��D��,�D�)�B�d�.B� � +�A�i�.A�L�L� �L� � �/�$�/����15��9?���C��"� #��s�l���J��'�'� �2�2�� �4�:� � ��z�$�'�H��y�(�(��_�/�(1�(8�/�$�.�;�;�!�+���/� %�0�=�=�!�-��� /��*�A�CG�H�����'�9�+>�>�>��*�*� :>��� @�����&��)�*<���(��Y�-?��"�.�&� � � �"�.�5���5�5�#,�-�5�5�5� � � �8A�@�� �9�=�!�D�J�t�$4��/� � � /�#�J�D�$��+� /� /���6�T�>�>��b�f��B���H�O�O�I�.�.�.�� � � +�&*�D� #� � 8�!� 0�+/��(�� 8��+�+� �{�:�+�+�+��(�(�Y�K�7�(�(�#�d�#� � �%��)�$�>�  � � �  � �� � � ��3�,�C�� r�c��t���r r�)r r� dbapi_typeros r�r�zSQLCompiler.render_bind_cast�s��!�#�#�#r�c ��|tur|}nz|j�l|j�e|�dd��}|r5|tjtjfvrtjd|j f��|j tj fi|��S|j }|jr|j}||||���\}} | S|�||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_limitedr0r�r%r�r�r9r�rr�) r r�rr�r�r��op�leepr-r/s r�rz$SQLCompiler.render_literal_bindparam�s��� �v� -� -�(�E�E���&�9�+=�+E��V�V�L�$�/�/����"�Y�]�I�4D�$E�E�E��%�@�#��(� ��� $�t�|�H�$5�<�<��<�<�<��-�E� � � D��J�D�*.�$���)A�+�+�+� '�I�'� $� #��,�,�U�I�N�C�C� Cr�c��|�8|js1|�tj�����S|�|j��}|rL ||��S#t$r3}tj dtj |���d|�d���|�d}~wwxYwtj dtj |���d|�����)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�r8r��sql_util�_repr_single_value)r r�r� processor�es r�rz SQLCompiler.render_literal_values�� �=��!;�=��<�<�� � 7� 7� 9� 9�:�:� :��3�3�D�L�A�A� � � � � �y��'�'�'��� � � ��&�#� �3�E�:�:�#�#��#�#�#��� � ����� �����"�)��/��6�6�)�)�!&�)�)��� s� A#�# B �-.B�B c��||jvr |j|S|j}t|tj��r|�d|��}||j|<|S)Nr�)r/r0r�rrEr�)r r�r�s r�r=zSQLCompiler._truncate_bindparam&sb�� ��� '� '��?�9�-� -��M� � �i��!:� ;� ;� K��2�2�;� �J�J�I�&/��� �"��r�� ident_classr�rEc��||f|jvr|j||fS|�|j��}t|��|jdz krd|j�|d��}|dt|jdz d���dzt|��dd�z}|dz|j|<n|}||j||f<|S)N�rrrr7) rr� apply_maprqr�rorsr��max�hex)r rXr��anonname�counter� truncnames r�r�z!SQLCompiler._truncated_identifier3s��� �� �$�"6� 6� 6��'��d�(;�<� <��>�>�$�-�0�0�� �x�=�=�4�,�q�0� 0� 0��.�2�2�;��B�B�G���S��!2�Q�!6��:�:�:�;����g�,�,�q�r�r�"�#� � 5<�a�K�D� $�[� 1� 1� �I�4=���k�4�0�1��r�c��||jzSr �rq�r r�s r�� _anonymizezSQLCompiler._anonymizeHs���d�m�#�#r�r8r9� escaped_fromr:�Optional[TypeEngine[Any]]�accumulate_bind_names�Optional[Set[str]]�visited_bindparamr�c ���|�|�|��|�|�|��|s<�j�|��r"�j��fd�|��} |}| }|r!�j�||i���_|rEd|z} |r| S|�8|��j��} | j r�� || | ��} | S�j tj ur �jd|iz} n �jd|iz} |�D�jjr8|��j��} | j r�� || | ��} | S)Nc�D���j|�d��S)Nr)r$r�)r�r s �r�r�z.SQLCompiler.bindparam_string.<locals>.<lambda>es���d�8�������D�r�z__[POSTCOMPILE_%s]r�)�addr�r#r�r�rEr�r�r��render_literal_castr�r�rerfr4r3r�) r r�r8r9rer:rgrir��new_namer^� type_impls ` r�r�zSQLCompiler.bindparam_stringKs���� !� ,� !� %� %�d� +� +� +� � (� � $� $�T� *� *� *�� ��&�-�-�d�3�3� � �2�6�6�D�D�D�D����� $� ��� � �&*�&=�&C�&C��t�$�'�'�D� #� � 5�&��-�C�� �� ��)�*�B�B��L��� ��0�P��/�/�� �3�O�O�C��J� �Z�=�2� 2� 2��/�6�4�.�@�C�C��#�v�t�n�4�C� � &�� �6� '�'�>�>�t�|�L�L�I��)� L��+�+�N�I�s�K�K��� r�c��|���}|�dd��t|j|j��D]\}}|j|fd|i|���dS)N�cte_opts)�copyr|r�r��_independent_ctes_optsr�)r �stmtr��local_kw�cte�opts r�r�z&SQLCompiler._dispatch_independent_ctes�s~���7�7�9�9��� � �Z��&�&�&�� � "�D�$?� � � C� C�H�C�� #�C� "�4� B� B�#� B�� B� B� B� B� C� Cr�rvrNrx�ashint� fromhints�Optional[_FromHintsType]� visiting_cte� Optional[CTE]r��Optional[FromLinter]rq�selectable._CTEOptsc �x������} | �jusJ�||d<|j} t| tj��r��d| ��} d} d} |���} |jp|j}| �j vr��j | \}}}|| ksJ�|| f}�j |}|jr]|jrtj d���|| f}|rt�j��nd}|| fx}}�j |=|�j |<||fz�j | <n5|rt�j��nd}|| f}|�j vr�j |}nd}|��||u} ||jus||urd} nr||jur,| |=|���}|| usJ�||usJ��j |=n=|j�|j�|�|��rd} ntj d| z���|s| sdS|j�D|j}|jj}t|tj��r��d|��}n|}d}| �rE|�j |<||fz�j | <|�jvr�j|fi|��|�s|| v�r|jrd�_�j�|| ��}|jrM|j}d�|�d��D��}|d d ��fd �|D����zz }|�d d��dusJ��js|jj�fd |i|��S�j||jfi|��}|jj�fd di|��}|d|�d|�d�z }|jr|d�j||jfi|��zz }|| |<|r�|r| |j |�!��<| s| r�j�|| ��S|ri�j�||��}�j�"| ��r�j�#| ��} |��$| ��z }|S�j�|| ��SdS)Nr{r�TFz6CTE is stated as 'nest_here' in more than one locationrz5Multiple, unrelated CTEs found with the same name: %rc�&�g|]\}}}}}|� |p|��Sr�r�)r�r� proxy_name�fallback_label_namer��repeateds r�r�z)SQLCompiler.visit_cte.<locals>.<listcomp>sF��"�"�"� ��&�/��$�'�"� ,�9�z� "�"�"r�rr�c3�Z�K�|]%}�j�|�j���V��&dS)rbN)r��format_label_namerq)r��identr s �r�r1z(SQLCompiler.visit_cte.<locals>.<genexpr>-sW�����"�"�!&�!�M�;�;� %�� �<���"�"�"�"�"�"r��subqueryrxr�z (rr!)%r�rJr�r�rrEr��_get_reference_cte�nestingrLrKr8r�r�r�� _restates� _is_clone_of�compare� _cte_alias� visit_cte� recursiverMr�� format_aliasr��_generate_columns_plus_namesrxr�r��_generate_prefixes� _prefixes� _suffixesryr*�_requires_quotesr��get_render_as_alias_suffix)r rvrxrxryr{r�rqr�� self_ctes�cte_name� is_new_cte�embedded_in_current_named_cte�_reference_cter�� cte_levelr�existing_cte_opts�cte_level_name� existing_cte�old_level_name�new_level_name�existing_cte_reference_cte� pre_alias_cte�cte_pre_alias_namer�� col_source� recur_cols�prefixesr�s` r�r�zSQLCompiler.visit_cte�s����(�(�*�*� ��D�I�%�%�%�%�!$��~���8�� �h�� 9� :� :� E��1�1�'�8�D�D�H�� �(-�%��/�/�1�1���+�1��!1�� �T�3� 3� 3�.2�.D��/� +�I�q�+���=�=�=�=�'��2�N��2�>�B�L� �� �$�,���*�1���� #,�X�!6��/6�=�C�� �O�O�O�A� �3<�h�2G�G����+�N�;�:F��'��7�9G��K�:��&�~�6�� ,3�9��D�J�����I�'��2�N���!8�8�8�#�6�~�F� � �#� � � #�,8�L�,H� )��l�,�,�,��|�0C�0C�"� � ����.�.��l�+�-9�-L�-L�-N�-N�*�1�^�C�C�C�C�1�\�A�A�A�A��*�+E�F�F� �$�0�#�0�<��k�k�,�/�/�=�!&�J�J��*�,�.6�7���� � �j� ��4� �>� %��N�M�!$��!4� ��,�h�.G�H�H� �%)�%?�%?��/�&�&�"�� �M�!%� � �D &�69�D� #�N� 3�5C��G�6�D� "�>� 2��D�I�-�-����}�7�7��7�7�7�%�; &�#�Y�*>�*>��=�/�*.�D�'��}�1�1�#�x�@�@���=��!$��J� "�"�)�E�E�d�K�K�"�"�"�J� �F�� � �"�"�"�"�*4� "�"�"�����D��z�z�*�e�4�4��=�=�=�=��z�?�:�3�;�9����%+��/5���� 7�t�6��S�]� � �.4� � �H�;�C�K�:����%)��-3���E��D�h�h�h����>�>�D��=���C�"9�$�"9��S�]�#�#�.4�#�#���D�"&� �#�� � A�� >�5=� �!�#�-�-�/�/�2�� 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�@�@�@��tr�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_aliasasX�� � #� %� $�B�}� � � � 3�%�4�%�g�4�4��4�4� 4�#�4�#�G�2�2�r�2�2� 2r�c ��|j|fi|��Sr )r�r�s r��visit_table_valued_columnz%SQLCompiler.visit_table_valued_columnis�� �t� ��/�/�B�/�/�/r�c �T��� �|r!d� vr�jsJ��� d<| r d� vr d� vr| � d<|�1|j�ur(�jj�f|||||�d�� ��} |r |s|rd| �d�} | S�x}� d<|s|rBt�jt j��r��d�j��} n�j} |r�j� �| ��S|r�| r| | j �� ��<�jj�fd|d �� ��} |rd| �d�} | �� �j� �| ����z} �j r5�jr.| d d ��� �fd ��jD����zz } |r"�|vr��| �|�|��} | S�jj�fd |i� ��S)Nr�r�)rxrx�iscrudry�lateral�enclosing_aliasrrr�r�T)rxr�rr�c3��K�|]N}�j�|j����jr d�jjj|jfi���znd��V��OdS)� %sr�N)r�r�r��_render_derived_w_typesr�r�r�r�)r�r�r�r�r s ���r�r1z*SQLCompiler.visit_alias.<locals>.<genexpr>�s�������� �!�M�/�/���9�9�9� $)�#@� !(��"M�$�,�"E�"M�$'�H�#"�#"�06�#"�#"�!"�!"� &(� !(� ������r�r�)r�r�r�r�r�rrEr�r�r�ryr*r��_supports_derived_columns�_render_derivedrxr��format_from_hint_text)r r�rxrxr�ryr�r�r�r�r�r�� alias_namer^s`` ` r�r�zSQLCompiler.visit_aliasls������ � <�"�&�0�0��(�(�(�(�.3��*�+� � <�)��7�7�'�6�1�1�0;��,�-� � &�?�+B�e�+K�+K�4�E�M�4�� ����#�� %� � �� � �E�� *�V� *�w� *��"'�%�%�)���L�:?� ?�O�f�%6�7� � (�V� (��%�*�h�&?�@�@� (�!�7�7����L�L� � �"�Z� � �- ��=�-�-�e�Z�@�@� @� �+ �� B�7A� �!�%�/�/�"3�"3�4�4�E�M�4���!�7���6<���E�� *� *�"'�%�%�)���$�9�9�� �*�*�5�*�=�=����C��.� �5�3H� ��v��I�I�������$)�7���������$� �U�i�/�/��0�0��� �%� 0�&�����J�4�5�=�3����%��)/��� r�c �(�d|d<|j|fi|��S)NTr��r�)r r�r�s r��visit_subqueryzSQLCompiler.visit_subquery�s&����:���t���/�/�B�/�/�/r�c �.�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|fi|����}|j�|d|jj|fi|��zz }|S)NrxTz TABLESAMPLE z REPEATABLE (%s))r�� _get_methodr��seed)r � tablesamplerxr�r�s r��visit_tablesamplezSQLCompiler.visit_tablesample�s��� �D� �[� <� <�� <�� <� <� <� <� 8�K� #� #� %� %� 8�� D� D�� D� D� D� �� � � '� �&�3� � �3�D�?�?�B�?�?�� �D�� r�c �������d�j��d����fd��jD����}d|��S)Nr6r�c 3��K�|]=}|D]8}�jtj|d�ji����fi���V��9�>dS)r�N)r�rr� _column_typesr)r��chunk�elemr�r�r s ���r�r1z-SQLCompiler._render_values.<locals>.<genexpr>�s������  �  ���  �  �� �D�L���26��!�/����*�,�,� � ��  � �  �  �  �  �  �  �  r�r�)� setdefaultr6rx�_data)r r�r��tupless``` r��_render_valueszSQLCompiler._render_values�ss����� � � �o�w�'<�=�=�=����  �  �  �  �  �  �!��  �  �  �  �  ��"��!�!�!r�c ������j|fi���}|jrd}nBt|jtj��r��d|j��}n|j}|jrd}nd}|r�|r |�|nd|j|� ��<|rdd�d<|�d|�d�� �j � |�����d d � ��fd �|jD�����d�}n|�d|�d�}|S) Nr�zLATERAL r�z(unnamed VALUES element)Fr�rr� (r�c3�4�K�|]}|j�fi���V��dSr r�rs ��r�r1z+SQLCompiler.visit_values.<locals>.<genexpr>sL�����"�"� !�1�A�0��<�<��<�<�"�"�"�"�"�"r�)r��_unnamedr�r�rrEr�r�ryr*r�r�r�rx�columns)r r�rxr�r�rfr�r�s` ` r�� visit_valueszSQLCompiler.visit_values�sg���� �D� �� .� .�2� .� .�� � � ��D�D� �� �h�&?� @� @� ��-�-�h�� �E�E�D�D��<�D� � � � �G�G��G� � ,�� � �,�D�D�2L��!�'�"3�"3�"5�"5�6�� ,�&+��?�#��G�G��A�A��3�3�D�M�4G�4G��4M�4M�N�N�N�N�� � �"�"�"�"�"�%,�_�"�"�"����� ���!(������+���r�c �&�d|j|fi|���d�Sru)r�r�s r��visit_scalar_valueszSQLCompiler.visit_scalar_valuess)��8�&�4�&�w�5�5�"�5�5�8�8�8�8r�c� �d|zS)Nr�r�)r �alias_name_texts r�r�z&SQLCompiler.get_render_as_alias_suffixs ����'�'r�r�r�rr�r c���|sJ�|�|dkrd|_d|_|jrtjd���|j�t||||����dS)N�*FTzxMost backends don't support SELECTing from a tuple() object. If this is an ORM query, consider using the Bundle object.)r8r7r�r8r�r�r�r�r s r�r�zSQLCompiler._add_to_result_maps������w� �?�g��n�n�$)�D� !�#'�D� � � � ��"�4��� � ��#�#� �w��g�u� =� =� � � � � r�c �.�|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)r rtr�r��column_clause_argsr�s r��_label_returning_columnz#SQLCompiler._label_returning_column8sC��)�t�(� � � � �$�,�B�B�2D�  � � �  � � r�c ������j�|j��} | jr| s|r| ����}n�}|r|j}| r|��fd�}n|�ur|���fd�}nd}| s Jd���t �tj��r'|�urt|�j �j f���}�n|}�n|r&|� Jd���t|||�j f���}n�|�urd}n�t �tj ��r|o�j o�jdu}ngt �tj��rd}nJt �tj��r �jp|}n&t �tj��s �j�d}nd}|rQ|s | rJ��j}t |tj��stj|��n|}t|||f���}n|}|�| || � ��|j|fi|��S) z.produce labeled columns present in a select().c�&���|||f|��dSr r�)r�r�r�rr�s �r�r�z;SQLCompiler._label_select_column.<locals>.add_to_result_mapss"���&�&�w��w�j�%�H�H�H�H�Hr�c�,���||�f|z|��dSr r�)r�r�r�rr�r�s ��r�r�z;SQLCompiler._label_select_column.<locals>.add_to_result_map{s2���&�&����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�r�r�)r�r;r��_has_column_expression�column_expressionr�r�rrIr�r�r�r�rGr�r�� TextClause�UnaryExpression�wraps_column_expression� NamedColumn�_non_anon_label�_anon_name_labelrErxr�)r r�r�r�rxr�r�r�r�r��column_is_repeated�need_column_expressionsr�rB�col_exprr�� result_expr�render_with_labelr�s ` @r�r�z SQLCompiler._label_select_columnMs/���� �{�'�'�� �5�5�� � &� � #� �':� ��-�-�f�5�5�H�H��H� � %� !%� 7� � "� �%6�"�I�I�I�I�I�I� ��'�'�%6�"�������� !%� �%� � � :� � �$� �f�h�n� -� -�\ '��v�%�%�+��f�k�f�n�5F���� � �'� � � �T '��&�&�;�'�&�&�(���� �$�� � � �K�K�&�v�%�%�%)�!�!��F�H�$9�:�:� *��1�"�-�-�1�� �D�0�"�!� �F�H�$7�8�8� *�$)�!�!��F�H�$<�=�=� *�$*�$B�$L�f�!�!� �v�x�';�<�<�  *��*�2�$(�!�!�$)�!� � '�*�B� 2�1�1�1�*0�*A�'�&�+�X�-F���-�H�-�.A�B�B�B�-� $�,��1�j�]���� � �'� ��!�!�"7�/�'� "� � � � .�{�-�d�I�I�6H�I�I�Ir�c�F�|�||��}|r|d|zz }|Sr)�get_from_hint_text)r ror��hintr��hinttexts r�r�z!SQLCompiler.format_from_hint_text�s2���*�*�5�$�7�7�� � &� �s�X�~� %�G��r�c��dSr r�)r �byfromss r��get_select_hint_textz SQLCompiler.get_select_hint_text�����tr�c��dSr r��r r�r�s r�r�zSQLCompiler.get_from_hint_text�r�r�c��dSr r�r�s r��get_crud_hint_textzSQLCompiler.get_crud_hint_text�r�r�c�,�d�|��Srr)r � hint_textss r��get_statement_hint_textz#SQLCompiler.get_statement_hint_texts���x�x� �#�#�#r�rr�rrc ��|j }|r|jn |jd}|�||��}|d}|d} |r-|s+|�|�| ��d���} n|�|| ���} | S)Nr�rrr���explicit_correlate_froms�implicit_correlate_froms)r�r�rs�_get_display_froms� difference) r � select_stmtrxr�r�r�r�rrrrys r��_display_froms_for_selectz%SQLCompiler._display_froms_for_select s����z�>��-5�I��)�)�4�:�b�>��#�:�:�;��M�M� �� 1�2���^�,� � � �'� �!�4�4�)8�)C�)C� �*�*�*,� 5���E�E�"�4�4�)8�)5�5���E�� r��translate_select_structurec ����������|� Jd���d| d<�j��fi| ��} | j| d<| j��j } | r�js| �_|dup|} �jr0�j�fd�i| ��} | �ur| }�}| ��j��fi| ��} | j�| r�jn �jd}| p+|�dd��p|�dd��x��|rd��sd | vr| d =���| |�||��}| � ����� ddd ���d }�j r#�� ���\}}|r||d zz }nd}�j r���| ���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 }�jr5| r| r1| st5�j��nd}��|���|z}�jr|d �j��jfi| ��zz }�j�d��|S)NzpSQLAlchemy 1.4 requires use of the translate_select_structure hook for structural translations of SELECT objectsFr�r�rxr�rrr�)r�r�zSELECT r!c��g|]}|�|��Sr r�r�s r�r�z,SQLCompiler.visit_select.<locals>.<listcomp>�s)�� � � ��*�}�- �,�}�}r�c�Z��g|]'\}}}}}� �� |� ��||||��� � ��(S))r�r�r�r�r�r�) r�r�r�r�r�r�rxr�r�r�rr s ������r�r�z,SQLCompiler.visit_select.<locals>.<listcomp>�sm���������'���#�)�)���'��&��)�(;�'/�,C�*� � ���r�c��g|] \}}}}}|�� Sr�r��r�r0r�r�r�r�s r�r�z,SQLCompiler.visit_select.<locals>.<listcomp>��9�� � � ���&�/� �$� � � � r�c��g|] \}}}}}|�� Sr�r�r s r�r�z,SQLCompiler.visit_select.<locals>.<listcomp>�r r�c �p��g|]2\}}}}t||t�fd�|D����|����3S)c3�D�K�|]}��||��V��dSr r�)r��orks �r�r1z6SQLCompiler.visit_select.<locals>.<listcomp>.<genexpr>�s1�����$F�$F�Q�Y�]�]�1�a�%8�%8�$F�$F�$F�$F�$F�$Fr�)r�r3)r�r0r�r�rrks �r�r�z,SQLCompiler.visit_select.<locals>.<listcomp>�sc���$�$�$�*�C��s�E�#���u�$F�$F�$F�$F�#�$F�$F�$F�F�F����$�$�$r�c�:��g|]\}}|d�jjfv�|��S�r��r�r�)r�� dialect_name�htr s �r�r�z,SQLCompiler.visit_select.<locals>.<listcomp>�s<������&�\�2��C���):�#;�;�;��;�;�;r�r�)rs�_ambiguous_table_name_mapr&r�rrr�r��_setup_select_stackrrrx�_hints�_setup_select_hintsr�r�r�r��get_select_precolumns�columns_plus_namesr�r�r��_compose_select_body�_statement_hintsr�rJr�r�r�r|)r rrx� insert_intoryr��select_wraps_forr�r�r�rr��is_embedded_select�new_select_stmt�compile_state_wraps_forr�ryr�� hint_text�byfrom� inner_columns� per_dialectr�r�r�r�rks``` @@@@r�� visit_selectzSQLCompiler.visit_select.s ��������� �'�'� -�(�'�'�+0��&�'�:� �:� �� � �!'� � � � � 3� �)�*�$�-� ��z�>�� � /�D�.� /�!.�D� �+�4�7�F�;�� � *� 6�=�d�=����$*��.4���O� �k�1�1�*7�'�#.� �-� � B� � B���!�!�)/�!�!� �,�5� �-5�I��)�)�4�:�b�>�� � >��y�y�7��?�?� >��y�y�5�u�=�=� ��5� � (�"'� � #� ,�':�f�'D�'D��*�+��(�(� ���v�w�� � ��$�[�[�]�]���!�!�$)�E� J� J� � � ��� � � � $� 8� 8�� E� E� �I�v�� (�� �C��'����F� � (� A� � +� +�K�� @� @� @� � � � �+�D�+��[�2���6<��� �D� �*��*�;�A�A�&�A�A�A�� � ����������&#�5�'��� � � � �4 �" �#3�#?��� � �+�=� � � � � �5�G� � � �����I�2$�$�$�$�.2�-A� $�$�$�D� ��(�(� � � � � � � � �  �  �� � '� H�����*5�*F����K� � H���d�:�:�;�G�G�G�G�� �9� O�0� O�H� O�3;�E�C�� �O�O�O��M��*�*��*�G�G�$�N�D� � � � �C�1�$�1��[�2���6<���� �D� � ���r����� r�r�r!�Tuple[str, _FromHintsType]c����fd�|j���D��}��|��}||fS)Nc �v��i|]5\\}}}|d�jjfv�||d|��d���iz��6S)r�r�T)rx�r�r�r�)r�r�r�r�r s �r�r`z3SQLCompiler._setup_select_hints.<locals>.<dictcomp>�sh��� � � �+� ���(��3�� � 1�2�2�2� �8��u�/�/��T�/�B�B�C�D�3�2�2r�)rryr�)r r�r$r#s` r�rzSQLCompiler._setup_select_hints�s[��� � � � �/5�m�.A�.A�.C�.C� � � �� �-�-�f�5�5� ��&� � r�c �.�|d}|d}|dkr||d<nf|rd|d} t| j��} t|j��| kr0tjdd| |dzt|j��fz���|r-|s+|�|�|��d���} n|�||���} tt| ���} | � |��} | | ||d �}|j � |��| S) Nrrrr z}All selectables passed to CompoundSelect must have identical numbers of columns; select #%d has %d columns, select #%d has %drr�r�)rrr$r) r�r�rr8r�rrrpr+r�r�r�)r r�rr�rxr�r�rrr �numcolsry�new_correlate_froms�all_correlate_fromsr�s r�rzSQLCompiler._setup_select_stacksu�� � 1�2���^�,� � �Q� � � &�E�*� � � � ��Z�(�H��(�8�9�9�G��=�3�4�4��?�?��&�!� ��&��*��F�8�9�9� � � � � � � �'� �!�4�4�)8�)C�)C� �*�*�*,� 5���E�E�"�4�4�)8�)5�5���E� "�-��"7�8�8��1�7�7��H�H��0�2� �*� * �* � � � ���)�$�$�$�� r�c �j���� �|d�|��z }�jtzr5tit ����� �jt z} |r� �_nd� d} |s|���}|r[|dz }|jr(|d��� ��fd�|D����z }n>|d�� ��fd�|D����z }n|�� ��z }|j r�j |j fd� i���} | r|d| zz }| r� �J�� � ��|j r|�j|fi���z }|jr�j |jfi���} | r|d| zz }|jr|�j|fi���z }|jr|�j|fi���z }|j�|�j|fi���z }|S) Nr�Fz FROM c �4��g|]}|j�fd��d������S)T)rxryr�r�)r��fr$r�r�r s ����r�r�z4SQLCompiler._compose_select_body.<locals>.<listcomp>`sZ��� � � ��-��,� ��#'�&,�(3� �� %� �� � � r�c�2��g|]}|j�fd�d������S)T�rxr�r�)r�r2r�r�r s ���r�r�z4SQLCompiler._compose_select_body.<locals>.<listcomp>msW������� -��,� ��#'�(3���%� ����r�r�z WHERE z HAVING )rxrXrlrprprmr��rstriprrh�_where_criteriarr��_group_by_clausesrw�_having_criteria�_order_by_clausesrxryrz�_for_update_arg�for_update_clause) r r�r�rr%ryr$r�r�� warn_linting�tr�s ` ` ` @r�rz SQLCompiler._compose_select_body;s������� �� � �-�(�(�(�� �<�4� 4� !�$�R����/�/�K��<�,�6�L�� /�#.�� ���K� �L�� !��;�;�=�=�D� � (� �J� �D��}� ��� � � � � � � � � �"'� � � � � � ����� � �������"'���� � � ��� �D�%�%�'�'� '�D� � !� (�1��1��&���4?��CI���A�� (�� �a��'�� � ��*�*�*� � � � � � � � #� ;� �(�D�(��:�:�6�:�:� :�D� � "� )�1��1��'���+1���A�� )�� �q�(�(�� � #� ;� �(�D�(��:�:�6�:�:� :�D� � *� =� �*�D�*�6�<�<�V�<�<� <�D� � !� -� �*�D�*�6�<�<�V�<�<� <�D�� r�c �\���d���fd�|D����}|r|dz }|S)Nr!c3�b�K�|])\}}|dvs|�jjk�|j�fi���V��*dS))Nr�Nr+)r��prefixrr�r s ��r�r1z1SQLCompiler._generate_prefixes.<locals>.<genexpr>�sb����� � �$�� ��{�*�*�l�d�l�>O�.O�.O� &�F� %�d� 1� 1�b� 1� 1�.O�.O�.O�.O� � r�r)r rtr�r�r+s` ` r�r�zSQLCompiler._generate_prefixes�sZ������� � � � � �(0� � � � � �� � � �c�M�F�� r�c�0�|jsdS|r�|dkr�tj��}t|j�����D]Y}|j|���\}}}|jp|j}||kp |o||dzk} |r| s�I|j|||<�Zn|j}|sdStd�|D����} |� | ��dz} | d� d�|� ��D����z } | dz } |ry|dkrst|�����D]Q}|j|���\}}}|j|=|j ||f=|j|���=�R| S)z� include_following_stack Also render the nesting CTEs on the next stack. Useful for SQL structures like UNION or INSERT that can wrap SELECT statements containing nesting CTEs. r�rc��g|] }|j�� Sr�)r�)r�rvs r�r�z2SQLCompiler._render_cte_clause.<locals>.<listcomp>�s��<�<�<��c�m�<�<�<r�r!�, c��g|]}|��Sr�r�)r��txts r�r�z2SQLCompiler._render_cte_clause.<locals>.<listcomp>�s�� >� >� >��� >� >� >r�z ) rJr&r�r��keysrLr�r�rh�get_cte_preamblerxr�rK) r r�rrrJrvr�r�rqr��is_rendered_levelrM�cte_texts r�r�zSQLCompiler._render_cte_clause�s����y� ��2� � �]�Q�.�.��#�%�%�D��D�I�N�N�,�,�-�-� +� +��04�0F��*�*�,�,�1�-� �8�X��+�9��)9��$-��$>�%�+�N� �]�Q�=N�0N�"� ��$5��� �I�c�N��S� � � +��9�D�� ��2��<�<�t�<�<�<�=�=���(�(��8�8�3�>���F�K�K� >� >�� � � � � >� >� >�?�?�?���E��� � E�]�Q�.�.��D�I�I�K�K�(�(� E� E��04�0F��*�*�,�,�1�-� �8�X��I�c�N��+�Y��,A�B��*�3�+A�+A�+C�+C�D�D��r�c��|rdSdS)NzWITH RECURSIVE�WITHr�)r r�s r�rGzSQLCompiler.get_cte_preamble�s�� � �#�#��6r�c �R�|jrtjdd���|jrdndS)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�r r�r�s r�rz!SQLCompiler.get_select_precolumns�sG�� � � � � �3� �  � � � �%�.�6�{�{�B�6r�c �f�|j|jttjfi|��}|rd|zSdS)z5allow dialects to customize how GROUP BY is rendered.z GROUP BY r�)r r7r�r!�comma_op)r r�r��group_bys r�rwzSQLCompiler.group_by_clause�sO��1�4�0� � $�i� �0B�&C� � �GI� � �� � ��(�*� *��2r�c �f�|j|jttjfi|��}|rd|zSdS)z5allow dialects to customize how ORDER BY is rendered.z ORDER BY r�)r r9r�r!rT)r r�r�rDs r�rxzSQLCompiler.order_by_clause�sO��1�4�0� � $�i� �0B�&C� � �GI� � �� � ��(�*� *��2r�c ��dS)Nz FOR UPDATEr�rRs r�r;zSQLCompiler.for_update_clauses���}r�rtrC�returning_cols�Sequence[ColumnElement[Any]]r�c ����������fd���dtj|�����D��}dd�|��zS)Nc �F��g|]\}}}}}�j� |�f||||d������S))r�r�r�r�)r�) r�r�r�r�r�r�r�r�r rts ����r�r�z0SQLCompiler.returning_clause.<locals>.<listcomp>st��� � � ����#��� )�D� (���#� �%8�#+��%� � �� � � � � r�T)�cols� RETURNING r�)r�r�_select_iterablesrx�r rtrXr�r�r�s`` `` r��returning_clausezSQLCompiler.returning_clause s}������ � � � � � � �"�2�2��4�1�.�A�A�3���# � � ��,�d�i�i��0�0�0�0r�c ��d}|j�|d|j|jfi|��zz }|j�%|j�|dz }|d|j|jfi|��zz }|S)Nr�z LIMIT z LIMIT -1z OFFSET )� _limit_clauser��_offset_clause)r r�r�r�s r�r�zSQLCompiler.limit_clause)s}���� � � +� �K�,�$�,�v�/C�"J�"J�r�"J�"J�J� J�D� � � ,��#�+�� �%�� �J����f�.C�!J�!J�r�!J�!J�J� J�D�� r�c ��|�|j}|j}nddd�}d}|j�I|j}|r)|�|��r|���}|j|fi|��} |d| zz }n|r|dz }|�X|r)|�|��r|���}|d|j|fi|���|drdnd�d |d rd nd ��z }|S) NF)r�� with_tiesr�z OFFSET %s ROWSz OFFSET 0 ROWSz FETCH FIRST r�z PERCENTz ROWS rez WITH TIES�ONLY)r��_fetch_clause_optionsrc�_simple_int_clause�render_literal_executer�) r r�r��require_offset�"use_literal_execute_for_simple_intr��fetch_clause_optionsr�� offset_clause� offset_strs r�r�zSQLCompiler.fetch_clause3sI�� � �!�/�L�#)�#?� � �/4�5�#I�#I� ��� � � ,�"�1�M�2� G��-�-�m�<�<� G�!.� D� D� F� F� �%���m�:�:�r�:�:�J� �'�*�4� 4�D�D� � '� �&� &�D� � #�2� E��-�-�l�;�;� E� ,�B�B�D�D� � �D��� �\�0�0�R�0�0�0�2�9�=�E� � �2�E�E�3�K�@�L� � �f�L�� �D� � r�c  �2�|r|j|j|<|s|�r|j�|��} |r@| r>|j�| ��dz|j�|j��z} n~|j�|j��} | s]|r[|j|vrR|�d||j��} | |�|j� d| ����z} |r"||vr|� | ||||��} | SdS)Nrr�r�) �fullnameryr�r�r�r�r�r�r�r�r�) r r�rxr�rxry� use_schemar�r�r�r�r^� anon_names r�� visit_tablezSQLCompiler.visit_table\s`�� � 6�',�~�K� �e� $� � �V� �#�}�>�>�u�E�E� �� �.� ��M�.�.�/?�@�@����m�)�)�%�*�5�5�6��� �m�)�)�%�*�5�5��)� �0� �� �&>�>�>� $� :� :��!9�%�*�!E�!�!�I��� ?� ?�� �2�2�4��C�C�!�!��C�� �U�i�/�/��0�0��� �%� 0�&�����J��2r�c �z�|r[|j�tjt |jj��t |jj������|jrd}n |j rd}nd}|jj |fd|d�|��|z|jj |fd|d�|��zdz|j j |fd|i|��zS)Nz FULL OUTER JOIN z LEFT OUTER JOIN z JOIN Tr4� ON r�) rzrxr�r�r*ryr+r�rv�isouterr��onclause)r rxrxr�r�� join_types r�� visit_joinzSQLCompiler.visit_join�s-�� � � � � $� $��!��d�i�5�6�6��d�j�6�7�7��� � � � �9� !�+�I�I� �\� !�+�I�I� �I� (�D�I� (�� �!�{� � �>D� � �� �,�d�j�+���!�{���>D���  �� �/�d�m�.����"-��17��� � r�c����fd�|j���D��}|j|vr(��||j||jd��}||fS)Nc�B��i|]\\}}}|d�jjfv�||��Srr)r�r�r�r#r s �r�r`z1SQLCompiler._setup_crud_hints.<locals>.<dictcomp>�sC��� � � �+� ���)��3�� � 1�2�2�2� �9�2�2�2r�T)rryr�r�)r rt� table_text� dialect_hintss` r��_setup_crud_hintszSQLCompiler._setup_crud_hints�s|��� � � � �/3�{�/@�/@�/B�/B� � � � � �:�� &� &��3�3��D�J� �d�j�(A�4���J��j�(�(r�r�rKrCc�D�|jj}|j}|j}|�dS|jr!|j�|jd��}n |j�|jd��}||zr|S|j r+tj d|d�d|jj �d����dS)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_explicitr8r2r�)r r�� sentinel_opts�sentinel_characteristics� sent_cols�bitmasks r��_get_sentinel_column_for_tablez*SQLCompiler._get_sentinel_column_for_table�s���� �G� �#(�#I� �,�4� � � ��4� #� .� ��7�;�;�(�A�1���G�G��;�?�?�(�A�1���G� �7� "� �� � #� /� ��)� @�)�A�,� @� @��<�$� @� @� @� � � ��tr�rX�compiled_parameters�%List[_MutableCoreSingleExecuteParams]�generic_setinputsizesrM� batch_sizer?rAr�r�� Iterator[_InsertManyValuesBatch]c #� ����1�2�3�4�5�6�7�8�9�:K��j}|�J�|jsd�1ntj|j��1t ���} |jr�jjsd} d} n,�jjr|r�j r|j �|j rd} d} nd} d} | r`ttdt�|����d��D]1\} \�9} t|�9��9g�1r �1| ��gngd| | || � � V��2dS|r!t!j�jj|����:nd�:|j}�:r �:|��}d|�d�}|�|d��}�jj}|rCt �j��}t |j��}||z }t3|||z |z��}td t5�����}td t5|����}d}d} | |z| |zrdnd z}|j}|�J��:r�:fd �|D��}d x�6�7�js��jr�j�4ni�4t;�d ��}�4�fd ��3|jrd }nd}dd��3fd�|D�����|�d�}|� �4fd�|D����}�fd�|�!|��D��}d�5n�d}t;��}i}|jrd|�d��5nd|�d��5t;���2|jD]}�2�"|d����2r_�j#}|�J��2fd�t|��D��} t3| ���6tI| ��dz�7t | ���7�6z ksJ��j%r2tMj'�j(��}!tMj)|!�d�d�5���5|�r�|d |�}"|d |�}#g|d |�<g|d |�<|r|}$nt |"��}$�r%d��fd�tU|$��D��D��}�j�r8|j+}%|%t |"d ��krdx}&}'|"}(n/|"d d�6�}&|"d �7d�}'�6�7fd�|"D��}(|jr7d��5fd�t|"��D����dd�})n �5|$zdd�})�j%rE|%d kr?|'rJ��6dz}*|%|$z|*z}+tY�fd�tU|*|+��D����},|)|,z})|�d|)��}-tYtZj.�/|(����}.|&|.z|'z}.n�g}/|�0��}.t|"��D]�\�8�9|�d tc�8����}0|jr#|0�d!tc�8����}0|/�2|0��|.�"�8�9fd"�|D������|�dd�|/����}-t|-|.||"�1r�1fd#�|#D��ng|$| ||d� � V�| dz } |���dSdS)$NTFzKSequence[Tuple[_DBAPISingleExecuteParams, _MutableCoreSingleExecuteParams]]r�r�rr�__EXECMANY_TOKEN__zList[Sequence[Any]]rc�8��g|]\}}}}||�|��|f��Sr�r�)r�r�r0r�st�rsts �r�r�zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<listcomp>�sB���"�"�"�&�C��d�B��c�3�3�t�9�9�b�)�"�"�"r�c���|D]E}��||��}|��jd|iz�jd|�d�iz��}�F|S)Nr��__EXECMANY_INDEX__)r�r�r3)rF� formattedr0rEr s ��r��apply_placeholderszISQLCompiler._deliver_insertmanyvalues_batches.<locals>.apply_placeholders�sq������C�,�0�0��c�:�:�C� )� 1� 1��)�V�S�M�9��)�!�c�#=�#=�#=�>�?�!�!�I�I� !� r�z, _IMV_VALUES_COUNTERr�r�c3�:�K�|]\}}}}�||��V��dSr r�)r�rr�� bind_keysr�s �r�r1z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>�sL�����6�6�.�A�q�)�Y�#�"�9�i�8�8�6�6�6�6�6�6r�c3�X�K�|]$\}}}}|D]}��||��V���%dSr r�)r�rr�r0rEs �r�r1z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>�sf�����4�4�&�A�q�!�Y�$�4�4��#�&�&�s�C�0�0�4�4�4�4�4�4�4r�c�.��i|]}|�d|��S)rr�)r�r0r's �r�r`zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<dictcomp>�s4��������Z��]�3�'���r�z, _IMV_VALUES_COUNTER), z), rc�"��h|] \}}|�v� |�� Sr�r�)r�r[r��all_names_we_will_expands �r�r�z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<setcomp>�s3���(�(�(�!��T��7�7�7��7�7�7r�z\d+r�c� �g|] \}}}|||f�� Sr�r�)r��new_key�len_r�s r�r�zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<listcomp>�s5��+�+�+�*���s��d�C�(�+�+�+r�c3�>�K�|]}�D]\}}}|�d|��||fV���dS)rNr�)r�rxr0r�r�r�s �r�r1z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>�si�����/�/�!�.C�/�/�+�C��s� �)�)�%�)�)�4��5�/�/�/�/�/�/�/r�r�c3�,�K�|]}|���V��dSr r�)r�r_�expand_pos_lower_index�expand_pos_upper_indexs ��r�r1z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>sC�����&�&���0�1G�G�H�&�&�&�&�&�&r�c3�d�K�|]*\}}��dt|����V��+dS)�_IMV_VALUES_COUNTERN)r�r�)r�rr�executemany_values_w_commas �r�r1z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>sX����� � �!%��1�7�>�>� 5�s�1�v�v��� � � � � � r������c3�.�K�|]}�j�|��V��dSr r�r�rr s �r�r1z@SQLCompiler._deliver_insertmanyvalues_batches.<locals>.<genexpr>4sE�����&�&�� �>�C��C�C�&�&�&�&�&�&r��EXECMANY_INDEX__r�c�,��i|]}|�d����|��S)�__r�)r�r0r�params ��r�r`zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<dictcomp>Us)���N�N�N�s�C���1����c� �N�N�Nr�c�&��g|] }�|����Sr�r�)r�rr�_sentinel_from_paramss �r�r�zASQLCompiler._deliver_insertmanyvalues_batches.<locals>.<listcomp>cs%���H�H�H�2�*�*�2�.�.�H�H�Hr�)3rArFr?r]r�r;r��supports_default_metavalue�supports_multivalues_insertr�rDrBrrr�rJ� functools�partialr�r�r<r��insertmanyvalues_max_parametersr/r>�minr�rcrErprHrxr>rrxr+r\r:rRrSr5r��ranger@r3r�r�� from_iterablerrr�r�);r r&r'r�r�r�rAr��imv� lenparams�use_row_at_a_time� downgradedrR�compiled_param�imv_single_values_expr�executemany_values� max_params�total_num_of_params�num_params_per_batch�num_params_outside_of_batch�batches�compiled_batchesrNrSr>�all_keys�imv_values_counter�formatted_values_clause�keys_to_replace�base_parametersr�r+�all_expand_positions�escapedrO�compiled_batchrQ�num_ins_params�extra_params_left�extra_params_right�batch_iterator�expanded_values_stringr�rjr�rKrL�replaced_values_clauses�fmvr�r�r�rEr�r�r�rr�r�s;` ` ` @@@@@@@@@@r��!_deliver_insertmanyvalues_batchesz-SQLCompiler._deliver_insertmanyvalues_batchess ������������������$�������&� �$(� !� !�$,�$7��(�%� !�� �O�O� � � � �t�|�'N� �!%� ��J�J���9� � #� ��$� ��%�-��1N�-� !%� ��J�J� %� ��J� � �5>��a�� �$7�8�8���� 6�6� � �1��1�5�.�-���)��G�1� �.�.�~�>�>�?�?�����+�������� �F� � ��#�� �7�%9����C�C� �C�!$�!7�� � A�%(�S�)?�%@�%@� "�:�!7�:�:�:���%�%�&8�:N�O�O� ��\�A� � � �"%�d�o�"6�"6� �#&�s�'=�#>�#>� �#�&:�:� (����"=�=�+�,���J��,�d�:�.>�.>�?�?��� !�4�(;�#<�#<� � ��HL����!�Z�/��Z�'� .�A�A�Q� � �!�3��!�-�-�-� � �"�"�"�"�*<�"�"�"� � ;<�;��!7���M ��&� (�%)�%<�"�"�%'�"��:�a�=�)�)�H� !� !� !� !� !� !��'� (�%<�"�"�%'�"�''�D�I�I�6�6�6�6�2D�6�6�6�-�-�''�"�''�''�''� #� '�3�3�4�4�4�4�*<�4�4�4���O� ����#�.�.��?�?����O�*,� &� &�&(� #�!�e�e�O� �O��'� M�H�.�H�H�H�+�*�.M�1G�-L�-L�-L�*�14��� $��.� 9� 9��(�/�/��Q��8�8�8�8� (� �"�.� �"�.�.�.�(�(�(�(�%.�{�%;�%;�(�(�(�$� *-�-A�)B�)B�&�),�-A�)B�)B�Q�)F�&��,�-�-�-�0F�F�G�G�G�G��"� ��)�D�$G�H�H��-/�V��$�$�$�d�,F�.�.�*��D ��A�j�L�)�E�-�a� �l�;�N�$&�G�A�j�L� !�-/� �Q�z�\� *�� 0�%/�"�"�%(��Z�Z�"�$� �+�+�/�/�/�/�%*�+=�%>�%>�/�/�/�+�+�+�'���X �!$�!B�� "�S��q��]�]�2�2�=?�?�%�(:�%*�N�N�(-�a��1H�2H�1H�(I�%�).�q��2H�2I�2I�)J�&�&�&�&�&�&�!&�&�&�&�N� �+� ���� � � � �)2�%�(8�(8�  � � ��� �r�c�.�*�*�4�6H�H��r�c�.�*��&�P�>�A�+=�+=� 2�1�1�1�2�Q�6�E�(�,>�?�%�G�C�!&�&�&�&�&�!&�u�c�!2�!2�&�&�&�!�!�I�.D�i�-O�*�%.�%6�%6�(�*@�&�&�"�',��O�1�1�.�A�A�'�'�#� &�)�*�(�)�$�#�+-�'�&5�&:�&:�&<�&<�#� )�%� 0� 0� � �H�A�u�1�9�9�*�C��F�F���C��/�I�!�k�k�*?��Q���H�H��+�2�2�3�7�7�7�'�.�.�N�N�N�N�N�o�N�N�N�����&/�%6�%6�(��I�I�5�6�6�&�&�"� )�"�#�'��-��H�H�H�H��H�H�H�H��"���'���� � � � ��M�H�I�D �D �D �D �D r�c �x ��|j|�fi|��}|j}|�||d<d}n�j }|r#d�_�js|�_�js|�_�j�t��t��|d���d}d}�jr|�g}tj �|||fd|i|��}�jr7|�5t|��}�j r�j ��xj |z c_ n|�_ |j} | sE�jjs9�jjs-�jjs!t'jd�jjz���|jr^�jjs!t'jd�jjz����js|jr|jrt'jd ���|j} n|j} �j} �jj} d } |jr| �j||jfi|��z } | d z } | �|j��} |j r��!|| ��\}} |j"r��#||��| | z } | s| s%| d d �$d�| D����zz } |j%}d}d}d}�jp|j}|r�|j&}|��|sJ�d�| D��}g}|D]B}||vrd}n9��'|��}|||vrd}n|�|���C|�3�jj(tRj*zrd}n|dj+r Jd���tY|��tY|��z}��-|||���}�j.r| d|zz } nd}|j/�w�j0�jddfddi|��}�j1rE�jj2r9|st�j��nd}| d��3|d����|��z } �n�| d|zz } �n�| s]| r[| dz } |rRtid�jj5tmd| ��||j|j7du||rt|��nd|�� � �_8�nn|jr,| dd �$d�|j9D������z } �n;d �$d�tmd| ��D����}|�r|r��jj(tRj:zr�|j;s�d}�jj(tRj<z}d �$d�t{| ��D����}|r/d �$�fd�t{| ��D����}n|}| d |�d!|�d"|�d#�z } n d}| d$|�d%�z } tid|tmd| ��||j|j7du||rt|��nd|||�&� � �_8n | d$|�d%�z } |j7��j0|j7fi|��}|r| d|zz } |r�j.s| d|zz } �j1r>�jj2s2|st�j��nd}��3|d���| z} �j�>d��| S)'Nr{FTr�rrizWThe '%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�c��g|] \}}}}|�� Sr�r�)r�rrs r�r�z,SQLCompiler.visit_insert.<locals>.<listcomp>�s ��>�>�>�-�!�T�1�a��>�>�>r�c��i|] \}}}}||�� Sr�r�)r�r�r� param_namess r�r`z,SQLCompiler.visit_insert.<locals>.<dictcomp>�s2��"�"�"�.��Q��;���"�"�"r�zTsentinel selection rules should have prevented us from getting here for this dialect�r�r!r�r"rrqr�z DEFAULT VALUESr=)rArBrDrErGz VALUES c3�ZK�|]&}dd�d�|D����zV��'dS)rr�c3�$K�|] \}}}}|V�� dSr r��r�rr�s r�r1z5SQLCompiler.visit_insert.<locals>.<genexpr>.<genexpr>gs*���� L� L�>�1�a���� L� L� L� L� L� Lr�Nr)r��crud_param_sets r�r1z+SQLCompiler.visit_insert.<locals>.<genexpr>es\������'���y�y� L� L�^� L� L� L�L�L�N������r�c��g|] \}}}}|�� Sr�r�r�s r�r�z,SQLCompiler.visit_insert.<locals>.<listcomp>ms0�����&��1�e�Q����r�c3�&K�|] \}}d|��V�� dS��pNr�)r�rrs r�r1z+SQLCompiler.visit_insert.<locals>.<genexpr>�s=����)�)�$(�A�q��A���)�)�)�)�)�)r�c3��K�|]E\}^}}��|j|j��j��d|����V��FdSr�)r�r�r�r�)r�rr�rr s �r�r1z+SQLCompiler.visit_insert.<locals>.<genexpr>�st�����4�4� !-��9�C�!� !�1�1� #�� #�� @� @��� N� N� '�A�����4�4�4�4�4�4r�z SELECT z FROM (VALUES (z)) AS imp_sen(z#, sen_counter) ORDER BY sen_counterz VALUES (r) r;r<r>r@rArBrDrErFrGrH)?rsr&r�r&r�rr�rprcr�_get_crud_paramsr�r:rG� single_paramsr��supports_default_valuesr��supports_empty_insertr8r�r��_has_multi_parametersr�r,� _returning�_sort_by_parameter_orderr�r�r�� format_tabler�rr~r�r�rx�use_insertmanyvalues�use_sentinel_columnsr<r�rWr`�_insert_sentinelr�r`r0r�r�rJ�cte_follows_insertr�r:�default_metavalue_tokenr�_post_values_clauserA�all_multi_paramsrb�is_default_metavalue_onlyrcrr|) r � insert_stmtrir{r�rr��counted_bindparam�crud_params_struct�crud_params_singler�r�r�r|rr��named_sentinel_params�add_sentinel_colsrGrX�_params_by_col�_add_sentinel_col� param_namer`� select_textr�r��embed_sentinel_value�render_bind_casts�colnames�colnames_w_cast�post_values_clauses ` r�� visit_insertzSQLCompiler.visit_insertos� ���;� �:� �� � �!#� � � �$�-� � � #�!-�B�~� ��H�H��:�~�H� � 3� �D�M��)� 7�)6��&��%� 3�%2��"� � ���#&�5�5� #���)� � � � � ���!�� �?� #�|�3� !#� �!�2� � � � �  � � 0�  � �  � �� �?� ?�0�<� #�$5� 6� 6� ��"� ?��)�5��*�*�.?�?�*�*�*�->�D�*�/�=��#� ��L�8� ��L�;� ��L�6� � �"��!�\�.�/��� � � .� B��<�;� ��&�1�37�<�3D�E���� �'� �+6�+A� ��6� ��&�I����"4�!A� � �!3�!A� ��=��"&�,�"F���� � � � �+�D�+��[�2���68��� �D� �����*�*�;�+<�=�=� � � � L� �2�2�;� �K�K�M�A�z� � (� =� � +� +�K�� <� <� <� � ��� � �%<� � �G�d�i�i�>�>�+=�>�>�>���� �D� 2�F��9=�� ��!���0�J�K�4J�� �H $� 2� G� � �,�+�+�+�+�"�"�2D�"�"�"��)+�%�):� =� =�%�(��>�>�04�-���!%�!C�!C�)�"�"�J�"��8I�)J�J�J�04�-���)�0�0��<�<�<�<�(�0�� �G�6�H�I��-1�)�)�$5�Q�#7�#H���D���H�"&�n�!5�!5��=N�8O�8O�!O��#�4�4���$,� 5� � � � �-� /���.�.�.��� $� � � � )�&�$�,�� �2��3�4���BF��JL���K��y� ,�T�\�<� ,�7?� I��D�J����T� ����+�+�&3�04�,���� �K� ������ �+�+���#�z A�(?�z A� �%� %�D�#� �):���L�8��9�;M���&�#�<�$�7�t�C�%6�2C�J��-�.�.�.��&7�#*�*�*��&��&� 0�d A� �D�� � ���+=�*M�������� �D�D�)-� � ���*.�9�*�+�+����)�)� %�$�Q A�%�6E�� �G�6�M�N�6E�0�I�6E�,0�(�� �G�6�N�O�&� $�y�y�)�)�,5�6H�,I�,I�)�)�)� � �H�)�3�+/�)�)�4�4�4�4� 1:�:L�0M�0M� 4�4�4�+�+���+3���/�?�/�/�$=�/�/�&.�/�/�/��D�D�,1�(��D�(A�D�D�D�D�D�):�$)�'@�'+�9�*�(�(�3D�#�<�$�7�t�C�%6�2C�J��-�.�.�.��(=�&7�)=�)*�*�*��&�&�0�@�$=�@�@�@�@�� � *� 6�!-����/�"�"�35�"�"� �"� 1���0�0�0�� � +�D�$B� +� �C�*�*� *�D� �9� �T�\�<� �3;�E�C�� �O�O�O��M��'�'�"/�,0�(���� � � � ���r����� r�c��dS)z3Provide a hook for MySQL to add LIMIT to the UPDATENr�)r � update_stmts r��update_limit_clausezSQLCompiler.update_limit_clause�����tr�c��dS)z3Provide a hook for MySQL to add LIMIT to the DELETENr�)r � delete_stmts r��delete_limit_clausezSQLCompiler.delete_limit_clause�r r�c �,�d|d<|j|fddi|��S)z|Provide a hook to override the initial table clause in an UPDATE statement. MySQL overrides this. Trxr�r�)r r � from_table� extra_fromsr�s r��update_tables_clausez SQLCompiler.update_tables_clause�s-����8� �,�z�,�T�E�E�$�E�"�E�E�Er�c � �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 rr� from_hintsr�s r��update_from_clausezSQLCompiler.update_from_clause�s��"� %� � � r�c ���|j||fi|��}|j}|�||d<d}n|j }|r#d|_|js||_|js||_|jtzr5tit����}|jtz}|r||_ nd}d}|j }t|��} | rEtt|j������fd�|D��} ��|��} n g} |jh} |j�| | |d���d} |jr| |j||jfi|��z } |j||j| fd|i|��} t+j||||fi|��}|j}|jr|�|| ��\}} nd}|jr|�||��| | z } | dz } | d �d �t;d |��D����z } |js|jr1|j r*| d |�!||jp|j|� ��zz } |r"|j"||j| |fd|i|��}|r| d |zz } |j#r|j$|j#fd|i|��}|r| d|zz } |�%|��}|r| d |zz } |js|jr1|j s*| d |�!||jp|j|� ��zz } |j&r1|stO|j��nd}|�(|���| z} |r|�J�|�)d���|j�*d��| S)Nr{FTc���g|]}|�v�|�� Sr�r�)r�r2� main_fromss �r�r�z,SQLCompiler.visit_update.<locals>.<listcomp>#s*���"�"�"��!�:�*=�*=��*=�*=�*=r�r�zUPDATE r�z SET r�c3�0K�|]\}}}}|dz|zV��dS)�=Nr�)r�rrr�s r�r1z+SQLCompiler.visit_update.<locals>.<genexpr>SsG���� � �!��4��� �3�J�� � � � � � � r�zList[Tuple[Any, str, str, Any]]r!r�� WHERE r��UPDATE�r�r�)+rsr&r�r'r�rrXrlrprprmr�� _extra_fromsrr+r�r�r�r�r�rrr�r�rr~r�r�rxrr,r�r0r`rr6rr rJr�r�r�r|)r r r{r�rr�r�r<r� is_multitable�render_extra_fromsrr�r|r�� crud_paramsr}�extra_from_textr=r�r�rs @r�� visit_updatezSQLCompiler.visit_updates���:� �:� �� � �!#� � � �$�-� � � #�!-�B�~� ��H�H��:�~�H� � 3� �D�M��)� 7�)6��&��%� 3�%2��"� �<�4� 4� !�$�R����/�/�K��<�,�6�L�� /�#.�� ���K� �L�#�0� ��[�)�)� � � 2��]�;�+<�=�=�>�>�J�"�"�"�"�&�"�"�"� �)�.�.�{�;�;�O�O�!#� �*�0�1�O� � ���#2� /�)� � � � � ��� � � � �+�D�+��[�2���68��� �D�/�T�.� � � � � � �$�  � �  � � �"�2� �+�}�h� � �:<� � ��)�6� � � � !�(,�(>�(>��Z�)�)� %�M�:�:�!�M� � (� =� � +� +�K�� <� <� <� � ��� ���� �� � � � �%)�1�;�&�&� � � � � � �� � "� �k�&<� ��-� ���d�3�3���+�E�{�/E�(0�4������ � .�5�d�5���!�"�� �� (� � � ��O�� .���o�-�-�� � &� &�1��1��+���9D��HJ���A�� &�� �A� �%���/�/� �<�<� � � '� �C�,�&� &�D� � #� �'2�'=� ��0� � �C�$�/�/���'�A�;�+A�$,�0���� �D� �9� O�3;�E�C�� �O�O�O��M��*�*��*�G�G�$�N�D� � 1��*�*�*� � � �x� � 0� 0� 0� � ���r����� r�c � �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�rs r��delete_extra_from_clausez$SQLCompiler.delete_extra_from_clause�s��"� %� � � r�c �$�|j|fddd�|��S)NT)rxr�r�)r r rrr�s r��delete_table_clausezSQLCompiler.delete_table_clause�s3��,�z�,� � ��d� � �.0� � � r�c �,�|j||fi|��}|j}|�||d<d}n|j }|r#d|_|js||_|js||_|jtzr5tit����}|jtz}|r||_ nd}d}|j }|j h�|��} |j�| | |d���d} |jr| |j||jfi|��z } | dz } |�||j ||���} nJ#t&$r=|�||j |��} |r|�|j |���} YnwxYwt+j||||fi|��|jr|�|| ��\} } nd} |jr|�||��| | z } |js|jr1|jr*| d|�||jp|j|� ��zz } |r"|j||j || fd |i|��}|r| d|zz } |j r|j!|j fd |i|��}|r| d |zz } |�"|��}|r| d|zz } |js|jr1|js*| d|�||jp|j|� ��zz } |j#r1|stI|j��nd}|�%|� ��| z} |r|�J�|�&d ���|j�'d��| S)Nr{FTr�zDELETE �FROM )r�r!r�r�rr��DELETErr�)(rsr&r�r%r�rrXrlrprprmr�rr�r�r�r�r�r(� TypeErrorr�rr�rr~r�r�r,r�r0r`r&r6rrrJr�r�r�r|)r r r{r�rr�r�r<rrr�r|rr}r#r=r�r�s r�� visit_deletezSQLCompiler.visit_delete�s���:� �:� �� � �!#� � � �$�-� � � #�!-�B�~� ��H�H��:�~�H� � 3� �D�M��)� 7�)6��&��%� 3�%2��"� �<�4� 4� !�$�R����/�/�K��<�,�6�L�� /�#.�� ���K� �L�#�0� �&�,�-�3�3�K�@�@�� � ���#2� /�)� � � � � ��� � � � �+�D�+��[�2���68��� �D� ���� M��1�1���!��'� 2���J�J�� � M� M� M��1�1��[�.� ���J�� M��L�L��!2� �L�L�L���� M���� ��d�K���O�O�B�O�O�O� � � !�(,�(>�(>��Z�)�)� %�M�:�:�!�M� � (� =� � +� +�K�� <� <� <� � ��� � #� �'2�'=� ��,� � �C�$�/�/���'�A�;�+A�$,�0���� �D� � .�;�d�;���!��� �� (� � � ��O�� .���o�-�-�� � &� &�1��1��+���9D��HJ���A�� &�� �A� �%���/�/� �<�<� � � '� �C�,�&� &�D� � #� �'2�'=� ��0� � �C�$�/�/���'�A�;�+A�$,�0���� �D� �9� O�3;�E�C�� �O�O�O��M��*�*��*�G�G�$�N�D� � 1��*�*�*� � � �x� � 0� 0� 0� � ���r����� s�<D�AE"�!E"c �<�d|j�|��zS)Nz SAVEPOINT %s�r��format_savepoint�r �savepoint_stmtr�s r��visit_savepointzSQLCompiler.visit_savepoint&s���� � >� >�~� N� N�N�Nr�c �<�d|j�|��zS)NzROLLBACK TO SAVEPOINT %sr/r1s r��visit_rollback_to_savepointz'SQLCompiler.visit_rollback_to_savepoint)s&��)�D�M�,J�,J� �- �- � � r�c �<�d|j�|��zS)NzRELEASE SAVEPOINT %sr/r1s r��visit_release_savepointz#SQLCompiler.visit_release_savepoint.s&��%�� �(F�(F� �) �) � � r�)r�r]r&r�r�r�rVr*rWrrXrjrYrZr�r)rr=)rr+)rr�)rr�)rr�)NT)r�r�r�rrr%)NNTNTF)r�r�r�r�r�rr�r�r�rrhrrr\�F)r'r\rirrr%)rr9)NFFNr�)NTr�N)r�r�r�r�r�rr�r�r�r�r�rrr�r )NF)rKrZr�r�r�rrr�)FN�Nr�)NFNN)FFFFF)rXr�r�rErr�)r�r�rr�)FFNNNN)r�r�r8rr9rrer=r:rfrgrhrir?r�rrr�)rvrNrxrrxrryrzr{r|r�r}rqr~r�rrr=)FFFNFFNN) r�r�r�r�r�r�rr�rr )NNNTFFT)FFNNNFN)r�r!rr(� rtrCrXrYr�rr�rrr�)NFF)FFFNTNN)r�rKrrC)r&r�r'rXr�r�r�rMr�r?rArr�r�rr�rr)�r�rrr� EXTRACT_MAPrPr&r�r"rr��COMPOUND_KEYWORDSrtr%r&r'r)r*r,r-r0r1r2r6r7r8r9r:r;r<r>r@rArB� frozensetrCrDr�rErA�postfetch_lastrowidrFr+rGrHrIrRrTr"r��patternr�r�r�rPrkr�r8r��ro_memoized_propertyr�r�r�r��memoized_propertyr��memoized_instancemethodr�� contextlib�contextmanagerr�r{rzr�r�r�r�r�r�r�r|�preload_moduler6r<rXrfrhrsryr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr rrrr&r-r1r5r<rFrIrNrSrYrUrirfrcr~rzr"r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�rrr r rrrrrrrr�rrrr(r*r.r1r3rEr�r/rrr=r�rdr�r�r$�_CTEOptsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rdrr�rrr'rrrr�r�rGrrwrxr;r`r�r�rsryr~r-� CLIENTSIDErWra�SENTINEL_DEFAULT�NONEr^r_r�r�r]r�r�r�rr rrrr$r&r(r-r3r5r7r�r�r�rr s��������� �K� ����������� � � � �� � � � ��:/�.�.�.�6�6�6�6� �F�)���H������H������H������ +�*�*�*�%�.0�O�/�/�/�/��.0�O�/�/�/�/�$�BF��E�E�E�E���K�����(�(�(�(�I�-�-�-�-�6�%�$�$�$�4�',��+�+�+�+��5:�+�9�9�9�9�� "�O�!�!�!�!������B�!�!�!�!��(�'�'�'�� .�-�-�-�� &+��*�*�*�*��"�O�!�!�!�!��"��!�!�!�!�� ).��-�-�-�-�� !�N� � � � �� !&��%�%�%�%��=A� �@�@�@�@��+/��.�.�.�.�� 6:��9�9�9�9�59��9�9�9�9�=A��A�A�A�A�<E�I�K�K��G�G�G�G�� :C�����D�D�D�D�� 8<���F�F�F�F�� ��� ��%� ��  �  �  �  �� (,�K�+�+�+�+��.2��1�1�1�1�.2��2�2�2�2��F�����,�,�,�,�3�2�2�2�G�F�F�F�����&�B�J�'L�M�M��"�� �#4�5�5��$�"�*� � $�F�F�'<�'D�F�F�����#�#��[�#��C�C��[�C�)-�/3� %�%�59�P�P�P�P�P�d�=�=�=��X�=�$ ��������0�(�(��X�(�� M� M��X� M�D�G�G��X�G� �������� �!����"�!��.�������.9�9�9�vG�G�G�R �� � � ��� �8#�#�#�����X�� 6:�!� � � � � �26:�GK�!�'+�� %�~�~�~�~�~�@ �!�$�$�"�!�$�L� 3� 3��X� 3� %�C�C�C�C�C�J�T��3�4�4� � �5�4� �4�3�3�3� �������� ���T��3�4�4�P�P�5�4���P�d ���T��3�4�4�,�,�5�4���,�\���>�>�>�@O�O�O�O�O�O�O�.3�- �- �- �- �`.3�+�+�+�+�`�!�#�"��/�/�/�/�b � � � /�/�/�;?�"�.0�EI� 9O�9O�9O�9O�9O�vA�A�A������� � � ���� ���  � � � �405�2�2�2�2�h������ ���  � � ����"@�@�@�L�L�L����&���&K�K�K� � � �( �( �( �T � � �: � � �  � � �  � � �7�7�7�;?�,�,�,�,�,�\8�8�8� � � � C�C�C�04�?�?�?�?�B3�3�3� -�-�-�AC�$�$�$�$�L���6���"B�B�B�B�B�B� � � �  � � �4�4�4�$ � � �;?�H*�H*�H*�H*�TM1�M1�M1�d��� � 6�6�6�6�p8�8�8� � � � � � � � � �  � � � 05�����*G�G�G�G�G�G� ��I�I���I�J�J�J�A�A�A� E�E�E� B�B�B�F�F�F�A�A�A� E�E�E� B�B�B�F�F�F�A�A�A� E�E�E� B�B�B�F�F�F�  �  �  �  �  �  �A�A�A�E�E�E� � � �  � � � � � �  � � �  � � �$��"�� �c�c�c�c�J$�$�$� $�!%� D�D�D�D�B#�#�#�J � � �����*$�$�$�$� #��&*�48�48�15�A�A�A�A�A�FC�C�C���.2�&*�,0�(;� �(;�E�(B�(B�I�I�I�I�I�V3�3�3�0�0�0� ��������b�b�b�b�H0�0�0�?�?�?� � � � � "� "� "�$�$�$�$�L9�9�9�(�(�(� � � � �4EI� � � � �8�� �"� � %��bJ�bJ�bJ�bJ�H��� ���������$�$�$�.�-�-�-� � � �1�t�1������ -�� � � � �/L� M� � �� ,1�����:'+��*�*�*�*���������K�K�K�K�Z !� !� !� !�2�2�2�h]�]�]�~���� %�3�3�3�3�j��� 7�7�7� � � � � � ����1�1�1�1�@�����+0� '�'�'�'�X������!%�.�.�.�.�` � � � �< )� )� )�"(:�t�'9� ,� 7�,�>� ,� =�,�>� ,� 1�,�>� ,� 5�,�5� ,� 5�,�5� �(�(�$�&$D�#I�#I� ,� 1�,�:� �$�$� �<�<�<�<�|Y�Y�Y�Y�x AE�p�p�p�p�d ������F�F�F�  �  �  �K�K�K�K�Z � � �  � � � A�A�A�A�FO�O�O� � � �  � � � � r�rc���eZdZdZd�Zejd���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��dS)Nz<name unknown>r�r�s r�r�z$StrSQLCompiler._fallback_column_nameHs���r�zsqlalchemy.engine.urlc �h��|jdkr�tjj}|j�|j�������}|�|d|���}t|t��s|j |fi|��St��� ||��S)Nr�)rY) �stringify_dialectr&r2� engine_url�URLr�� get_dialect�statement_compilerr�rKr�r�r�)r r�r�r��urlr��compilerr�s �r�r�z,StrSQLCompiler.visit_unsupported_compilationKs���� � $� � 1� 1��.�+�C�M�c�g�n�n�W�%>�?�?�K�K�M�M�O�O�G��1�1���4�2���H��h��7�7� 7�'�x�'��6�6�2�6�6�6��w�w�4�4�W�c�B�B�Br�c �V�|j|jfi|���d|j|jfi|���d�S)Nrr )r�ryr�r�s r��visit_getitem_binaryz#StrSQLCompiler.visit_getitem_binaryYsJ�� �D�L��� +� +�� +� +� +� +� �D�L��� ,� ,�� ,� ,� ,� ,� � r�c � �|j||fi|��Sr �rVr�s r��visit_json_getitem_op_binaryz+StrSQLCompiler.visit_json_getitem_op_binary_���(�t�(���@�@�R�@�@�@r�c � �|j||fi|��Sr rXr�s r��!visit_json_path_getitem_op_binaryz0StrSQLCompiler.visit_json_path_getitem_op_binarybrZr�c �>�d|j�|���d�S)Nz<next sequence value: �>)r��format_sequencerls r�rfzStrSQLCompiler.visit_sequencees%�� O�T�]�%B�%B�8�%L�%L� O� O� O� r�rtrCrXrYr�rr�rrr�c �t���fd�tj|��D��}dd�|��zS)Nc �B��g|]}��d|ddi����S)NTFr��r�r�r s �r�r�z3StrSQLCompiler.returning_clause.<locals>.<listcomp>rs?��� � � �� � %� %�d�A�t�U�B� ?� ?� � � r�r]r�)rr^rxr_s` r�r`zStrSQLCompiler.returning_clausejsO��� � � � ��+�N�;�;� � � ���d�i�i��0�0�0�0r�c �^����d�d<dd����fd�|D����zS)NTrxr*r�c3�8�K�|]}|j�fd�i���V��dS�ryNr��r�r=rr�r s ���r�r1z4StrSQLCompiler.update_from_clause.<locals>.<genexpr>|sQ�����# �# �� !�A� �� B� B�� B�r� B� B�# �# �# �# �# �# r�rrs` ``r�rz!StrSQLCompiler.update_from_clausexs]�������8� �����# �# �# �# �# �# � �# �# �# � � � � r�c �^����d�d<dd����fd�|D����zS)NTrxr�c3�8�K�|]}|j�fd�i���V��dSrer�rfs ���r�r1z:StrSQLCompiler.delete_extra_from_clause.<locals>.<genexpr>�sQ����� � �� !�A� �� B� B�� B�r� B� B� � � � � � r�rrs` ``r�r&z'StrSQLCompiler.delete_extra_from_clause�s]�������8� ��d�i�i� � � � � � � � � � � � � � r�c ��dS)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�r�s r�r.z+StrSQLCompiler.visit_regexp_match_op_binary�s��,�t�,�V�\�H�H�R�H�H�Hr�c � �|j|dfi|��S)Nz <not regexp> rlr�s r�r1z/StrSQLCompiler.visit_not_regexp_match_op_binary�s ��,�t�,�V�5E�L�L��L�L�Lr�c �X�d|jj|fi|���d|jj|fi|���d�S)Nz<regexp replace>(r�r)ryr�r�r�s r�r3z-StrSQLCompiler.visit_regexp_replace_op_binary�sN��� *�F�K� *�4� 6� 6�2� 6� 6� 6� 6� +�F�L� +�D� 7� 7�B� 7� 7� 7� 7� � r�c �X�d|jj|fi|���d|jj|fi|���d�S)Nz TRY_CAST(r�r)r+r�r�)r rr�s r��visit_try_castzStrSQLCompiler.visit_try_cast�sN��� *�D�K� *�4� :� :�6� :� :� :� :� .�D�O� .�t� >� >�v� >� >� >� >� � r�r:)r�rrrr�r&rEr�rVrYr\rfr`rr&r�r�r.r1r3rpr�r�s@r�rKrK4sE���������& � � ��T��0�1�1� C� C� C� C�2�1� C� � � � A�A�A�A�A�A� � � � 1� 1� 1� 1� � � � � � �%�%�%����I�I�I�M�M�M� � � �  � � � � � � r�rKc�z�eZdZdZer dCdDd �Zejd���Zejd���Z dEdFd�Z d�Z d�Z d�Z d�ZdGd�Z dHd�Zd �Zd!�Zd"�Z dId#�Zd$�ZdGd%�Zd&�Zd'�Zd(�Zd)�Zd*�Zd+�Zd,�Zd-�ZdHd.�Zd/�Z d0�Z!d1�Z"d2�Z#d3�Z$d4�Z%d5�Z&d6�Z'd7�Z(d8�Z)d9�Z*d:�Z+d;�Z,d<�Z-d=�Z.d>�Z/d?�Z0d@�Z1dA�Z2dB�Z3dS)J� DDLCompilerT.r�r]r&rAr�r�r�rr�r�c��dSr r�r�s r�r�zDDLCompiler.__init__�s �� �3r�c�P�|j�|jd|j���S)Nr�)r�rRr�r4s r�r�zDDLCompiler.sql_compiler�s-���|�.�.� �L�$�T�5N�/� � � r�c��|jjSr )r�r�r4s r�� type_compilerzDDLCompiler.type_compiler�s ���|�2�2r�Nr�r�r�r�r�rr�c��dSr r�r�s r�r�zDDLCompiler.construct_params�s �� �tr�c � �|j}t|jtj��r�|���}|j}|�|j��}t|��dkr |dd}}n|d|d}}|� d|��|� d|��|� d|� |j����|j � |j |z��S)Nrrr�r�r�r#rp)�contextr��targetr#rKrrr��format_table_seqr�r�r�r�r�r&)r �ddlr�ryr��pathr��schs r�� visit_ddlzDDLCompiler.visit_ddl�s����+�� �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�Kr�c �b�d}|jr|dz }||j�|j��zS)NzCREATE SCHEMA �IF NOT EXISTS )� if_not_existsr�� format_schemar�)r r�r�r�s r��visit_create_schemazDDLCompiler.visit_create_schema�s:���� � � %� �$� $�D��d�m�1�1�&�.�A�A�A�Ar�c �~�d}|jr|dz }||j�|j��z }|jr|dz }|S)Nz DROP SCHEMA � IF EXISTS � CASCADE)� if_existsr�r�r��cascade�r �dropr�r�s r��visit_drop_schemazDDLCompiler.visit_drop_schema�sP���� �>� !� �L� �D� �� �+�+�D�L�9�9�9�� �<� � �J� �D�� r�c ���|j}|j}d}|jr |d�|j��dzz }|dz }|jr|dz }||�|��dzz }|�|��}|r||dzz }|dz }d}d}|jD]�} | j} |�| | j o| ���} | �||z }d }|d | zz }| j rd }�D#tj $r8} tj d |j �d | j �d| jd����| �d} ~ wwxYw|�||j���} | r ||d z| zz }|d|�|��zz }|S)Nz CREATE r!zTABLE r�r� F��first_pkrC� Tz (in table 'z ', column 'z'): r)� _include_foreign_key_constraintsz )%s )r�r�r�rxr�r��create_table_suffixr�r�rSr8r�� descriptionr��args�create_table_constraints�include_foreign_key_constraints�post_create_table)r r�r�r�r�r�r�rr�� create_columnr�� processed�ce�consts r��visit_create_tablezDDLCompiler.visit_create_table�s�������=���� �?� 4� �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����#� � � ��&�&��(�(�(�&�+�+�+�r�w�q�z�z�C��������� ���� �-�-� �-3�-S�.� � �� � -� �I��$�u�,� ,�D� � �d�4�4�U�;�;�;�;��� s�9C�D�&3D�DFc ���|j}|jrdS��||���}d��fd�|jD����}|r|d|zz }|S)Nr�r!c3�B�K�|]}��|��V��dSr )r��r�r�r s �r�r1z2DDLCompiler.visit_create_column.<locals>.<genexpr> s@����� � �)3�D�L�L�� $� $� � � � � � r�)r��system�get_column_specificationrx� constraints)r r�r�r�r�r�r�s` r��visit_create_columnzDDLCompiler.visit_create_columns������� �=� ��4��,�,�V�h�,�G�G����� � � � �7=�7I� � � � � �� � � �C�%�K� �D�� r�c �L����g}�jr|��j���j}|�|�|���nt ���|���fd��jD����d�d��fd�|D��D����S)Nc�.��g|]}|�ju� |�v�|��Sr�)rS)r�r�� omit_fkcsr�s ��r�r�z8DDLCompiler.create_table_constraints.<locals>.<listcomp>8s;��� � � ���E�-�-�-�!�9�2D�2D��2D�2D�2Dr�z, c3�K�|]}|�|V�� dSr r�)r�r�s r�r1z7DDLCompiler.create_table_constraints.<locals>.<genexpr>?s4����  �  ���}� ��}�}�}�  �  r�c3��K�|]K}|������jjrt|dd���4��|��V��LdS)� use_alterFN)�_should_create_for_compilerr��supports_alterr^r�r�s �r�r1z7DDLCompiler.create_table_constraints.<locals>.<genexpr>As|���������:�:�4�@�@�� � �3� � #�:�{�E�B�B� �� � �Z�(�(������r�)rSr��foreign_key_constraintsrrpr!�_sorted_constraintsrx)r r�r�r�r��all_fkcsr�s`` @r�r�z$DDLCompiler.create_table_constraints(s������ � � � � 2� � � �u�0� 1� 1� 1��0�� +� 7� �+�+�,L�M�M�I�I����I���� � � � � ��2� � � � � � ��}�}�  �  �����"-����  �  �  �  �  � r�c �b�d}|jr|dz }||j�|j��zS)Nz DROP TABLE r�)r�r�r�r�r�s r��visit_drop_tablezDDLCompiler.visit_drop_tableMs8���� �>� !� �L� �D��d�m�0�0���>�>�>�>r�c �F�d|j�|j��zS)Nz DROP VIEW �r�r�r��r r�r�s r��visit_drop_viewzDDLCompiler.visit_drop_viewSs���� � :� :�4�<� H� H�H�Hr�c�L�|j�tjd|jz���dS)Nz,Index '%s' is not associated with any table.)r�r8r�r��r rxs r��_verify_index_tablezDDLCompiler._verify_index_tableVs1�� �;� ��"�>���K��� � � r�c ���|j}��|���j}d}|jr|dz }|j�t jd���|dz }|jr|dz }|��||����d|� |j |����d d � �fd �|j D�����d �z }|S) NzCREATE �UNIQUE z0CREATE INDEX requires that the index have a namezINDEX r���include_schemaru�rqr�r�c3�R�K�|]!}�j�|dd���V��"dS)FT�r�r6N)r�r�)r�rr s �r�r1z1DDLCompiler.visit_create_index.<locals>.<genexpr>ssX���������!�)�)���T�*��������r�r) r�r�r�r�r�r8r�r��_prepared_index_namer�r�rx� expressions)r r�r��include_table_schemar�rxr�r�s` r��visit_create_indexzDDLCompiler.visit_create_index\s&������ � � ��'�'�'��=���� �<� � �I� �D� �:� ��"�B��� � ���� � � %� �$� $�D� � � %� %�e�N� %� K� K� K� K� � !� !�� �(<� "� � � � � �I�I�����"�-� ��� � � � �  � ��� r�c ��|j}|j�tjd���d}|jr|dz }||�|d���zS)Nz.DROP INDEX requires that the index have a namez DROP INDEX r�Tr�)r�r�r8r�r�r�)r r�r�rxr�s r��visit_drop_indexzDDLCompiler.visit_drop_index|sb��� �� �:� ��"�@��� ��� �>� !� �L� �D��d�/�/��d�/�K�K�K�Kr�c���|j� |j�|j��}nd}|r|r|j�|��}nd}|j�|��}|r|dz|z}|S�Nr)r�r�r�r�� format_index)r rxr�r�� schema_name� index_names r�r�z DDLCompiler._prepared_index_name�s��� �;� "�#�}�>�>�u�{�K�K� � �#� � � �.� ��-�4�4�5E�F�F�K�K��K��]�/�/��6�6� � � 8�$�s�*�Z�7�J��r�c ��d|j�|jj���d|�|j����S)N� ALTER TABLE z ADD )r�r�r�r�r��r r�r�s r��visit_add_constraintz DDLCompiler.visit_add_constraint�s@��� �M� &� &�v�~�';� <� <� <� <� �L�L��� (� (� (� � r�c ��d|j�|j���d|j�|jjt j������S)NzCOMMENT ON TABLE r�)r�r�r�r�r�commentr%�Stringr�s r��visit_set_table_commentz#DDLCompiler.visit_set_table_comment�sV��� �M� &� &�v�~� 6� 6� 6� 6� � � 2� 2���&���(9�(9� � � � � r�c �F�d|j�|j��zS)NzCOMMENT ON TABLE %s IS NULLr�r�s r��visit_drop_table_commentz$DDLCompiler.visit_drop_table_comment�s(��,�t�}�/I�/I� �L�0 �0 � � r�c ��d|j�|jdd����d|j�|jjt j������S)NzCOMMENT ON COLUMN T)� use_tablerqr�)r�� format_columnr�r�rr�r%r�r�s r��visit_set_column_commentz$DDLCompiler.visit_set_column_comment�sj��� �M� '� '���$�4� (� � � � � � � 2� 2���&���(9�(9� � � �  � r�c �J�d|j�|jd���zS)NzCOMMENT ON COLUMN %s IS NULLT)r�)r�r�r�r�s r��visit_drop_column_commentz%DDLCompiler.visit_drop_column_comment�s0��-�� �0K�0K� �L�D�1L�1 �1 � � r�c �F�tj|t|�����r r�r�s r��visit_set_constraint_commentz(DDLCompiler.visit_set_constraint_comment�s���-�d�D��L�L�A�A�Ar�c �F�tj|t|�����r r�r�s r��visit_drop_constraint_commentz)DDLCompiler.visit_drop_constraint_comment�s���-�d�D��J�J�?�?�?r�c�R�g}|j�|�d|jz��|j�|�d|jz��|j�|�d|jz��|j�|�d|jz��|j�|�d��|j�|�d��|j�|�d|jz��|j�|�|jrdnd ��d � |��S) NzINCREMENT BY %dz START WITH %dz MINVALUE %dz MAXVALUE %dz NO MINVALUEz NO MAXVALUEzCACHE %d�CYCLEzNO CYCLEr!) � incrementr�r��minvalue�maxvalue� nominvalue� nomaxvalue�cache�cyclerx)r �identity_optionsr�s r��get_identity_optionsz DDLCompiler.get_identity_options�s*���� � %� 1� �K�K�)�,<�,F�F� G� G� G� � !� -� �K�K��*:�*@�@� A� A� A� � $� 0� �K�K� �(8�(A�A� B� B� B� � $� 0� �K�K� �(8�(A�A� B� B� B� � &� 2� �K�K� � &� &� &� � &� 2� �K�K� � &� &� &� � !� -� �K�K� �%5�%;�;� <� <� <� � !� -� �K�K�#3�#9�I���z� J� J� J��x�x��~�~�r�c ��d}|jr|dz }||j�|j��z }|r||z }|�|j��}|r|d|zz }|S)NzCREATE SEQUENCE r�r!)r�r�r_r�r�)r r�r@r�r��optionss r��visit_create_sequencez!DDLCompiler.visit_create_sequence�sz��!�� � � %� �$� $�D� �� �-�-�f�n�=�=�=�� � � �F�N�D��+�+�F�N�;�;�� � "� �C�'�M� !�D�� r�c �b�d}|jr|dz }||j�|j��zS)NzDROP SEQUENCE r�)r�r�r_r�r�s r��visit_drop_sequencezDDLCompiler.visit_drop_sequence�s8���� �>� !� �L� �D��d�m�3�3�D�L�A�A�A�Ar�c ��|j}|j�|j�|��}nd}|�t jd|jz���d|j�|jj���d|jrdnd�|�|j rdnd��S)Nz<Can't emit DROP CONSTRAINT for constraint %r; it has no namer�z DROP CONSTRAINT r�r�r�) r�r�r��format_constraintr8r�r�r�r�r�)r r�r�r��formatted_names r��visit_drop_constraintz!DDLCompiler.visit_drop_constraint�s����\� � �?� &�!�]�<�<�Z�H�H�N�N�!�N� � !��"�!�#'�<�0��� � "� �M� &� &�t�|�'9� :� :� :� :� �N� 2�L�L�� 2� �N��,� .�J�J�B� .�  � r�c ��|j�|��dz|jj�|j|���z}|�|��}|�|d|zz }|j� |d|�|j��zz }|j�,|jj r |d|�|j��zz }|j s|jr |jj s|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)r r�r��colspecr�s r�r�z$DDLCompiler.get_column_specification�s�� �M� '� '�� /� /�� ��l�1�9�9�� �V�:��� � ��0�0��8�8�� � � �{�W�,� ,�G� �?� &� �s�T�\�\�&�/�:�:�:� :�G� �O� '�� �6� (� �s�T�\�\�&�/�:�:�:� :�G��� #��� #�'+�|�'M� #� �{� "�G��r�c��dS�Nr�r��r r�s r�r�zDDLCompiler.create_table_suffix����rr�c��dSr�r�r�s r�r�zDDLCompiler.post_create_tabler�r�c��t|jtj��r|�|jj��SdSr )r��server_defaultr#� DefaultClause�render_default_string�argr�s r�r�z%DDLCompiler.get_column_default_strings9�� �f�+�V�-A� B� B� ��-�-�f�.C�.G�H�H� H��4r�c��t|t��r%|j�|tj��S|j�|d���S)NT)r6)r�r�r�rr%r�r�)r r�s r�rz!DDLCompiler.render_default_string"sV�� �g�s� #� #� J��$�9�9���,��� ��$�,�,�W�D�,�I�I� Ir�c �d�|jr|�|��S|�|��Sr )�is_column_level�visit_column_check_constraint�visit_check_constraint�r r�r�s r��&visit_table_or_column_check_constraintz2DDLCompiler.visit_table_or_column_check_constraint*s5�� � %� ;��5�5�j�A�A� A��.�.�z�:�:� :r�c ���d}|j�$|j�|��}|�|d|zz }|d|j�|jdd���zz }||�|��z }|S�Nr��CONSTRAINT %s z CHECK (%s)FTr��r�r�r�r�r�ro�define_constraint_deferrability�r r�r�r�r�s r�rz"DDLCompiler.visit_check_constraint0����� �?� &�!�]�<�<�Z�H�H�N��)��(�>�9�9�� � �t�0�8�8� � �e�4� 9� � � � �� ��4�4�Z�@�@�@��� r�c ���d}|j�$|j�|��}|�|d|zz }|d|j�|jdd���zz }||�|��z }|Sr rrs r�rz)DDLCompiler.visit_column_check_constraint<rr�c �:��t|��dkrdSd}|j�$�j�|��}|�|d|zz }|dz }|dd��fd�|jr|jn|jD����zz }|��|��z }|S)Nrr�r z PRIMARY KEY rr�c3�V�K�|]#}�j�|j��V��$dSr �r�r�r�rbs �r�r1z;DDLCompiler.visit_primary_key_constraint.<locals>.<genexpr>QsI�����# �# �� �M� � ��� '� '�# �# �# �# �# �# r�) r�r�r�r�rx�_implicit_generated�columns_autoinc_firstr�rrs` r��visit_primary_key_constraintz(DDLCompiler.visit_primary_key_constraintHs���� �z�?�?�a� � ��2��� �?� &�!�]�<�<�Z�H�H�N��)��(�>�9�9�� ���� �����# �# �# �# ��1�(� �0�0��'� # �# �# � � � � �� ��4�4�Z�@�@�@��� r�c � ��|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��r�r2r�s �r�r1z;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>e�D�������23����q�x�}�-�-������r�z ) REFERENCES r�c3�V�K�|]#}��|jj��V��$dSr )r�r�r�rs �r�r1z;DDLCompiler.visit_foreign_key_constraint.<locals>.<genexpr>krr�r) r�r�r�r�rr�r�rx�define_constraint_remote_table�define_constraint_match�define_constraint_cascadesr)r r�r�r�r�� remote_tabler�s @r��visit_foreign_key_constraintz(DDLCompiler.visit_foreign_key_constraint\sm����=���� �?� &�!�]�<�<�Z�H�H�N��)��(�>�9�9���J�/�0�0��3�:�@� � �� �I�I�����7A�7J���� � � � � � /� /��L�(� � � � � �I�I�����7A�7J���� � � � �  � �� ��,�,�Z�8�8�8�� ��/�/� �;�;�;�� ��4�4�Z�@�@�@��� r�c�,�|�|��S)z=Format the remote table clause of a CREATE CONSTRAINT clause.)r�)r r�r�r�s r�rz*DDLCompiler.define_constraint_remote_tablets���$�$�U�+�+�+r�c �*��t|��dkrdSd}|j�$�j�|��}|�|d|zz }|d�j|fi|���dd��fd�|D�����d�z }|��|��z }|S) Nrr�r r�rr�c3�V�K�|]#}�j�|j��V��$dSr rrbs �r�r1z6DDLCompiler.visit_unique_constraint.<locals>.<genexpr>�s5�����F�F�a�d�m�)�)�!�&�1�1�F�F�F�F�F�Fr�r)r�r�r�r��!define_unique_constraint_distinctrxrrs` r��visit_unique_constraintz#DDLCompiler.visit_unique_constraintys���� �z�?�?�a� � ��2��� �?� &�!�]�<�<�Z�H�H�N��)��(�>�9�9�� �� 2�D� 2�:� D� D�� D� D� D� D� �I�I�F�F�F�F�:�F�F�F� F� F� F� F� � �� ��4�4�Z�@�@�@��� r�c ��dSr�r�r s r�r'z-DDLCompiler.define_unique_constraint_distinct�r�r�c���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 r�r!z&DDLCompiler.define_constraint_cascades�s|���� � � *� �O�d�m�&G�&G��#�\�'�'�� �D� � � *� �O�d�m�&G�&G��#�\�'�'�� �D�� r�c��d}|j�|jr|dz }n|dz }|j�+|d|j�|jt��zz }|S)Nr�z DEFERRABLEz NOT DEFERRABLEz INITIALLY %s)r�r�r�r,� FK_INITIALLYr0s r�rz+DDLCompiler.define_constraint_deferrability�so���� � � ,��$� *�� �%����)�)�� � � +� �O�d�m�&G�&G��$�l�'�'�� �D�� r�c�2�d}|j� |d|jzz }|S)Nr�z MATCH %s)r3r0s r�r z#DDLCompiler.define_constraint_match�s'���� � � '� �K�*�"2�2� 2�D�� r�c ��d|j�|jdd���z}|jdur|dz }n|jdur|dz }|S)NzGENERATED ALWAYS AS (%s)FTr�z STOREDz VIRTUAL)r�r�ro� persisted)r � generatedr�r�s r��visit_computed_columnz!DDLCompiler.visit_computed_column�sj��)�D�,=�,E�,E� � �U�$�-F�- �- � �� � �$� &� &� �I� �D�D� � �E� )� )� �J� �D�� r�c �b�d|jrdnd�d�}|�|��}|r|d|zz }|S)Nz GENERATED �ALWAYSz BY DEFAULTz AS IDENTITYr�)�alwaysr�)r r�r�r�r�s r��visit_identity_columnz!DDLCompiler.visit_identity_column�sP��� �� 9�H�H�\� 9� 9� ���+�+�H�5�5�� � &� �G�g�%� %�D�� r�)...) r�r]r&rAr�r�r�rr�r�r�r�r8r )FT)4r�rrr�rr�r&rAr�rvr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr rrrr#rr(r'r!rr r7r;r�r�r�rrrr�sP������ �F�� � FI�,/�03�  � � � � � �� � ��� �  ��3�3���3� 6:�GK�!� �����L�L�L�&B�B�B� ���2�2�2�h � � � � 7;�# �# �# �# �J?�?�?� I�I�I����BF�����@ L� L� L�����  � � �  � � � � � �  � � � � � � B�B�B�@�@�@����( � � � �B�B�B�  � � �&���6��������� J�J�J�;�;�;� � � � � � ����(���0,�,�,� � � ���� � � � � � ���� �������r�rrc�*�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �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�Z1dS)2�GenericTypeCompilerc ��dS)N�FLOATr�r�s r�� visit_FLOATzGenericTypeCompiler.visit_FLOAT�����wr�c ��dS)N�DOUBLEr�r�s r�� visit_DOUBLEz GenericTypeCompiler.visit_DOUBLE�����xr�c ��dS)NzDOUBLE PRECISIONr�r�s r��visit_DOUBLE_PRECISIONz*GenericTypeCompiler.visit_DOUBLE_PRECISION�s��!�!r�c ��dS)N�REALr�r�s r�� visit_REALzGenericTypeCompiler.visit_REAL�r�r�c �^�|j�dS|j� dd|jizSd|j|jd�zS)N�NUMERICzNUMERIC(%(precision)s)� precisionz!NUMERIC(%(precision)s, %(scale)s)�rM�scalerNr�s r�� visit_NUMERICz!GenericTypeCompiler.visit_NUMERIC��J�� �?� "��9� �[� �+�{�E�O�.L�L� L�6�"�_���:�:�� r�c �^�|j�dS|j� dd|jizSd|j|jd�zS)N�DECIMALzDECIMAL(%(precision)s)rMz!DECIMAL(%(precision)s, %(scale)s)rNrNr�s r�� visit_DECIMALz!GenericTypeCompiler.visit_DECIMAL�rQr�c ��dS)N�INTEGERr�r�s r�� visit_INTEGERz!GenericTypeCompiler.visit_INTEGER�����yr�c ��dS)N�SMALLINTr�r�s r��visit_SMALLINTz"GenericTypeCompiler.visit_SMALLINT�����zr�c ��dS)N�BIGINTr�r�s r�� visit_BIGINTz GenericTypeCompiler.visit_BIGINT�rEr�c ��dS)N� TIMESTAMPr�r�s r��visit_TIMESTAMPz#GenericTypeCompiler.visit_TIMESTAMP�s���{r�c ��dS)N�DATETIMEr�r�s r��visit_DATETIMEz"GenericTypeCompiler.visit_DATETIME�r\r�c ��dS)N�DATEr�r�s r�� visit_DATEzGenericTypeCompiler.visit_DATE�r�r�c ��dS)N�TIMEr�r�s r�� visit_TIMEzGenericTypeCompiler.visit_TIME�r�r�c ��dS)N�CLOBr�r�s r�� visit_CLOBzGenericTypeCompiler.visit_CLOB�r�r�c ��dS)N�NCLOBr�r�s r�� visit_NCLOBzGenericTypeCompiler.visit_NCLOB�rAr�Nc�p�|}|r |d|zz }n|jr |d|jzz }|jr |d|jzz }|S)N�(%d)z COLLATE "%s")�lengthr�)r rr��length_overrider�s r��_render_string_typez'GenericTypeCompiler._render_string_type�s[���� � *� �F�_�,� ,�D�D� �\� *� �F�U�\�)� )�D� �?� 6� �O�e�o�5� 5�D�� r�c �.�|�|d��S)N�CHAR�rvr�s r�� visit_CHARzGenericTypeCompiler.visit_CHAR����'�'��v�6�6�6r�c �.�|�|d��S)N�NCHARryr�s r�� visit_NCHARzGenericTypeCompiler.visit_NCHAR s���'�'��w�7�7�7r�c �.�|�|d��S)N�VARCHARryr�s r�� visit_VARCHARz!GenericTypeCompiler.visit_VARCHAR s���'�'��y�9�9�9r�c �.�|�|d��S)N�NVARCHARryr�s r��visit_NVARCHARz"GenericTypeCompiler.visit_NVARCHARs���'�'��z�:�:�:r�c �.�|�|d��S)N�TEXTryr�s r�� visit_TEXTzGenericTypeCompiler.visit_TEXTr{r�c ��dS)N�UUIDr�r�s r�� visit_UUIDzGenericTypeCompiler.visit_UUIDr�r�c ��dS)N�BLOBr�r�s r�� visit_BLOBzGenericTypeCompiler.visit_BLOBr�r�c �.�d|jr d|jzpdzS)N�BINARYrsr��rtr�s r�� visit_BINARYz GenericTypeCompiler.visit_BINARYs ���5�<�A�F�U�\�,A�G�R�H�Hr�c �.�d|jr d|jzpdzS)N� VARBINARYrsr�r�r�s r��visit_VARBINARYz#GenericTypeCompiler.visit_VARBINARYs ���e�l�D�v�� �/D�J��K�Kr�c ��dS)N�BOOLEANr�r�s r�� visit_BOOLEANz!GenericTypeCompiler.visit_BOOLEAN!rXr�c �t�|jr |jjs|�|dd���S|j|fi|��S)Nrx� )ru)� native_uuidr��supports_native_uuidrvr�r�s r�� visit_uuidzGenericTypeCompiler.visit_uuid$sN��� � 0�� �(I� 0��+�+�E�6�2�+�N�N� N�"�4�?�5�/�/�B�/�/� /r�c ��|j|fi|��Sr )r�r�s r��visit_large_binaryz&GenericTypeCompiler.visit_large_binary*����t��u�+�+��+�+�+r�c ��|j|fi|��Sr )r�r�s r�� visit_booleanz!GenericTypeCompiler.visit_boolean-���!�t�!�%�.�.�2�.�.�.r�c ��|j|fi|��Sr )rkr�s r�� visit_timezGenericTypeCompiler.visit_time0r�r�c ��|j|fi|��Sr )rer�s r��visit_datetimez"GenericTypeCompiler.visit_datetime3���"�t�"�5�/�/�B�/�/�/r�c ��|j|fi|��Sr )rhr�s r�� visit_datezGenericTypeCompiler.visit_date6r�r�c ��|j|fi|��Sr )r_r�s r��visit_big_integerz%GenericTypeCompiler.visit_big_integer9��� �t� ��-�-�"�-�-�-r�c ��|j|fi|��Sr )r[r�s r��visit_small_integerz'GenericTypeCompiler.visit_small_integer<r�r�c ��|j|fi|��Sr )rWr�s r�� visit_integerz!GenericTypeCompiler.visit_integer?r�r�c ��|j|fi|��Sr )rJr�s r�� visit_realzGenericTypeCompiler.visit_realBr�r�c ��|j|fi|��Sr )r@r�s r�� visit_floatzGenericTypeCompiler.visit_floatEs���t���,�,��,�,�,r�c ��|j|fi|��Sr )rDr�s r�� visit_doublez GenericTypeCompiler.visit_doubleHr�r�c ��|j|fi|��Sr )rPr�s r�� visit_numericz!GenericTypeCompiler.visit_numericKr�r�c ��|j|fi|��Sr �r�r�s r�� visit_stringz GenericTypeCompiler.visit_stringNr�r�c ��|j|fi|��Sr r�r�s r�� visit_unicodez!GenericTypeCompiler.visit_unicodeQr�r�c ��|j|fi|��Sr �r�r�s r�� visit_textzGenericTypeCompiler.visit_textTr�r�c ��|j|fi|��Sr r�r�s r��visit_unicode_textz&GenericTypeCompiler.visit_unicode_textWr�r�c ��|j|fi|��Sr r�r�s r�� visit_enumzGenericTypeCompiler.visit_enumZr�r�c �0�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_null]s$���� #�%*� +� � � r�c �N�|j|�|j��fi|��Sr )r�� type_enginer�r�s r��visit_type_decoratorz(GenericTypeCompiler.visit_type_decoratords,���t�|�E�-�-�d�l�;�;�B�B�r�B�B�Br�c ��|jdi|��Sr9)� get_col_specr�s r��visit_user_definedz&GenericTypeCompiler.visit_user_definedgs��!�u�!�'�'�B�'�'�'r�r )2r�rrr@rDrGrJrPrTrWr[r_rbrerhrkrnrqrvrzr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r=r=�s�������������"�"�"���� � � � � � ��������������������������������7�7�7�8�8�8�:�:�:�;�;�;�7�7�7�������I�I�I�L�L�L����0�0�0� ,�,�,�/�/�/�,�,�,�0�0�0�,�,�,�.�.�.�0�0�0�/�/�/�,�,�,�-�-�-�.�.�.�/�/�/�/�/�/�/�/�/�,�,�,�,�,�,�/�/�/� � � �C�C�C�(�(�(�(�(r�r=c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�StrSQLTypeCompilerc �`� |j}||fi|��S#t$r|j|fi|��cYSwxYwr )r��AttributeError�_visit_unknown)r rr�r�s r�r�zStrSQLTypeCompiler.processlsi�� 2�!&�!9� �&�%�d�1�1�b�1�1� 1��� 4� 4� 4�&�4�&�u�3�3��3�3� 3� 3� 3� 4���s ��-�-c�X�|�d��r|jSt|���)Nr�)rlr�r�)r r0s r�� __getattr__zStrSQLTypeCompiler.__getattr__ts-�� �>�>�(� #� #� &��&� &� ��%�%� %r�c ��|jj|jj���kr |jjSt|��Sr )r�r��upper�reprr�s r�r�z!StrSQLTypeCompiler._visit_unknownzs:�� �?� #�u��'?�'E�'E�'G�'G� G� G��?�+� +���;�;� r�c ��dSr�r�r�s r�r�zStrSQLTypeCompiler.visit_null�r�r�c �`� |j}|di|��S#t$rt|��cYSwxYwr9)r�r�r�)r rr�r�s r�r�z%StrSQLTypeCompiler.visit_user_defined�sV�� &� �-�L� �<�%�%�"�%�%� %��� � � ���;�;� � � � ���s ��-�-N)r�rrr�r�r�r�r�r�r�r�r�r�ks_������2�2�2�&�&�&� ��� ���&�&�&�&�&r�r�c��eZdZdd�ZdS)�_SchemaForObjectCallable�_SchemaForObjectCallable__objrrr�c��dSr r�)r r�s r�rz!_SchemaForObjectCallable.__call__�����r�N)r�rrr�rr�r�r�r�r��s������.�.�.�.�.�.r�r�c��eZdZdd�ZdS)r7r�r�rr�c��dSr r�)r r�s r�rz _BindNameForColProtocol.__call__�r�r�N)r�r�rr�rr�r�r�r7r7�s������:�:�:�:�:�:r�r7c��eZdZUdZeZeZeZ de d<de d<de d<e j d��Z de d < d Zd e d < d8d�Zd�Zd�Zd9d�Zd9d�Zd�Zd9d�Zd:d�Zd�Zd;d<d�Zd;d=d�Zd �Zd>d!�Z d;d?d&�Z d;d@d)�Zd;d*�Zej d+��d>d,���Z!d>d-�Z"d>d.�Z#d/�Z$d0�Z%dAd1�Z&d2�Z' d;d3�Z( dBd4�Z)d>d5�Z*ej+d6���Z,d7�Z-dS)Cr�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_translater�NTc��||_||_|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. r7)r�r�N) r�r�r�� escape_quote�escape_to_quote� omit_schema�quote_case_sensitive_collationsr�rkr�)r r�r�r�r�r�r�s r�r�zIdentifierPreparer.__init__�so��.�� �*���&�<�$�*<���(���#�0�1�4���&���/N��,��� � $� � 7�< �! ����r�c���|j�|j��}|j�|j��d|v��fd�}||_�|_|S)Nc���|j}|jr;|��r7|�d|vsd|vrtjd|z���t d|pdzd���S|jS)Nrr zJSquare bracket characters ([]) not supported in schema translate name '%s'z __[SCHEMA_%s]�_noneF�r�)r#�_use_schema_mapr8r�r1)r�r�� includes_nones �r�� symbol_getterz@IdentifierPreparer._with_schema_translate.<locals>.symbol_getter�s�����:�D��"� "��(8�M�(8��#������t� � ��*�8�:>�?����#�#�t��w�7�u������z�!r�)r��__new__rwrxr�r�)r r��prepr�r�s @r�r�z)IdentifierPreparer._with_schema_translate�sm����~�%�%�d�n�5�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����|�d��}|�vr �|}n|dvrtjd���|}|s"�jj}|stjd�����|��S)Nr7)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�r8r2r��default_schema_namer�r�)r�r�r��dr s ��r�r�z=IdentifierPreparer._render_schema_translates.<locals>.replace�s�����7�7�1�:�:�D��q�y�y�#$�T�7� � ��?�*�*��1�=����$(� �#� �#'�<�#C� �'���*�=�����$�$�%5�6�6� 6r�z(__\[SCHEMA_([^\]]+)\]))r�r8r2rRr�)r r&r�r�r�s` @r�r�z,IdentifierPreparer._render_schema_translates�s{���� �� �1�9�9��7� ��-�9�����4��A�g�J� 7� 7� 7� 7� 7� 7�2�v�0�'�9�E�E�Er�r�rc��|�|j|j��}|jr|�dd��}|S)z�Escape an identifier. Subclasses should override this to provide database-dependent escaping behavior. rr�)r�r�r�r��r r�s r��_escape_identifierz%IdentifierPreparer._escape_identifiers@��� � �d�/��1E�F�F�� � � -��M�M�#�t�,�,�E�� r�c�B�|�|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�4�3D�E�E�Er�c�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 r)r3r8r�r?)r r�rUs r�r,z&IdentifierPreparer.validate_sql_phrase*sN�� � �s�y�y��'9�'9� ��"�"��7�7�C�K�K�K�)��� ��r�c�L�|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_identifier<s0�� � ��%�%�e�,�,� -��� � r�c��|���}||jvp<|d|jvp-|j�t |���� p||kS)z5Return True if the given identifier requires quoting.r)r_�reserved_words�illegal_initial_characters�legal_charactersr3r�)r r��lc_values r�r�z#IdentifierPreparer._requires_quotesIsd���;�;�=�=�� ��+� +� #��Q�x�4�:�:� #��(�.�.�s�5�z�z�:�:�:� #��E�!�  r�c�R�|j�t|���� S)zjReturn True if the given identifier requires quoting, but not taking case convention into account.)r r3r�r�s r�r]z1IdentifierPreparer._requires_quotes_illegal_charsSs$���(�.�.�s�5�z�z�:�:�:�:r��forcerc�\�|�tjdd���|�|��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().�0.9rM)r&rPr�)r r#r s r�r�zIdentifierPreparer.quote_schemaXsD��. � � � �!� � � � � ��z�z�&�!�!�!r�r�c�J�|�tjdd���t|dd��}|�`||jvr |j|S|�|��r|�|��|j|<n ||j|<|j|S|r|�|��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 rMr�)r&rPr^r�r�r�)r r�r s r�r�zIdentifierPreparer.quotes���, � � � �!� � � � � ���w��-�-�� �=��� �%�%��}�U�+�+��(�(��/�/�1�+/�+@�+@��+G�+G�D�M�%�(�(�+0�D�M�%�(��}�U�+�+� � ��(�(��/�/� /��Lr�c�>�|jr|�|��S|Sr )r�r�)r �collation_names r�r�z#IdentifierPreparer.format_collation�s%�� � /� "��:�:�n�-�-� -�!� !r�c��|�|j��}|�|��}|js|r|�|�|��dz|z}|Sr�)r�r�r�r�r�)r rgrqr�r�s r�r_z"IdentifierPreparer.format_sequence�sk���z�z�(�-�(�(���1�1�(�;�;��� � D�� D�!�,��$�$�%5�6�6��<�t�C�D�� r�r�� Label[Any]r�r=c�:�|�|p|j��Sr �r�r�)r r�r�s r�r�zIdentifierPreparer.format_label�s���z�z�$�,�%�*�-�-�-r�r��Optional[AliasedReturnsRows]c�l�|�|�J�|�|j��S|�|��Sr r )r r�r�s r�r�zIdentifierPreparer.format_alias�s;�� �<��$�$�$��:�:�e�j�)�)� )��:�:�d�#�#� #r�c�l�|p|j}|�|��r|�|��}|Sr )r�r�r�)r � savepointr�r�s r�r0z#IdentifierPreparer.format_savepoint�s>���'� ��� � � �� '� '� 1��)�)�%�0�0�E�� r�zsqlalchemy.sql.namingc��tjj}|jtur |�||j��}|�dSn|j}|jdkr|�||���S|� ||���S)Nrx)�_alembic_quote) r&r2� sql_namingr�r,�_constraint_name_for_tabler�r�truncate_and_render_index_name�#truncate_and_render_constraint_name)r r�r �namingr�s r�r�z$IdentifierPreparer.format_constraint�s�����*�� �?�j� (� (��4�4��J�,���D��|��t���?�D� � $�� /� /��6�6��^�7��� ��;�;��^�<��� r�c�`�|jjp |jj}|�|||��Sr )r��max_index_name_lengthrp� _truncate_and_render_maxlen_name�r r�r �max_s r�r z1IdentifierPreparer.truncate_and_render_index_name�s?�� �L� .� 2��|�1� ��4�4� �$�� � � r�c�`�|jjp |jj}|�|||��Sr )r��max_constraint_name_lengthrpr r s r�r z6IdentifierPreparer.truncate_and_render_constraint_names?�� �L� 3� 2��|�1� ��4�4� �$�� � � r�c��t|tj��rAt|��|kr-|d|dz �dzt j|��dd�z}n|j�|��|s|S|�|��S)NrrYr�����) r�rrEr�r&�md5_hexr��validate_identifierr�)r r�r r s r�r z3IdentifierPreparer._truncate_and_render_maxlen_name s��� �d�H�5� 6� 6� 3��4�y�y�4����A��q��L�)�C�/�$�,�t�2D�2D�R�S�S�2I�I��� �L� ,� ,�T� 2� 2� 2�� $��K��:�:�d�#�#� #r�c�,�|�|��Sr )r�r�s r�r�zIdentifierPreparer.format_indexs���%�%�e�,�,�,r�c��|�|j}|�|��}|�|��}|js|r|r|�|��dz|z}|S)z'Prepare a quoted table and schema name.Nr)r�r�r�r�r�)r r�rqr�rWr�s r�r�zIdentifierPreparer.format_tablesu�� �<��:�D����D�!�!���1�1�%�8�8���� H�J� H�3C� H��&�&�'7�8�8�3�>��G�F�� r�c�,�|�|��S)zPrepare a quoted schema name.r�rcs r�r�z IdentifierPreparer.format_schema)s���z�z�$���r�c��|�/t|tj��r|�|��}|�|��S)�Prepare a quoted column name.)r�rrEr[r�)r r�rqs r�r�z$IdentifierPreparer.format_label_name.sF�� � �J� �(�+�% �% � ��>�>�(�+�+�D��z�z�$���r�c��|�|j}|�/t|tj��r|�|��}t |dd��sM|r6|�|j||���dz|�|��zS|�|��S|r#|�|j||���dz|zS|S)r( Nr�F)rqr�r) r�r�rrEr[r^r�r�r�)r r�r�r�� table_namerqrqs r�r�z IdentifierPreparer.format_column<s�� �<��;�D� � �J� �(�+�% �% � ��>�>�(�+�+�D��v�|�U�3�3� �� (��%�%�� ��*�&������j�j��&�&� '���z�z�$�'�'�'� � ��%�%�� ��*�&������ ��� r�c���|�|��}|js0|r.|r,|�|��|�|d���fS|�|d���fS)z(Format table name and schema as a tuple.Fr�)r�r�r�r�)r r�rqr�s r�r{z#IdentifierPreparer.format_table_seqis��� �1�1�%�8�8���� A�J� A�3C� A��!�!�"2�3�3��!�!�%�E�!�:�:�� � �%�%�e��%�>�>�@� @r�c��d�|j|j|�|j��fD��\}}}tjd|||d�z��}|S)Nc3�>K�|]}tj|��V��dSr )rRrSrs r�r1z4IdentifierPreparer._r_identifiers.<locals>.<genexpr>|s>����) �) �� �I�a�L�L�) �) �) �) �) �) r�zM(?:(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s|([^\.]+))(?=\.|$))+)�initial�finalr�)r�r�r�rRrT)r r. r/ � escaped_final�rs r��_r_identifiersz!IdentifierPreparer._r_identifierszs��) �) ��"�� ��'�'��(8�9�9��) �) �) �%��� � �J� $�"�E�m�L�L� M� � �� �r�c�h���j}�fd�d�|�|��D��D��S)z:Unpack 'schema.table.column'-like strings into components.c�:��g|]}��|����Sr�)r�r�s �r�r�z;IdentifierPreparer.unformat_identifiers.<locals>.<listcomp>�s7��� � � �� � %� %�a� (� (� � � r�c��g|] \}}|p|�� Sr�r�)r��ar_s r�r�z;IdentifierPreparer.unformat_identifiers.<locals>.<listcomp>�s ��@�@�@���A�a�f�1�@�@�@r�)r2 �findall)r � identifiersr1 s` r��unformat_identifiersz'IdentifierPreparer.unformat_identifiers�sR��� � �� � � � �@�@����;�)?�)?�@�@�@� � � � r�)r�Nr�TF)r�r�rr�)r�r�rrr )r#r�r rrr�)r�r�r rrr�)T)r�r r�r=rr�)r�r r�r=rr�)TN)FNNFN).r�rrr�RESERVED_WORDSr��LEGAL_CHARACTERSr �ILLEGAL_INITIAL_CHARACTERSr rr?� attrgetterr�r�r�r�r�r�r�r,r�r�r]r�r�r�r_r�r�r0r&rEr�r r r r�r�r�r�r�r{rAr2 r9 r�r�r�r�r��s �������J�J�#�N�'��!;����������&�&�&�&�2E�(�2E�h�2O�2O��O�O�O�O��-2�#�1�1�1�1� ���(,��" �" �" �" �H���0'F�'F�'F�R � � � �F�F�F�F����$  �  �  �  � � � � �;�;�;� %"�%"�%"�%"�%"�N2�2�2�2�2�h"�"�"� � � � �8<�.�.�.�.�.� JN�$�$�$�$�$������T��0�1�1����2�1��,  �  �  �  �  �  �  �  � $� $� $�-�-�-� � � � � � � ��  �  �  �  �"� ����+�+�+�+�ZA�A�A�A�" �������" � � � � r�r�)�r� __future__rr}�collections.abc�abcr�rC�enumrr�r�r?rR�timerrdrrrr r r r r rrrrrrrrrrrrrr�rrrrr r!r"r#r$r%r&rS�_typingr(r)r*r+r,r-r.r/r0r1r2r3�type_apir4�visitorsr5r6r8r9� util.typingr:r;r<� annotationr=r>r?r�r@r|rA�dmlrBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrT� engine.cursorrU�engine.interfacesrVrWrXrYrZr[r\r]r^r��_FromHintsTyper: rT�Ir; �LEGAL_CHARACTERS_PLUS_SPACEr�r�r< r-r/r2�UNICODEr�r�rmrnr�or_rl�mulr��mod�neg�lt�le�ne�gt�ge�eq�is_distinct_from�is_not_distinct_from� concat_opr�� not_match_opr�r�rTr�r�rIrJr��exists� distinct_op�inv�any_op�all_op�desc_op�asc_op�nulls_first_op� nulls_last_op�bitwise_xor_op� bitwise_or_op�bitwise_and_op�bitwise_not_op�bitwise_lshift_op�bitwise_rshift_opr�r�r�r�r�r�r�r�r�r�r�r��cube�rollup� grouping_setsr�rr;�_CompoundSelectKeywordr�� UNION_ALLr�� EXCEPT_ALLr�� INTERSECT_ALLr<r�rrrrrrrr%r:rJrWrerjr3rkrlrmrn� namedtuplerpr�� EnsureKWArgr��BinaryElementRole�CompilerColumnElementr�r rrKrrr=r�r�r7r�r�r�r��<module>rw s�����"#�"�"�"�"�"�����)�)�)�)�)�)����������������������� � � � ������� � � � �������������������������������������������������������������!�!�!�!�!�!������������������������������������������������� � � � � � �������������������������������������������������������������������������&�&�&�&�&�&�������������������������2�2�2�2�2�2�������������#�#�#�#�#�#�!�!�!�!�!�!������������� � � � � � �%�%�%�%�%�%�������������������������!�!�!�!�!�!�"�"�"�"�"�"�#�#�#�#�#�#� ��";�+�+�+�+�+�+�,�,�,�,�,�,�"�"�"�"�"�"�#�#�#�#�#�#�)�)�)�)�)�)�������������������*�*�*�*�*�*�'�'�'�'�'�'�&�&�&�&�&�&�'�'�'�'�'�'�������#�#�#�#�#�#�������.�.�.�.�.�.�/�/�/�/�/�/�������&�&�&�&�&�&�+�+�+�+�+�+�'�'�'�'�'�'�"�"�"�"�"�"�'�'�'�'�'�'�,�,�,�,�,�,�4�4�4�4�4�4�<�<�<�<�<�<�:�:�:�:�:�:�<�<�<�<�<�<�=�=�=�=�=�=�3�3�3�3�3�3�=�=�=�=�=�=�C�C�C�C�C�C�+�+�+�+�+�+�:�:�:�:�:�:��l�C�'�(��_�_�_��B�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�3�. ��L�%�. ��L�&�. ��L�&�. ��L�%�. ��L�&�. ��L�%�. ��� 4�. � �"�$<�!. �"���#. �$�� �%. �. �&��M�'. �(�O�V�). �*���+. �,���-. �.�O�X�/. �0�M�6�1. �2�M�6�3. �4��j�5. �6��{�7. �:��i�;. �<��;�=. �>�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�F� �N�F� ��h� ��_�-� �����&� � �� � ��� � � �"�"�$�(��� �&�%�+�W��%�/���%�,�h��%�0�,��%�/���%�3�_� �����������>��������� !�� � � � �������� ����������������i���� $�$�$�$�$�1��$�$�$�$�:�:�:�:�:�J�:�:�:�zt�t�t�t�t� �t�t�t�n�����Z����2!�!�!�!�!�;�!�!�!�$ � � � � �G� � � � �����g����.FK�U� �F�F�B� � &� �l� ?#�?#�?#�?#�?#�'��'� �w��6H�I�I�?#�?#�?#�DH'�H'�H'�H'�H'�H'�H'�H'�VF�F�F�F�F�4�#�F�F�F�0����� ��C� �(�"@����2# �# �# �# �# � ��C� �(�"@�# �# �# �LhT �hT �hT �hT �hT �(�hT �hT �hT �Vil �l �l �l �l �[�l �l �l �^X�X�X�X�X�(�X�X�X�vj(�j(�j(�j(�j(�,�j(�j(�j(�Z&�&�&�&�&�,�&�&�&�B/�/�/�/�/�x�/�/�/�;�;�;�;�;�h�;�;�;� � � � � � � � � � r�
Memory