Files
Home-AssistantConfig/deps/sqlalchemy/sql/__pycache__/elements.cpython-34.pyc

2100 lines
133 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
|<7C><>W<EFBFBD>
<00>@s<>dZddlmZddlmZmZmZddlmZddlmZddl m
Z
m Z m Z dd l mZdd
lZdd lmZmZmZmZdd lmZdd
lZdd
lZdd
lZd d<00>Zdd<00>Zddd<00>Zd
dd<00>Zdd<00>Zd
dd<00>Zdd<00>Zej Gdd<00>de
<00><00>Z!Gdd<00>dej"e!<00>Z#Gd d!<00>d!e#<00>Z$Gd"d#<00>d#e!<00>Z%Gd$d%<00>d%ee!<00>Z&Gd&d'<00>d'e#<00>Z'Gd(d)<00>d)e#<00>Z(Gd*d+<00>d+e#<00>Z)Gd,d-<00>d-e!<00>Z*Gd.d/<00>d/e*e#<00>Z+e+j,Z,e+j-Z-Gd0d1<00>d1e*e#<00>Z.Gd2d3<00>d3e#<00>Z/d
d4d5<00>Z0Gd6d7<00>d7e#<00>Z1Gd8d9<00>d9e#<00>Z2Gd:d;<00>d;e#<00>Z3Gd<d=<00>d=e#<00>Z4Gd>d?<00>d?e#<00>Z5Gd@dA<00>dAe5<00>Z6GdBdC<00>dCe#<00>Z7GdDdE<00>dEe#<00>Z8GdFdG<00>dGe#<00>Z9GdHdI<00>dIe#<00>Z:GdJdK<00>dKe#<00>Z;GdLdM<00>dMee#<00>Z<GdNdO<00>dOee!<00>Z=GdPdQ<00>dQe=<00>Z>GdRdS<00>dSe=<00>Z?GdTdU<00>dUe=<00>Z@GdVdW<00>dWejAejB<00>ZCGdXdY<00>dYeC<00>ZDGdZd[<00>d[eD<00>ZEGd\d]<00>d]eD<00>ZFGd^d_<00>d_eF<00>ZGeGd`<00>ZHeDZIGdadb<00>dbeD<00>ZJdcdd<00>ZKdedf<00>ZLdgdh<00>ZMdidj<00>ZNdkdl<00>ZOdmdn<00>ZPejQdo<00>dpdq<00><00>ZRdrds<00>ZSdtdu<00>ZTdvdw<00>ZUdxdy<00>ZVdzd{<00>ZWd|d}<00>ZXd~d<00>ZYdd<>d<><00>ZZd<>d<><00>Z[d<>d<><00>Z\d<>d<><00>Z]d<>d<><00>Z^d
d
d<>d<><00>Z_ej`d<>eja<00>Zbd<>d<><00>Zcd<>d<><00>Zdd<>d<><00>Zedd<>d<><00>ZfGd<47>d<><00>d<>e<00>Zgd
S)<29>zpCore SQL expression elements, including :class:`.ClauseElement`,
:class:`.ColumnElement`, and derived classes.
<EFBFBD>)<01>unicode_literals<6C>)<03>util<69>exc<78>
inspection<EFBFBD>)<01>type_api)<01> operators)<03> Visitable<6C>cloned_traverse<73>traverse)<01> AnnotatedN)<04>
Executable<EFBFBD>PARSE_AUTOCOMMIT<49> Immutable<6C>NO_ARG)<01> _generativecKs
|j<00>S)N)<01>_clone)<02>element<6E>kw<6B>r<00>=/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/sql/elements.pyrsrcCs.t|<00>}t|t|<00>tjd|j<00>S)z<>Return the clause ``expression COLLATE collation``.
e.g.::
collate(mycolumn, 'utf8_bin')
produces::
mycolumn COLLATE utf8_bin
<20>type_)<06>_literal_as_binds<64>BinaryExpression<6F>_literal_as_textr <00>collate<74>type)<03>
expressionZ collation<6F>exprrrrr!s
 rFcCs"t|<00>}|j||d|<00>S)aEProduce a ``BETWEEN`` predicate clause.
E.g.::
from sqlalchemy import between
stmt = select([users_table]).where(between(users_table.c.id, 5, 7))
Would produce SQL resembling::
SELECT id, name FROM user WHERE id BETWEEN :id_1 AND :id_2
The :func:`.between` function is a standalone version of the
:meth:`.ColumnElement.between` method available on all
SQL expressions, as in::
stmt = select([users_table]).where(users_table.c.id.between(5, 7))
All arguments passed to :func:`.between`, including the left side
column expression, are coerced from Python scalar values if a
the value is not a :class:`.ColumnElement` subclass. For example,
three fixed values can be compared as in::
print(between(5, 3, 7))
Which would produce::
:param_1 BETWEEN :param_2 AND :param_3
:param expr: a column expression, typically a :class:`.ColumnElement`
instance or alternatively a Python scalar expression to be coerced
into a column expression, serving as the left side of the ``BETWEEN``
expression.
:param lower_bound: a column or Python scalar expression serving as the
lower bound of the right side of the ``BETWEEN`` expression.
:param upper_bound: a column or Python scalar expression serving as the
upper bound of the right side of the ``BETWEEN`` expression.
:param symmetric: if True, will render " BETWEEN SYMMETRIC ". Note
that not all databases support this syntax.
.. versionadded:: 0.9.5
.. seealso::
:meth:`.ColumnElement.between`
<20> symmetric)r<00>between)rZ lower_boundZ upper_boundr rrrr!5s2 r!cCstd|d|dd<00>S)a<>Return a literal clause, bound to a bind parameter.
Literal clauses are created automatically when non-
:class:`.ClauseElement` objects (such as strings, ints, dates, etc.) are
used in a comparison operation with a :class:`.ColumnElement` subclass,
such as a :class:`~sqlalchemy.schema.Column` object. Use this function
to force the generation of a literal clause, which will be created as a
:class:`BindParameter` with a bound value.
:param value: the value to be bound. Can be any Python object supported by
the underlying DB-API, or is translatable via the given type argument.
:param type\_: an optional :class:`~sqlalchemy.types.TypeEngine` which
will provide bind-parameter translation for this literal.
Nr<00>uniqueT)<01> BindParameter)<02>valuerrrr<00>literalksr%cCs<>tj|<00>}t|d<00>r1t|j<00>|<00>St|t<00>rY|j<00>}||_|St|t <00>s<>|dkr{t
<00>St |d|<00>Snt d|d|<00>SdS)avAssociate a SQL expression with a particular type, without rendering
``CAST``.
E.g.::
from sqlalchemy import type_coerce
stmt = select([type_coerce(log_table.date_string, StringDateTime())])
The above construct will produce SQL that is usually otherwise unaffected
by the :func:`.type_coerce` call::
SELECT date_string FROM log
However, when result rows are fetched, the ``StringDateTime`` type
will be applied to result rows on behalf of the ``date_string`` column.
A type that features bound-value handling will also have that behavior
take effect when literal values or :func:`.bindparam` constructs are
passed to :func:`.type_coerce` as targets.
For example, if a type implements the :meth:`.TypeEngine.bind_expression`
method or :meth:`.TypeEngine.bind_processor` method or equivalent,
these functions will take effect at statement compilation/execution time
when a literal value is passed, as in::
# bound-value handling of MyStringType will be applied to the
# literal value "some string"
stmt = select([type_coerce("some string", MyStringType)])
:func:`.type_coerce` is similar to the :func:`.cast` function,
except that it does not render the ``CAST`` expression in the resulting
statement.
:param expression: A SQL expression, such as a :class:`.ColumnElement`
expression or a Python string which will be coerced into a bound literal
value.
:param type_: A :class:`.TypeEngine` class or instance indicating
the type to which the expression is coerced.
.. seealso::
:func:`.cast`
<20>__clause_element__Nr) r<00> to_instance<63>hasattr<74> type_coercer&<00>
isinstancer#rrr
<00>Nullr%<00>Label)rrZbprrrr)s.   r)c Cst|dd|dddd<00>S)awCreate an 'OUT' parameter for usage in functions (stored procedures),
for databases which support them.
The ``outparam`` can be used like a regular function parameter.
The "output" value will be available from the
:class:`~sqlalchemy.engine.ResultProxy` object via its ``out_parameters``
attribute, which returns a dictionary containing the values.
Nrr"F<>
isoutparamT)r#)<02>keyrrrr<00>outparam<61>s
r/cCstjt|<00><00>S)z<>Return a negation of the given clause, i.e. ``NOT(clause)``.
The ``~`` operator is also overloaded on all
:class:`.ColumnElement` subclasses to produce the
same result.
)r <00>invr)<01>clauserrr<00>not_<74>sr2c@s<>eZdZdZdZiZdZgZdZdZ dZ
dZ dZ dZ dZdd<00>Zedd <00><00>Zejd
d <00><00>Zd d <00>Zdd<00>Zdd<00>Zdddd<00>Zdd<00>Zdd<00>Zdd<00>Zdd<00>Zdd<00>Zedd<00>Zd d!<00>Zdd"d#<00>Z ej!d$<00>ddd%d&<00><00>Z"d'd(<00>Z#d)d*<00>Z$d+d,<00>Z%d-d.<00>Z&d/d0<00>Z'd1d2<00>Z(d3d4<00>Z)e)Z*d5d6<00>Z+dS)7<> ClauseElementzSBase class for elements of a programmatically constructed SQL
expression.
r1FNTcCsT|jj|j<00>}|jj<00>|_tjj|<00>tjj|<00>||_ |S)z<>Create a shallow copy of this ClauseElement.
This method may be used by a generative API. Its also used as
part of the "deep" copy afforded by a traversal that combines
the _copy_internals() method.
)
<EFBFBD> __class__<5F>__new__<5F>__dict__<5F>copyr3<00> _cloned_set<65>_reset<65> ColumnElement<6E>
comparator<EFBFBD> _is_clone_of)<02>self<6C>crrrr<00>s  zClauseElement._clonecCs|jS)a.return the 'constructor' for this ClauseElement.
This is for the purposes for creating a new object of
this type. Usually, its just the element's __class__.
However, the "Annotated" version of the object overrides
to return the class of its proxied element.
)r4)r=rrr<00> _constructors
zClauseElement._constructorcCs?tj<00>}|}x&|dk r:|j|<00>|j}qW|S)aReturn the set consisting all cloned ancestors of this
ClauseElement.
Includes this ClauseElement. This accessor tends to be used for
FromClause objects to identify 'equivalent' FROM clauses, regardless
of transformative operations.
N)r<00>
column_set<EFBFBD>addr<)r=<00>s<>frrrr8 s
  zClauseElement._cloned_setcCs#|jj<00>}|jdd<00>|S)Nr<)r6r7<00>pop)r=<00>drrr<00> __getstate__szClauseElement.__getstate__cCs t||<00>S)zgreturn a copy of this ClauseElement with annotations
updated by the given dictionary.
)r )r=<00>valuesrrr<00> _annotate#szClauseElement._annotatecCs t||<00>S)zhreturn a copy of this ClauseElement with annotations
replaced by the given dictionary.
)r )r=rGrrr<00>_with_annotations*szClauseElement._with_annotationscCs|r|j<00>S|SdS)z<>return a copy of this :class:`.ClauseElement` with annotations
removed.
:param values: optional tuple of individual values
to remove.
N)r)r=rG<00>clonerrr<00> _deannotate1s
zClauseElement._deannotatecCs|j|||<00>S)N)Z_execute_clauseelement)r=<00>
connectionZ multiparams<6D>paramsrrr<00>_execute_on_connectionBsz$ClauseElement._execute_on_connectioncOs|jd||<00>S)z<>Return a copy with :func:`bindparam()` elements replaced.
Same functionality as ``params()``, except adds `unique=True`
to affected bind parameters so that multiple statements can be
used.
T)<01>_params)r=<00> optionaldict<63>kwargsrrr<00> unique_paramsEszClauseElement.unique_paramscOs|jd||<00>S)a<>Return a copy with :func:`bindparam()` elements replaced.
Returns a copy of this ClauseElement with :func:`bindparam()`
elements replaced with values taken from the given dictionary::
>>> clause = column('x') + bindparam('foo')
>>> print clause.compile().params
{'foo':None}
>>> print clause.params({'foo':7}).compile().params
{'foo':7}
F)rO)r=rPrQrrrrMOs zClauseElement.paramscsvt|<00>dkr&<00>j|d<19>n$t|<00>dkrJtjd<00><00>n<00><00>fdd<00>}t|ii|d6<>S)Nrrz9params() takes zero or one positional dictionary argumentcsB|j<00>kr+<00>|j|_d|_n<00>r>|j<00>ndS)NF)r.r$<00>required<65>_convert_to_unique)<01>bind)rQr"rr<00>visit_bindparames
 z.ClauseElement._params.<locals>.visit_bindparam<61> bindparam)<05>len<65>updater<00> ArgumentErrorr )r=r"rPrQrVr)rQr"rrO^s zClauseElement._paramscKs
||kS)aTCompare this ClauseElement to the given ClauseElement.
Subclasses should override the default behavior, which is a
straight identity comparison.
\**kw are arguments consumed by subclass compare() methods and
may be used to modify the criteria for comparison.
(see :class:`.ColumnElement`)
r)r=<00>otherrrrr<00>comparems zClauseElement.comparecKsdS)atReassign internal elements to be clones of themselves.
Called during a copy-and-traverse operation on newly
shallow-copied elements to create a deep copy.
The given clone function should be used, which may be applying
additional transformations to the element (i.e. replacement
traversal, cloned traversal, annotations).
Nr)r=rJrrrr<00>_copy_internalszs zClauseElement._copy_internalscKsgS)a<>Return immediate child elements of this :class:`.ClauseElement`.
This is used for visit traversal.
\**kwargs may contain flags that change the collection that is
returned, for example to return a subset of items in order to
cut down on larger traversals, or to return child items from a
different context (such as schema-level collections instead of
clause-level).
r)r=rQrrr<00> get_children<65>s zClauseElement.get_childrencCs|S)aaApply a 'grouping' to this :class:`.ClauseElement`.
This method is overridden by subclasses to return a
"grouping" construct, i.e. parenthesis. In particular
it's used by "binary" expressions to provide a grouping
around themselves when placed into a larger expression,
as well as by :func:`.select` constructs when placed into
the FROM clause of another :func:`.select`. (Note that
subqueries should be normally created using the
:meth:`.Select.alias` method, as many platforms require
nested SELECT statements to be named).
As expressions are composed together, the application of
:meth:`self_group` is automatic - end-user code should never
need to use this method directly. Note that SQLAlchemy's
clause constructs take operator precedence into account -
so parenthesis might not be needed, for example, in
an expression like ``x OR (y AND z)`` - AND takes precedence
over OR.
The base :meth:`self_group` method of :class:`.ClauseElement`
just returns self.
r)r=<00>againstrrr<00>
self_group<EFBFBD>szClauseElement.self_groupzsqlalchemy.engine.defaultcKs^|sH|r|j}qH|jr9|jj}|j}qH|j<00>}n|j|d||<00>S)a Compile this SQL expression.
The return value is a :class:`~.Compiled` object.
Calling ``str()`` or ``unicode()`` on the returned value will yield a
string representation of the result. The
:class:`~.Compiled` object also can return a
dictionary of bind parameter names and values
using the ``params`` accessor.
:param bind: An ``Engine`` or ``Connection`` from which a
``Compiled`` will be acquired. This argument takes precedence over
this :class:`.ClauseElement`'s bound engine, if any.
:param column_keys: Used for INSERT and UPDATE statements, a list of
column names which should be present in the VALUES clause of the
compiled statement. If ``None``, all columns from the target table
object are rendered.
:param dialect: A ``Dialect`` instance from which a ``Compiled``
will be acquired. This argument takes precedence over the `bind`
argument as well as this :class:`.ClauseElement`'s bound engine,
if any.
:param inline: Used for INSERT statements, for a dialect which does
not support inline retrieval of newly generated primary key
columns, will force the expression used to create the new primary
key value to be rendered inline within the INSERT statement's
VALUES clause. This typically refers to Sequence execution but may
also refer to any server-side default generation function
associated with a primary key `Column`.
:param compile_kwargs: optional dictionary of additional parameters
that will be passed through to the compiler within all "visit"
methods. This allows any custom flag to be passed through to
a custom compilation construct, for example. It is also used
for the case of passing the ``literal_binds`` flag through::
from sqlalchemy.sql import table, column, select
t = table('t', column('x'))
s = select([t]).where(t.c.x == 5)
print s.compile(compile_kwargs={"literal_binds": True})
.. versionadded:: 0.9.0
.. seealso::
:ref:`faq_sql_expression_string`
rU)<04>dialectrUZDefaultDialect<63> _compiler)r=<00>defaultrUrarrrr<00>compile<6C>s7    zClauseElement.compilecKs|j|||<00>S)zNReturn a compiler appropriate for this ClauseElement, given a
Dialect.)Zstatement_compiler)r=rarrrrrb<00>szClauseElement._compilercCs9tjrt|j<00><00>St|j<00><00>jdd<00>SdS)N<>ascii<69>backslashreplace)r<00>py3k<33>strrd<00>unicode<64>encode)r=rrr<00>__str__<5F>s zClauseElement.__str__cCs t||<00>S)z<>'and' at the ClauseElement level.
.. deprecated:: 0.9.5 - conjunctions are intended to be
at the :class:`.ColumnElement`. level
)<01>and_)r=r[rrr<00>__and__<5F>szClauseElement.__and__cCs t||<00>S)z<>'or' at the ClauseElement level.
.. deprecated:: 0.9.5 - conjunctions are intended to be
at the :class:`.ColumnElement`. level
)<01>or_)r=r[rrr<00>__or__szClauseElement.__or__cCs$t|d<00>r|jS|j<00>SdS)N<>negation_clause)r(rp<00>_negate)r=rrr<00>
__invert__szClauseElement.__invert__cCs(t|jdtj<00>dtjdd<00>S)Nr_<00>operator<6F>negate)<04>UnaryExpressionr`r r0)r=rrrrqs zClauseElement._negatecCstd<00><00>dS)Nz+Boolean value of this clause is not defined)<01> TypeError)r=rrr<00>__bool__szClauseElement.__bool__cCsI|j}|dkr"tj|<00>Sd|j|jjt|<00>|fSdS)Nz<%s.%s at 0x%x; %s>)<07> description<6F>object<63>__repr__<5F>
__module__r4<00>__name__<5F>id)r=Zfriendlyrrrrzs
   zClauseElement.__repr__),r|r{<00> __qualname__<5F>__doc__<5F>__visit_name__Z _annotationsZsupports_execution<6F> _from_objectsrUr<Z is_selectableZis_clause_elementrx<00>_order_by_label_elementZ_is_from_containerr<00>propertyr?r<00>memoized_propertyr8rFrHrIrKrNrRrMrOr\r]r^r`<00> dependenciesrdrbrkrmrorrrqrw<00> __nonzero__rzrrrrr3<00>sL       
    @     r3cs<>eZdZdZdZdZgZdZdZdZ dZ
dZ dZ fZ ddd<00>Z<00>fdd <00>Zejd
d <00><00>Zejd d <00><00>Zdd<00>Zdd<00>Zdd<00>Zdd<00>Zedd<00><00>Zedd<00><00>Zejdd<00><00>Zejdd<00><00>Zdd<00>Zd d!<00>Zddd"d#<00>Zddd$d%<00>Z d&d'<00>Z!d(d)<00>Z"ejd*d+<00><00>Z#<00>S),r:aZRepresent a column-oriented SQL expression suitable for usage in the
"columns" clause, WHERE clause etc. of a statement.
While the most familiar kind of :class:`.ColumnElement` is the
:class:`.Column` object, :class:`.ColumnElement` serves as the basis
for any unit that may be present in a SQL expression, including
the expressions themselves, SQL functions, bound parameters,
literal expressions, keywords such as ``NULL``, etc.
:class:`.ColumnElement` is the ultimate base class for all such elements.
A wide variety of SQLAlchemy Core functions work at the SQL expression
level, and are intended to accept instances of :class:`.ColumnElement` as
arguments. These functions will typically document that they accept a
"SQL expression" as an argument. What this means in terms of SQLAlchemy
usually refers to an input which is either already in the form of a
:class:`.ColumnElement` object, or a value which can be **coerced** into
one. The coercion rules followed by most, but not all, SQLAlchemy Core
functions with regards to SQL expressions are as follows:
* a literal Python value, such as a string, integer or floating
point value, boolean, datetime, ``Decimal`` object, or virtually
any other Python object, will be coerced into a "literal bound
value". This generally means that a :func:`.bindparam` will be
produced featuring the given value embedded into the construct; the
resulting :class:`.BindParameter` object is an instance of
:class:`.ColumnElement`. The Python value will ultimately be sent
to the DBAPI at execution time as a paramterized argument to the
``execute()`` or ``executemany()`` methods, after SQLAlchemy
type-specific converters (e.g. those provided by any associated
:class:`.TypeEngine` objects) are applied to the value.
* any special object value, typically ORM-level constructs, which
feature a method called ``__clause_element__()``. The Core
expression system looks for this method when an object of otherwise
unknown type is passed to a function that is looking to coerce the
argument into a :class:`.ColumnElement` expression. The
``__clause_element__()`` method, if present, should return a
:class:`.ColumnElement` instance. The primary use of
``__clause_element__()`` within SQLAlchemy is that of class-bound
attributes on ORM-mapped classes; a ``User`` class which contains a
mapped attribute named ``.name`` will have a method
``User.name.__clause_element__()`` which when invoked returns the
:class:`.Column` called ``name`` associated with the mapped table.
* The Python ``None`` value is typically interpreted as ``NULL``,
which in SQLAlchemy Core produces an instance of :func:`.null`.
A :class:`.ColumnElement` provides the ability to generate new
:class:`.ColumnElement`
objects using Python expressions. This means that Python operators
such as ``==``, ``!=`` and ``<`` are overloaded to mimic SQL operations,
and allow the instantiation of further :class:`.ColumnElement` instances
which are composed from other, more fundamental :class:`.ColumnElement`
objects. For example, two :class:`.ColumnClause` objects can be added
together with the addition operator ``+`` to produce
a :class:`.BinaryExpression`.
Both :class:`.ColumnClause` and :class:`.BinaryExpression` are subclasses
of :class:`.ColumnElement`::
>>> from sqlalchemy.sql import column
>>> column('a') + column('b')
<sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
>>> print column('a') + column('b')
a + b
.. seealso::
:class:`.Column`
:func:`.expression.column`
<20>columnFNTcCsT|tjtjtjfkrL|jjtjjkrLt|tj tj
<00>S|SdS)N) r rlrn<00>_asboolr<00>_type_affinityr<00> BOOLEANTYPE<50> AsBoolean<61>istrue<75>isfalse)r=r_rrrr`<00>s
 zColumnElement.self_groupcsE|jjtjjkr.t|tjtj<00>Stt |<00>j
<00>SdS)N) rr<>rr<>r<>r r<>r<><00>superr:rq)r=)r4rrrq<00>szColumnElement._negatecCstjS)N)r<00>NULLTYPE)r=rrrr<00>szColumnElement.typec CsFy|jj}Wn%tk
r7td|j<16><00>Yn X||<00>SdS)NzOObject %r associated with '.type' attribute is not a TypeEngine class or object)r<00>comparator_factory<72>AttributeErrorrv)r=r<>rrrr;<00>s zColumnElement.comparatorc Cs[yt|j|<00>SWn@tk
rVtdt|<00>jt|j<00>j|f<16><00>YnXdS)Nz3Neither %r object nor %r object has an attribute %r)<05>getattrr;r<>rr|)r=r.rrr<00> __getattr__<5F>s  zColumnElement.__getattr__cOs||j||<00>S)N)r;)r=<00>opr[rQrrr<00>operate<74>szColumnElement.operatecKs|||j|<00>S)N)r;)r=r<>r[rQrrr<00>reverse_operate<74>szColumnElement.reverse_operatec Cs"td|d|d|jdd<00>S)N<>_compared_to_operator<6F>_compared_to_typer"T)r#r)r=rs<00>objrrr<00> _bind_param<61>s zColumnElement._bind_paramcCs|S)z^Return a column expression.
Part of the inspection interface; returns self.
r)r=rrrr<00>szColumnElement.expressioncCs|fS)Nr)r=rrr<00>_select_iterable<6C>szColumnElement._select_iterablecCstjdd<00>|jD<><00>S)Ncss$|]}t|d<00>s|VqdS)<02>_proxiesN)r()<02>.0r>rrr<00> <genexpr><3E>sz-ColumnElement.base_columns.<locals>.<genexpr>)rr@<00> proxy_set)r=rrr<00> base_columns<6E>szColumnElement.base_columnscCsLtj|g<00>}t|d<00>rHx$|jD]}|j|j<00>q+Wn|S)Nr<4E>)rr@r(r<>rYr<>)r=rBr>rrrr<>s
zColumnElement.proxy_setcCst|jj|j<00><00>S)zoReturn True if the given :class:`.ColumnElement`
has a common ancestor to this :class:`.ColumnElement`.)<03>boolr<6C><00> intersection)r=Z othercolumnrrr<00>shares_lineage
szColumnElement.shares_lineagecCs.t|d<00>o-t|d<00>o-|j|jkS)zhReturn True if the given column element compares to this one
when targeting within a result row.<2E>name)r(r<>)r=r[rrr<00>_compare_name_for_resultsz&ColumnElement._compare_name_for_resultcKs<>|dkr^|j}|jr*|j}qdyt|<00>}Wqdtjk
rZ|j}YqdXn|}t|ryt|<00>n|dt|dd<00>d|<00>}|g|_|j dk r<>|j j
j |<00>|_ n||j |<|S)z<>Create a new :class:`.ColumnElement` representing this
:class:`.ColumnElement` as it appears in the select list of a
descending selectable.
Nrr<00> _selectable) <0A>
anon_labelr.rhrZUnsupportedCompilationError<6F> ColumnClause<73> _as_truncatedr<64>r<>r<<00>columns<6E>get<65>_columns)r=<00>
selectabler<EFBFBD><00>name_is_truncatablerr.<00>corrr<00> _make_proxys$       zColumnElement._make_proxycKs|f}|r1||kr1||j|<00>}nxG|D];}|rW|j|<00>rWdSt|<00>t|<00>kr8dSq8WdSdS)a<>Compare this ColumnElement to another.
Special arguments understood:
:param use_proxies: when True, consider two columns that
share a common base column as equivalent (i.e. shares_lineage())
:param equivalents: a dictionary of columns as keys mapped to sets
of columns. If the given "other" column is present in this
dictionary, if any of the columns in the corresponding set() pass
the comparison test, the result is True. This is used to expand the
comparison to other columns that may be known to be equivalent to
this one via foreign key or other criterion.
TFN)<03>unionr<6E><00>hash)r=r[Z use_proxiesZ equivalentsrZ
to_compareZothrrrr\6s  zColumnElement.comparecCs t||<00>S)z<>Produce a type cast, i.e. ``CAST(<expression> AS <type>)``.
This is a shortcut to the :func:`~.expression.cast` function.
.. versionadded:: 1.0.7
)<01>Cast)r=rrrr<00>castRszColumnElement.castcCst|||j<00>S)z<>Produce a column label, i.e. ``<columnname> AS <name>``.
This is a shortcut to the :func:`~.expression.label` function.
if 'name' is None, an anonymous label name will be generated.
)r,r)r=r<>rrr<00>label\szColumnElement.labelcCsEx|jdk r|j}qWtdt|<00>t|dd<00>f<16>S)aprovides a constant 'anonymous label' for this ColumnElement.
This is a label() expression which will be named at compile time.
The same label() is returned each time anon_label is called so
that expressions can reference anon_label multiple times, producing
the same label name at compile time.
the compiler uses this function automatically at compile time
for expressions that are known to be 'unnamed' like binary
expressions and function calls.
Nz
%%(%d %s)sr<73><00>anon)r<<00>_anonymous_labelr}r<>)r=rrrr<>fs zColumnElement.anon_label)$r|r{r~rr<><00> primary_key<65> foreign_keys<79>_labelr.<00>
_key_label<EFBFBD>_render_label_in_columns_clause<73>_resolve_label<65>_allow_label_resolveZ
_alt_namesr`rqrr<>rr;r<>r<>r<>r<>r<>rr<>r<>r<>r<>r<>r<>r\r<>r<>r<>rr)r4rr:(s< H

        
r:c @s<>eZdZdZdZdZeddeddddddd<00> Zdd<00>Ze d d
<00><00>Z
d d <00>Z d d<00>Z dd<00>Z dd<00>Zdd<00>ZdS)r#a<>Represent a "bound expression".
:class:`.BindParameter` is invoked explicitly using the
:func:`.bindparam` function, as in::
from sqlalchemy import bindparam
stmt = select([users_table]).\
where(users_table.c.name == bindparam('username'))
Detailed discussion of how :class:`.BindParameter` is used is
at :func:`.bindparam`.
.. seealso::
:func:`.bindparam`
rWFNc Cs<>t|t<00>r$|j}|j}n|tkrK|tkoE|dk}n|tkr`d}n|dk r~t||<00>}n|r<>tdt|<00>|p<>df<16>|_n|p<>tdt|<00><16>|_|j|_|p<>d|_ ||_
||_ ||_ ||_ ||_|dkrg|
dk rC|
j| |<00>|_q<>tjjt|<00>tj<00>|_n't|t<00>r<>|<00>|_n ||_dS)a<>!Produce a "bound expression".
The return value is an instance of :class:`.BindParameter`; this
is a :class:`.ColumnElement` subclass which represents a so-called
"placeholder" value in a SQL expression, the value of which is
supplied at the point at which the statement in executed against a
database connection.
In SQLAlchemy, the :func:`.bindparam` construct has
the ability to carry along the actual value that will be ultimately
used at expression time. In this way, it serves not just as
a "placeholder" for eventual population, but also as a means of
representing so-called "unsafe" values which should not be rendered
directly in a SQL statement, but rather should be passed along
to the :term:`DBAPI` as values which need to be correctly escaped
and potentially handled for type-safety.
When using :func:`.bindparam` explicitly, the use case is typically
one of traditional deferment of parameters; the :func:`.bindparam`
construct accepts a name which can then be referred to at execution
time::
from sqlalchemy import bindparam
stmt = select([users_table]).\
where(users_table.c.name == bindparam('username'))
The above statement, when rendered, will produce SQL similar to::
SELECT id, name FROM user WHERE name = :username
In order to populate the value of ``:username`` above, the value
would typically be applied at execution time to a method
like :meth:`.Connection.execute`::
result = connection.execute(stmt, username='wendy')
Explicit use of :func:`.bindparam` is also common when producing
UPDATE or DELETE statements that are to be invoked multiple times,
where the WHERE criterion of the statement is to change on each
invocation, such as::
stmt = (users_table.update().
where(user_table.c.name == bindparam('username')).
values(fullname=bindparam('fullname'))
)
connection.execute(
stmt, [{"username": "wendy", "fullname": "Wendy Smith"},
{"username": "jack", "fullname": "Jack Jones"},
]
)
SQLAlchemy's Core expression system makes wide use of
:func:`.bindparam` in an implicit sense. It is typical that Python
literal values passed to virtually all SQL expression functions are
coerced into fixed :func:`.bindparam` constructs. For example, given
a comparison operation such as::
expr = users_table.c.name == 'Wendy'
The above expression will produce a :class:`.BinaryExpression`
construct, where the left side is the :class:`.Column` object
representing the ``name`` column, and the right side is a
:class:`.BindParameter` representing the literal value::
print(repr(expr.right))
BindParameter('%(4327771088 name)s', 'Wendy', type_=String())
The expression above will render SQL such as::
user.name = :name_1
Where the ``:name_1`` parameter name is an anonymous name. The
actual string ``Wendy`` is not in the rendered string, but is carried
along where it is later used within statement execution. If we
invoke a statement like the following::
stmt = select([users_table]).where(users_table.c.name == 'Wendy')
result = connection.execute(stmt)
We would see SQL logging output as::
SELECT "user".id, "user".name
FROM "user"
WHERE "user".name = %(name_1)s
{'name_1': 'Wendy'}
Above, we see that ``Wendy`` is passed as a parameter to the database,
while the placeholder ``:name_1`` is rendered in the appropriate form
for the target database, in this case the Postgresql database.
Similarly, :func:`.bindparam` is invoked automatically
when working with :term:`CRUD` statements as far as the "VALUES"
portion is concerned. The :func:`.insert` construct produces an
``INSERT`` expression which will, at statement execution time,
generate bound placeholders based on the arguments passed, as in::
stmt = users_table.insert()
result = connection.execute(stmt, name='Wendy')
The above will produce SQL output as::
INSERT INTO "user" (name) VALUES (%(name)s)
{'name': 'Wendy'}
The :class:`.Insert` construct, at compilation/execution time,
rendered a single :func:`.bindparam` mirroring the column
name ``name`` as a result of the single ``name`` parameter
we passed to the :meth:`.Connection.execute` method.
:param key:
the key (e.g. the name) for this bind param.
Will be used in the generated
SQL statement for dialects that use named parameters. This
value may be modified when part of a compilation operation,
if other :class:`BindParameter` objects exist with the same
key, or if its length is too long and truncation is
required.
:param value:
Initial value for this bind param. Will be used at statement
execution time as the value for this parameter passed to the
DBAPI, if no other value is indicated to the statement execution
method for this particular parameter name. Defaults to ``None``.
:param callable\_:
A callable function that takes the place of "value". The function
will be called at statement execution time to determine the
ultimate value. Used for scenarios where the actual bind
value cannot be determined at the point at which the clause
construct is created, but embedded bind values are still desirable.
:param type\_:
A :class:`.TypeEngine` class or instance representing an optional
datatype for this :func:`.bindparam`. If not passed, a type
may be determined automatically for the bind, based on the given
value; for example, trivial Python types such as ``str``,
``int``, ``bool``
may result in the :class:`.String`, :class:`.Integer` or
:class:`.Boolean` types being autoamtically selected.
The type of a :func:`.bindparam` is significant especially in that
the type will apply pre-processing to the value before it is
passed to the database. For example, a :func:`.bindparam` which
refers to a datetime value, and is specified as holding the
:class:`.DateTime` type, may apply conversion needed to the
value (such as stringification on SQLite) before passing the value
to the database.
:param unique:
if True, the key name of this :class:`.BindParameter` will be
modified if another :class:`.BindParameter` of the same name
already has been located within the containing
expression. This flag is used generally by the internals
when producing so-called "anonymous" bound expressions, it
isn't generally applicable to explicitly-named :func:`.bindparam`
constructs.
:param required:
If ``True``, a value is required at execution time. If not passed,
it defaults to ``True`` if neither :paramref:`.bindparam.value`
or :paramref:`.bindparam.callable` were passed. If either of these
parameters are present, then :paramref:`.bindparam.required`
defaults to ``False``.
.. versionchanged:: 0.8 If the ``required`` flag is not specified,
it will be set automatically to ``True`` or ``False`` depending
on whether or not the ``value`` or ``callable`` parameters
were specified.
:param quote:
True if this parameter name requires quoting and is not
currently known as a SQLAlchemy reserved word; this currently
only applies to the Oracle backend, where bound names must
sometimes be quoted.
:param isoutparam:
if True, the parameter should be treated like a stored procedure
"OUT" parameter. This applies to backends such as Oracle which
support OUT parameters.
.. seealso::
:ref:`coretutorial_bind_param`
:ref:`coretutorial_insert_expressions`
:func:`.outparam`
Nz
%%(%d %s)s<>paramz %%(%d param)s)r*r<>rr.r<00> quoted_namer<65>r}Z_identifying_key<65> _orig_keyr"r$<00>callabler-rSZcoerce_compared_valuer<00> _type_mapr<70>r<>) r=r.r$rr"rS<00>quoteZ callable_r-r<>r<>rrr<00>__init__<5F>s<<00>               zBindParameter.__init__cCsa|j<00>}||_d|_d|_|jtjkr]tjjt|<00>tj<00>|_n|S)zXReturn a copy of this :class:`.BindParameter` with the given value
set.
NF) rr$r<>rSrrr<>r<>r<>)r=r$Zclonedrrr<00> _with_value<75>s    zBindParameter._with_valuecCs|jr|j<00>S|jSdS)z<>Return the value of this bound parameter,
taking into account if the ``callable`` parameter
was set.
The ``callable`` value will be evaluated
and returned if present, else ``value``.
N)r<>r$)r=rrr<00>effective_value<75>s

zBindParameter.effective_valuecCsGtj|<00>}|jrCtdt|<00>|jp3df<16>|_n|S)Nz
%%(%d %s)sr<73>)r3rr"r<>r}r<>r.)r=r>rrrr<00>s
 zBindParameter._clonecCsA|js=d|_tdt|<00>|jp-df<16>|_ndS)NTz
%%(%d %s)sr<73>)r"r<>r}r<>r.)r=rrrrT<00>s  z BindParameter._convert_to_uniquecKs4t|t<00>o3|jj|j<00>o3|j|jkS)z@Compare this :class:`BindParameter` to the given
clause.)r*r#rZ_compare_type_affinityr$)r=r[rrrrr\<00>szBindParameter.comparecCsH|jj<00>}|j}|jr:|j<00>}d|d<n||d<|S)z4execute a deferred value for serialization purposes.Nr<4E>r$)r6r7r$r<>)r=rE<00>vrrrrF<00>s    
zBindParameter.__getstate__cCsd|j|j|jfS)NzBindParameter(%r, %r, type_=%r))r.r$r)r=rrrrz<00>s zBindParameter.__repr__)r|r{r~rr<>Z_is_crudrr<>r<>r<>r<>rrTr\rFrzrrrrr#|s <0F>     r#c@s(eZdZdZdZdd<00>ZdS)<06>
TypeClausezTHandle a type keyword in a SQL statement.
Used by the ``Case`` statement.
<20>
typeclausecCs ||_dS)N)r)r=rrrrr<><00>szTypeClause.__init__N)r|r{r~rr<>r<>rrrrr<><00>s r<>c@s<eZdZdZdZejdej<00>Ze j
j ie d6<>Z
e dd<00><00>Ze dd<00><00>ZgZd ZZZd
Zd d d <00>Zed d d d d d<00><00>Zedd<00><00>Zejd<00>dd<00><00>Ze dd<00><00>Ze dd<00><00>Zd dd<00>Ze dd<00>Z!dd<00>Z"dd<00>Z#d S) <20>
TextClauseaURepresent a literal SQL text fragment.
E.g.::
from sqlalchemy import text
t = text("SELECT * FROM users")
result = connection.execute(t)
The :class:`.Text` construct is produced using the :func:`.text`
function; see that function for full documentation.
.. seealso::
:func:`.text`
Z
textclausez(?<![:\w\x5c]):(\w+)(?!:)<29>
autocommitcCs|fS)Nr)r=rrrr<><00>szTextClause._select_iterablecCs|S)Nr)r=rrrr<><00>szTextClause.selectableNFcs@|<00>_i<00>_<00>fdd<00>}<00>jj||<00><00>_dS)Ncs6t|jd<00><00><00>j|jd<00><d|jd<00>S)Nrz:%s)r#<00>group<75> _bindparams)<01>m)r=rr<00>repls%z!TextClause.__init__.<locals>.repl)Z_bindr<64><00>_bind_params_regex<65>sub<75>text)r=r<>rUr<>r)r=rr<>s  zTextClause.__init__cCstt|d|<00>}|r*|j|<00>}n|rB|j|<00>}n|dk rptjd<00>|jd|<00>}n|S)aConstruct a new :class:`.TextClause` clause, representing
a textual SQL string directly.
E.g.::
from sqlalchemy import text
t = text("SELECT * FROM users")
result = connection.execute(t)
The advantages :func:`.text` provides over a plain string are
backend-neutral support for bind parameters, per-statement
execution options, as well as
bind parameter and result-column typing behavior, allowing
SQLAlchemy type constructs to play a role when executing
a statement that is specified literally. The construct can also
be provided with a ``.c`` collection of column elements, allowing
it to be embedded in other SQL expression constructs as a subquery.
Bind parameters are specified by name, using the format ``:name``.
E.g.::
t = text("SELECT * FROM users WHERE id=:user_id")
result = connection.execute(t, user_id=12)
For SQL statements where a colon is required verbatim, as within
an inline string, use a backslash to escape::
t = text("SELECT * FROM users WHERE name='\:username'")
The :class:`.TextClause` construct includes methods which can
provide information about the bound parameters as well as the column
values which would be returned from the textual statement, assuming
it's an executable SELECT type of statement. The
:meth:`.TextClause.bindparams` method is used to provide bound
parameter detail, and :meth:`.TextClause.columns` method allows
specification of return columns including names and types::
t = text("SELECT * FROM users WHERE id=:user_id").\
bindparams(user_id=7).\
columns(id=Integer, name=String)
for id, name in connection.execute(t):
print(id, name)
The :func:`.text` construct is used in cases when
a literal string SQL fragment is specified as part of a larger query,
such as for the WHERE clause of a SELECT statement::
s = select([users.c.id, users.c.name]).where(text("id=:user_id"))
result = connection.execute(s, user_id=12)
:func:`.text` is also used for the construction
of a full, standalone statement using plain text.
As such, SQLAlchemy refers
to it as an :class:`.Executable` object, and it supports
the :meth:`Executable.execution_options` method. For example,
a :func:`.text` construct that should be subject to "autocommit"
can be set explicitly so using the
:paramref:`.Connection.execution_options.autocommit` option::
t = text("EXEC my_procedural_thing()").\
execution_options(autocommit=True)
Note that SQLAlchemy's usual "autocommit" behavior applies to
:func:`.text` constructs implicitly - that is, statements which begin
with a phrase such as ``INSERT``, ``UPDATE``, ``DELETE``,
or a variety of other phrases specific to certain backends, will
be eligible for autocommit if no transaction is in progress.
:param text:
the text of the SQL statement to be created. use ``:<param>``
to specify bind parameters; they will be compiled to their
engine-specific format.
:param autocommit:
Deprecated. Use .execution_options(autocommit=<True|False>)
to set the autocommit option.
:param bind:
an optional connection or engine to be used for this text query.
:param bindparams:
Deprecated. A list of :func:`.bindparam` instances used to
provide information about parameters embedded in the statement.
This argument now invokes the :meth:`.TextClause.bindparams`
method on the construct before returning it. E.g.::
stmt = text("SELECT * FROM table WHERE id=:id",
bindparams=[bindparam('id', value=5, type_=Integer)])
Is equivalent to::
stmt = text("SELECT * FROM table WHERE id=:id").\
bindparams(bindparam('id', value=5, type_=Integer))
.. deprecated:: 0.9.0 the :meth:`.TextClause.bindparams` method
supersedes the ``bindparams`` argument to :func:`.text`.
:param typemap:
Deprecated. A dictionary mapping the names of columns
represented in the columns clause of a ``SELECT`` statement
to type objects,
which will be used to perform post-processing on columns within
the result set. This parameter now invokes the
:meth:`.TextClause.columns` method, which returns a
:class:`.TextAsFrom` construct that gains a ``.c`` collection and
can be embedded in other expressions. E.g.::
stmt = text("SELECT * FROM table",
typemap={'id': Integer, 'name': String},
)
Is equivalent to::
stmt = text("SELECT * FROM table").columns(id=Integer,
name=String)
Or alternatively::
from sqlalchemy.sql import column
stmt = text("SELECT * FROM table").columns(
column('id', Integer),
column('name', String)
)
.. deprecated:: 0.9.0 the :meth:`.TextClause.columns` method
supersedes the ``typemap`` argument to :func:`.text`.
rUNzLautocommit on text() is deprecated. Use .execution_options(autocommit=True)r<>)r<><00>
bindparamsr<EFBFBD>rZwarn_deprecatedZexecution_options)r=r<>rUr<><00>typemapr<70>Zstmtrrr<00> _create_texts<00>  zTextClause._create_textc Os<>|jj<00>|_}xW|D]O}y||j}Wn(tk
r^tjd|j<16><00>YqX|||j<qWxc|j<00>D]U\}}y||}Wn%tk
r<>tjd|<16><00>Yq}X|j|<00>||<q}WdS)a^ Establish the values and/or types of bound parameters within
this :class:`.TextClause` construct.
Given a text construct such as::
from sqlalchemy import text
stmt = text("SELECT id, name FROM user WHERE name=:name "
"AND timestamp=:timestamp")
the :meth:`.TextClause.bindparams` method can be used to establish
the initial value of ``:name`` and ``:timestamp``,
using simple keyword arguments::
stmt = stmt.bindparams(name='jack',
timestamp=datetime.datetime(2012, 10, 8, 15, 12, 5))
Where above, new :class:`.BindParameter` objects
will be generated with the names ``name`` and ``timestamp``, and
values of ``jack`` and ``datetime.datetime(2012, 10, 8, 15, 12, 5)``,
respectively. The types will be
inferred from the values given, in this case :class:`.String` and
:class:`.DateTime`.
When specific typing behavior is needed, the positional ``*binds``
argument can be used in which to specify :func:`.bindparam` constructs
directly. These constructs must include at least the ``key``
argument, then an optional value and type::
from sqlalchemy import bindparam
stmt = stmt.bindparams(
bindparam('name', value='jack', type_=String),
bindparam('timestamp', type_=DateTime)
)
Above, we specified the type of :class:`.DateTime` for the
``timestamp`` bind, and the type of :class:`.String` for the ``name``
bind. In the case of ``name`` we also set the default value of
``"jack"``.
Additional bound parameters can be supplied at statement execution
time, e.g.::
result = connection.execute(stmt,
timestamp=datetime.datetime(2012, 10, 8, 15, 12, 5))
The :meth:`.TextClause.bindparams` method can be called repeatedly,
where it will re-use existing :class:`.BindParameter` objects to add
new information. For example, we can call
:meth:`.TextClause.bindparams` first with typing information, and a
second time with value information, and it will be combined::
stmt = text("SELECT id, name FROM user WHERE name=:name "
"AND timestamp=:timestamp")
stmt = stmt.bindparams(
bindparam('name', type_=String),
bindparam('timestamp', type_=DateTime)
)
stmt = stmt.bindparams(
name='jack',
timestamp=datetime.datetime(2012, 10, 8, 15, 12, 5)
)
.. versionadded:: 0.9.0 The :meth:`.TextClause.bindparams` method
supersedes the argument ``bindparams`` passed to
:func:`~.expression.text`.
z?This text() construct doesn't define a bound parameter named %rN)r<>r7r.<00>KeyErrorrrZ<00>itemsr<73>)r=ZbindsZnames_to_values<65>
new_paramsrU<00>existingr.r$rrrr<><00>s"G   zTextClause.bindparamszsqlalchemy.sql.selectablecs@<00>fdd<00>|D<>dd<00><00>j<00>D<>}|j||<00>S)ad Turn this :class:`.TextClause` object into a :class:`.TextAsFrom`
object that can be embedded into another statement.
This function essentially bridges the gap between an entirely
textual SELECT statement and the SQL expression language concept
of a "selectable"::
from sqlalchemy.sql import column, text
stmt = text("SELECT id, name FROM some_table")
stmt = stmt.columns(column('id'), column('name')).alias('st')
stmt = select([mytable]).\
select_from(
mytable.join(stmt, mytable.c.name == stmt.c.name)
).where(stmt.c.id > 5)
Above, we used untyped :func:`.column` elements. These can also have
types specified, which will impact how the column behaves in
expressions as well as determining result set behavior::
stmt = text("SELECT id, name, timestamp FROM some_table")
stmt = stmt.columns(
column('id', Integer),
column('name', Unicode),
column('timestamp', DateTime)
)
for id, name, timestamp in connection.execute(stmt):
print(id, name, timestamp)
Keyword arguments allow just the names and types of columns to be
specified, where the :func:`.column` elements will be generated
automatically::
stmt = text("SELECT id, name, timestamp FROM some_table")
stmt = stmt.columns(
id=Integer,
name=Unicode,
timestamp=DateTime
)
for id, name, timestamp in connection.execute(stmt):
print(id, name, timestamp)
The :meth:`.TextClause.columns` method provides a direct
route to calling :meth:`.FromClause.alias` as well as
:meth:`.SelectBase.cte` against a textual SELECT statement::
stmt = stmt.columns(id=Integer, name=String).cte('st')
stmt = select([sometable]).where(sometable.c.id == stmt.c.id)
.. versionadded:: 0.9.0 :func:`.text` can now be converted into a
fully featured "selectable" construct using the
:meth:`.TextClause.columns` method. This method supersedes the
``typemap`` argument to :func:`.text`.
csCg|]9}|j<00>kr9t|j<00>j|j<00><00>n|<00>qSr)r.r<>rD)r<><00>col)<01>typesrr<00>
<listcomp>=s z&TextClause.columns.<locals>.<listcomp>cSs%g|]\}}t||<00><00>qSr)r<>)r<>r.rrrrr<>As )r<>Z
TextAsFrom)r=r<><00>colsr<73>Z
input_colsr)r<>rr<><00>s?zTextClause.columnscCstjS)N)rr<>)r=rrrrDszTextClause.typecCs|jj|<00>S)N)rr<>)r=rrrr;HszTextClause.comparatorcCs!|tjkrt|<00>S|SdS)N)r Zin_op<6F>Grouping)r=r_rrrr`Ls
zTextClause.self_groupc s2t<00><00>fdd<00>|jj<00>D<><00>|_dS)Nc3s'|]}|j<00>|<00><00>fVqdS)N)r.)r<><00>b)rJrrrr<>Ssz-TextClause._copy_internals.<locals>.<genexpr>)<03>dictr<74>rG)r=rJrr)rJrrr]RszTextClause._copy_internalscKst|jj<00><00>S)N)<03>listr<74>rG)r=rQrrrr^VszTextClause.get_childrencCst|t<00>o|j|jkS)N)r*r<>r<>)r=r[rrrr\YszTextClause.compare)$r|r{r~rr<><00>rerd<00>UNICODEr<45>r<00>_execution_optionsr<73>rr<>r<>r<>Z _hide_fromsr.r<>r<>r<>r<><00> classmethodr<64>rr<>rr<>r<>rr;r`rr]r^r\rrrrr<><00>s,   <15>]F r<>c@sOeZdZdZdZejdd<00><00>Zedd<00><00>Z dd<00>Z
d S)
r+z<>Represent the NULL keyword in a SQL statement.
:class:`.Null` is accessed as a constant via the
:func:`.null` function.
<20>nullcCstjS)N)rr<>)r=rrrrgsz Null.typecCst<00>S)z+Return a constant :class:`.Null` construct.)r+)<01>clsrrr<00> _instancekszNull._instancecCs t|t<00>S)N)r*r+)r=r[rrrr\qsz Null.compareN) r|r{r~rr<>rr<>rr<>r<>r\rrrrr+]s
r+c@s[eZdZdZdZejdd<00><00>Zdd<00>Ze dd<00><00>Z
d d
<00>Z d S) <0C>False_z<5F>Represent the ``false`` keyword, or equivalent, in a SQL statement.
:class:`.False_` is accessed as a constant via the
:func:`.false` function.
<20>falsecCstjS)N)rr<>)r=rrrrsz False_.typecCst<00>S)N)<01>True_)r=rrrrq<00>szFalse_._negatecCst<00>S)aReturn a :class:`.False_` construct.
E.g.::
>>> from sqlalchemy import false
>>> print select([t.c.x]).where(false())
SELECT x FROM t WHERE false
A backend which does not support true/false constants will render as
an expression against 1 or 0::
>>> print select([t.c.x]).where(false())
SELECT x FROM t WHERE 0 = 1
The :func:`.true` and :func:`.false` constants also feature
"short circuit" operation within an :func:`.and_` or :func:`.or_`
conjunction::
>>> print select([t.c.x]).where(or_(t.c.x > 5, true()))
SELECT x FROM t WHERE true
>>> print select([t.c.x]).where(and_(t.c.x > 5, false()))
SELECT x FROM t WHERE false
.. versionchanged:: 0.9 :func:`.true` and :func:`.false` feature
better integrated behavior within conjunctions and on dialects
that don't support true/false constants.
.. seealso::
:func:`.true`
)r<>)r<>rrrr<><00>s$zFalse_._instancecCs t|t<00>S)N)r*r<>)r=r[rrrr\<00>szFalse_.compareN) r|r{r~rr<>rr<>rrqr<>r<>r\rrrrr<>us  &r<>c@smeZdZdZdZejdd<00><00>Zdd<00>Ze dd<00><00>Z
e d d
<00><00>Z d d <00>Z d S)r<>z<>Represent the ``true`` keyword, or equivalent, in a SQL statement.
:class:`.True_` is accessed as a constant via the
:func:`.true` function.
<20>truecCstjS)N)rr<>)r=rrrr<00>sz
True_.typecCst<00>S)N)r<>)r=rrrrq<00>sz True_._negatecCs|dkr|j<00>S|SdS)N)r<>)r<>r[rrr<00>_ifnone<6E>s 
z True_._ifnonecCst<00>S)aReturn a constant :class:`.True_` construct.
E.g.::
>>> from sqlalchemy import true
>>> print select([t.c.x]).where(true())
SELECT x FROM t WHERE true
A backend which does not support true/false constants will render as
an expression against 1 or 0::
>>> print select([t.c.x]).where(true())
SELECT x FROM t WHERE 1 = 1
The :func:`.true` and :func:`.false` constants also feature
"short circuit" operation within an :func:`.and_` or :func:`.or_`
conjunction::
>>> print select([t.c.x]).where(or_(t.c.x > 5, true()))
SELECT x FROM t WHERE true
>>> print select([t.c.x]).where(and_(t.c.x > 5, false()))
SELECT x FROM t WHERE false
.. versionchanged:: 0.9 :func:`.true` and :func:`.false` feature
better integrated behavior within conjunctions and on dialects
that don't support true/false constants.
.. seealso::
:func:`.false`
)r<>)r<>rrrr<><00>s$zTrue_._instancecCs t|t<00>S)N)r*r<>)r=r[rrrr\<00>sz True_.compareN) r|r{r~rr<>rr<>rrqr<>r<>r<>r\rrrrr<><00>s  &r<>c@s<>eZdZdZdZdd<00>Zdd<00>Zdd<00>Zed d
<00><00>Z d d <00>Z
e d d<00>Z dd<00>Z edd<00><00>Zddd<00>Zdd<00>ZdS)<18>
ClauseListzzDescribe a list of clauses, separated by an operator.
By default, is comma-separated, such as a column listing.
<20>
clauselistcs<>|jdtj<00><00>_|jdd<00><00>_|jdd<00><00>_|jdt<00><00><00>jr<00><00>fdd<00>|D<><00>_n<00>fdd<00>|D<><00>_dS) Nrsr<>T<>group_contentsrcs+g|]!}<00>|<00>jd<00>j<00><01>qS)r_)r`rs)r<>r1)r=<00>text_converterrrr<>s z'ClauseList.__init__.<locals>.<listcomp>csg|]}<00>|<00><00>qSrr)r<>r1)r<>rrr<>s )rDr Zcomma_oprsr<>r<><00>_expression_literal_as_text<78>clauses)r=r<>rQr)r=r<>rr<><00>s  zClauseList.__init__cCs t|j<00>S)N)<02>iterr<72>)r=rrr<00>__iter__
szClauseList.__iter__cCs t|j<00>S)N)rXr<>)r=rrr<00>__len__ szClauseList.__len__cCs
t|<00>S)N)r<>)r=rrrr<>szClauseList._select_iterablecCsK|jr1|jjt|<00>jd|j<00><01>n|jjt|<00><00>dS)Nr_)r<>r<><00>appendrr`rs)r=r1rrrr<>s  zClauseList.appendc s&<00><00>fdd<00>|jD<>|_dS)Ncsg|]}<00>|<00><00><00>qSrr)r<>r1)rJrrrr<>s z.ClauseList._copy_internals.<locals>.<listcomp>)r<>)r=rJrr)rJrrr]szClauseList._copy_internalscKs|jS)N)r<>)r=rQrrrr^szClauseList.get_childrencCs#ttjdd<00>|jD<><00><00>S)NcSsg|]}|j<00>qSr)r<>)r<>r>rrrr<>#s z,ClauseList._from_objects.<locals>.<listcomp>)r<><00> itertools<6C>chainr<6E>)r=rrrr<>!szClauseList._from_objectsNcCs0|jr(tj|j|<00>r(t|<00>S|SdS)N)r<>r <00> is_precedentrsr<>)r=r_rrrr`%s
zClauseList.self_groupcKs<>t|t<00> r<t|j<00>dkr<|jdj||<00>St|t<00>r<>t|j<00>t|j<00>kr<>x[tdt|j<00><00>D]*}|j|j|j||<00>s<>dSq<53>W|j|jkSndSdS)z<>Compare this :class:`.ClauseList` to the given :class:`.ClauseList`,
including a comparison of all the clause items.
rrFN)r*r<>rXr<>r\<00>rangers)r=r[r<00>irrrr\+s% zClauseList.compare)r|r{r~rr<>r<>r<>r<>r<>r<>r<>rr]r^r<>r`r\rrrrr<><00>s      r<>cs<>eZdZdZdd<00>Zedd<00><00>Zedd<00><00>Zedd <00><00>Ze d
d <00><00>Z
d <00>fd d<00>Z dd<00>Z <00>S)<11>BooleanClauseListr<74>cOstd<00><00>dS)Nz+BooleanClauseList has a private constructor)<01>NotImplementedError)r=<00>argrrrrr<>@szBooleanClauseList.__init__c s g}dd<00>tj|<00>D<>}xR|D]J}t||<00>rDq)n"t||<00>rf|jdtj<00>S|j|<00>q)Wt|<00>dkr<>|djdtj<00>S| r<>|r<>|djdtj<00>S<>fdd<00>|D<>}|j|<00>}||_ d|_
<00>|_ d|_ t j|_|S)NcSsg|]}t|<00><00>qSr)r<>)r<>r1rrrr<>Is z0BooleanClauseList._construct.<locals>.<listcomp>r_rrcs"g|]}|jd<00><00><01>qS)r_)r`)r<>r>)rsrrr<>[s T)rZcoerce_generator_argr*r`r r<>r<>rXr5r<>r<>rsr<>rr<>r) r<>rsZ continue_onZskip_onr<6E>rZconvert_clausesr1r=r)rsr<00>
_constructDs,   
     zBooleanClauseList._constructcGs|jtjtt|<00>S)a Produce a conjunction of expressions joined by ``AND``.
E.g.::
from sqlalchemy import and_
stmt = select([users_table]).where(
and_(
users_table.c.name == 'wendy',
users_table.c.enrolled == True
)
)
The :func:`.and_` conjunction is also available using the
Python ``&`` operator (though note that compound expressions
need to be parenthesized in order to function with Python
operator precedence behavior)::
stmt = select([users_table]).where(
(users_table.c.name == 'wendy') &
(users_table.c.enrolled == True)
)
The :func:`.and_` operation is also implicit in some cases;
the :meth:`.Select.where` method for example can be invoked multiple
times against a statement, which will have the effect of each
clause being combined using :func:`.and_`::
stmt = select([users_table]).\
where(users_table.c.name == 'wendy').\
where(users_table.c.enrolled == True)
.. seealso::
:func:`.or_`
)rr rlr<>r<>)r<>r<>rrrrlfs'zBooleanClauseList.and_cGs|jtjtt|<00>S)adProduce a conjunction of expressions joined by ``OR``.
E.g.::
from sqlalchemy import or_
stmt = select([users_table]).where(
or_(
users_table.c.name == 'wendy',
users_table.c.name == 'jack'
)
)
The :func:`.or_` conjunction is also available using the
Python ``|`` operator (though note that compound expressions
need to be parenthesized in order to function with Python
operator precedence behavior)::
stmt = select([users_table]).where(
(users_table.c.name == 'wendy') |
(users_table.c.name == 'jack')
)
.. seealso::
:func:`.and_`
)rr rnr<>r<>)r<>r<>rrrrn<00>szBooleanClauseList.or_cCs|fS)Nr)r=rrrr<><00>sz"BooleanClauseList._select_iterableNcs*|js |Stt|<00>jd|<00>SdS)Nr_)r<>r<>r<>r`)r=r_)r4rrr`<00>s zBooleanClauseList.self_groupcCs tj|<00>S)N)r<>rq)r=rrrrq<00>szBooleanClauseList._negate) r|r{r~r<>r<>r<>rrlrnr<>r<>r`rqrr)r4rr<>=s  ") r<>csFeZdZdZ<00>fdd<00>Zedd<00><00>Zdd<00>Z<00>S)<08>TuplezRepresent a SQL tuple.cstdd<00>|D<>}dd<00>|D<>|_|jd|jrH|jdntj<00>|_tt|<00>j||<00>dS)aJReturn a :class:`.Tuple`.
Main usage is to produce a composite IN construct::
from sqlalchemy import tuple_
tuple_(table.c.col1, table.c.col2).in_(
[(1, 2), (5, 12), (10, 19)]
)
.. warning::
The composite IN construct is not supported by all backends,
and is currently known to work on Postgresql and MySQL,
but not SQLite. Unsupported backends will raise
a subclass of :class:`~sqlalchemy.exc.DBAPIError` when such
an expression is invoked.
cSsg|]}t|<00><00>qSr)r)r<>r>rrrr<><00>s z"Tuple.__init__.<locals>.<listcomp>cSsg|]}|j<00>qSr)r)r<>rrrrr<><00>s rrN)<08> _type_tuplerDrr<>rr<>rr<>)r=r<>r)r4rrr<><00>s
 %zTuple.__init__cCs|fS)Nr)r=rrrr<><00>szTuple._select_iterablecs/t<00>fdd<00>t||j<00>D<><00>j<00>S)Nc s7g|]-\}}td|d<00>d|dd<00><03>qS)Nr<4E>r<>r"T)r#)r<><00>or)rsrrr<><00>s z%Tuple._bind_param.<locals>.<listcomp>)r<00>ziprr`)r=rsr<>r)rsrr<><00>szTuple._bind_param)r|r{r~rr<>r<>r<>r<>rr)r4rr<00>s rc@s[eZdZdZdZdddd<00>Zedd<00>Zdd <00>Ze d
d <00><00>Z
dS) <0C>Casea<65>Represent a ``CASE`` expression.
:class:`.Case` is produced using the :func:`.case` factory function,
as in::
from sqlalchemy import case
stmt = select([users_table]).\
where(
case(
[
(users_table.c.name == 'wendy', 'W'),
(users_table.c.name == 'jack', 'J')
],
else_='E'
)
)
Details on :class:`.Case` usage is at :func:`.case`.
.. seealso::
:func:`.case`
ZcaseNc Cs<>ytj|<00>}Wntk
r'YnX|dk rJdd<00>|D<>}ndd<00>|D<>}|r}t|d<19>dj}nd}|dkr<>d|_nt|<00>|_||_||_|dk r<>t|<00>|_n d|_dS)aProduce a ``CASE`` expression.
The ``CASE`` construct in SQL is a conditional object that
acts somewhat analogously to an "if/then" construct in other
languages. It returns an instance of :class:`.Case`.
:func:`.case` in its usual form is passed a list of "when"
constructs, that is, a list of conditions and results as tuples::
from sqlalchemy import case
stmt = select([users_table]).\
where(
case(
[
(users_table.c.name == 'wendy', 'W'),
(users_table.c.name == 'jack', 'J')
],
else_='E'
)
)
The above statement will produce SQL resembling::
SELECT id, name FROM user
WHERE CASE
WHEN (name = :name_1) THEN :param_1
WHEN (name = :name_2) THEN :param_2
ELSE :param_3
END
When simple equality expressions of several values against a single
parent column are needed, :func:`.case` also has a "shorthand" format
used via the
:paramref:`.case.value` parameter, which is passed a column
expression to be compared. In this form, the :paramref:`.case.whens`
parameter is passed as a dictionary containing expressions to be
compared against keyed to result expressions. The statement below is
equivalent to the preceding statement::
stmt = select([users_table]).\
where(
case(
{"wendy": "W", "jack": "J"},
value=users_table.c.name,
else_='E'
)
)
The values which are accepted as result values in
:paramref:`.case.whens` as well as with :paramref:`.case.else_` are
coerced from Python literals into :func:`.bindparam` constructs.
SQL expressions, e.g. :class:`.ColumnElement` constructs, are accepted
as well. To coerce a literal string expression into a constant
expression rendered inline, use the :func:`.literal_column` construct,
as in::
from sqlalchemy import case, literal_column
case(
[
(
orderline.c.qty > 100,
literal_column("'greaterthan100'")
),
(
orderline.c.qty > 10,
literal_column("'greaterthan10'")
)
],
else_=literal_column("'lessthan10'")
)
The above will render the given constants without using bound
parameters for the result values (but still for the comparison
values), as in::
CASE
WHEN (orderline.qty > :qty_1) THEN 'greaterthan100'
WHEN (orderline.qty > :qty_2) THEN 'greaterthan10'
ELSE 'lessthan10'
END
:param whens: The criteria to be compared against,
:paramref:`.case.whens` accepts two different forms, based on
whether or not :paramref:`.case.value` is used.
In the first form, it accepts a list of 2-tuples; each 2-tuple
consists of ``(<sql expression>, <value>)``, where the SQL
expression is a boolean expression and "value" is a resulting value,
e.g.::
case([
(users_table.c.name == 'wendy', 'W'),
(users_table.c.name == 'jack', 'J')
])
In the second form, it accepts a Python dictionary of comparison
values mapped to a resulting value; this form requires
:paramref:`.case.value` to be present, and values will be compared
using the ``==`` operator, e.g.::
case(
{"wendy": "W", "jack": "J"},
value=users_table.c.name
)
:param value: An optional SQL expression which will be used as a
fixed "comparison point" for candidate values within a dictionary
passed to :paramref:`.case.whens`.
:param else\_: An optional SQL expression which will be the evaluated
result of the ``CASE`` construct if all expressions within
:paramref:`.case.whens` evaluate to false. When omitted, most
databases will produce a result of NULL if none of the "when"
expressions evaluate to true.
NcSs4g|]*\}}t|<00>j<00>t|<00>f<00>qSr)rr`)r<>r><00>rrrrr<><00>s z!Case.__init__.<locals>.<listcomp>cSs4g|]*\}}t|<00>j<00>t|<00>f<00>qSr)<03> _no_literalsr`r)r<>r>rrrrr<><00>s r<00><><EFBFBD><EFBFBD><EFBFBD>r ) rZdictlike_iteritemsrvr<>rr$r<00>whens<6E>else_)r=r
r$r Zwhenlistrrrrr<> s(y     
     z Case.__init__c st|jdk r'<00>|j<00><00>|_n<00><00>fdd<00>|jD<>|_|jdk rp<00>|j<00><00>|_ndS)Ncs4g|]*\}}<00>|<00><00><00>|<00><00>f<00>qSrr)r<><00>x<>y)rJrrrr<><00>s z(Case._copy_internals.<locals>.<listcomp>)r$r
r )r=rJrr)rJrrr]<00>s zCase._copy_internalscks\|jdk r|jVnx!|jD]\}}|V|Vq$W|jdk rX|jVndS)N)r$r
r )r=rQr r rrrr^<00>s  zCase.get_childrencCs&ttjdd<00>|j<00>D<><00><00>S)NcSsg|]}|j<00>qSr)r<>)r<>r rrrr<><00>s z&Case._from_objects.<locals>.<listcomp>)r<>r<>r<>r^)r=rrrr<><00>szCase._from_objects) r|r{r~rr<>r<>rr]r^r<>r<>rrrrr<00>s <12> rcCst|d|dd<00>S)a3Produce a :class:`.ColumnClause` object that has the
:paramref:`.column.is_literal` flag set to True.
:func:`.literal_column` is similar to :func:`.column`, except that
it is more often used as a "standalone" column expression that renders
exactly as stated; while :func:`.column` stores a string name that
will be assumed to be part of a table and may be quoted as such,
:func:`.literal_column` can be that, or any other arbitrary column-oriented
expression.
:param text: the text of the expression; can be any SQL expression.
Quoting rules will not be applied. To specify a column-name expression
which should be subject to quoting rules, use the :func:`column`
function.
:param type\_: an optional :class:`~sqlalchemy.types.TypeEngine`
object which will
provide result-set translation and additional expression semantics for
this column. If left as None the type will be NullType.
.. seealso::
:func:`.column`
:func:`.text`
:ref:`sqlexpression_literal_column`
r<00>
is_literalT)r<>)r<>rrrr<00>literal_column<6D>src@sUeZdZdZdZdd<00>Zedd<00>Zdd<00>Ze d d
<00><00>Z
d S) r<>a~Represent a ``CAST`` expression.
:class:`.Cast` is produced using the :func:`.cast` factory function,
as in::
from sqlalchemy import cast, Numeric
stmt = select([
cast(product_table.c.unit_price, Numeric(10, 4))
])
Details on :class:`.Cast` usage is at :func:`.cast`.
.. seealso::
:func:`.cast`
r<>cCs@tj|<00>|_t|d|j<00>|_t|j<00>|_dS)a<>Produce a ``CAST`` expression.
:func:`.cast` returns an instance of :class:`.Cast`.
E.g.::
from sqlalchemy import cast, Numeric
stmt = select([
cast(product_table.c.unit_price, Numeric(10, 4))
])
The above statement will produce SQL resembling::
SELECT CAST(unit_price AS NUMERIC(10, 4)) FROM product
The :func:`.cast` function performs two distinct functions when
used. The first is that it renders the ``CAST`` expression within
the resulting SQL string. The second is that it associates the given
type (e.g. :class:`.TypeEngine` class or instance) with the column
expression on the Python side, which means the expression will take
on the expression operator behavior associated with that type,
as well as the bound-value handling and result-row-handling behavior
of the type.
.. versionchanged:: 0.9.0 :func:`.cast` now applies the given type
to the expression such that it takes effect on the bound-value,
e.g. the Python-to-database direction, in addition to the
result handling, e.g. database-to-Python, direction.
An alternative to :func:`.cast` is the :func:`.type_coerce` function.
This function performs the second task of associating an expression
with a specific type, but does not render the ``CAST`` expression
in SQL.
:param expression: A SQL expression, such as a :class:`.ColumnElement`
expression or a Python string which will be coerced into a bound
literal value.
:param type_: A :class:`.TypeEngine` class or instance indicating
the type to which the ``CAST`` should apply.
.. seealso::
:func:`.type_coerce` - Python-side type coercion without emitting
CAST.
rN)rr'rrr1r<>r<>)r=rrrrrr<><00>s1z Cast.__init__cKs.||j|<00>|_||j|<00>|_dS)N)r1r<>)r=rJrrrrr]& szCast._copy_internalscKs|j|jfS)N)r1r<>)r=rQrrrr^* szCast.get_childrencCs
|jjS)N)r1r<>)r=rrrr<>- szCast._from_objectsN) r|r{r~rr<>r<>rr]r^r<>r<>rrrrr<><00>s  5 r<>c@sUeZdZdZdZdd<00>Zedd<00>Zdd<00>Ze d d
<00><00>Z
d S) <0C>Extractz=Represent a SQL EXTRACT clause, ``extract(field FROM expr)``.<2E>extractcKs+tj|_||_t|d<00>|_dS)z<>Return a :class:`.Extract` construct.
This is typically available as :func:`.extract`
as well as ``func.extract`` from the
:data:`.func` namespace.
N)rZ INTEGERTYPEr<00>fieldrr)r=rrrQrrrr<>7 s  zExtract.__init__cKs||j|<00>|_dS)N)r)r=rJrrrrr]C szExtract._copy_internalscKs
|jfS)N)r)r=rQrrrr^F szExtract.get_childrencCs
|jjS)N)rr<>)r=rrrr<>I szExtract._from_objectsN) r|r{r~rr<>r<>rr]r^r<>r<>rrrrr2 s   rc@sIeZdZdZdZdd<00>Zedd<00>Zedd<00><00>Z d S)
<EFBFBD>_label_referencea<65>Wrap a column expression as it appears in a 'reference' context.
This expression is any that inclues an _order_by_label_element,
which is a Label, or a DESC / ASC construct wrapping a Label.
The production of _label_reference() should occur when an expression
is added to this context; this includes the ORDER BY or GROUP BY of a
SELECT statement, as well as a few other places, such as the ORDER BY
within an OVER clause.
Zlabel_referencecCs ||_dS)N)r)r=rrrrr<>\ sz_label_reference.__init__cKs||j|<00>|_dS)N)r)r=rJrrrrr]_ sz _label_reference._copy_internalscCsfS)Nr)r=rrrr<>b sz_label_reference._from_objectsN)
r|r{r~rr<>r<>rr]r<>r<>rrrrrN s
 rc@s7eZdZdZdd<00>Zejdd<00><00>ZdS)<07>_textual_label_referenceZtextual_label_referencecCs ||_dS)N)r)r=rrrrr<>j sz!_textual_label_reference.__init__cCstj|j<00>S)N)r<>r<>r)r=rrr<00> _text_clausem sz%_textual_label_reference._text_clauseN)r|r{r~r<>r<>rr<>rrrrrrg s  rc@s<>eZdZdZdZddddddd<00>Zedd<00><00>Zed d
<00><00>Zed d <00><00>Z ed d<00><00>Z
edd<00><00>Z e dd<00><00>Z e dd<00><00>Zedd<00>Zdd<00>Zdd<00>Zdd<00>Zddd<00>ZdS)rua<>Define a 'unary' expression.
A unary expression has a single column expression
and an operator. The operator can be placed on the left
(where it is called the 'operator') or right (where it is called the
'modifier') of the column expression.
:class:`.UnaryExpression` is the basis for several unary operators
including those used by :func:`.desc`, :func:`.asc`, :func:`.distinct`,
:func:`.nullsfirst` and :func:`.nullslast`.
ZunaryNFcCs[||_||_|jd|jp*|j<00>|_tj|<00>|_||_||_dS)Nr_) rs<00>modifierr`rrr'rrt<00>wraps_column_expression)r=rrsrrrtrrrrr<><00> s    zUnaryExpression.__init__cCstt|<00>dtjdd<00>S)a\Produce the ``NULLS FIRST`` modifier for an ``ORDER BY`` expression.
:func:`.nullsfirst` is intended to modify the expression produced
by :func:`.asc` or :func:`.desc`, and indicates how NULL values
should be handled when they are encountered during ordering::
from sqlalchemy import desc, nullsfirst
stmt = select([users_table]).\
order_by(nullsfirst(desc(users_table.c.name)))
The SQL expression from the above would resemble::
SELECT id, name FROM user ORDER BY name DESC NULLS FIRST
Like :func:`.asc` and :func:`.desc`, :func:`.nullsfirst` is typically
invoked from the column expression itself using
:meth:`.ColumnElement.nullsfirst`, rather than as its standalone
function version, as in::
stmt = (select([users_table]).
order_by(users_table.c.name.desc().nullsfirst())
)
.. seealso::
:func:`.asc`
:func:`.desc`
:func:`.nullslast`
:meth:`.Select.order_by`
rrF)ru<00>_literal_as_label_referencer Z nullsfirst_op)r<>r<>rrr<00>_create_nullsfirst<73> s&  z"UnaryExpression._create_nullsfirstcCstt|<00>dtjdd<00>S)aCProduce the ``NULLS LAST`` modifier for an ``ORDER BY`` expression.
:func:`.nullslast` is intended to modify the expression produced
by :func:`.asc` or :func:`.desc`, and indicates how NULL values
should be handled when they are encountered during ordering::
from sqlalchemy import desc, nullslast
stmt = select([users_table]).\
order_by(nullslast(desc(users_table.c.name)))
The SQL expression from the above would resemble::
SELECT id, name FROM user ORDER BY name DESC NULLS LAST
Like :func:`.asc` and :func:`.desc`, :func:`.nullslast` is typically
invoked from the column expression itself using
:meth:`.ColumnElement.nullslast`, rather than as its standalone
function version, as in::
stmt = select([users_table]).\
order_by(users_table.c.name.desc().nullslast())
.. seealso::
:func:`.asc`
:func:`.desc`
:func:`.nullsfirst`
:meth:`.Select.order_by`
rrF)rurr Z nullslast_op)r<>r<>rrr<00>_create_nullslast<73> s%  z!UnaryExpression._create_nullslastcCstt|<00>dtjdd<00>S)a(Produce a descending ``ORDER BY`` clause element.
e.g.::
from sqlalchemy import desc
stmt = select([users_table]).order_by(desc(users_table.c.name))
will produce SQL as::
SELECT id, name FROM user ORDER BY name DESC
The :func:`.desc` function is a standalone version of the
:meth:`.ColumnElement.desc` method available on all SQL expressions,
e.g.::
stmt = select([users_table]).order_by(users_table.c.name.desc())
:param column: A :class:`.ColumnElement` (e.g. scalar SQL expression)
with which to apply the :func:`.desc` operation.
.. seealso::
:func:`.asc`
:func:`.nullsfirst`
:func:`.nullslast`
:meth:`.Select.order_by`
rrF)rurr <00>desc_op)r<>r<>rrr<00> _create_desc<73> s#  zUnaryExpression._create_desccCstt|<00>dtjdd<00>S)a!Produce an ascending ``ORDER BY`` clause element.
e.g.::
from sqlalchemy import asc
stmt = select([users_table]).order_by(asc(users_table.c.name))
will produce SQL as::
SELECT id, name FROM user ORDER BY name ASC
The :func:`.asc` function is a standalone version of the
:meth:`.ColumnElement.asc` method available on all SQL expressions,
e.g.::
stmt = select([users_table]).order_by(users_table.c.name.asc())
:param column: A :class:`.ColumnElement` (e.g. scalar SQL expression)
with which to apply the :func:`.asc` operation.
.. seealso::
:func:`.desc`
:func:`.nullsfirst`
:func:`.nullslast`
:meth:`.Select.order_by`
rrF)rurr <00>asc_op)r<>r<>rrr<00> _create_asc
s"  zUnaryExpression._create_asccCs.t|<00>}t|dtjd|jdd<00>S)asProduce an column-expression-level unary ``DISTINCT`` clause.
This applies the ``DISTINCT`` keyword to an individual column
expression, and is typically contained within an aggregate function,
as in::
from sqlalchemy import distinct, func
stmt = select([func.count(distinct(users_table.c.name))])
The above would produce an expression resembling::
SELECT COUNT(DISTINCT name) FROM user
The :func:`.distinct` function is also available as a column-level
method, e.g. :meth:`.ColumnElement.distinct`, as in::
stmt = select([func.count(users_table.c.name.distinct())])
The :func:`.distinct` operator is different from the
:meth:`.Select.distinct` method of :class:`.Select`,
which produces a ``SELECT`` statement
with ``DISTINCT`` applied to the result set as a whole,
e.g. a ``SELECT DISTINCT`` expression. See that method for further
information.
.. seealso::
:meth:`.ColumnElement.distinct`
:meth:`.Select.distinct`
:data:`.func`
rsrrF)rrur Z distinct_opr)r<>rrrr<00>_create_distinct/
s$ z UnaryExpression._create_distinctcCs-|jtjtjfkr%|jjSdSdS)N)rr rrrr<>)r=rrrr<>X
s
z'UnaryExpression._order_by_label_elementcCs
|jjS)N)rr<>)r=rrrr<>_
szUnaryExpression._from_objectscKs||j|<00>|_dS)N)r)r=rJrrrrr]c
szUnaryExpression._copy_internalscKs
|jfS)N)r)r=rQrrrr^f
szUnaryExpression.get_childrencKsIt|t<00>oH|j|jkoH|j|jkoH|jj|j|<00>S)zXCompare this :class:`UnaryExpression` against the given
:class:`.ClauseElement`.)r*rursrrr\)r=r[rrrrr\i
szUnaryExpression.comparec Cs<>|jdk rIt|jd|jd|jd|jd|jd|j<00>S|jjtj jkr<>t|j
dt j <00>dt j dtj d|jdd<00>St j|<00>SdS)Nrsrtrrrr_)rtrurrsrrrr<>rr<>r`r r0r3rq)r=rrrrqt
s      
   zUnaryExpression._negatecCs0|jr(tj|j|<00>r(t|<00>S|SdS)N)rsr r<>r<>)r=r_rrrr`<00>
s
zUnaryExpression.self_group)r|r{r~rr<>r<>r<>rrrrrr<>r<>r<>rr]r^r\rqr`rrrrrur s  +*(')  ruc@s7eZdZdd<00>Zddd<00>Zdd<00>ZdS)r<>cCs=||_tj|_||_||_d|_d|_dS)NT)rrr<>rrsrtrr)r=rrsrtrrrr<><00>
s      zAsBoolean.__init__NcCs|S)Nr)r=r_rrrr`<00>
szAsBoolean.self_groupcCs |jj<00>S)N)rrq)r=rrrrq<00>
szAsBoolean._negate)r|r{r~r<>r`rqrrrrr<><00>
s  r<>cs<>eZdZdZdZddddd<00>Zdd<00>ZeZedd <00><00>Z ed
d <00><00>Z
e d d <00>Z dd<00>Z dd<00>Zddd<00>Z<00>fdd<00>Z<00>S)ra<>Represent an expression that is ``LEFT <operator> RIGHT``.
A :class:`.BinaryExpression` is generated automatically
whenever two column expressions are used in a Python binary expression::
>>> from sqlalchemy.sql import column
>>> column('a') + column('b')
<sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
>>> print column('a') + column('b')
a + b
<20>binaryNcCs<>t|tj<00>r$tj|<00>}n||f|_|jd|<00>|_|jd|<00>|_||_ t
j |<00>|_ ||_ |dkr<>i|_n ||_dS)Nr_)r*r<00> string_typesr Z custom_op<6F>_origr`<00>left<66>rightrsrr'rrt<00> modifiers)r=r#r$rsrrtr%rrrr<><00>
s    zBinaryExpression.__init__cCsU|jtjtjfkrE|jt|jd<19>t|jd<19><00>Std<00><00>dS)Nrrz+Boolean value of this clause is not defined)rs<00>eq<65>ner<65>r"rv)r=rrrrw<00>
s*zBinaryExpression.__bool__cCstj|j<00>S)N)r <00> is_comparisonrs)r=rrrr(<00>
szBinaryExpression.is_comparisoncCs|jj|jjS)N)r#r<>r$)r=rrrr<><00>
szBinaryExpression._from_objectscKs.||j|<00>|_||j|<00>|_dS)N)r#r$)r=rJrrrrr]<00>
sz BinaryExpression._copy_internalscKs|j|jfS)N)r#r$)r=rQrrrr^<00>
szBinaryExpression.get_childrencKs<>t|t<00>o<>|j|jko<>|jj|j|<00>rQ|jj|j|<00>p<>tj|j<00>o<>|jj|j|<00>o<>|jj|j|<00>S)z[Compare this :class:`BinaryExpression` against the
given :class:`BinaryExpression`.)r*rrsr#r\r$r Zis_commutative)r=r[rrrrr\<00>
szBinaryExpression.comparecCs'tj|j|<00>rt|<00>S|SdS)N)r r<>rsr<>)r=r_rrrr`<00>
s
zBinaryExpression.self_groupc
sZ|jdk rCt|j|j|jd|jd|jd|j<00>Stt|<00>j<00>SdS)Nrtrr%) rtrr#r$rsrr%r<>rq)r=)r4rrrq<00>
s   
zBinaryExpression._negate)r|r{r~rr<>r<>rwr<>r<>r(r<>rr]r^r\r`rqrr)r4rr<00>
s    rc@s<>eZdZdZdZdd<00>Zddd<00>Zedd <00><00>Zed
d <00><00>Z e
d d <00>Z dd<00>Z edd<00><00>Z dd<00>Zdd<00>Zdd<00>Zdd<00>ZdS)r<>z/Represent a grouping within a column expression<6F>groupingcCs%||_t|dtj<00>|_dS)Nr)rr<>rr<>r)r=rrrrr<> s zGrouping.__init__NcCs|S)Nr)r=r_rrrr` szGrouping.self_groupcCs|jS)N)r<>)r=rrrr<> szGrouping._key_labelcCst|jdd<00>p|jS)Nr<4E>)r<>rr<>)r=rrrr<> szGrouping._labelcKs||j|<00>|_dS)N)r)r=rJrrrrr] szGrouping._copy_internalscKs
|jfS)N)r)r=rQrrrr^ szGrouping.get_childrencCs
|jjS)N)rr<>)r=rrrr<> szGrouping._from_objectscCst|j|<00>S)N)r<>r)r=<00>attrrrrr<> szGrouping.__getattr__cCsi|jd6|jd6S)Nrr)rr)r=rrrrF! szGrouping.__getstate__cCs|d|_|d|_dS)Nrr)rr)r=<00>staterrr<00> __setstate__$ s zGrouping.__setstate__cKs"t|t<00>o!|jj|j<00>S)N)r*r<>rr\)r=r[rrrrr\( szGrouping.compare)r|r{r~rr<>r<>r`r<>r<>r<>rr]r^r<>r<>rFr,r\rrrrr<> s      r<>c@s|eZdZdZdZdZdZdddd<00>Zej dd<00><00>Z
dd <00>Z e d
d <00>Z ed d <00><00>ZdS)<0E>OveraRepresent an OVER clause.
This is a special operator against a so-called
"window" function, as well as any aggregate function,
which produces results relative to the result set
itself. It's supported only by certain database
backends.
<20>overNcCsg||_|dk r6tdttj|<00><00>|_n|dk rctdttj|<00><00>|_ndS)a<>Produce an :class:`.Over` object against a function.
Used against aggregate or so-called "window" functions,
for database backends that support window functions.
E.g.::
from sqlalchemy import over
over(func.row_number(), order_by='x')
Would produce "ROW_NUMBER() OVER(ORDER BY x)".
:param func: a :class:`.FunctionElement` construct, typically
generated by :data:`~.expression.func`.
:param partition_by: a column element or string, or a list
of such, that will be used as the PARTITION BY clause
of the OVER construct.
:param order_by: a column element or string, or a list
of such, that will be used as the ORDER BY clause
of the OVER construct.
This function is also available from the :data:`~.expression.func`
construct itself via the :meth:`.FunctionElement.over` method.
.. versionadded:: 0.7
Nr)<07>funcr<63>rrZto_list<73>order_by<62> partition_by)r=r/r1r0rrrr<>< s   z Over.__init__cCs
|jjS)N)r/r)r=rrrrb sz Over.typecKs#dd<00>|j|j|jfD<>S)NcSs"g|]}|dk r|<00>qS)Nr)r<>r>rrrr<>g s z%Over.get_children.<locals>.<listcomp>)r/r1r0)r=rQrrrr^f s zOver.get_childrencKsg||j|<00>|_|jdk r<||j|<00>|_n|jdk rc||j|<00>|_ndS)N)r/r1r0)r=rJrrrrr]k s
zOver._copy_internalscCs2ttjdd<00>|j|j|jfD<><00><00>S)NcSs%g|]}|dk r|j<00>qS)N)r<>)r<>r>rrrr<>u s z&Over._from_objects.<locals>.<listcomp>)r<>r<>r<>r/r1r0)r=rrrr<>r s  zOver._from_objects)r|r{r~rr<>r0r1r<>rr<>rr^rr]r<>r<>rrrrr-- s & r-c@s<>eZdZdZdZdZdd<00>Zdd<00>Zdddd <00>Ze j
d
d <00><00>Z d d <00>Z e dd<00>Zedd<00><00>ZdS)<12>FunctionFiltera<72>Represent a function FILTER clause.
This is a special operator against aggregate and window functions,
which controls which rows are passed to it.
It's supported only by certain database backends.
Invocation of :class:`.FunctionFilter` is via
:meth:`.FunctionElement.filter`::
func.count(1).filter(True)
.. versionadded:: 1.0.0
.. seealso::
:meth:`.FunctionElement.filter`
Z
funcfilterNcGs||_|j|<00>dS)a<>Produce a :class:`.FunctionFilter` object against a function.
Used against aggregate and window functions,
for database backends that support the "FILTER" clause.
E.g.::
from sqlalchemy import funcfilter
funcfilter(func.count(1), MyClass.name == 'some name')
Would produce "COUNT(1) FILTER (WHERE myclass.name = 'some name')".
This function is also available from the :data:`~.expression.func`
construct itself via the :meth:`.FunctionElement.filter` method.
.. versionadded:: 1.0.0
.. seealso::
:meth:`.FunctionElement.filter`
N)r/<00>filter)r=r/<00> criterionrrrr<><00> s zFunctionFilter.__init__cGsRxKt|<00>D]=}t|<00>}|jdk rA|j|@|_q ||_q W|S)a Produce an additional FILTER against the function.
This method adds additional criteria to the initial criteria
set up by :meth:`.FunctionElement.filter`.
Multiple criteria are joined together at SQL render time
via ``AND``.
N)r<>r<>r4)r=r4rrrr3<00> s   zFunctionFilter.filtercCst|d|d|<00>S)a<>Produce an OVER clause against this filtered function.
Used against aggregate or so-called "window" functions,
for database backends that support window functions.
The expression::
func.rank().filter(MyClass.y > 5).over(order_by='x')
is shorthand for::
from sqlalchemy import over, funcfilter
over(funcfilter(func.rank(), MyClass.y > 5), order_by='x')
See :func:`~.expression.over` for a full description.
r1r0)r-)r=r1r0rrrr.<00> szFunctionFilter.overcCs
|jjS)N)r/r)r=rrrr<00> szFunctionFilter.typecKsdd<00>|j|jfD<>S)NcSs"g|]}|dk r|<00>qS)Nr)r<>r>rrrr<><00> s z/FunctionFilter.get_children.<locals>.<listcomp>)r/r4)r=rQrrrr^<00> s zFunctionFilter.get_childrencKs@||j|<00>|_|jdk r<||j|<00>|_ndS)N)r/r4)r=rJrrrrr]<00> szFunctionFilter._copy_internalscCs,ttjdd<00>|j|jfD<><00><00>S)NcSs%g|]}|dk r|j<00>qS)N)r<>)r<>r>rrrr<><00> s z0FunctionFilter._from_objects.<locals>.<listcomp>)r<>r<>r<>r/r4)r=rrrr<><00> s zFunctionFilter._from_objects)r|r{r~rr<>r4r<>r3r.rr<>rr^rr]r<>r<>rrrrr2{ s    r2c@s<>eZdZdZdZddd<00>Zdd<00>Zejdd <00><00>Z e
d
d <00><00>Z ejd d <00><00>Z ejdd<00><00>Z ddd<00>Ze
dd<00><00>Ze
dd<00><00>Zdd<00>Zeddd<00>Ze
dd<00><00>Zddd<00>ZdS)r,z<>Represents a column label (AS).
Represent a label, as typically applied to any column-level
element using the ``AS`` sql keyword.
r<>NcCs<>t|t<00>r|j|_nxt|t<00>r<|j}q!W|r[||_|j|_n+tdt|<00>t|dd<00>f<16>|_|j|_ |_|_
||_ ||_ |g|_ dS)a<>Return a :class:`Label` object for the
given :class:`.ColumnElement`.
A label changes the name of an element in the columns clause of a
``SELECT`` statement, typically via the ``AS`` SQL keyword.
This functionality is more conveniently available via the
:meth:`.ColumnElement.label` method on :class:`.ColumnElement`.
:param name: label name
:param obj: a :class:`.ColumnElement`.
z
%%(%d %s)sr<73>r<>N)r*r,r<>r<>rr<>r<>r}r<>r.r<><00>_element<6E>_typer<65>)r=r<>rrrrrr<><00> s  (  zLabel.__init__cCs|j|j|j|jffS)N)r4r<>r5r6)r=rrr<00>
__reduce__ szLabel.__reduce__cCs
|jjS)N)rr<>)r=rrrr<> szLabel._allow_label_resolvecCs|S)Nr)r=rrrr<>! szLabel._order_by_label_elementcCs%tj|jp!t|jdd<00><00>S)Nr)rr'r6r<>r5)r=rrrr% sz
Label.typecCs|jjdtj<00>S)Nr_)r5r`r Zas_)r=rrrr+ sz Label.elementcCsE|jjd|<00>}||jk r=t|j|d|j<00>S|SdS)Nr_r)r5r`r,r<>r6)r=r_Z sub_elementrrrr`/ s  
zLabel.self_groupcCs
|jjS)N)rr<>)r=rrrr<>8 szLabel.primary_keycCs
|jjS)N)rr<>)r=rrrr<>< szLabel.foreign_keyscKs
|jfS)N)r)r=rQrrrr^@ szLabel.get_childrenFcKs<>||j|<00>|_|jjdd<00>|jjdd<00>|r<>tdt|<00>t|jdd<00>f<16>|_|_|j|_ |_
|_ ndS)Nrr<>z
%%(%d %s)sr<73>r<>) r5r6rDr<>r}r<>rr<>r<>r.r<>r<>)r=rJZanonymize_labelsrrrrr]C s/zLabel._copy_internalscCs
|jjS)N)rr<>)r=rrrr<>N szLabel._from_objectscKsY|jj|d|r|n|j<00>}|jj|<00>|jdk rU|j|_n|S)Nr<4E>)rr<>r<>r<>r<>r6r)r=r<>r<>r<00>errrr<>R s zLabel._make_proxy)r|r{r~rr<>r<>r7rr<>r<>r<>r<>rrr`r<>r<>r^rr]r<>r<>rrrrr,<00> s #    r,c@s eZdZdZdZdZZZZe j
<00>Z ddddd<00>Z dd<00>Z d d
<00>Zd d <00>Zeee<00>Ze d d<00><00>Ze jdd<00><00>Ze dd<00><00>Ze dd<00><00>Ze dd<00><00>Zdd<00>Zdd<00>Zddddd<00>ZdS)r<>a<>Represents a column expression from any textual string.
The :class:`.ColumnClause`, a lightweight analogue to the
:class:`.Column` class, is typically invoked using the
:func:`.column` function, as in::
from sqlalchemy import column
id, name = column("id"), column("name")
stmt = select([id, name]).select_from("user")
The above statement would produce SQL like::
SELECT id, name FROM user
:class:`.ColumnClause` is the immediate superclass of the schema-specific
:class:`.Column` object. While the :class:`.Column` class has all the
same capabilities as :class:`.ColumnClause`, the :class:`.ColumnClause`
class is usable by itself in those cases where behavioral requirements
are limited to simple SQL expression generation. The object has none of
the associations with schema-level metadata or with execution-time
behavior that :class:`.Column` does, so in that sense is a "lightweight"
version of :class:`.Column`.
Full details on :class:`.ColumnClause` usage is at :func:`.column`.
.. seealso::
:func:`.column`
:class:`.Column`
r<>NFcCs8||_|_||_tj|<00>|_||_dS)aC Produce a :class:`.ColumnClause` object.
The :class:`.ColumnClause` is a lightweight analogue to the
:class:`.Column` class. The :func:`.column` function can
be invoked with just a name alone, as in::
from sqlalchemy import column
id, name = column("id"), column("name")
stmt = select([id, name]).select_from("user")
The above statement would produce SQL like::
SELECT id, name FROM user
Once constructed, :func:`.column` may be used like any other SQL
expression element such as within :func:`.select` constructs::
from sqlalchemy.sql import column
id, name = column("id"), column("name")
stmt = select([id, name]).select_from("user")
The text handled by :func:`.column` is assumed to be handled
like the name of a database column; if the string contains mixed case,
special characters, or matches a known reserved word on the target
backend, the column expression will render using the quoting
behavior determined by the backend. To produce a textual SQL
expression that is rendered exactly without any quoting,
use :func:`.literal_column` instead, or pass ``True`` as the
value of :paramref:`.column.is_literal`. Additionally, full SQL
statements are best handled using the :func:`.text` construct.
:func:`.column` can be used in a table-like
fashion by combining it with the :func:`.table` function
(which is the lightweight analogue to :class:`.Table`) to produce
a working table construct with minimal boilerplate::
from sqlalchemy import table, column, select
user = table("user",
column("id"),
column("name"),
column("description"),
)
stmt = select([user.c.description]).where(user.c.name == 'wendy')
A :func:`.column` / :func:`.table` construct like that illustrated
above can be created in an
ad-hoc fashion and is not associated with any
:class:`.schema.MetaData`, DDL, or events, unlike its
:class:`.Table` counterpart.
.. versionchanged:: 1.0.0 :func:`.expression.column` can now
be imported from the plain ``sqlalchemy`` namespace like any
other SQL element.
:param text: the text of the element.
:param type: :class:`.types.TypeEngine` object which can associate
this :class:`.ColumnClause` with a type.
:param is_literal: if True, the :class:`.ColumnClause` is assumed to
be an exact expression that will be delivered to the output with no
quoting rules applied regardless of case sensitive settings. the
:func:`.literal_column()` function essentially invokes
:func:`.column` while passing ``is_literal=True``.
.. seealso::
:class:`.Column`
:func:`.literal_column`
:func:`.table`
:func:`.text`
:ref:`sqlexpression_literal_column`
N)r.r<><00>tablerr'rr)r=r<>rrr<>rrrr<><00> sT zColumnClause.__init__cCs<>|jsg|jdksg|jjsgt|d<00> sgt|t<00>r<>|jsg|jdksg|jjr<>t|d<00>r<>|j|jkp<>t|d<00>o<>|j|jkS|jj |j<00>SdS)Nr<4E>r<>r<>)
rr9Z_textualr(r*r<>r<>r<>r<>r<>)r=r[rrrr<><00> s   !z%ColumnClause._compare_name_for_resultcCs |jdS)Nr9)r6)r=rrr<00>
_get_table<EFBFBD> szColumnClause._get_tablecCs!|jj|<00>||jd<dS)Nr9)<03>_memoized_propertyZexpire_instancer6)r=r9rrr<00>
_set_table<EFBFBD> szColumnClause._set_tablecCs$|j}|dk r|gSgSdS)N)r9)r=<00>trrrr<><00> s  zColumnClause._from_objectscCs'tjr|jS|jjdd<00>SdS)Nrerf)rrgr<>rj)r=rrrrx<00> s zColumnClause.descriptioncCs-|j|jkr"|j|j<00>S|jSdS)N)r.r<><00>
_gen_labelr<EFBFBD>)r=rrrr<> szColumnClause._key_labelcCs|j|j<00>S)N)r>r<>)r=rrrr<> szColumnClause._labelcCs |jdk S)N)r9)r=rrrr<> sz,ColumnClause._render_label_in_columns_clausecCsw|j}|jrdS|dk ro|jrot|dd<00>rh|jjdd<00>d|jd|}n|jd|}t|dd<00>dk r<>t|t<00>r<>|j |_ q t||j <00>}nIt|jdd<00>dk r t|t<00> s<>t
<00>t||jj <00>}n||j kre|}d}x1||j kr[|dt |<00>}|d7}q+W|}nt |<00>S|SdS)N<>schema<6D>.<2E>_r<5F>r)r9rZnamed_with_columnr<6E>r?<00>replacer<65>r*r<>r<><00>AssertionErrorr>rhr<>)r=r<>r=r<>r<><00>counterrrrr> s.  + 
zColumnClause._gen_labelc Cs%t|j|d|d|jdd<00>S)Nr<4E>r<>r"T)r#r.r)r=rsr<>rrrr<>8 s zColumnClause._bind_paramTcKs<>|jo!|dkp!||jk}|j|rEt|p?|j<00>n |pQ|jd|jd|d|<00>}|dkr<>|j|_n|g|_|jdk r<>|jjj |j<00>|_n|r<>||j
|j<n|S)Nrr<>r) rr<>r?r<>rr.r<>r<r<>r<>r<>)r=r<>r<><00>attachr<68>rrr>rrrr<>> s$    zColumnClause._make_proxy)r|r{r~rr<>ZonupdatercZserver_defaultZserver_onupdaterZ!group_expirable_memoized_propertyr;r<>r<>r:r<r<>r9r<>r<>rxr<>r<>r<>r>r<>r<>rrrrr<>[ s$ ! Y    ( r<>c@s;eZdZdZejjidd6<>Zdd<00>ZdS)<07>_IdentifiedClauseZ
identifiedFr<EFBFBD>cCs ||_dS)N)<01>ident)r=rGrrrr<>] sz_IdentifiedClause.__init__N)r|r{r~r<>rr<>r<>r<>rrrrrFW s rFc@seZdZdZdS)<03>SavepointClauseZ savepointN)r|r{r~r<>rrrrrHa s rHc@seZdZdZdS)<03>RollbackToSavepointClauseZrollback_to_savepointN)r|r{r~r<>rrrrrIe s rIc@seZdZdZdS)<03>ReleaseSavepointClauseZrelease_savepointN)r|r{r~r<>rrrrrJi s rJcs^eZdZdZdZ<00>fdd<00>Zdd<00>Zd d
<00>Zd d <00>Zd d<00>Z <00>S)r<>a<>Represent a SQL identifier combined with quoting preferences.
:class:`.quoted_name` is a Python unicode/str subclass which
represents a particular identifier name along with a
``quote`` flag. This ``quote`` flag, when set to
``True`` or ``False``, overrides automatic quoting behavior
for this identifier in order to either unconditionally quote
or to not quote the name. If left at its default of ``None``,
quoting behavior is applied to the identifier on a per-backend basis
based on an examination of the token itself.
A :class:`.quoted_name` object with ``quote=True`` is also
prevented from being modified in the case of a so-called
"name normalize" option. Certain database backends, such as
Oracle, Firebird, and DB2 "normalize" case-insensitive names
as uppercase. The SQLAlchemy dialects for these backends
convert from SQLAlchemy's lower-case-means-insensitive convention
to the upper-case-means-insensitive conventions of those backends.
The ``quote=True`` flag here will prevent this conversion from occurring
to support an identifier that's quoted as all lower case against
such a backend.
The :class:`.quoted_name` object is normally created automatically
when specifying the name for key schema constructs such as
:class:`.Table`, :class:`.Column`, and others. The class can also be
passed explicitly as the name to any function that receives a name which
can be quoted. Such as to use the :meth:`.Engine.has_table` method with
an unconditionally quoted name::
from sqlaclchemy import create_engine
from sqlalchemy.sql.elements import quoted_name
engine = create_engine("oracle+cx_oracle://some_dsn")
engine.has_table(quoted_name("some_table", True))
The above logic will run the "has table" logic against the Oracle backend,
passing the name exactly as ``"some_table"`` without converting to
upper case.
.. versionadded:: 0.9.0
r<><00>lower<65>uppercsf|dkrdSt||<00>r>|dks:|j|kr>|Stt|<00>j||<00>}||_|S)N)r*r<>r<>r<>r5)r<>r$r<>r=)r4rrr5<00> s  zquoted_name.__new__cCsttj|<00>|jffS)N)r<>r<00> text_typer<65>)r=rrrr7<00> szquoted_name.__reduce__cCs$|jr |Stj|<00>j<00>SdS)N)r<>rrMrK)r=rrr<00>_memoized_method_lower<65> s z"quoted_name._memoized_method_lowercCs$|jr |Stj|<00>j<00>SdS)N)r<>rrMrL)r=rrr<00>_memoized_method_upper<65> s z"quoted_name._memoized_method_uppercCs5|jdd<00>}tjs-|jd<00>}nd|S)Nrerfz'%s')rjrZpy2k<32>decode)r=Z backslashedrrrrz<00> s zquoted_name.__repr__)zquotezlowerzupper)
r|r{r~r<00> __slots__r5r7rNrOrzrr)r4rr<>m s *   r<>csIeZdZdZfZd<00>fdd<00>Zdd<00>Zdd<00>Z<00>S) <09>_truncated_labelzVA unicode subclass used to identify symbolic "
"names that may require truncation.Ncs.t|d|<00>}tt|<00>j|||<00>S)Nr<4E>)r<>r<>rRr5)r<>r$r<>)r4rrr5<00> sz_truncated_label.__new__cCs|jtj|<00>|jffS)N)r4rrMr<>)r=rrrr7<00> sz_truncated_label.__reduce__cCs|S)Nr)r=<00>map_rrr<00> apply_map<61> sz_truncated_label.apply_map)r|r{r~rrQr5r7rTrr)r4rrR<00> s
 rRc@seZdZdZfZdS)<03>convaMark a string indicating that a name has already been converted
by a naming convention.
This is a string subclass that indicates a name that should not be
subject to any further naming conventions.
E.g. when we create a :class:`.Constraint` using a naming convention
as follows::
m = MetaData(naming_convention={
"ck": "ck_%(table_name)s_%(constraint_name)s"
})
t = Table('t', m, Column('x', Integer),
CheckConstraint('x > 5', name='x5'))
The name of the above constraint will be rendered as ``"ck_t_x5"``.
That is, the existing name ``x5`` is used in the naming convention as the
``constraint_name`` token.
In some situations, such as in migration scripts, we may be rendering
the above :class:`.CheckConstraint` with a name that's already been
converted. In order to make sure the name isn't double-modified, the
new name is applied using the :func:`.schema.conv` marker. We can
use this explicitly as follows::
m = MetaData(naming_convention={
"ck": "ck_%(table_name)s_%(constraint_name)s"
})
t = Table('t', m, Column('x', Integer),
CheckConstraint('x > 5', name=conv('ck_t_x5')))
Where above, the :func:`.schema.conv` marker indicates that the constraint
name here is final, and the name will render as ``"ck_t_x5"`` and not
``"ck_t_ck_t_x5"``
.. versionadded:: 0.9.4
.. seealso::
:ref:`constraint_naming_conventions`
N)r|r{r~rrQrrrrrU<00> s +rUcs:eZdZdZfZ<00>fdd<00>Zdd<00>Z<00>S)<06> _defer_namezRmark a name as 'deferred' for the purposes of automated name
generation.
cs@|dkrtSt|t<00>r#|Stt|<00>j||<00>SdS)N)<06>
_NONE_NAMEr*rUr<>rVr5)r<>r$)r4rrr5 s
 z_defer_name.__new__cCs|jtj|<00>ffS)N)r4rrM)r=rrrr7sz_defer_name.__reduce__)r|r{r~rrQr5r7rr)r4rrVs rVc@seZdZdZfZdS)<03>_defer_none_namez>indicate a 'deferred' name that was ultimately the value None.N)r|r{r~rrQrrrrrXs rXZ _unnamed_c@s@eZdZdZfZdd<00>Zdd<00>Zdd<00>ZdS) r<>zDA unicode subclass used to identify anonymously
generated names.cCs.tttjj|tj|<00><00>|j<00><00>S)N)r<>r<>rrM<00>__add__r<5F>)r=r[rrrrY(sz_anonymous_label.__add__cCs.tttjjtj|<00>|<00>|j<00><00>S)N)r<>r<>rrMrYr<>)r=r[rrr<00>__radd__/sz_anonymous_label.__radd__cCs/|jdk r#t|||j<00>S||SdS)N)r<>r<>)r=rSrrrrT6sz_anonymous_label.apply_mapN)r|r{r~rrQrYrZrTrrrrr<>"s
  r<>cCs!t|t<00>r|St|<00>SdS)z<>coerce the given value to :class:`._truncated_label`.
Existing :class:`._truncated_label` and
:class:`._anonymous_label` objects are passed
unchanged.
N)r*rR)r$rrrr<>?sr<>c CsEt|tj<00>r|Syt|<00>SWntk
r@d|SYnXdS)Nzunprintable element %r)r*rr!rh<00> Exception)rrrr<00>_string_or_unprintableMs  r\cCstjdd<00>|D<><00>S)z\expand the given set of ClauseElements to be the set of all 'cloned'
predecessors.
cSsg|]}|j<00>qSr)r8)r<>r rrrr<>\s z"_expand_cloned.<locals>.<listcomp>)r<>r<>)<01>elementsrrr<00>_expand_clonedWsr^cCstjdd<00>|D<><00>S)zXexpand tables into individual columns in the
given list of column expressions.
cSsg|]}|j<00>qSr)r<>)r<>r>rrrr<>ds z%_select_iterables.<locals>.<listcomp>)r<>r<>)r]rrr<00>_select_iterables_sr_cs>tt|<00><00>jt|<00><00><00>t<00>fdd<00>|D<><00>S)z<>return the intersection of sets a and b, counting
any overlap between 'cloned' predecessors.
The returned set is in terms of the entities present within 'a'.
c3s'|]}<00>j|j<00>r|VqdS)N)r<>r8)r<><00>elem)<01> all_overlaprrr<>osz'_cloned_intersection.<locals>.<genexpr>)<03>setr^r<>)<02>ar<61>r)rar<00>_cloned_intersectiongs!rdcs>tt|<00><00>jt|<00><00><00>t<00>fdd<00>|D<><00>S)Nc3s'|]}<00>j|j<00>s|VqdS)N)r<>r8)r<>r`)rarrr<>usz%_cloned_difference.<locals>.<genexpr>)rbr^r<>)rcr<>r)rar<00>_cloned_differencess!rezsqlalchemy.sql.functionscCs7t|d<00> s"t||j<00>r/|jd<00>S|SdS)Nr<4E>)r(r*ZFunctionElementr<74>)Z functionsrrrr<00>_labeledys rfcCs t|t<00>S)z:True if ``col`` is an instance of :class:`.ColumnElement`.)r*r:)r<>rrr<00>
_is_column<EFBFBD>srgcCs*tj<00>}t|ii|jd6<>|S)z2locate Column objects within the given expression.r<>)rr@r rA)r1r<>rrr<00> _find_columns<6E>s rhc Cs\t|tj<00>r|St|d<00>r4|j<00>}ny |jSWntk
rWdSYnXdS)Nr&)r*rr!r(r&r.r<>)rrrr<00>_column_as_key<65>s  ricCs!t|d<00>r|j<00>S|SdS)Nr&)r(r&)rrrr<00>_clause_element_as_expr<70>s
rjcCsDt|tj<00>rt|<00>St|d<00>r:|j<00>}nt|<00>S)Nr&)r*rr!rr(r&r)rrrrr<00>s

rcCspt|tj<00>rt|<00>St|d<00>r:|j<00>}nt|t<00>rb|jdk rbt|<00>St |<00>SdS)Nr&)
r*rr!rr(r&r:r<>rr)rrrr<00>&_literal_and_labels_as_label_reference<63>s

rkcCst|dd<00>S)N<>warnT)r)rrrrr<><00>sr<>cCs<>t|t<00>r|St|d<00>r,|j<00>St|tj<00>rz|rgtjditj|<00>d6<>nttj |<00><00>St|tj
t f<00>r<>t |<00>St jdt|<00><16><00>dS)Nr&zOTextual SQL expression %(expr)r should be explicitly declared as text(%(expr)r)rzGSQL expression object or string expected, got object of type %r instead)r*r
r(r&rr!<00> warn_limited<65>ellipses_stringr<67>rM<00>NoneTyper<65><00> _const_exprrrZr)rrlrrrr<00>s

rcCsFt|d<00>r|j<00>St|t<00>s>tjd|<16><00>n|SdS)Nr&z<>Ambiguous literal: %r. Use the 'text()' function to indicate a SQL expression literal, or 'literal()' to indicate a bound value.)r(r&r*r
rrZ)rrrrr<00>s 
  rcCst|t<00> ot|d<00> S)Nr&)r*r
r()rrrr<00> _is_literal<61>srqcCs!|dkrdSt||<00>SdS)N)<01>_only_column_elements)rr<>rrr<00>_only_column_elements_or_none<6E>s rscCsVt|d<00>r|j<00>}nt|t<00>sRtjd||t|<00>f<16><00>n|S)Nr&zMColumn-based expression object expected for argument '%s'; got: '%s', type %s)r(r&r*r:rrZr)rr<>rrrrr<00>srrcCs_t|d<00>r|j<00>St|t<00>sW|dkr;t<00>St||d|dd<00>Sn|SdS)Nr&rr"T)r(r&r*r
r+r#)rr<>rrrrrs
 rz^\w\S*$cCs$t|t<00>r|St|d<00>r,|j<00>Stj|dd<00>}|dkrrt|tjtf<00>r<>t |<00>Snt|d<00>r<>|j
S|dkr<>d}nwt|t j <00>r<>t t|<00>dd<00>St|<00>}tj|<00> }tjditj|<00>d 6|r d
nd d
6<>t |d|<00>S) Nr&ZraiseerrFr<46><00>*Trz<>Textual column expression %(column)r should be explicitly declared with text(%(column)r), or use %(literal_column)s(%(column)r) for more specificityr<79>r)r*r
r(r&r<00>inspectrror<>rpr<><00>numbers<72>Numberr<72>rh<00>_guess_straight_column<6D>matchrmrn)rZinspZguess_is_literalrrr<00>_interpret_as_column_or_froms0
     rzcCsht|tttf<00>r|S|dkr/t<00>S|dkrBt<00>S|dkrUt<00>Stjd<00><00>dS)NFTzExpected None, False, or True)r*r+r<>r<>rrZ)rrrrrp7s   rpcCs/x(|D]}|jjs|jSqWtjSdS)N)rZ_isnullrr<>)<02>argsrcrrr<00>_type_from_argsFs   r|cCsS|j|d|<00>}|dkrOtjd|t|dd<00>|jf<16><00>n|S)N<>require_embeddedzbGiven column '%s', attached to table '%s', failed to locate a corresponding column from table '%s'r9)Zcorresponding_columnrZInvalidRequestErrorr<72>rx)Z
fromclauser<EFBFBD>r}r>rrr<00>_corresponding_column_or_errorNs   r~cs<>eZdZdd<00>Z<00>fdd<00>Zejdd<00><00>Zejdd<00><00>Zejd d
<00><00>Z ejd d <00><00>Z
ejd d<00><00>Z <00>S)<0F>AnnotatedColumnElementcCsftj|||<00>tjj|<00>x<dD]4}|jj|d<00>dkr*|jj|<00>q*q*WdS)Nr<4E>r.r9F)znamezkeyztable)r r<>r:r;r9r6r<>rD)r=rrGr*rrrr<>_s
 zAnnotatedColumnElement.__init__cs,tt|<00>j|<00>}tjj|<00>|S)N)r<>rrIr:r;r9)r=rGrJ)r4rrrIfsz(AnnotatedColumnElement._with_annotationscCs
|jjS)z'pull 'name' from parent, if not present)<02>_Annotated__elementr<74>)r=rrrr<>kszAnnotatedColumnElement.namecCs
|jjS)z(pull 'table' from parent, if not present)r<>r9)r=rrrr9pszAnnotatedColumnElement.tablecCs
|jjS)z&pull 'key' from parent, if not present)r<>r.)r=rrrr.uszAnnotatedColumnElement.keycCs
|jjS)N)r<><00>info)r=rrrr<>zszAnnotatedColumnElement.infocCs
|jjS)N)r<>r<>)r=rrrr<>~sz!AnnotatedColumnElement.anon_label) r|r{r~r<>rIrr<>r<>r9r.r<>r<>rr)r4rr^s  r)hr<00>
__future__r<00>rrrrr Zvisitorsr
r r Z
annotationr r<><00>baserrrrrrvr<>rsrrr!r%r)r/r2Z_self_inspectsr3ZColumnOperatorsr:r#r<>r<>r+r<>r<>r<>r<>rlrnrrrr<>rrrrur<>rr<>r-r2r,r<>rFrHrIrJZ MemoizedSlotsrMr<>rRrUrVrXrWZ_generated_labelr<6C>r<>r\r^r_rdrer<>rfrgrhrirjrrkr<>rrrqrsrrrrd<00>Irxrzrpr|r~rrrrr<00><module> s<> "     6 ?  <0C>Q<1C>U<16>L <19><00>;BK<19>  +<16>!W <16>^-Nrn<19>
T/  
     
   
  (