JezK
Edit File: ext.pyc
� 1��fc @ 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 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 util( t coercions( t elements( t expression( t functions( t roles( t schema( t ColumnCollectionConstraint( t InternalTraversalt aggregate_order_byc B s� e Z d Z d Z d Z d e j f d e j f d e j f g 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:`_functions.array_agg` R t postgresqlt targett typet order_byc G s� t j t j | � | _ | j j | _ t | � } | d k rN t d � � nF | d k ry t j 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_role( R t expectR t ExpressionElementRoleR R t lent TypeErrorR R t ClauseList( t selfR R t _lob( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyt __init__@ s c C s | S( N( ( R t against( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyt self_groupP 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_childrenS 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_internalsV 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 Z s N( t __name__t __module__t __doc__t __visit_name__t stringify_dialectR t dp_clauseelementt dp_typet _traverse_internalsR 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 sY e Z d Z d Z d Z e Z d Z e j d d d � d � � Z d � Z d d � Z RS( s� A table-level EXCLUDE constraint. Defines an EXCLUDE constraint as described in the `PostgreSQL documentation`__. __ https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE t exclude_constraintR t wheres :class:`.ExcludeConstraint`s$ :paramref:`.ExcludeConstraint.where`c O su g } g } i | _ t | � \ } } x� t t j t j | � | � D]� \ \ } } } } } | d k rz | j | � n | d k r� | j n | } | d k r� | | j | <n | j | | | f � qF W| | _ t j | d | j d � d | j d � d | j d � | �| j d d � | _ | j d � } | d k r\t j t j | � | _ n | j d i � | _ d S( s2 Create an :class:`.ExcludeConstraint` object. E.g.:: const = ExcludeConstraint( (Column('period'), '&&'), (Column('group'), '='), where=(Column('group') != 'some group'), ops={'group': 'my_operator_class'} ) The constraint is normally embedded into the :class:`_schema.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', ops={'group': 'my_operator_class'} ) ) :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:`_schema.Column` object, and "operator" is a string containing the operator to use. In order to specify a column name when a :class:`_schema.Column` object is not available, while ensuring that any necessary quoting rules take effect, an ad-hoc :class:`_schema.Column` or :func:`_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. :param ops: Optional dictionary. Used to define operator classes for the elements; works the same way as that of the :ref:`postgresql_ops <postgresql_operator_classes>` parameter specified to the :class:`_schema.Index` construct. .. versionadded:: 1.3.21 .. seealso:: :ref:`postgresql_operator_classes` - general description of how PostgreSQL operator classes are specified. t namet deferrablet initiallyt usingt gistR- t opsN( t operatorst zipR t expect_col_expression_collectionR t DDLConstraintColumnRoleR( t appendR. t _render_exprsR R t getR1 R t StatementOptionRoleR- R3 ( R R R t columnst render_exprst expressionsR4 t exprt columnt strnamet add_elementt operatorR. R- ( ( sU /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ext.pyR p s2 W c K sx t t | � j | � g t j | j | j � D]<