File: //opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/__pycache__/compiler.cpython-37.pyc
B
��4]�� � _ @ s d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm
Z
dd
lmZ ddlmZ dd
lm
Z
ddlmZ edddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdlg^�Ze�dmej�Ze�dnej�Zdodp� eddq�D ��drg�Ze�dsej�Ze�dsej�Ze�dtej�Ze�duej�Ze�dvej�Zdwdxdydzd{d|�Zejd}ej d~ej!dej"d�ej#d�ej$d�ej%d�ej&d�ej'd�ej(d�ej)d�ej*d�ej+d�ej,d�ej-d�ej.d�ej/d�ej0d�ej1d�ej2d�ej3d�ej4d�ej5d�ej6d�ej7d�ej8d�ej9d�ej:d�ej;d�ej<d�ej=d�ej>d�ej?d�ej@d�ejAd�ejBd�ejCd�i%ZDejEd�ejFd�ejGd�ejHd�ejId�ejJd�ejKd�ejLd�ejMd�ejNd�ejOd�ejPd�ejQd�ejRd�iZSd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��ZTe
jUjVd�e
jUjWd�e
jUjXd�e
jUjYd�e
jUjZd�e
jUj[d�iZ\G d�dƄ d�e]�Z^G d�dȄ d�e�_ej`e]��ZaG d�dʄ d�ejb�ZcG d�d̄ d�e^�ZdG d�d΄ d�ed�ZeG d�dЄ d�e^�ZfG d�d҄ d�ea�ZgG d�dԄ d�eg�ZhG d�dք d�e]�ZidS )�a] Base SQL and DDL compiler implementations.
Classes provided include:
:class:`.compiler.SQLCompiler` - renders SQL
strings
:class:`.compiler.DDLCompiler` - renders DDL
(data definition language) strings
:class:`.compiler.GenericTypeCompiler` - renders
type specification strings.
To generate user-defined SQL strings, see
:doc:`/ext/compiler`.
� N� )�crud)�elements)� functions)� operators)�schema)�
selectable)�sqltypes)�visitors� )�exc)�util�allZanalyseZanalyze�and�anyZarray�asZascZ
asymmetricZ
authorizationZbetween�binaryZbothZcase�castZcheck�collate�column�
constraint�createZcross�current_dateZcurrent_role�current_time�current_timestamp�current_user�default�
deferrableZdescZdistinctZdo�else�end�except�false�forZforeignZfreeze�from�fullZgrant�groupZhavingZilike�in� initially�innerZ intersectZinto�isZisnull�joinZleading�leftZlike�limit� localtime�localtimestampZnatural�new�notZnotnullZnullZoff�offset�oldZonZonly�or�orderZouterZoverlapsZplacingZprimaryZ
references�right�select�session_user�setZsimilarZsome� symmetric�tableZthen�toZtrailing�true�union�unique�userZusing�verboseZwhen�wherez
^[A-Z0-9_$]+$z^[A-Z0-9_ $]+$c C s h | ]}t |��qS � )�str)�.0�xrB rB �J/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/compiler.py� <setcomp>� s rG �
�$z5^(?:RESTRICT|CASCADE|SET NULL|NO ACTION|SET DEFAULT)$z^(?:DEFERRED|IMMEDIATE)$z%(?<![:\w\$\x5c]):([\w\$]+)(?![:\w\$])z\x5c(:[\w\$]*)(?![:\w\$])z
%%(%(name)s)s�?z%%sz:[_POSITION]z :%(name)s)�pyformatZqmark�format�numericZnamedz AND z OR z + z * z - z / z % �-z < z <= z != z > z >= z = z IS DISTINCT FROM z IS NOT DISTINCT FROM z || z MATCH z NOT MATCH z IN z NOT IN z, z FROM z AS z IS z IS NOT z COLLATE zEXISTS z DISTINCT zNOT zANY zALL z DESCz ASCz NULLS FIRSTz NULLS LAST�coalesceZCURRENT_DATEZCURRENT_TIMEZCURRENT_TIMESTAMPZCURRENT_USERZ LOCALTIMEZLOCALTIMESTAMP�random�sysdateZSESSION_USERZUSERZCUBEZROLLUPz
GROUPING SETS�month�day�year�second�hour�doy�minute�quarter�dow�week�epoch�milliseconds�microseconds�
timezone_hour�timezone_minute)rR rS rT rU rV rW rX rY rZ r[ r\ r] r^ r_ r` �UNIONz UNION ALL�EXCEPTz
EXCEPT ALL� INTERSECTz
INTERSECT ALLc @ s� e Zd ZdZdZe�� Zdde�� fdd�Ze� dd�dd� �Z
d d
� Zedd� �Z
d
d� Zdd� Zddd�Zedd� �Zdd� Zdd� ZdS )�Compileda Represent a compiled SQL or DDL expression.
The ``__str__`` method of the ``Compiled`` object should produce
the actual text of the statement. ``Compiled`` objects are
specific to their underlying database dialect, and also may
or may not be specific to the columns referenced within a
particular set of bind parameters. In no case should the
``Compiled`` object be dependent on the actual values of those
bind parameters, even though it may reference those values as
defaults.
Nc C sb || _ || _| j j| _|r(| j�|�| _|dk r^|| _|j| _| jrL|j| _ | j
| jf|�| _dS )aq Construct a new :class:`.Compiled` object.
:param dialect: :class:`.Dialect` to compile against.
:param statement: :class:`.ClauseElement` to be compiled.
:param bind: Optional Engine or Connection to compile this
statement against.
:param schema_translate_map: dictionary of schema names to be
translated when forming the resultant SQL
.. versionadded:: 1.1
.. seealso::
:ref:`schema_translating`
:param compile_kwargs: additional kwargs that will be
passed to the initial call to :meth:`.Compiled.process`.
N)�dialect�bindZidentifier_preparer�preparer�_with_schema_translate� statementZsupports_execution�can_execute�_execution_options�execution_options�process�string)�selfre ri rf �schema_translate_mapZcompile_kwargsrB rB rF �__init__ s
zCompiled.__init__z0.7z�The :meth:`.Compiled.compile` method is deprecated and will be removed in a future release. The :class:`.Compiled` object now runs its compilation within the constructor, and this method does nothing.c C s dS )zDProduce the internal string representation of this element.
NrB )ro rB rB rF �compileA s
zCompiled.compilec C s$ | j r|�| ||�S t�| j��d S )N)rj �_execute_compiledr ZObjectNotExecutableErrorri )ro Z
connection�multiparams�paramsrB rB rF �_execute_on_connectionM s zCompiled._execute_on_connectionc C s
t � �dS )z�Return a Compiled that is capable of processing SQL expressions.
If this compiler is one, it would likely just return 'self'.
N)�NotImplementedError)ro rB rB rF �sql_compilerS s zCompiled.sql_compilerc K s |j | f|�S )N)�_compiler_dispatch)ro �obj�kwargsrB rB rF rm ] s zCompiled.processc C s
| j pdS )z3Return the string text of the generated SQL or DDL.� )rn )ro rB rB rF �__str__` s zCompiled.__str__c C s
t � �dS )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.
N)rw )ro ru rB rB rF �construct_paramse s zCompiled.construct_paramsc C s | � � S )z0Return the bind params for this compiled object.)r~ )ro rB rB rF ru o s zCompiled.paramsc O s* | j }|dkrtjddd��|�| ||�S )zExecute this compiled object.Nz>This Compiled object is not bound to any Engine or Connection.Z2afi)�code)rf r ZUnboundExecutionErrorrs )ro rt ru �erB rB rF �executet s zCompiled.executec O s | j ||��� S )zJExecute this compiled object and return the result's
scalar value.)r� �scalar)ro rt ru rB rB rF r� � s zCompiled.scalar)N)�__name__�
__module__�__qualname__�__doc__Z_cached_metadatar
�
immutabledictrl rq Z
deprecatedrr rv �propertyrx rm r} r~ ru r� r� rB rB rB rF rd � s"