3
a                 @   s   d dl mZ dZG dd deZG dd deejZG dd deejZG d	d deejZ	G d
d deejZ
G dd deejZG dd deejZdS )   )types	INT4RANGE	INT8RANGENUMRANGEc               @   s$   e Zd ZdZG dd dejjZdS )RangeOperatorsaN  
    This mixin provides functionality for the Range Operators
    listed in Table 9-44 of the `PostgreSQL documentation`__ for Range
    Functions and Operators. It is used by all the range types
    provided in the ``postgres`` dialect and can likely be used for
    any range types you create yourself.

    __ https://www.postgresql.org/docs/devel/static/functions-range.html

    No extra support is provided for the Range Functions listed in
    Table 9-45 of the PostgreSQL documentation. For these, the normal
    :func:`~sqlalchemy.sql.expression.func` object should be used.

    c                   sp   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d ZeZ	dd Z
e
Zdd Zdd Zdd Zdd Z  ZS )z!RangeOperators.comparator_factoryz-Define comparison operations for range types.c                s2   |dkrt tj| j|S | jjddd|S dS )z<Boolean expression. Returns true if two ranges are not equalNz<>T)is_comparison)superr   comparator_factory__ne__exprop)selfother)	__class__ K/tmp/pip-build-6_cqtusv/SQLAlchemy/sqlalchemy/dialects/postgresql/ranges.pyr
       s    z(RangeOperators.comparator_factory.__ne__c             K   s   | j jddd|S )zBoolean expression. Returns true if the right hand operand,
            which can be an element or a range, is contained within the
            column.
            z@>T)r   )r   r   )r   r   kwr   r   r   contains)   s    z*RangeOperators.comparator_factory.containsc             C   s   | j jddd|S )zsBoolean expression. Returns true if the column is contained
            within the right hand operand.
            z<@T)r   )r   r   )r   r   r   r   r   contained_by0   s    z.RangeOperators.comparator_factory.contained_byc             C   s   | j jddd|S )zBoolean expression. Returns true if the column overlaps
            (has points in common with) the right hand operand.
            z&&T)r   )r   r   )r   r   r   r   r   overlaps6   s    z*RangeOperators.comparator_factory.overlapsc             C   s   | j jddd|S )zsBoolean expression. Returns true if the column is strictly
            left of the right hand operand.
            z<<T)r   )r   r   )r   r   r   r   r   strictly_left_of<   s    z2RangeOperators.comparator_factory.strictly_left_ofc             C   s   | j jddd|S )ztBoolean expression. Returns true if the column is strictly
            right of the right hand operand.
            z>>T)r   )r   r   )r   r   r   r   r   strictly_right_ofD   s    z3RangeOperators.comparator_factory.strictly_right_ofc             C   s   | j jddd|S )zBoolean expression. Returns true if the range in the column
            does not extend right of the range in the operand.
            z&<T)r   )r   r   )r   r   r   r   r   not_extend_right_ofL   s    z5RangeOperators.comparator_factory.not_extend_right_ofc             C   s   | j jddd|S )zBoolean expression. Returns true if the range in the column
            does not extend left of the range in the operand.
            z&>T)r   )r   r   )r   r   r   r   r   not_extend_left_ofR   s    z4RangeOperators.comparator_factory.not_extend_left_ofc             C   s   | j jddd|S )z}Boolean expression. Returns true if the range in the column
            is adjacent to the range in the operand.
            z-|-T)r   )r   r   )r   r   r   r   r   adjacent_toX   s    z-RangeOperators.comparator_factory.adjacent_toc             C   s   | j jd|S )zRange expression. Returns the union of the two ranges.
            Will raise an exception if the resulting range is not
            contiguous.
            +)r   r   )r   r   r   r   r   __add__^   s    z)RangeOperators.comparator_factory.__add__)__name__
__module____qualname____doc__r
   r   r   r   r   
__lshift__r   
__rshift__r   r   r   r   __classcell__r   r   )r   r   r	      s   	r	   N)r   r   r   r    sqltypesZConcatenableZ
Comparatorr	   r   r   r   r   r      s   r   c               @   s   e Zd ZdZd ZdS )r   z(Represent the PostgreSQL INT4RANGE type.N)r   r   r   r    __visit_name__r   r   r   r   r   f   s   c               @   s   e Zd ZdZd ZdS )r   z(Represent the PostgreSQL INT8RANGE type.N)r   r   r   r    r%   r   r   r   r   r   l   s   c               @   s   e Zd ZdZd ZdS )r   z'Represent the PostgreSQL NUMRANGE type.N)r   r   r   r    r%   r   r   r   r   r   r   s   c               @   s   e Zd ZdZd ZdS )	DATERANGEz(Represent the PostgreSQL DATERANGE type.N)r   r   r   r    r%   r   r   r   r   r&   x   s   r&   c               @   s   e Zd ZdZd ZdS )TSRANGEz&Represent the PostgreSQL TSRANGE type.N)r   r   r   r    r%   r   r   r   r   r'   ~   s   r'   c               @   s   e Zd ZdZd ZdS )	TSTZRANGEz(Represent the PostgreSQL TSTZRANGE type.N)r   r   r   r    r%   r   r   r   r   r(      s   r(   N)r   r   r   ) r   r$   __all__objectr   Z
TypeEnginer   r   r   r&   r'   r(   r   r   r   r   <module>   s   Y