File: //opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyo
�
��4]c @ s� d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d e j f d � � YZ d e f d
� � YZ
d � Z d S(
i ( t ARRAYi ( t elements( t
expression( t functions( t ColumnCollectionConstraintt aggregate_order_byc B sP e Z d Z d Z d � Z d d � Z d � Z e j d � Z
e d � � Z RS( s� Represent a PostgreSQL aggregate order by expression.
E.g.::
from sqlalchemy.dialects.postgresql import aggregate_order_by
expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc()))
stmt = select([expr])
would represent the expression::
SELECT array_agg(a ORDER BY b DESC) FROM table;
Similarly::
expr = func.string_agg(
table.c.a,
aggregate_order_by(literal_column("','"), table.c.a)
)
stmt = select([expr])
Would represent::
SELECT string_agg(a, ',' ORDER BY a) FROM table;
.. versionadded:: 1.1
.. versionchanged:: 1.2.13 - the ORDER BY argument may be multiple terms
.. seealso::
:class:`.array_agg`
R c G s} t j | � | _ t | � } | d k r9 t d � � n@ | d k r^ t j | d � | _ n t j d t j | � | _ d S( Ni s) at least one ORDER BY element is requiredi t _literal_as_text( R t _literal_as_bindst targett lent TypeErrort order_byt
ClauseList( t selfR R t _lob( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyt __init__4 s c C s | S( N( ( R
t against( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyt
self_groupA s c K s | j | j f S( N( R R ( R
t kwargs( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyt get_childrenD s c K s. | | j | � | _ | | j | � | _ d S( N( R R ( R
t clonet kw( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyt _copy_internalsG s c C s | j j | j j S( N( R t
_from_objectsR ( R
( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyR K s N(
t __name__t
__module__t __doc__t __visit_name__R t NoneR R R t _cloneR t propertyR ( ( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyR s !
t ExcludeConstraintc B sA e Z d Z d Z d Z e j d d d � d � � Z d � Z RS( s� A table-level EXCLUDE constraint.
Defines an EXCLUDE constraint as described in the `postgres
documentation`__.
__ http://www.postgresql.org/docs/9.0/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
t exclude_constraintt wheres :class:`.ExcludeConstraint`s$ :paramref:`.ExcludeConstraint.where`c O si g } g } i | _ t | � \ } } x� t | j | � | � D]� \ \ } } } }
} |
d k rt | j |
� n | d k r� | j n | } | d k r� | | j | <n t j | � } | j | | | f � q@ W| | _ t j
| d | j d � d | j d � d | j d � | �| j d d � | _ | j d � }
|
d k ret j
|
d t �| _ n d S( s�
Create an :class:`.ExcludeConstraint` object.
E.g.::
const = ExcludeConstraint(
(Column('period'), '&&'),
(Column('group'), '='),
where=(Column('group') != 'some group')
)
The constraint is normally embedded into the :class:`.Table` construct
directly, or added later using :meth:`.append_constraint`::
some_table = Table(
'some_table', metadata,
Column('id', Integer, primary_key=True),
Column('period', TSRANGE()),
Column('group', String)
)
some_table.append_constraint(
ExcludeConstraint(
(some_table.c.period, '&&'),
(some_table.c.group, '='),
where=some_table.c.group != 'some group',
name='some_table_excl_const'
)
)
:param \*elements:
A sequence of two tuples of the form ``(column, operator)`` where
"column" is a SQL expression element or a raw SQL string, most
typically a :class:`.Column` object, and "operator" is a string
containing the operator to use. In order to specify a column name
when a :class:`.Column` object is not available, while ensuring
that any necessary quoting rules take effect, an ad-hoc
:class:`.Column` or :func:`.sql.expression.column` object should be
used.
:param name:
Optional, the in-database name of this constraint.
:param deferrable:
Optional bool. If set, emit DEFERRABLE or NOT DEFERRABLE when
issuing DDL for this constraint.
:param initially:
Optional string. If set, emit INITIALLY <value> when issuing DDL
for this constraint.
:param using:
Optional string. If set, emit USING <index_method> when issuing DDL
for this constraint. Defaults to 'gist'.
:param where:
Optional SQL expression construct or literal SQL string.
If set, emit WHERE <predicate> when issuing DDL
for this constraint.
t namet
deferrablet initiallyt usingt gistR! t allow_coercion_to_textN( t operatorst zipt"